mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-11-16 21:25:45 +01:00
added SerializableStruct which defines serialize() and toPropertyTree()
This commit is contained in:
@@ -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 -----------------------------
|
||||
|
||||
}
|
||||
@@ -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.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user