31 #include <rapidjson/reader.h> 32 #include <net/HttpClient.hpp> 36 #ifndef LEDGER_CORE_ABSTRACTTRANSACTIONSPARSER_H 37 #define LEDGER_CORE_ABSTRACTTRANSACTIONSPARSER_H 39 #define PROXY_PARSE_TX(method, ...) \ 40 if (_arrayDepth > 0) { \ 41 return getTransactionParser().method(__VA_ARGS__); \ 48 template <
typename BlockchainExplorerTransaction,
typename TxParser>
57 PROXY_PARSE_TX(Bool, b)
61 PROXY_PARSE_TX(Int, i)
64 bool Uint(
unsigned i) {
65 PROXY_PARSE_TX(Uint, i)
68 bool Int64(int64_t i) {
69 PROXY_PARSE_TX(Int64, i)
72 bool Uint64(uint64_t i) {
73 PROXY_PARSE_TX(Uint64, i)
76 bool Double(
double d) {
77 PROXY_PARSE_TX(Double, d)
81 RawNumber(
const rapidjson::Reader::Ch *str, rapidjson::SizeType length,
bool copy) {
82 PROXY_PARSE_TX(RawNumber, str, length, copy)
85 bool String(
const rapidjson::Reader::Ch *str, rapidjson::SizeType length,
bool copy) {
86 PROXY_PARSE_TX(
String, str, length, copy)
92 if (_arrayDepth == 1 && _objectDepth == 1) {
93 BlockchainExplorerTransaction transaction;
94 _transactions->push_back(transaction);
95 getTransactionParser().init(&_transactions->back());
98 PROXY_PARSE_TX(StartObject)
101 bool Key(
const rapidjson::Reader::Ch *str, rapidjson::SizeType length,
bool copy) {
102 PROXY_PARSE_TX(Key, str, length, copy)
105 bool EndObject(rapidjson::SizeType memberCount) {
106 if (_arrayDepth > 0) {
108 auto result = getTransactionParser().EndObject(memberCount);
116 if (_arrayDepth > 0) {
117 _arrayDepth = _arrayDepth + 1;
118 return getTransactionParser().StartArray();
120 _arrayDepth = _arrayDepth + 1;
125 bool EndArray(rapidjson::SizeType elementCount) {
127 PROXY_PARSE_TX(EndArray, elementCount)
133 std::vector<BlockchainExplorerTransaction> *transactions) {
134 _transactions = transactions;
138 virtual TxParser &getTransactionParser() = 0;
139 std::vector<BlockchainExplorerTransaction>* _transactions;
140 uint32_t _arrayDepth;
141 uint32_t _objectDepth;
146 #endif //LEDGER_CORE_ABSTRACTTRANSACTIONSPARSER_H Definition: AbstractTransactionsParser.h:49
Definition: Account.cpp:8