mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-18 15:51:34 +02:00
compiling with toPropertyTree() overrides
This commit is contained in:
@@ -12,28 +12,25 @@ namespace monero {
|
||||
// -------------------------- MODEL SERIALIZATION ---------------------------
|
||||
|
||||
string SerializableStruct::serialize() const {
|
||||
return MoneroUtils::serialize(toPropertyTree2());
|
||||
return MoneroUtils::serialize(toPropertyTree());
|
||||
}
|
||||
|
||||
boost::property_tree::ptree SerializableStruct::toPropertyTree2() const {
|
||||
boost::property_tree::ptree node;
|
||||
toPropertyTree(node);
|
||||
return node;
|
||||
}
|
||||
|
||||
void MoneroBlockHeader::toPropertyTree(boost::property_tree::ptree& node) const {
|
||||
boost::property_tree::ptree MoneroBlockHeader::toPropertyTree() const {
|
||||
cout << "MoneroBlockHeader::toPropertyTree(block)" << endl;
|
||||
throw runtime_error("not implemented");
|
||||
}
|
||||
|
||||
void MoneroBlock::toPropertyTree(boost::property_tree::ptree& node) const {
|
||||
boost::property_tree::ptree MoneroBlock::toPropertyTree() const {
|
||||
cout << "MoneroBlock::toPropertyTree(block)" << endl;
|
||||
boost::property_tree::ptree node;
|
||||
if (height != boost::none) node.put("height", *height); // TODO: finish this, add txs
|
||||
//node.add_child("txs", toPropertyTree(txs)); // TODO: txs is vector<shared_ptr<MoneroTx>> so need to handle
|
||||
return node;
|
||||
}
|
||||
|
||||
void MoneroTx::toPropertyTree(boost::property_tree::ptree& node) const {
|
||||
boost::property_tree::ptree MoneroTx::toPropertyTree() const {
|
||||
cout << "MoneroTx::txToPropertyTree(tx)" << endl;
|
||||
boost::property_tree::ptree node;
|
||||
if (id != boost::none) node.put("id", *id);
|
||||
if (version != boost::none) node.put("version", *version);
|
||||
if (isCoinbase != boost::none) node.put("isCoinbase", *isCoinbase);
|
||||
@@ -71,6 +68,7 @@ namespace monero {
|
||||
if (maxUsedBlockHeight != boost::none) node.put("maxUsedBlockHeight", *maxUsedBlockHeight);
|
||||
if (maxUsedBlockId != boost::none) node.put("maxUsedBlockId", *maxUsedBlockId);
|
||||
if (!signatures.empty()) throw runtime_error("not implemented");
|
||||
return node;
|
||||
}
|
||||
|
||||
// ---------------------------- PRIVATE HELPERS -----------------------------
|
||||
|
||||
@@ -27,14 +27,7 @@ namespace monero {
|
||||
*
|
||||
* @return the converted property tree
|
||||
*/
|
||||
boost::property_tree::ptree toPropertyTree2() const;
|
||||
|
||||
/**
|
||||
* Convert the struct to a property tree.
|
||||
*
|
||||
* @param node is the property tree node to initialize from the struct
|
||||
*/
|
||||
virtual void toPropertyTree(boost::property_tree::ptree& node) const = 0;
|
||||
virtual boost::property_tree::ptree toPropertyTree() const = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -106,7 +99,7 @@ namespace monero {
|
||||
boost::optional<string> maxUsedBlockId;
|
||||
vector<string> signatures;
|
||||
|
||||
void toPropertyTree(boost::property_tree::ptree& node) const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -131,7 +124,7 @@ namespace monero {
|
||||
boost::optional<string> prevId;
|
||||
boost::optional<uint64_t> reward;
|
||||
|
||||
void toPropertyTree(boost::property_tree::ptree& node) const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -143,7 +136,7 @@ namespace monero {
|
||||
vector<shared_ptr<MoneroTx>> txs;
|
||||
vector<string> txIds;
|
||||
|
||||
void toPropertyTree(boost::property_tree::ptree& node) const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -16,23 +16,26 @@ namespace monero {
|
||||
|
||||
// -------------------------- MODEL SERIALIZATION ---------------------------
|
||||
|
||||
void MoneroAccount::toPropertyTree(boost::property_tree::ptree& node) const {
|
||||
boost::property_tree::ptree MoneroAccount::toPropertyTree() const {
|
||||
cout << "MoneroAccount::toPropertyTree(node)" << endl;
|
||||
boost::property_tree::ptree node;
|
||||
if (index != boost::none) node.put("index", *index);
|
||||
if (primaryAddress != boost::none) node.put("primaryAddress", *primaryAddress);
|
||||
if (balance != boost::none) node.put("balance", *balance);
|
||||
if (unlockedBalance != boost::none) node.put("unlockedBalance", *unlockedBalance);
|
||||
if (!subaddresses.empty()) {
|
||||
boost::property_tree::ptree subaddressesNode;
|
||||
for (const auto& subaddress : subaddresses) {
|
||||
subaddressesNode.push_back(std::make_pair("", subaddress.toPropertyTree2()));
|
||||
for (const MoneroSubaddress& subaddress : subaddresses) {
|
||||
subaddressesNode.push_back(std::make_pair("", subaddress.toPropertyTree()));
|
||||
}
|
||||
node.add_child("subaddresses", subaddressesNode);
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
void MoneroSubaddress::toPropertyTree(boost::property_tree::ptree& node) const {
|
||||
boost::property_tree::ptree MoneroSubaddress::toPropertyTree() const {
|
||||
cout << "MoneroSubaddress::toPropertyTree(node)" << endl;
|
||||
boost::property_tree::ptree node;
|
||||
if (accountIndex != boost::none) node.put("accountIndex", *accountIndex);
|
||||
if (index != boost::none) node.put("index", *index);
|
||||
if (address != boost::none) node.put("address", *address);
|
||||
@@ -44,11 +47,11 @@ namespace monero {
|
||||
if (numBlocksToUnlock != boost::none) node.put("numBlocksToUnlock", *numBlocksToUnlock);
|
||||
}
|
||||
|
||||
void MoneroTxWallet::toPropertyTree(boost::property_tree::ptree& node) const {
|
||||
boost::property_tree::ptree MoneroTxWallet::toPropertyTree() const {
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
void MoneroTxRequest::toPropertyTree(boost::property_tree::ptree& node) const {
|
||||
boost::property_tree::ptree MoneroTxRequest::toPropertyTree() const {
|
||||
throw runtime_error("Not implemented");
|
||||
}
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ namespace monero {
|
||||
// KV_SERIALIZE(numBlocksToUnlock)
|
||||
// END_KV_SERIALIZE_MAP()
|
||||
|
||||
void toPropertyTree(boost::property_tree::ptree& node) const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -75,7 +75,7 @@ namespace monero {
|
||||
// KV_SERIALIZE(subaddresses)
|
||||
// END_KV_SERIALIZE_MAP()
|
||||
|
||||
void toPropertyTree(boost::property_tree::ptree& node) const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
// forward declarations
|
||||
@@ -137,7 +137,7 @@ namespace monero {
|
||||
boost::optional<uint32_t> numSuggestedConfirmations;
|
||||
boost::optional<string> note;
|
||||
|
||||
virtual void toPropertyTree(boost::property_tree::ptree& node) const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -178,7 +178,7 @@ namespace monero {
|
||||
boost::optional<MoneroTransferRequest> transferRequest;
|
||||
|
||||
boost::optional<uint64_t> getHeight() { return block == boost::none ? boost::none : (*block)->height; }
|
||||
virtual void toPropertyTree(boost::property_tree::ptree& node) const;
|
||||
boost::property_tree::ptree toPropertyTree() const;
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user