标签:add move accept one 友元 virtual unknown ldo fun
对应于DOM结构中的节点,是TinyXML中很重要的一个类,它继承自TiXmlBase
friend class TiXmlDocument; friend class TiXmlElement;
virtual ~TiXmlNode(); const char *Value() const { return value.c_str (); } const std::string& ValueStr() const { return value; } const TIXML_STRING& ValueTStr() const { return value; } // 返回TiXmlNode的值 void SetValue(const char * _value) { value = _value;} void SetValue( const std::string& _value ) { value = _value; } // 设置TiXmlNode的值 void Clear(); // 删除此节点的所有子节点 TiXmlNode* Parent() { return parent; } const TiXmlNode* Parent() const { return parent; } // 获取此节点的父节点 const TiXmlNode* FirstChild() const { return firstChild; } TiXmlNode* FirstChild() { return firstChild; } const TiXmlNode* FirstChild( const char * value ) const; TiXmlNode* FirstChild( const char * _value ); const TiXmlNode* FirstChild( const std::string& _value ) const { return FirstChild (_value.c_str ()); } ///< STL std::string form. TiXmlNode* FirstChild( const std::string& _value ) { return FirstChild (_value.c_str ()); } ///< STL std::string form. // 获取此节点的第一个子节点 const TiXmlNode* LastChild() const { return lastChild; } TiXmlNode* LastChild() { return lastChild; } const TiXmlNode* LastChild( const char * value ) const; TiXmlNode* LastChild( const char * _value ); const TiXmlNode* LastChild( const std::string& _value ) const { return LastChild (_value.c_str ()); } ///< STL std::string form. TiXmlNode* LastChild( const std::string& _value ) { return LastChild (_value.c_str ()); } ///< STL std::string form. // 获取此节点的最后一个子节点 const TiXmlNode* IterateChildren( const TiXmlNode* previous ) const; TiXmlNode* IterateChildren( const TiXmlNode* previous ); const TiXmlNode* IterateChildren( const char * value, const TiXmlNode* previous ) const; TiXmlNode* IterateChildren( const char * _value, const TiXmlNode* previous ); const TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) const { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. TiXmlNode* IterateChildren( const std::string& _value, const TiXmlNode* previous ) { return IterateChildren (_value.c_str (), previous); } ///< STL std::string form. // 提供遍历此节点的子节点的另一种方式,while( child = parent->IterateChildren( child ) ) TiXmlNode* InsertEndChild( const TiXmlNode& addThis ); TiXmlNode* LinkEndChild( TiXmlNode* addThis ); // 插入一个新的子节点,通过引用/指针 TiXmlNode* InsertBeforeChild( TiXmlNode* beforeThis, const TiXmlNode& addThis ); TiXmlNode* InsertAfterChild( TiXmlNode* afterThis, const TiXmlNode& addThis ); // 向某个子节点前(/后)添加一个子节点 TiXmlNode* ReplaceChild( TiXmlNode* replaceThis, const TiXmlNode& withThis ); // 替换掉某个子节点 bool RemoveChild( TiXmlNode* removeThis ); // 删除此节点的某个子节点 const TiXmlNode* PreviousSibling() const { return prev; } TiXmlNode* PreviousSibling() { return prev; } const TiXmlNode* PreviousSibling( const char * ) const; TiXmlNode* PreviousSibling( const char *_prev ); const TiXmlNode* PreviousSibling( const std::string& _value ) const { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. TiXmlNode* PreviousSibling( const std::string& _value ) { return PreviousSibling (_value.c_str ()); } ///< STL std::string form. const TiXmlNode* NextSibling( const std::string& _value) const { return NextSibling (_value.c_str ()); } ///< STL std::string form. TiXmlNode* NextSibling( const std::string& _value) { return NextSibling (_value.c_str ()); } ///< STL std::string form. // 前一个兄弟节点 const TiXmlNode* NextSibling() const { return next; } TiXmlNode* NextSibling() { return next; } const TiXmlNode* NextSibling( const char * ) const; TiXmlNode* NextSibling( const char* _next ); // 后一个兄弟节点 const TiXmlElement* NextSiblingElement() const; TiXmlElement* NextSiblingElement(); const TiXmlElement* NextSiblingElement( const char * ) const; TiXmlElement* NextSiblingElement( const char *_next ); const TiXmlElement* NextSiblingElement( const std::string& _value) const { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. TiXmlElement* NextSiblingElement( const std::string& _value) { return NextSiblingElement (_value.c_str ()); } ///< STL std::string form. const TiXmlElement* FirstChildElement() const; TiXmlElement* FirstChildElement(); const TiXmlElement* FirstChildElement( const char * _value ) const; TiXmlElement* FirstChildElement( const char * _value ); const TiXmlElement* FirstChildElement( const std::string& _value ) const { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. TiXmlElement* FirstChildElement( const std::string& _value ) { return FirstChildElement (_value.c_str ()); } ///< STL std::string form. // Convenience function to get through elements. int Type() const { return type; } // 返回节点类型,下面要讲到的NodeType const TiXmlDocument* GetDocument() const; TiXmlDocument* GetDocument(); // 获取此节点所在DOM的指针 bool NoChildren() const { return !firstChild; } // 测试此节点是否有子节点 virtual const TiXmlDocument* ToDocument() const { return 0; } virtual const TiXmlElement* ToElement() const { return 0; } virtual const TiXmlComment* ToComment() const { return 0; } virtual const TiXmlUnknown* ToUnknown() const { return 0; } virtual const TiXmlText* ToText() const { return 0; } virtual const TiXmlDeclaration* ToDeclaration() const { return 0; } virtual TiXmlDocument* ToDocument() { return 0; } virtual TiXmlElement* ToElement() { return 0; } virtual TiXmlComment* ToComment() { return 0; } virtual TiXmlUnknown* ToUnknown() { return 0; } virtual TiXmlText* ToText() { return 0; } virtual TiXmlDeclaration* ToDeclaration() { return 0; } // 将Node转换为其他NodeType virtual TiXmlNode* Clone() const = 0; // 创建此节点的副本 virtual bool Accept( TiXmlVisitor* visitor ) const = 0; // 是否接受对TinyXML DOM中的节点进行层次访问
TiXmlNode( NodeType _type ); TiXmlNode* parent; NodeType type; TiXmlNode* firstChild; TiXmlNode* lastChild; TIXML_STRING value; TiXmlNode* prev; TiXmlNode* next;
enum NodeType { TINYXML_DOCUMENT, TINYXML_ELEMENT, TINYXML_COMMENT, TINYXML_UNKNOWN, TINYXML_TEXT, TINYXML_DECLARATION, TINYXML_TYPECOUNT };
标签:add move accept one 友元 virtual unknown ldo fun
原文地址:https://www.cnblogs.com/lnlin/p/9651023.html