Merge branch 'master' of git://github.com/jwittner/tinyxml2 into jwittner-master

This commit is contained in:
Lee Thomason 2016-10-27 14:33:52 -07:00
commit c9a6102bf1
2 changed files with 101 additions and 33 deletions

View File

@ -1461,6 +1461,47 @@ const char* XMLElement::Attribute( const char* name, const char* value ) const
return 0; return 0;
} }
int XMLElement::IntAttribute(const char* name, int defaultValue) const
{
int i = defaultValue;
QueryIntAttribute(name, &i);
return i;
}
unsigned XMLElement::UnsignedAttribute(const char* name, unsigned defaultValue) const
{
unsigned i = defaultValue;
QueryUnsignedAttribute(name, &i);
return i;
}
int64_t XMLElement::Int64Attribute(const char* name, int64_t defaultValue) const
{
int64_t i = defaultValue;
QueryInt64Attribute(name, &i);
return i;
}
bool XMLElement::BoolAttribute(const char* name, bool defaultValue) const
{
bool b = defaultValue;
QueryBoolAttribute(name, &b);
return b;
}
double XMLElement::DoubleAttribute(const char* name, double defaultValue) const
{
double d = defaultValue;
QueryDoubleAttribute(name, &d);
return d;
}
float XMLElement::FloatAttribute(const char* name, float defaultValue) const
{
float f = defaultValue;
QueryFloatAttribute(name, &f);
return f;
}
const char* XMLElement::GetText() const const char* XMLElement::GetText() const
{ {
@ -1607,6 +1648,47 @@ XMLError XMLElement::QueryFloatText( float* fval ) const
return XML_NO_TEXT_NODE; return XML_NO_TEXT_NODE;
} }
int XMLElement::IntText(int defaultValue) const
{
int i = defaultValue;
QueryIntText(&i);
return i;
}
unsigned XMLElement::UnsignedText(unsigned defaultValue) const
{
unsigned i = defaultValue;
QueryUnsignedText(&i);
return i;
}
int64_t XMLElement::Int64Text(int64_t defaultValue) const
{
int64_t i = defaultValue;
QueryInt64Text(&i);
return i;
}
bool XMLElement::BoolText(bool defaultValue) const
{
bool b = defaultValue;
QueryBoolText(&b);
return b;
}
double XMLElement::DoubleText(double defaultValue) const
{
double d = defaultValue;
QueryDoubleText(&d);
return d;
}
float XMLElement::FloatText(float defaultValue) const
{
float f = defaultValue;
QueryFloatText(&f);
return f;
}
XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name ) XMLAttribute* XMLElement::FindOrCreateAttribute( const char* name )

View File

@ -1237,44 +1237,17 @@ public:
returned if there is an error. For a method with error returned if there is an error. For a method with error
checking, see QueryIntAttribute() checking, see QueryIntAttribute()
*/ */
int IntAttribute( const char* name ) const { int IntAttribute(const char* name, int defaultValue = 0) const;
int i=0;
QueryIntAttribute( name, &i );
return i;
}
/// See IntAttribute() /// See IntAttribute()
unsigned UnsignedAttribute( const char* name ) const { unsigned UnsignedAttribute(const char* name, unsigned defaultValue = 0) const;
unsigned i=0;
QueryUnsignedAttribute( name, &i );
return i;
}
/// See IntAttribute() /// See IntAttribute()
int64_t Int64Attribute(const char* name) const { int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
int64_t i = 0;
QueryInt64Attribute(name, &i);
return i;
}
/// See IntAttribute() /// See IntAttribute()
bool BoolAttribute( const char* name ) const { bool BoolAttribute(const char* name, bool defaultValue = false) const;
bool b=false;
QueryBoolAttribute( name, &b );
return b;
}
/// See IntAttribute() /// See IntAttribute()
double DoubleAttribute( const char* name ) const { double DoubleAttribute(const char* name, double defaultValue = 0) const;
double d=0;
QueryDoubleAttribute( name, &d );
return d;
}
/// See IntAttribute() /// See IntAttribute()
float FloatAttribute( const char* name ) const { float FloatAttribute(const char* name, float defaultValue = 0) const;
float f=0;
QueryFloatAttribute( name, &f );
return f;
}
/** Given an attribute name, QueryIntAttribute() returns /** Given an attribute name, QueryIntAttribute() returns
XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion XML_SUCCESS, XML_WRONG_ATTRIBUTE_TYPE if the conversion
@ -1548,6 +1521,19 @@ public:
/// See QueryIntText() /// See QueryIntText()
XMLError QueryFloatText( float* fval ) const; XMLError QueryFloatText( float* fval ) const;
int IntText(int defaultValue = 0) const;
/// See QueryIntText()
unsigned UnsignedText(unsigned defaultValue = 0) const;
/// See QueryIntText()
int64_t Int64Text(int64_t defaultValue = 0) const;
/// See QueryIntText()
bool BoolText(bool defaultValue = false) const;
/// See QueryIntText()
double DoubleText(double defaultValue = 0) const;
/// See QueryIntText()
float FloatText(float defaultValue = 0) const;
// internal: // internal:
enum { enum {
OPEN, // <foo> OPEN, // <foo>