UnsignedInt64 support
This commit is contained in:
19
tinyxml2.cpp
19
tinyxml2.cpp
@@ -653,6 +653,16 @@ bool XMLUtil::ToInt64(const char* str, int64_t* value)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool XMLUtil::ToUnsigned64(const char* str, uint64_t* value) {
|
||||||
|
unsigned long long v = 0; // horrible syntax trick to make the compiler happy about %llu
|
||||||
|
if(TIXML_SSCANF(str, "%llu", &v) == 1) {
|
||||||
|
*value = (uint64_t)v;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
char* XMLDocument::Identify( char* p, XMLNode** node )
|
char* XMLDocument::Identify( char* p, XMLNode** node )
|
||||||
{
|
{
|
||||||
TIXMLASSERT( node );
|
TIXMLASSERT( node );
|
||||||
@@ -1414,6 +1424,15 @@ XMLError XMLAttribute::QueryInt64Value(int64_t* value) const
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
XMLError XMLAttribute::QueryUnsigned64Value(uint64_t* value) const
|
||||||
|
{
|
||||||
|
if(XMLUtil::ToUnsigned64(Value(), value)) {
|
||||||
|
return XML_SUCCESS;
|
||||||
|
}
|
||||||
|
return XML_WRONG_ATTRIBUTE_TYPE;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
XMLError XMLAttribute::QueryBoolValue( bool* value ) const
|
XMLError XMLAttribute::QueryBoolValue( bool* value ) const
|
||||||
{
|
{
|
||||||
if ( XMLUtil::ToBool( Value(), value )) {
|
if ( XMLUtil::ToBool( Value(), value )) {
|
||||||
|
|||||||
21
tinyxml2.h
21
tinyxml2.h
@@ -625,7 +625,7 @@ public:
|
|||||||
static bool ToFloat( const char* str, float* value );
|
static bool ToFloat( const char* str, float* value );
|
||||||
static bool ToDouble( const char* str, double* value );
|
static bool ToDouble( const char* str, double* value );
|
||||||
static bool ToInt64(const char* str, int64_t* value);
|
static bool ToInt64(const char* str, int64_t* value);
|
||||||
|
static bool ToUnsigned64(const char* str, uint64_t* value);
|
||||||
// Changes what is serialized for a boolean value.
|
// Changes what is serialized for a boolean value.
|
||||||
// Default to "true" and "false". Shouldn't be changed
|
// Default to "true" and "false". Shouldn't be changed
|
||||||
// unless you have a special testing or compatibility need.
|
// unless you have a special testing or compatibility need.
|
||||||
@@ -1164,6 +1164,12 @@ public:
|
|||||||
return i;
|
return i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Unsigned64Value() const {
|
||||||
|
uint64_t i = 0;
|
||||||
|
QueryUnsigned64Value(&i);
|
||||||
|
return i;
|
||||||
|
}
|
||||||
|
|
||||||
/// Query as an unsigned integer. See IntValue()
|
/// Query as an unsigned integer. See IntValue()
|
||||||
unsigned UnsignedValue() const {
|
unsigned UnsignedValue() const {
|
||||||
unsigned i=0;
|
unsigned i=0;
|
||||||
@@ -1199,6 +1205,8 @@ public:
|
|||||||
/// See QueryIntValue
|
/// See QueryIntValue
|
||||||
XMLError QueryInt64Value(int64_t* value) const;
|
XMLError QueryInt64Value(int64_t* value) const;
|
||||||
/// See QueryIntValue
|
/// See QueryIntValue
|
||||||
|
XMLError QueryUnsigned64Value(uint64_t* value) const;
|
||||||
|
/// See QueryIntValue
|
||||||
XMLError QueryBoolValue( bool* value ) const;
|
XMLError QueryBoolValue( bool* value ) const;
|
||||||
/// See QueryIntValue
|
/// See QueryIntValue
|
||||||
XMLError QueryDoubleValue( double* value ) const;
|
XMLError QueryDoubleValue( double* value ) const;
|
||||||
@@ -1302,6 +1310,8 @@ public:
|
|||||||
/// See IntAttribute()
|
/// See IntAttribute()
|
||||||
int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
|
int64_t Int64Attribute(const char* name, int64_t defaultValue = 0) const;
|
||||||
/// See IntAttribute()
|
/// See IntAttribute()
|
||||||
|
uint64_t Unsigned64Attribute(const char* name, uint64_t defaultValue = 0) const;
|
||||||
|
/// See IntAttribute()
|
||||||
bool BoolAttribute(const char* name, bool defaultValue = false) const;
|
bool BoolAttribute(const char* name, bool defaultValue = false) const;
|
||||||
/// See IntAttribute()
|
/// See IntAttribute()
|
||||||
double DoubleAttribute(const char* name, double defaultValue = 0) const;
|
double DoubleAttribute(const char* name, double defaultValue = 0) const;
|
||||||
@@ -1348,6 +1358,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// See QueryIntAttribute()
|
/// See QueryIntAttribute()
|
||||||
|
XMLError QueryUnsigned64Attribute(const char* name, uint64_t* value) const {
|
||||||
|
const XMLAttribute* a = FindAttribute(name);
|
||||||
|
if(!a) {
|
||||||
|
return XML_NO_ATTRIBUTE;
|
||||||
|
}
|
||||||
|
return a->QueryUnsigned64Value(value);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// See QueryIntAttribute()
|
||||||
XMLError QueryBoolAttribute( const char* name, bool* value ) const {
|
XMLError QueryBoolAttribute( const char* name, bool* value ) const {
|
||||||
const XMLAttribute* a = FindAttribute( name );
|
const XMLAttribute* a = FindAttribute( name );
|
||||||
if ( !a ) {
|
if ( !a ) {
|
||||||
|
|||||||
Reference in New Issue
Block a user