zoukankan      html  css  js  c++  java
  • 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 );
  • 相关阅读:
    用于主题检测的临时日志(594fb726-af0b-400d-b647-8b1d1b477d72
    返璞归真vc++之字符类型
    DIV居中
    程序员职业生涯
    枚举进程句柄
    不使用mutex设计模式解决并发访问cache
    服务器权重分配算法
    xmemecached中的一致性hash算法
    安卓课堂练习
    pythonPTA---分支循环与集合7-1 jmu-python-韩信点兵 (20分) 7-2 打印数字矩形 (10分) 7-3 成绩统计 (10分) 7-4 找列表中最大元素的下标 7-5 删除列表中的重复值
  • 原文地址:https://www.cnblogs.com/lnlin/p/9651016.html
Copyright © 2011-2022 走看看