diff options
author | George Hazan <george.hazan@gmail.com> | 2015-01-25 17:45:10 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2015-01-25 17:45:10 +0000 |
commit | dac1f42ef81ac1119430fd294a6b35b0b8cd6837 (patch) | |
tree | e3b972fc4bb56a3158e57adc70df6655f6a34dcf /protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp | |
parent | 357ae09c7eba86e783583566816285750933beaa (diff) |
- 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
Diffstat (limited to 'protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp')
-rw-r--r-- | protocols/WhatsApp/src/WhatsAPI++/BinTreeNodeWriter.cpp | 40 |
1 files changed, 18 insertions, 22 deletions
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 <cstring>
#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) {
|