代表XML中的属性,TiXmlAttribute中定义了一系列对属性的操作
friend class TiXmlAttributeSet
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的名字和值
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指针,使得属性可以报告错误
相当于TiXmlAttribute的一个辅助类,定义了一些用于属性操作
TiXmlAttributeSet的成员函数(不过多解释,因为都可以从名字上看出相应函数的作用):
TiXmlAttributeSet();
~TiXmlAttributeSet();
void Add( TiXmlAttribute* attribute );
void Remove( TiXmlAttribute* attribute );
const TiXmlAttribute* First() const { return ( sentinel.next == &sentinel ) ? : sentinel.next; }
TiXmlAttribute* First() { return ( sentinel.next == &sentinel ) ? : sentinel.next; }
const TiXmlAttribute* Last() const { return ( sentinel.prev == &sentinel ) ? : sentinel.prev; }
TiXmlAttribute* Last() { return ( sentinel.prev == &sentinel ) ? : sentinel.prev; }
TiXmlAttribute* Find( const char* _name ) const;
TiXmlAttribute* FindOrCreate( const char* _name );
手机扫一扫
移动阅读更方便
你可能感兴趣的文章