TinyXML:属性

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 ) constvoid 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 );

 

转载于:https://www.cnblogs.com/lnlin/p/9651016.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值