133 #ifndef OPENTXS_CORE_OTSTORAGE_HPP
134 #define OPENTXS_CORE_OTSTORAGE_HPP
144 #include "containers/simple_ptr.hpp"
163 #define OTDB_PROTOCOL_BUFFERS 1
167 #define OTDB_DEFAULT_PACKER OTDB::PACK_PROTOCOL_BUFFERS
169 #define OTDB_DEFAULT_STORAGE OTDB::STORE_FILESYSTEM
185 #define OTInterface class
187 #define DeclareInterface(name) \
195 #define DeclareBasedInterface(name, base) \
196 class name : public base \
203 #define EndInterface \
207 #define implements public
339 typedef std::map<InstantiateFuncKey, InstantiateFunc*>
396 #ifdef SWIG // swig version
397 #define DEFINE_OT_DYNAMIC_CAST(CLASS_NAME_A) \
398 CLASS_NAME_A* clone() const \
401 << "********* THIS SHOULD NEVER HAPPEN!!!!! *****************" \
405 static CLASS_NAME_A* ot_dynamic_cast(Storable* pObject) \
407 return dynamic_cast<CLASS_NAME_A*>(pObject); \
413 #ifndef SWIG // normal version
414 #define DEFINE_OT_DYNAMIC_CAST(CLASS_NAME) \
415 virtual CLASS_NAME* clone() const \
418 << "********* THIS SHOULD NEVER HAPPEN!!!!! *****************" \
422 static CLASS_NAME* ot_dynamic_cast(Storable* pObject) \
424 return dynamic_cast<CLASS_NAME*>(pObject); \
480 virtual bool PackString(std::string& theString) = 0;
483 virtual bool ReadFromIStream(std::istream& inStream, int64_t lFilesize) = 0;
486 virtual const uint8_t*
GetData() = 0;
489 virtual void SetData(
const uint8_t* pData,
size_t theSize) = 0;
506 #define DECLARE_PACKED_BUFFER_SUBCLASS(theNewType, thePackerType, \
507 theInterfaceType, theInternalType) \
508 class theNewType : public PackedBuffer \
510 friend class thePackerType; \
511 friend OTInterface theInterfaceType; \
512 theInternalType m_buffer; \
519 virtual ~theNewType() \
522 virtual bool PackString(std::string& theString); \
523 virtual bool UnpackString(std::string& theString); \
524 virtual bool ReadFromIStream(std::istream& inStream, \
525 int64_t lFilesize); \
526 virtual bool WriteToOStream(std::ostream& outStream); \
527 virtual const uint8_t* GetData(); \
528 virtual size_t GetSize(); \
529 virtual void SetData(const uint8_t* pData, size_t theSize); \
530 theInternalType& GetBuffer() \
570 template <
class theBufferType>
584 return new theBufferType;
630 m_pPacker = &thePacker;
651 std::string strFolder,
652 std::string oneStr =
"",
653 std::string twoStr =
"",
654 std::string threeStr =
"") = 0;
657 std::string strFolder,
658 std::string oneStr =
"",
659 std::string twoStr =
"",
660 std::string threeStr =
"") = 0;
663 std::string strFolder,
664 std::string oneStr =
"",
665 std::string twoStr =
"",
666 std::string threeStr =
"") = 0;
669 std::string strFolder,
670 std::string oneStr =
"",
671 std::string twoStr =
"",
672 std::string threeStr =
"") = 0;
675 std::string oneStr =
"",
676 std::string twoStr =
"",
677 std::string threeStr =
"") = 0;
705 virtual bool Exists(std::string strFolder, std::string oneStr =
"",
706 std::string twoStr =
"", std::string threeStr =
"") = 0;
709 std::string strFolder,
710 std::string oneStr =
"",
711 std::string twoStr =
"",
712 std::string threeStr =
"") = 0;
716 if (
nullptr != m_pPacker)
delete m_pPacker;
722 EXPORT
bool StoreString(std::string strContents, std::string strFolder,
723 std::string oneStr =
"", std::string twoStr =
"",
724 std::string threeStr =
"");
726 EXPORT std::string
QueryString(std::string strFolder,
727 std::string oneStr =
"",
728 std::string twoStr =
"",
729 std::string threeStr =
"");
731 EXPORT
bool StorePlainString(std::string strContents, std::string strFolder,
732 std::string oneStr =
"",
733 std::string twoStr =
"",
734 std::string threeStr =
"");
737 std::string oneStr =
"",
738 std::string twoStr =
"",
739 std::string threeStr =
"");
744 std::string oneStr =
"", std::string twoStr =
"",
745 std::string threeStr =
"");
749 std::string strFolder, std::string oneStr =
"",
750 std::string twoStr =
"",
751 std::string threeStr =
"");
758 std::string strInput);
762 EXPORT
bool EraseValueByKey(std::string strFolder, std::string oneStr =
"",
763 std::string twoStr =
"",
764 std::string threeStr =
"");
811 std::string& oneStr, std::string& twoStr,
812 std::string& threeStr,
813 const char* szFuncName =
nullptr);
817 EXPORT
bool Exists(std::string strFolder, std::string oneStr =
"",
818 std::string twoStr =
"", std::string threeStr =
"");
820 EXPORT int64_t
FormPathString(std::string& strOutput, std::string strFolder,
821 std::string oneStr =
"", std::string twoStr =
"",
822 std::string threeStr =
"");
825 EXPORT
bool StoreString(std::string strContents, std::string strFolder,
826 std::string oneStr =
"", std::string twoStr =
"",
827 std::string threeStr =
"");
829 EXPORT std::string
QueryString(std::string strFolder, std::string oneStr =
"",
830 std::string twoStr =
"",
831 std::string threeStr =
"");
833 EXPORT
bool StorePlainString(std::string strContents, std::string strFolder,
834 std::string oneStr =
"", std::string twoStr =
"",
835 std::string threeStr =
"");
838 std::string oneStr =
"",
839 std::string twoStr =
"",
840 std::string threeStr =
"");
844 EXPORT
bool StoreObject(Storable& theContents, std::string strFolder,
845 std::string oneStr =
"", std::string twoStr =
"",
846 std::string threeStr =
"");
850 std::string strFolder, std::string oneStr =
"",
851 std::string twoStr =
"",
852 std::string threeStr =
"");
859 std::string strInput);
863 EXPORT
bool EraseValueByKey(std::string strFolder, std::string oneStr =
"",
864 std::string twoStr =
"", std::string threeStr =
"");
879 #ifdef SWIG // swig version
880 #define DECLARE_GET_ADD_REMOVE(name) \
882 std::deque<stlplus::simple_ptr_clone<name>> list_##name##s; \
885 size_t Get##name##Count(); \
886 name* Get##name(size_t nIndex); \
887 bool Remove##name(size_t nIndex##name); \
888 bool Add##name(name& disownObject)
893 #define DECLARE_GET_ADD_REMOVE(name) \
895 std::deque<stlplus::simple_ptr_clone<name>> list_##name##s; \
898 EXPORT size_t Get##name##Count(); \
899 EXPORT name* Get##name(size_t nIndex); \
900 EXPORT bool Remove##name(size_t nIndex##name); \
901 EXPORT bool Add##name(name& disownObject)
983 void SetValue(
const std::string& strKey,
const std::string& strValue)
985 std::map<std::string, std::string>::iterator ii =
the_map.find(strKey);
992 std::string ret_val(
"");
993 std::map<std::string, std::string>::iterator ii =
the_map.find(strKey);
994 if (ii !=
the_map.end()) ret_val = (*ii).second;
1130 m_Type =
"OfferDataMarket";
1228 m_Type =
"OfferListMarket";
1255 m_Type =
"TradeDataMarket";
1282 m_Type =
"TradeListMarket";
1576 m_Type =
"BitcoinServer";
1706 std::cout <<
"WalletData destructor" << std::endl;
1815 std::string m_strDataPath;
1825 std::string strFolder,
1826 std::string oneStr =
"",
1827 std::string twoStr =
"",
1828 std::string threeStr =
"");
1832 std::string strFolder,
1833 std::string oneStr =
"",
1834 std::string twoStr =
"",
1835 std::string threeStr =
"");
1838 int64_t ConstructAndConfirmPathImp(
bool bMakePath, std::string& strOutput,
1839 std::string zeroStr, std::string oneStr,
1841 std::string threeStr);
1849 std::string strFolder,
1850 std::string oneStr =
"",
1851 std::string twoStr =
"",
1852 std::string threeStr =
"");
1855 std::string strFolder,
1856 std::string oneStr =
"",
1857 std::string twoStr =
"",
1858 std::string threeStr =
"");
1861 std::string strFolder,
1862 std::string oneStr =
"",
1863 std::string twoStr =
"",
1864 std::string threeStr =
"");
1867 std::string strFolder,
1868 std::string oneStr =
"",
1869 std::string twoStr =
"",
1870 std::string threeStr =
"");
1873 std::string oneStr =
"",
1874 std::string twoStr =
"",
1875 std::string threeStr =
"");
1887 virtual bool Exists(std::string strFolder, std::string oneStr =
"",
1888 std::string twoStr =
"", std::string threeStr =
"");
1891 std::string strFolder,
1892 std::string oneStr =
"",
1893 std::string twoStr =
"",
1894 std::string threeStr =
"");
1906 struct stat* pst =
nullptr);
1909 struct stat* pst =
nullptr);
1967 #define OT_USING_ISTORABLE_HOOKS \
1968 using IStorable::hookBeforePack; \
1969 using IStorable::hookAfterUnpack
1971 #endif // (not) SWIG
1975 #endif // OPENTXS_CORE_OTSTORAGE_HPP
EXPORT bool StorePlainString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT Storage * GetDefaultStorage()
Storable *( InstantiateFunc)()
std::string bitcoin_acct_name
std::string loom_username
EXPORT Storable * CreateObject(StoredObjectType eType)
std::string bitcoin_password
std::map< InstantiateFuncKey, InstantiateFunc * > mapOfFunctions
EXPORT bool Unpack(PackedBuffer &inBuf, Storable &outObj)
OTDBString(const std::string &rhs)
static StorageFS * Instantiate()
virtual void hookAfterUnpack()
std::string currency_type_id
EXPORT std::string QueryString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::string transaction_id
std::string minimum_increment
EXPORT std::string EncodeObject(Storable &theContents)
virtual ~PackerSubclass()
void SetPacker(OTPacker &thePacker)
virtual bool onStorePackedBuffer(PackedBuffer &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::string volume_currency
PackedBuffer * Pack(Storable &inObj)
EXPORT bool StorePlainString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool StoreString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::vector< uint8_t > m_memBuffer
#define OTDB_DEFAULT_PACKER
virtual bool PackString(std::string &theString)=0
virtual bool ReadFromIStream(std::istream &inStream, int64_t lFilesize)=0
virtual ~TradeListMarket()
std::string asset_type_id
virtual int64_t FormPathString(std::string &strOutput, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT std::string QueryString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool InitDefaultStorage(StorageType eStoreType, PackType ePackType)
virtual void hookBeforePack()
virtual bool onEraseValueByKey(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")=0
static EXPORT Storage * Create(StorageType eStorageType, PackType ePackType)
EXPORT bool CheckStringsExistInOrder(std::string &strFolder, std::string &oneStr, std::string &twoStr, std::string &threeStr, const char *szFuncName=nullptr)
std::string finished_so_far
std::string currency_acct_id
virtual bool onQueryPlainString(std::string &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")=0
bool ConfirmOrCreateFolder(const char *szFolderName, struct stat *pst=nullptr)
EXPORT Storable * QueryObject(StoredObjectType theObjectType, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT std::string EncodeObject(Storable &theContents)
EXPORT Storable * DecodeObject(StoredObjectType theObjectType, std::string strInput)
virtual bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")=0
EXPORT Storable * CreateObject(StoredObjectType eType)
virtual bool onQueryPlainString(std::string &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
DECLARE_GET_ADD_REMOVE(BitcoinServer)
virtual bool onQueryPackedBuffer(PackedBuffer &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")=0
std::string currency_type_id
std::string recent_lowest_ask
std::string last_sale_price
std::pair< PackType, StoredObjectType > InstantiateFuncKey
DECLARE_GET_ADD_REMOVE(MarketData)
virtual void SetData(const uint8_t *pData, size_t theSize)=0
virtual bool WriteToOStream(std::ostream &outStream)=0
std::string available_assets
std::string ripple_username
EXPORT Storage * CreateStorageContext(StorageType eStoreType, PackType ePackType=OTDB_DEFAULT_PACKER)
const char * StoredObjectTypeStrings[]
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
virtual bool onQueryPackedBuffer(PackedBuffer &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::string finished_so_far
std::string transaction_id
int64_t ConstructAndConfirmPath(std::string &strOutput, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
DeclareInterface(IStorable) virtual bool onPack(PackedBuffer &theBuffer
std::string GetValue(const std::string &strKey)
static OTPacker * Create(PackType ePackType)
virtual bool onStorePlainString(std::string &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")=0
OTDB::Storage * s_pStorage
EXPORT std::string QueryPlainString(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool EraseValueByKey(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
virtual bool UnpackString(std::string &theString)=0
std::string transaction_id
virtual bool onStorePackedBuffer(PackedBuffer &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")=0
EXPORT StorageType GetType() const
std::string currency_paid
EXPORT bool StoreString(std::string strContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
virtual size_t GetSize()=0
virtual ~OfferListMarket()
DECLARE_GET_ADD_REMOVE(BidData)
bool ConfirmFile(const char *szFileName, struct stat *pst=nullptr)
DECLARE_GET_ADD_REMOVE(OfferDataNym)
std::string minimum_increment
EXPORT bool EraseValueByKey(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT OTPacker * GetPacker(PackType ePackType=OTDB_DEFAULT_PACKER)
DECLARE_GET_ADD_REMOVE(Contact)
std::map< std::string, std::string > the_map
OTDB::mapOfFunctions * pFunctionMap
virtual PackedBuffer * CreateBuffer()=0
EXPORT Storable * QueryObject(StoredObjectType theObjectType, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::string completed_count
virtual int64_t FormPathString(std::string &strOutput, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")=0
DECLARE_GET_ADD_REMOVE(TradeDataMarket)
EXPORT int64_t FormPathString(std::string &strOutput, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::string recent_highest_bid
static EXPORT Storable * Create(StoredObjectType eType, PackType thePackType)
EXPORT Storable * DecodeObject(StoredObjectType theObjectType, std::string strInput)
virtual ~TradeDataMarket()
std::string asset_acct_id
std::string asset_type_id
virtual PackedBuffer * CreateBuffer()
virtual const uint8_t * GetData()=0
virtual bool onEraseValueByKey(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
virtual ~OfferDataMarket()
EXPORT bool StoreObject(Storable &theContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
DECLARE_GET_ADD_REMOVE(TradeDataNym)
#define DEFINE_OT_DYNAMIC_CAST(CLASS_NAME)
std::string bitcoin_username
std::string last_sale_date
virtual bool onUnpack(PackedBuffer &theBuffer, Storable &outObj)=0
void SetValue(const std::string &strKey, const std::string &strValue)
std::string transaction_id
std::string ripple_password
virtual bool Exists(std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::string volume_trades
std::string volume_assets
std::string price_per_scale
int64_t ConstructAndCreatePath(std::string &strOutput, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
std::string price_per_scale
virtual bool onStorePlainString(std::string &theBuffer, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")
EXPORT bool StoreObject(Storable &theContents, std::string strFolder, std::string oneStr="", std::string twoStr="", std::string threeStr="")