См. документацию.00001
00002
00003
00004
00005
00006
00007
00008 #ifndef NODE_H_
00009 #define NODE_H_
00010 #include <map>
00011 #include <list>
00012 #include <vector>
00013 #include <string>
00014 #include <sstream>
00015 #include <algorithm>
00016 #include "../options.h"
00017 using namespace std;
00018 string XMLescape(string txt);
00019 struct _Kinds_iterator;
00020
00021 class Node {
00022 protected:
00023 pthread_mutex_t add_remove_mutex;
00024
00025 string name;
00026
00027 map <string, string> attrs;
00028 Node* parent;
00029 string xmlBody;
00030
00031 list <Node*> kinds;
00032
00033 void destroyKinds();
00034 virtual void copyKinds(const Node &basedNode);
00035 bool parentContainSelf();
00036
00037 public:
00038
00039
00040
00041
00042 Node(string name, map <string, string> attrs, Node* parent);
00043 Node(string name, Node* parent=NULL,string xmlns="");
00044 list <Node*>::iterator firstChild(){return kinds.begin();}
00045 list <Node*>::iterator endChild(){return kinds.end();}
00046
00047 string getName(){return name;}
00048
00049 Node* getParent(){return parent;}
00050 void setName(string n){name=n; };
00051 void setNamespace(string xmlns);
00052 void setAttribute(string name, string value);
00053 void setAttribute(string name, long value);
00054 string getAttribute(string name){return attrs[name];};
00055 long getAttributeInt(string name);
00056 string getNamesapace() {return attrs["xmlns"];};
00057 void removeKind(Node* node);
00058 void deleteByXMLNS(string xmlns);
00059 string toXMLString();
00060 string toXMLStringStart();
00061 string toXMLStringEnd();
00062 void setXMLBody(string body){xmlBody=body;};
00063 void addXMLBody(string body){xmlBody+=body;};
00064 void setXMLBody(long body);
00065 string getXMLBody(){return xmlBody;};
00066 long getXMLBodyInt();
00067 Node* getKind(string xmlns);
00068
00069 virtual void addChild(Node* child);
00070 Node(const Node &baseNode);
00071 _Kinds_iterator kindsNameBegin(string name);
00072 _Kinds_iterator kindsNameEnd(string name);
00073 virtual ~Node();
00074 friend class Stanza;
00075 friend class TagIQ;
00076 typedef _Kinds_iterator nameiterator;
00077 Node &operator=(Node &obj);
00078 };
00079
00080 class _Kinds_iterator{
00081 private:
00082 list<Node*>::iterator curitem;
00083 list<Node*>::iterator beginitem;
00084 list<Node*>::iterator enditem;
00085 string name;
00086 public:
00087 _Kinds_iterator &operator++()
00088 {
00089 do{
00090 ++curitem;
00091 }while ((curitem!=enditem)&&((*curitem)->getName()!=name));
00092 return (*this);
00093 }
00094
00095 _Kinds_iterator operator++(int)
00096 {
00097 _Kinds_iterator temp=*this;
00098 do{
00099 ++curitem;
00100 }while ((curitem!=enditem)&&((*curitem)->getName()!=name));
00101 return temp;
00102 }
00103
00104 bool operator==(_Kinds_iterator &i1){
00105 return this->curitem==i1.curitem;
00106 }
00107
00108 bool operator!=(_Kinds_iterator &i1){
00109 return !(*this==i1);
00110 }
00111 Node* operator*() const
00112 { return (*curitem); }
00113 friend class Node;
00114 };
00115
00116 #endif