32 #ifndef LEDGER_CORE_TEZOSLIKEWEBSOCKETNOTIFICATIONPARSER_H 33 #define LEDGER_CORE_TEZOSLIKEWEBSOCKETNOTIFICATIONPARSER_H 37 #include <rapidjson/reader.h> 39 #include <net/HttpClient.hpp> 40 #include <collections/collections.hpp> 41 #include "../TezosLikeBlockchainExplorer.h" 42 #include "TezosLikeBlockParser.h" 43 #include "TezosLikeTransactionParser.h" 44 #include <wallet/common/explorers/api/AbstractWebSocketNotificationParser.h> 47 #define PROXY_PARSE_TEZOS_WS(method, ...) \ 48 auto& currentObject = _currentObject; \ 49 if (currentObject == "transaction") { \ 50 return getTransactionParser().method(__VA_ARGS__); \ 56 :
public AbstractWebSocketNotificationParser<TezosLikeBlockchainExplorerTransaction, TezosLikeBlockchainExplorer::Block, TezosLikeTransactionParser, TezosLikeBlockParser> {
61 _blockParser(lastKey),
62 _transactionParser(lastKey) {
66 bool Key(
const rapidjson::Reader::Ch *str, rapidjson::SizeType length,
bool copy)
override {
67 _lastKey = std::string(str, length);
77 auto lastKey = getLastKey();
78 if (lastKey ==
"transaction") {
79 _currentObject = lastKey;
80 getTransactionParser().init(&_result->transaction);
83 PROXY_PARSE_TEZOS_WS(StartObject) {
88 bool RawNumber(
const rapidjson::Reader::Ch *str, rapidjson::SizeType length,
90 PROXY_PARSE_TEZOS_WS(
String, str, length, copy) {
91 auto value = std::string(str, length);
92 if (getLastKey() ==
"block_height") {
93 BigInt bigIntValue = BigInt::fromString(value);
94 _result->block.height = bigIntValue.toUint64();
101 String(
const rapidjson::Reader::Ch *str, rapidjson::SizeType length,
bool copy) {
103 auto value = std::string(str, length);
104 if (getLastKey() ==
"type") {
105 _result->type = value;
108 PROXY_PARSE_TEZOS_WS(
String, str, length, copy) {
109 if (getLastKey() ==
"block_hash") {
110 _result->block.hash = value;
116 bool EndObject(rapidjson::SizeType memberCount) {
120 PROXY_PARSE_WS(EndObject, memberCount) {
128 return _transactionParser;
135 std::string &getLastKey()
override {
140 std::string &_lastKey;
147 #endif //LEDGER_CORE_TEZOSLIKEWEBSOCKETNOTIFICATIONPARSER_H Definition: TezosLikeBlockchainExplorer.h:68
Definition: TezosLikeBlockParser.h:40
Definition: TezosLikeTransactionParser.h:48
Definition: Account.cpp:8
Definition: AbstractWebSocketNotificationParser.h:46
Definition: TezosLikeWebSocketNotificationParser.h:55