133 #ifndef OPENTXS_CORE_OTSTORAGEPB_HPP
134 #define OPENTXS_CORE_OTSTORAGEPB_HPP
143 #if defined(OTDB_PROTOCOL_BUFFERS)
146 #pragma warning(push)
147 #pragma warning(disable : 4244)
148 #pragma warning(disable : 4267)
151 #if defined(ANDROID) || defined(OT_KEYRING_IOS)
152 #include "Generics-lite.pb.h"
153 #include "Markets-lite.pb.h"
154 #include "Bitcoin-lite.pb.h"
155 #include "Moneychanger-lite.pb.h"
160 #include "Generics.pb.h"
161 #include "Markets.pb.h"
162 #include "Bitcoin.pb.h"
163 #include "Moneychanger.pb.h"
230 IStorable) virtual ::google::protobuf::MessageLite
232 virtual
bool onPack(PackedBuffer& theBuffer, Storable&
inObj);
233 virtual
bool onUnpack(PackedBuffer& theBuffer, Storable& outObj);
244 IStorablePB, std::
string);
248 typedef PackerSubclass<BufferPB> PackerPB;
252 template <class theBaseType, class theInternalType,
254 class ProtobufSubclass : public theBaseType,
implements IStorablePB
257 theInternalType __pb_obj;
261 static Storable* Instantiate()
263 return dynamic_cast<Storable*
>(
264 new ProtobufSubclass<theBaseType, theInternalType, theObjectType>);
275 ProtobufSubclass(
const ProtobufSubclass<theBaseType, theInternalType,
283 .CopyToObject(*
this);
286 ProtobufSubclass<theBaseType, theInternalType, theObjectType>& operator=(
287 const ProtobufSubclass<theBaseType, theInternalType, theObjectType>&
290 rhs.CopyToObject(*
this);
294 void CopyToObject(ProtobufSubclass<theBaseType, theInternalType,
295 theObjectType>& theNewStorable)
const
298 const OTDB::Storable* pIntermediate =
299 dynamic_cast<const OTDB::Storable*
>(
this);
301 if (
nullptr == pPacker) {
304 PackedBuffer* pBuffer =
305 pPacker->Pack(*(const_cast<OTDB::Storable*>(pIntermediate)));
306 if (
nullptr == pBuffer) {
309 if (!pPacker->Unpack(*pBuffer, theNewStorable)) {
312 if (
nullptr != pPacker) {
316 if (
nullptr != pBuffer) {
322 virtual ::google::protobuf::MessageLite* getPBMessage();
328 virtual theBaseType* clone(
void)
const
330 return dynamic_cast<theBaseType*
>(do_clone());
333 IStorable* do_clone(
void)
const
335 Storable* pNewStorable =
337 if (
nullptr == pNewStorable)
OT_FAIL;
338 CopyToObject(*(
dynamic_cast<
339 ProtobufSubclass<theBaseType, theInternalType, theObjectType>*
>(
341 return dynamic_cast<IStorable*
>(pNewStorable);
344 virtual ~ProtobufSubclass()
352 #define DECLARE_PROTOBUF_SUBCLASS(theBaseType, theInternalType, theNewType, \
355 void ProtobufSubclass<theBaseType, theInternalType, \
356 theObjectType>::hookBeforePack(); \
358 void ProtobufSubclass<theBaseType, theInternalType, \
359 theObjectType>::hookAfterUnpack(); \
360 typedef ProtobufSubclass<theBaseType, theInternalType, theObjectType> \
365 DECLARE_PROTOBUF_SUBCLASS(OTDBString, String_InternalPB, StringPB,
367 DECLARE_PROTOBUF_SUBCLASS(Blob, Blob_InternalPB, BlobPB,
STORED_OBJ_BLOB);
368 DECLARE_PROTOBUF_SUBCLASS(StringMap, StringMap_InternalPB, StringMapPB,
370 DECLARE_PROTOBUF_SUBCLASS(BitcoinAcct, BitcoinAcct_InternalPB, BitcoinAcctPB,
372 DECLARE_PROTOBUF_SUBCLASS(BitcoinServer, BitcoinServer_InternalPB,
374 DECLARE_PROTOBUF_SUBCLASS(RippleServer, RippleServer_InternalPB, RippleServerPB,
376 DECLARE_PROTOBUF_SUBCLASS(LoomServer, LoomServer_InternalPB, LoomServerPB,
378 DECLARE_PROTOBUF_SUBCLASS(ServerInfo, ServerInfo_InternalPB, ServerInfoPB,
380 DECLARE_PROTOBUF_SUBCLASS(ContactAcct, ContactAcct_InternalPB, ContactAcctPB,
382 DECLARE_PROTOBUF_SUBCLASS(ContactNym, ContactNym_InternalPB, ContactNymPB,
384 DECLARE_PROTOBUF_SUBCLASS(Contact, Contact_InternalPB, ContactPB,
386 DECLARE_PROTOBUF_SUBCLASS(AddressBook, AddressBook_InternalPB, AddressBookPB,
388 DECLARE_PROTOBUF_SUBCLASS(WalletData, WalletData_InternalPB, WalletDataPB,
390 DECLARE_PROTOBUF_SUBCLASS(MarketData, MarketData_InternalPB, MarketDataPB,
392 DECLARE_PROTOBUF_SUBCLASS(MarketList, MarketList_InternalPB, MarketListPB,
395 DECLARE_PROTOBUF_SUBCLASS(BidData, OfferDataMarket_InternalPB, BidDataPB,
397 DECLARE_PROTOBUF_SUBCLASS(AskData, OfferDataMarket_InternalPB, AskDataPB,
399 DECLARE_PROTOBUF_SUBCLASS(OfferListMarket, OfferListMarket_InternalPB,
401 DECLARE_PROTOBUF_SUBCLASS(TradeDataMarket, TradeDataMarket_InternalPB,
403 DECLARE_PROTOBUF_SUBCLASS(TradeListMarket, TradeListMarket_InternalPB,
405 DECLARE_PROTOBUF_SUBCLASS(OfferDataNym, OfferDataNym_InternalPB, OfferDataNymPB,
407 DECLARE_PROTOBUF_SUBCLASS(OfferListNym, OfferListNym_InternalPB, OfferListNymPB,
409 DECLARE_PROTOBUF_SUBCLASS(TradeDataNym, TradeDataNym_InternalPB, TradeDataNymPB,
411 DECLARE_PROTOBUF_SUBCLASS(TradeListNym, TradeListNym_InternalPB, TradeListNymPB,
414 typedef OfferDataMarket_InternalPB BidData_InternalPB;
415 typedef OfferDataMarket_InternalPB AskData_InternalPB;
435 #endif // defined(OTDB_PROTOCOL_BUFFERS)
437 #endif // OPENTXS_CORE_OTSTORAGEPB_HPP
virtual void hookAfterUnpack()
#define DeclareBasedInterface(name, base)
#define DECLARE_PACKED_BUFFER_SUBCLASS(theNewType, thePackerType,theInterfaceType, theInternalType)
#define OT_USING_ISTORABLE_HOOKS
virtual void hookBeforePack()
const char * StoredObjectTypeStrings[]
static OTPacker * Create(PackType ePackType)
static EXPORT Storable * Create(StoredObjectType eType, PackType thePackType)
virtual bool onUnpack(PackedBuffer &theBuffer, Storable &outObj)=0