From 89f3cf8bbb9dc1fa0fe72f6af6638ac086c7e011 Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Wed, 29 Nov 2017 09:33:41 +0300 Subject: libevent, telegram, whatsapp moved to deprecated coz doesn't work --- .../WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp | 183 --------------------- 1 file changed, 183 deletions(-) delete mode 100644 protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp (limited to 'protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp') diff --git a/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp b/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp deleted file mode 100644 index 2e04563fda..0000000000 --- a/protocols/WhatsApp/src/WhatsAPI++/ProtocolTreeNode.cpp +++ /dev/null @@ -1,183 +0,0 @@ -/* - * ProtocolTreeNode.cpp - * - * Created on: 26/06/2012 - * Author: Antonio - */ - -#include "../stdafx.h" // #TODO Remove Miranda-dependency - -#include "WAException.h" -#include "ProtocolTreeNode.h" - -static std::string nilstr; - -ProtocolTreeNode::ProtocolTreeNode(const string &_tag, vector* _data, vector *_children) : - tag(_tag) -{ - data = _data; - attributes = NULL; - children = _children; -} - -ProtocolTreeNode::ProtocolTreeNode(const string &_tag, ProtocolTreeNode *_child) : - tag(_tag) -{ - this->data = NULL; - this->attributes = NULL; - this->children = new std::vector(); - children->push_back(_child); -} - -ProtocolTreeNode::~ProtocolTreeNode() -{ - delete this->attributes; - - if (this->children != NULL) { - for (size_t i = 0; i < this->children->size(); i++) - if (this->children->at(i) != NULL) - delete this->children->at(i); - delete this->children; - } - - delete data; -} - - -string ProtocolTreeNode::toString() const -{ - string out; - out += "<" + this->tag; - if (this->attributes != NULL) { - map::iterator ii; - for (ii = attributes->begin(); ii != attributes->end(); ii++) - out += " " + ii->first + "=\"" + ii->second + "\""; - } - out += ">\n"; - out += getDataAsString(); - - if (this->children != NULL) { - vector::iterator ii; - for (ii = children->begin(); ii != children->end(); ii++) - out += (*ii)->toString(); - } - - out += "tag + ">\n"; - - return out; -} - -ProtocolTreeNode* ProtocolTreeNode::getChild(const string& id) -{ - if (this->children == NULL || this->children->size() == 0) - return NULL; - - for (std::size_t i = 0; i < this->children->size(); i++) - if (id.compare((*children)[i]->tag) == 0) - return (*children)[i]; - - return NULL; -} - -ProtocolTreeNode* ProtocolTreeNode::getChild(size_t id) -{ - if (this->children == NULL || this->children->size() == 0) - return NULL; - - if (children->size() > id) - return (*children)[id]; - - return NULL; -} - -const string& ProtocolTreeNode::getAttributeValue(const string& attribute) -{ - if (this->attributes == NULL) - return nilstr; - - map::iterator it = attributes->find(attribute); - if (it == attributes->end()) - return nilstr; - - return it->second; -} - -vector ProtocolTreeNode::getAllChildren() -{ - if (this->children == NULL) - return vector(); - - return *this->children; -} - -std::string ProtocolTreeNode::getDataAsString() const -{ - if (this->data == NULL) - return nilstr; - return std::string(this->data->begin(), this->data->end()); -} - -vector ProtocolTreeNode::getAllChildren(const string &tag) -{ - vector ret; - - if (this->children != NULL) - for (size_t i = 0; i < this->children->size(); i++) - if (tag.compare((*children)[i]->tag) == 0) - ret.push_back((*children)[i]); - - return ret; -} - -bool ProtocolTreeNode::tagEquals(ProtocolTreeNode *node, const string& tag) -{ - return (node != NULL && node->tag.compare(tag) == 0); -} - -void ProtocolTreeNode::require(ProtocolTreeNode *node, const string& tag) -{ - if (!tagEquals(node, tag)) - throw WAException("failed require. node:" + node->toString() + "tag: " + tag, WAException::CORRUPT_STREAM_EX, 0); -} - -///////////////////////////////////////////////////////////////////////////////////////// - -ProtocolTreeNode& operator<<(ProtocolTreeNode &node, const XATTR &attr) -{ - if (node.attributes == NULL) - node.attributes = new map; - - (*node.attributes)[attr.name] = attr.value; - return node; -} - -ProtocolTreeNode* operator<<(ProtocolTreeNode *node, const XATTR &attr) -{ - if (node->attributes == NULL) - node->attributes = new map; - - (*node->attributes)[attr.name] = attr.value; - return node; -} - -ProtocolTreeNode& operator<<(ProtocolTreeNode &node, const XATTRI &attr) -{ - if (node.attributes == NULL) - node.attributes = new map; - - char szValue[100]; - _itoa_s(attr.value, szValue, 10); - (*node.attributes)[attr.name] = szValue; - return node; -} - -ProtocolTreeNode* operator<<(ProtocolTreeNode *node, const XATTRI &attr) -{ - if (node->attributes == NULL) - node->attributes = new map; - - char szValue[100]; - _itoa_s(attr.value, szValue, 10); - (*node->attributes)[attr.name] = szValue; - return node; -} -- cgit v1.2.3