diff options
author | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-05 22:47:35 +0000 |
---|---|---|
committer | arseny.kapoulkine <arseny.kapoulkine@99668b35-9821-0410-8761-19e4c4f06640> | 2009-01-05 22:47:35 +0000 |
commit | 5a2fa3fe5079c8e917f7938602d3def7df71f210 (patch) | |
tree | a734b02f1cc27f9ba167e14efefd5ac836b95e90 /src/pugixml.cpp | |
parent | 81ef99a27b3ff96ee664ca58054b3b671b97be17 (diff) |
Unsigned integer support for attributes (as_uint, operator=)
git-svn-id: http://pugixml.googlecode.com/svn/trunk@101 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.cpp')
-rw-r--r-- | src/pugixml.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/pugixml.cpp b/src/pugixml.cpp index fbb95f1..e0d74aa 100644 --- a/src/pugixml.cpp +++ b/src/pugixml.cpp @@ -1676,6 +1676,13 @@ namespace pugi return atoi(_attr->value);
}
+ unsigned int xml_attribute::as_uint() const
+ {
+ if(empty() || !_attr->value) return 0;
+ int result = atoi(_attr->value);
+ return result < 0 ? 0 : static_cast<unsigned int>(result);
+ }
+
double xml_attribute::as_double() const
{
if(empty() || !_attr->value) return 0.0;
@@ -1740,6 +1747,14 @@ namespace pugi return *this;
}
+ xml_attribute& xml_attribute::operator=(unsigned int rhs)
+ {
+ char buf[128];
+ sprintf(buf, "%u", rhs);
+ set_value(buf);
+ return *this;
+ }
+
xml_attribute& xml_attribute::operator=(double rhs)
{
char buf[128];
|