added SerializableStruct which defines serialize() and toPropertyTree()

This commit is contained in:
woodser
2019-06-07 09:26:03 -04:00
parent 1a0fd84872
commit 78eb67d4cb
4 changed files with 55 additions and 2 deletions
+24
View File
@@ -0,0 +1,24 @@
#include "utils/MoneroUtils.h"
#include <stdio.h>
#include <iostream>
#include "mnemonics/electrum-words.h"
#include "mnemonics/english.h"
using namespace cryptonote;
using namespace epee;
/**
* Public interface for libmonero-cpp library.
*/
namespace monero {
string SerializableStruct::serialize() {
boost::property_tree::ptree node;
toPropertyTree(node);
return MoneroUtils::serialize(node);
}
// ---------------------------- PRIVATE HELPERS -----------------------------
}
+23
View File
@@ -1,6 +1,9 @@
#include "utils/MoneroUtils.h"
#include "include_base_utils.h"
#include "common/util.h"
#include "wallet/wallet2.h" // TODO: this is imported so BEGIN_KV_SERIALIZE_MAP works; more precise import?
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/json_parser.hpp>
using namespace std;
@@ -9,6 +12,26 @@ using namespace std;
*/
namespace monero {
/**
* Base struct model which is serializable.
*/
struct SerializableStruct {
/**
* Serializes the struct to a json string.
*
* @return the struct serialized to a json string
*/
string serialize();
/**
* Initializes a property tree node from this struct.
*
* @param node is the node to initialize
*/
virtual void toPropertyTree(boost::property_tree::ptree& node);
};
/**
* Enumerates Monero network types.
*/