Follow this link to skip to the main content

pug::xml_attribute Class Reference

#include <pugxml.h>

Collaboration diagram for pug::xml_attribute:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 xml_attribute ()
 xml_attribute (xml_attribute_struct *attr)
 xml_attribute (xml_attribute_struct *attr, const bool delete_attr)
 xml_attribute (const xml_attribute &r)
virtual ~xml_attribute ()
void attach (xml_attribute_struct *v)
xml_attributeoperator= (const xml_attribute &r)
bool operator== (const xml_attribute &r)
bool operator!= (const xml_attribute &r)
 operator xml_attribute_struct * ()
 operator std::string ()
 operator const TCHAR * ()
 operator int ()
 operator long ()
 operator double ()
 operator bool ()
xml_attributeoperator= (const std::string &rhs)
xml_attributeoperator= (const TCHAR *rhs)
xml_attributeoperator= (const int rhs)
xml_attributeoperator= (const long rhs)
xml_attributeoperator= (const double rhs)
xml_attributeoperator= (const bool rhs)
xml_attributeoperator>> (std::string &rhs)
xml_attributeoperator>> (long &rhs)
xml_attributeoperator>> (double &rhs)
xml_attributeoperator>> (bool &rhs)
bool empty () const
bool has_name () const
bool has_value () const
bool has_name (const TCHAR *name) const
bool has_value (const TCHAR *value) const
const TCHARname () const
std::string getname ()
bool name (TCHAR *new_name)
const TCHARvalue ()
std::string getvalue ()
bool value (const TCHAR *new_value)

Protected Attributes

xml_attribute_struct_attr
bool _delete_attr

Friends

long & operator<< (long &lhs, xml_attribute &rhs)
double & operator<< (double &lhs, xml_attribute &rhs)
bool & operator<< (bool &lhs, xml_attribute &rhs)
xml_attributeoperator<< (xml_attribute &lhs, const long rhs)
xml_attributeoperator<< (xml_attribute &lhs, const double &rhs)
xml_attributeoperator<< (xml_attribute &lhs, const bool &rhs)

Detailed Description

Definition at line 1519 of file pugxml.h.


Constructor & Destructor Documentation

pug::xml_attribute::xml_attribute (  )  [inline]

Definition at line 1527 of file pugxml.h.

01527 : _attr(NULL), _delete_attr(false) {} //Default constructor.

pug::xml_attribute::xml_attribute ( xml_attribute_struct attr  )  [inline]

Definition at line 1528 of file pugxml.h.

01528 : _attr(attr), _delete_attr(false) {} //Initializing constructor.

pug::xml_attribute::xml_attribute ( xml_attribute_struct attr,
const bool  delete_attr 
) [inline]

Definition at line 1529 of file pugxml.h.

01529                                                                         : 
01530         _attr(attr), _delete_attr(delete_attr) {} //Initializing constructor. NF 3 Mar 2003

pug::xml_attribute::xml_attribute ( const xml_attribute r  )  [inline]

Definition at line 1531 of file pugxml.h.

01531 : _attr(r._attr),  _delete_attr(r._delete_attr) {} //Copy constructor.

virtual pug::xml_attribute::~xml_attribute (  )  [inline, virtual]

Definition at line 1532 of file pugxml.h.

01532 { if  (_delete_attr) delete _attr; } //Destructor.


Member Function Documentation

void pug::xml_attribute::attach ( xml_attribute_struct v  )  [inline]

Definition at line 1535 of file pugxml.h.

01535 { _attr = v; }

xml_attribute& pug::xml_attribute::operator= ( const xml_attribute r  )  [inline]

Definition at line 1536 of file pugxml.h.

References _attr.

01536 { _attr = r._attr; return *this; } //Assign internal pointer.

bool pug::xml_attribute::operator== ( const xml_attribute r  )  [inline]

Definition at line 1537 of file pugxml.h.

References _attr.

01537 { return (_attr == r._attr); } //Compare internal pointer.

bool pug::xml_attribute::operator!= ( const xml_attribute r  )  [inline]

Definition at line 1538 of file pugxml.h.

References _attr.

01538 { return (_attr != r._attr); }

pug::xml_attribute::operator xml_attribute_struct * (  )  [inline]

Definition at line 1539 of file pugxml.h.

01539 { return _attr; }

pug::xml_attribute::operator std::string (  )  [inline]

Definition at line 1544 of file pugxml.h.

References _attr, has_value(), and pug::t_xml_attribute_struct::value.

01545         {
01546           std::string temp;
01547           if(has_value())
01548             {
01549 #ifdef PUGOPT_NONSEG
01550               // temp.append(_attr->value,_attr->value_size);
01551               temp.assign(_attr->value,_attr->value_size);  // NF 2 Mar 2003
01552 #else
01553               temp = _attr->value;
01554 #endif
01555             }
01556           return temp;
01557         }

Here is the call graph for this function:

pug::xml_attribute::operator const TCHAR * (  )  [inline]

Definition at line 1562 of file pugxml.h.

01563         {
01564           if(!has_value()) return NULL;
01565           return _attr->value;
01566         }

pug::xml_attribute::operator int (  )  [inline]

Definition at line 1574 of file pugxml.h.

References _tcsncpy, _tcstol, and PUGDEF_ATTR_VALU_SIZE.

01575         {
01576           if(!has_value()) return 0;
01577 #ifdef PUGOPT_NONSEG
01578           TCHAR temp[PUGDEF_ATTR_VALU_SIZE];
01579           unsigned int valulen = sizeof(temp)-1;
01580           const unsigned int maxlen = valulen ? min(valulen,_attr->value_size) : _attr->value_size;
01581           _tcsncpy(temp,_attr->value,maxlen);
01582           temp[maxlen] = 0;
01583           return (int)_tcstol( temp, NULL, 0 );    // rem: base = 0 so value can be Dec|Octal|Hex
01584 #else
01585           return (int)_tcstol( _attr->value, NULL, 0 ); // rem: base = 0 so value can be Dec|Octal|Hex
01586 #endif
01587         }

pug::xml_attribute::operator long (  )  [inline]

Definition at line 1591 of file pugxml.h.

References _tcsncpy, _tcstol, and PUGDEF_ATTR_VALU_SIZE.

01592         {
01593           if(!has_value()) return 0;
01594 #ifdef PUGOPT_NONSEG
01595           TCHAR temp[PUGDEF_ATTR_VALU_SIZE];
01596           unsigned int valulen = sizeof(temp)-1;
01597           const unsigned int maxlen = valulen ? min(valulen,_attr->value_size) : _attr->value_size;
01598           _tcsncpy(temp,_attr->value,maxlen);
01599           temp[maxlen] = 0;
01600           return _tcstol(temp,NULL,10);
01601 #else
01602           return _tcstol(_attr->value,NULL,10);
01603 #endif
01604         }

pug::xml_attribute::operator double (  )  [inline]

Definition at line 1608 of file pugxml.h.

References _tcsncpy, _tcstod, and PUGDEF_ATTR_VALU_SIZE.

01609         {
01610           if(!has_value()) return 0.0;
01611 #ifdef PUGOPT_NONSEG
01612           TCHAR temp[PUGDEF_ATTR_VALU_SIZE];
01613           unsigned int valulen = sizeof(temp)-1;
01614           const unsigned int maxlen = valulen ? min(valulen,_attr->value_size) : _attr->value_size;
01615           _tcsncpy(temp,_attr->value,maxlen);
01616           temp[maxlen] = 0;
01617           return _tcstod(temp,0);
01618 #else
01619           return _tcstod(_attr->value,0);
01620 #endif
01621         }

pug::xml_attribute::operator bool (  )  [inline]

Definition at line 1625 of file pugxml.h.

References _T.

01626         {
01627           if(!has_value()) return false;
01628           if(*(_attr->value))
01629             {
01630               return //Only look at first char:
01631                 (
01632                  *(_attr->value) == _T('1') || //1*
01633                  *(_attr->value) == _T('t') || //t* (true)
01634                  *(_attr->value) == _T('T') || //T* (True|TRUE)
01635                  *(_attr->value) == _T('y') || //y* (yes)
01636                  *(_attr->value) == _T('Y') //Y* (Yes|YES)
01637                  )
01638                 ? true : false; //Return true if matches above, else false.
01639             }
01640           return false;
01641         }

xml_attribute& pug::xml_attribute::operator= ( const std::string &  rhs  )  [inline]

Definition at line 1645 of file pugxml.h.

01645 { value(rhs.c_str()); return *this; }

xml_attribute& pug::xml_attribute::operator= ( const TCHAR rhs  )  [inline]

Definition at line 1650 of file pugxml.h.

01650 { if(rhs) value(rhs); return *this; }

xml_attribute& pug::xml_attribute::operator= ( const int  rhs  )  [inline]

Definition at line 1656 of file pugxml.h.

References _itot.

01657         {
01658           TCHAR temp[32] = {0};
01659           _itot( rhs, temp, 10 );
01660           value(temp);
01661           return *this;
01662         }

xml_attribute& pug::xml_attribute::operator= ( const long  rhs  )  [inline]

Definition at line 1666 of file pugxml.h.

References _ltot.

01667         {
01668           TCHAR temp[32] = {0};
01669           // _stprintf(temp,_T("%ld"),rhs);
01670           _ltot( rhs, temp, 10 );    // NF changed from _stprintf 5 Mar 2003
01671           value(temp);
01672           return *this;
01673         }

xml_attribute& pug::xml_attribute::operator= ( const double  rhs  )  [inline]

Definition at line 1677 of file pugxml.h.

References _stprintf, and _T.

01678         {
01679           TCHAR temp[32] = {0};
01680           _stprintf(temp,_T("%f"),rhs);
01681           value(temp);
01682           return *this;
01683         }

xml_attribute& pug::xml_attribute::operator= ( const bool  rhs  )  [inline]

Definition at line 1687 of file pugxml.h.

References _T.

01688         {
01689           value(rhs?_T("true"):_T("false"));
01690           return *this;
01691         }

xml_attribute& pug::xml_attribute::operator>> ( std::string &  rhs  )  [inline]

Definition at line 1695 of file pugxml.h.

01696         {
01697 #ifdef PUGOPT_NONSEG
01698           // rhs.clear();  // NF 2 Mar 2003
01699           // rhs.append(_attr->value,_attr->value_size);
01700           rhs.assign(_attr->value,_attr->value_size);
01701 #else
01702           rhs = value();
01703 #endif
01704           return *this;
01705         }

xml_attribute& pug::xml_attribute::operator>> ( long &  rhs  )  [inline]

Definition at line 1709 of file pugxml.h.

01709 { rhs = (long)*this; return *this; }

xml_attribute& pug::xml_attribute::operator>> ( double &  rhs  )  [inline]

Definition at line 1714 of file pugxml.h.

01714 { rhs = (double)*this; return *this; }

xml_attribute& pug::xml_attribute::operator>> ( bool &  rhs  )  [inline]

Definition at line 1719 of file pugxml.h.

01719 { rhs = (bool)*this; return *this; }

bool pug::xml_attribute::empty (  )  const [inline]

Definition at line 1758 of file pugxml.h.

01758 { return (_attr == NULL); } //True if the internal xml_attribute_struct pointer is NULL.

bool pug::xml_attribute::has_name (  )  const [inline]

Definition at line 1759 of file pugxml.h.

01759 { return (!empty() && _attr->name); } //True if the attribute has a name.

bool pug::xml_attribute::has_value (  )  const [inline]

bool pug::xml_attribute::has_name ( const TCHAR name  )  const [inline]

Definition at line 1769 of file pugxml.h.

References _tcscmp.

01769                                              { 
01770         return (name && !empty() && has_name() && _tcscmp(_attr->name,name)==0); 
01771       } //Is named 'name'.

bool pug::xml_attribute::has_value ( const TCHAR value  )  const [inline]

Definition at line 1772 of file pugxml.h.

References _tcscmp.

01772                                                { 
01773         return (value && !empty() && has_value() && _tcscmp(_attr->value,value)==0);
01774       } //Has value 'value'.

const TCHAR* pug::xml_attribute::name (  )  const [inline]

Definition at line 1777 of file pugxml.h.

References _T, and name().

Referenced by name().

01777                                 { 
01778         return (!empty() && _attr->name) ? _attr->name : _T(""); 
01779       } //Access the attribute name.

Here is the call graph for this function:

std::string pug::xml_attribute::getname (  )  [inline]

Definition at line 1782 of file pugxml.h.

01783         {
01784           std::string temp;
01785           if( has_name() )
01786             {
01787 #ifdef PUGOPT_NONSEG
01788               temp.assign(_attr->name,_attr->name_size);
01789 #else
01790               temp = _attr->name;
01791 #endif
01792             }
01793           return temp;
01794         }

bool pug::xml_attribute::name ( TCHAR new_name  )  [inline]

Definition at line 1801 of file pugxml.h.

References pug::strcpyinsitu().

01802         {
01803           if(!empty() && new_name)
01804 #ifdef PUGOPT_NONSEG
01805             return strcpyinsitu(&_attr->name,new_name,&_attr->name_insitu,_attr->name_size);
01806 #else
01807           return strcpyinsitu(&_attr->name,new_name,&_attr->name_insitu);
01808 #endif
01809           return false;
01810         }

Here is the call graph for this function:

const TCHAR* pug::xml_attribute::value (  )  [inline]

Definition at line 1811 of file pugxml.h.

References _T.

Referenced by claraty::Parameter_Parser::_evaluate_expression(), claraty::Parameter_Parser::_fetch_var_value(), claraty::Parameter_Parser::_get_double(), and claraty::Parameter_Parser::evaluate_expression().

01811 { return (!empty()) ? _attr->value : _T(""); } //Access the attribute value.

std::string pug::xml_attribute::getvalue (  )  [inline]

Definition at line 1812 of file pugxml.h.

01812 { return *this; } // Access the attribute value. uses operator std::string(). NF 2 Mar 2003

bool pug::xml_attribute::value ( const TCHAR new_value  )  [inline]

Definition at line 1816 of file pugxml.h.

References pug::strcpyinsitu().

01817         {
01818           if(!empty() && new_value)
01819 #ifdef PUGOPT_NONSEG
01820             return strcpyinsitu(&_attr->value,new_value,&_attr->value_insitu,_attr->value_size);
01821 #else
01822           return strcpyinsitu(&_attr->value,new_value,&_attr->value_insitu);
01823 #endif
01824           return false;
01825         }

Here is the call graph for this function:


Friends And Related Function Documentation

long& operator<< ( long &  lhs,
xml_attribute rhs 
) [friend]

Definition at line 1725 of file pugxml.h.

01725 { lhs = (long)rhs; return lhs; }

double& operator<< ( double &  lhs,
xml_attribute rhs 
) [friend]

Definition at line 1731 of file pugxml.h.

01731 { lhs = (double)rhs; return lhs; }

bool& operator<< ( bool &  lhs,
xml_attribute rhs 
) [friend]

Definition at line 1737 of file pugxml.h.

01737 { lhs = (bool)rhs; return lhs; }

xml_attribute& operator<< ( xml_attribute lhs,
const long  rhs 
) [friend]

Definition at line 1743 of file pugxml.h.

01743 { lhs = rhs; return lhs; }

xml_attribute& operator<< ( xml_attribute lhs,
const double &  rhs 
) [friend]

Definition at line 1749 of file pugxml.h.

01749 { lhs = rhs; return lhs; }

xml_attribute& operator<< ( xml_attribute lhs,
const bool &  rhs 
) [friend]

Definition at line 1755 of file pugxml.h.

01755 { lhs = rhs; return lhs; }


Member Data Documentation

Definition at line 1524 of file pugxml.h.


The documentation for this class was generated from the following file: