From dac1f42ef81ac1119430fd294a6b35b0b8cd6837 Mon Sep 17 00:00:00 2001 From: George Hazan Date: Sun, 25 Jan 2015 17:45:10 +0000 Subject: - class KeyStream extracted to the separate module; - xml attributes redesigned to produce efficient code; - many small improvements git-svn-id: http://svn.miranda-ng.org/main/trunk@11905 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- .../WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp | 40 ++++++++++------------ 1 file changed, 18 insertions(+), 22 deletions(-) (limited to 'protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp') diff --git a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp index b79bdcfd09..d4387278e1 100644 --- a/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp +++ b/protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp @@ -5,8 +5,9 @@ * Author: Antonio */ +#include "../common.h" // #TODO Remove Miranda-dependency + #include "BinTreeNodeWriter.h" -#include #include "utilities.h" BinTreeNodeWriter::BinTreeNodeWriter(WAConnection* conn, ISocketConnection* connection, @@ -195,22 +196,21 @@ void BinTreeNodeWriter::writeInt24(int v) this->out->write(v & 0xFF); } -void BinTreeNodeWriter::writeInternal(ProtocolTreeNode* node) +void BinTreeNodeWriter::writeInternal(const ProtocolTreeNode &node) { writeListStart( - 1 + (node->attributes == NULL ? 0 : (int)node->attributes->size() * 2) - + (node->children == NULL ? 0 : 1) - + (node->data == NULL ? 0 : 1)); - writeString(node->tag); - writeAttributes(node->attributes); - if (node->data != NULL) { - writeBytes((unsigned char*)node->data->data(), (int)node->data->size()); - } - if (node->children != NULL && !node->children->empty()) { - writeListStart((int)node->children->size()); - for (size_t a = 0; a < node->children->size(); a++) { - writeInternal((*node->children)[a]); - } + 1 + (node.attributes == NULL ? 0 : (int)node.attributes->size() * 2) + + (node.children == NULL ? 0 : 1) + + (node.data == NULL ? 0 : 1)); + writeString(node.tag); + writeAttributes(node.attributes); + if (node.data != NULL) + writeBytes((unsigned char*)node.data->data(), (int)node.data->size()); + + if (node.children != NULL && !node.children->empty()) { + writeListStart((int)node.children->size()); + for (size_t a = 0; a < node.children->size(); a++) + writeInternal(*(*node.children)[a]); } } @@ -258,21 +258,17 @@ void BinTreeNodeWriter::streamEnd() this->mutex->unlock(); } -void BinTreeNodeWriter::write(ProtocolTreeNode* node) +void BinTreeNodeWriter::write(const ProtocolTreeNode& node) { write(node, true); } -void BinTreeNodeWriter::write(ProtocolTreeNode* node, bool needsFlush) +void BinTreeNodeWriter::write(const ProtocolTreeNode &node, bool needsFlush) { this->mutex->lock(); try { this->writeDummyHeader(); - if (node == NULL) - this->out->write(0); - else { - writeInternal(node); - } + writeInternal(node); flushBuffer(needsFlush); } catch (exception& ex) { -- cgit v1.2.3