summaryrefslogtreecommitdiff
path: root/protocols/WhatsAppWeb/src/utils.h
diff options
context:
space:
mode:
authorGeorge Hazan <ghazan@miranda.im>2021-04-23 16:29:57 +0300
committerGeorge Hazan <ghazan@miranda.im>2021-04-23 16:29:57 +0300
commit2b49ffbabfb41a50a764cf666f9de226e89da856 (patch)
tree51bcccc9c70b7cdfffc58d52a98d81bc2ecac8ac /protocols/WhatsAppWeb/src/utils.h
parent413700b665fcc1475410d2df2d92dff249b97bc2 (diff)
perversion with XML -> JSON translation replaced with hand-made pseudo-XML WANode class
Diffstat (limited to 'protocols/WhatsAppWeb/src/utils.h')
-rw-r--r--protocols/WhatsAppWeb/src/utils.h34
1 files changed, 31 insertions, 3 deletions
diff --git a/protocols/WhatsAppWeb/src/utils.h b/protocols/WhatsAppWeb/src/utils.h
index d37c8fb187..c2a5d90ca3 100644
--- a/protocols/WhatsAppWeb/src/utils.h
+++ b/protocols/WhatsAppWeb/src/utils.h
@@ -20,6 +20,34 @@ Copyright © 2019-21 George Hazan
#define BINARY_32 254
#define NIBBLE_8 255
+class WANode // kinda XML
+{
+ struct Attr
+ {
+ Attr(const char *pszName, const char *pszValue) :
+ name(pszName),
+ value(pszValue)
+ {}
+
+ CMStringA name, value;
+ };
+
+ std::list<Attr*> attrs;
+
+public:
+ WANode();
+ ~WANode();
+
+ void addAttr(const char *pszName, const char *pszValue);
+ CMStringA getAttr(const char *pszFieldValue) const;
+
+ void print(CMStringA &dest, int level = 0) const;
+
+ CMStringA title;
+ MBinBuffer content;
+ std::list<WANode*> children;
+};
+
class WAReader
{
const BYTE *m_buf, *m_limit;
@@ -37,11 +65,11 @@ public:
__forceinline uint32_t readInt16() { return readIntN(2); }
__forceinline uint32_t readInt32() { return readIntN(4); }
- bool readAttributes(JSONNode &node, int count);
+ bool readAttributes(WANode *node, int count);
uint32_t readInt20();
- bool readList(JSONNode &node, int tag);
+ bool readList(WANode *pParent, int tag);
int readListSize(int tag);
CMStringA readPacked(int tag);
CMStringA readString(int tag);
- bool readNode(JSONNode&);
+ WANode* readNode();
};