TinyXML:属性
发布时间:2020-12-16 23:44:38 所属栏目:百科 来源:网络整理
导读:TiXmlAttribute: 代表XML中的属性,TiXmlAttribute中定义了一系列对属性的操作 TiXmlAttribute的友元类: friend class TiXmlAttributeSet TiXmlAttribute的成员函数(即对TiXmlAttribute的操作): TiXmlAttribute();TiXmlAttribute( const std:: string _nam
TiXmlAttribute:代表XML中的属性,TiXmlAttribute中定义了一系列对属性的操作 TiXmlAttribute的友元类:friend class TiXmlAttributeSet
TiXmlAttribute的成员函数(即对TiXmlAttribute的操作):TiXmlAttribute(); TiXmlAttribute( const std::string& _name,const std::string& _value ); TiXmlAttribute( const char * _name,const char * _value ); // 构造一个TiXmlAttribute const char* Name() const { return name.c_str(); } const char* Value() const { return value.c_str(); } const TIXML_STRING& NameTStr() const { return name; } const std::string& ValueStr() const { return value; } // 获取TiXmlAttribute的名字和值 <Student name="value"/> int IntValue() const; double DoubleValue() const; // 返回属性值,并将其转化为int/double int QueryIntValue( int* _value ) const; int QueryDoubleValue( double* _value ) const; // 用于检查值字符串 void SetName( const char* _name ) { name = _name; } void SetValue( const char* _value ) { value = _value; } void SetName( const std::string& _name ) { name = _name; } void SetValue( const std::string& _value ) { value = _value; } // 设置属性名字/值 void SetIntValue( int _value ); void SetDoubleValue( double _value ); // 设置属性值,通过int/double const TiXmlAttribute* Next() const; // 获取此属性在DOM中后一个兄弟属性 TiXmlAttribute* Next(); const TiXmlAttribute* Previous() const; TiXmlAttribute* Previous(); // 获取此属性在DOM中前一个兄弟属性 bool operator==( const TiXmlAttribute& rhs ) const { return rhs.name == name; } bool operator<( const TiXmlAttribute& rhs ) const { return name < rhs.name; } bool operator>( const TiXmlAttribute& rhs ) const { return name > rhs.name; } // 运算符重载 virtual const char* Parse( const char* p,TiXmlParsingData* data,TiXmlEncoding encoding ); virtual void Print( FILE* cfile,int depth ) const; void Print( FILE* cfile,int depth,TIXML_STRING* str ) const; // 将属性print到一个文件流 void SetDocument( TiXmlDocument* doc ) { document = doc; } // 设置document指针,使得属性可以报告错误 TiXmlAttributeSet:相当于TiXmlAttribute的一个辅助类,定义了一些用于属性操作 TiXmlAttributeSet的成员函数(不过多解释,因为都可以从名字上看出相应函数的作用): TiXmlAttributeSet(); ~TiXmlAttributeSet(); void Add( TiXmlAttribute* attribute ); void Remove( TiXmlAttribute* attribute ); const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? 0 : sentinel.next; } const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? 0 : sentinel.prev; } TiXmlAttribute* Find( const char* _name ) const; TiXmlAttribute* FindOrCreate( const char* _name ); (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |