Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef GNASH_ASOBJ3_XMLNODE_H
00021 #define GNASH_ASOBJ3_XMLNODE_H
00022
00023 #include <list>
00024 #include <string>
00025 #include <sstream>
00026 #include <cassert>
00027
00028 #include "Relay.h"
00029
00030 namespace gnash {
00031 class as_object;
00032 class Global_as;
00033 struct ObjectURI;
00034 }
00035
00036 namespace gnash {
00037
00038
00040
00043
00054 class XMLNode_as : public Relay
00055 {
00056 public:
00057
00058 enum NodeType {
00059 Element = 1,
00060 Attribute = 2,
00061 Text = 3,
00062 Cdata = 4,
00063 EntityRef = 5,
00064 Entity = 6,
00065 ProcInstr = 7,
00066 Comment = 8,
00067 Document = 9,
00068 DocType = 10,
00069 DocFragment = 11,
00070 Notation = 12
00071 };
00072
00073 XMLNode_as(Global_as& gl);
00074
00075 virtual ~XMLNode_as();
00076
00077 size_t length() const { return _children.size(); }
00078
00079 const std::string& nodeName() const { return _name; }
00080
00081 const std::string& nodeValue() const { return _value; }
00082
00084 NodeType nodeType() const { return _type; }
00085
00087 void nodeTypeSet(NodeType type) {
00088 _type = type;
00089 }
00090
00092 void nodeNameSet(const std::string& name) { _name = name; }
00093
00094 bool extractPrefix(std::string& prefix);
00095
00097 void nodeValueSet(const std::string& value) { _value = value; }
00098
00100 void getNamespaceForPrefix(const std::string& prefix, std::string& ns);
00101
00103
00105 bool getPrefixForNamespace(const std::string& ns, std::string& prefix);
00106
00107 void setNamespaceURI(const std::string value) {
00108 _namespaceURI = value;
00109 }
00110
00111 const std::string& getNamespaceURI() const {
00112 return _namespaceURI;
00113 }
00114
00117 bool hasChildNodes();
00118
00119 XMLNode_as* firstChild();
00120 XMLNode_as* lastChild();
00121
00122
00123 typedef std::list<XMLNode_as*> Children;
00124
00125 as_object* childNodes();
00126
00127 XMLNode_as* previousSibling();
00128 XMLNode_as* nextSibling();
00129
00131
00136 XMLNode_as* cloneNode(bool deep);
00137
00139
00142
00144
00146 void appendChild(XMLNode_as* node);
00147
00149
00152
00154
00156 void removeChild(XMLNode_as* node);
00157
00159 XMLNode_as* getParent() const {
00160 return _parent;
00161 }
00162
00164
00178 void insertBefore(XMLNode_as* newnode, XMLNode_as* pos);
00179
00181
00186 virtual void toString(std::ostream& str, bool encode = false) const;
00187
00189 as_object* getAttributes() const { return _attributes; }
00190
00192
00197 void setAttribute(const std::string& name, const std::string& value);
00198
00200
00204 void setObject(as_object* o) {
00205 assert(!_object);
00206 assert(o);
00207 _object = o;
00208 }
00209
00211
00213 as_object* object();
00214
00215 protected:
00216
00218
00220 virtual void setReachable();
00221
00222 Global_as& _global;
00223
00225
00228 void clearChildren();
00229
00230 private:
00231
00233
00235 void setParent(XMLNode_as* node) { _parent = node; }
00236
00238
00242 void updateChildNodes();
00243
00245 XMLNode_as(const XMLNode_as &node, bool deep);
00246
00247 Children _children;
00248
00249 as_object* _object;
00250
00251 XMLNode_as* _parent;
00252
00253 as_object* _attributes;
00254
00255 as_object* _childNodes;
00256
00257 std::string _name;
00258
00259 std::string _value;
00260
00261 NodeType _type;
00262
00263 std::string _namespaceURI;
00264
00265 static void stringify(const XMLNode_as& xml, std::ostream& xmlout,
00266 bool encode);
00267
00268 };
00269
00270
00271 void xmlnode_class_init(as_object& where, const ObjectURI& uri);
00272
00274 void registerXMLNodeNative(as_object& where);
00275
00276 }
00277
00278
00279 #endif
00280
00281
00282
00283
00284
00285
00286