summaryrefslogtreecommitdiff
path: root/src/pugixml.hpp
diff options
context:
space:
mode:
authorarseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640>2012-04-03 04:44:36 +0000
committerarseny.kapoulkine@gmail.com <arseny.kapoulkine@gmail.com@99668b35-9821-0410-8761-19e4c4f06640>2012-04-03 04:44:36 +0000
commit40777b2ce1fd576fcdc58cb58fc60b81da3bf791 (patch)
tree96b469499113c3e57198b5c62cec6d65dfb37559 /src/pugixml.hpp
parentf4ac43c549fe98157c80c6c3cd9b65fc42e26d08 (diff)
Added xml_attribute::as_string and xml_text::as_string, added default value to all as_* member functions
git-svn-id: http://pugixml.googlecode.com/svn/trunk@893 99668b35-9821-0410-8761-19e4c4f06640
Diffstat (limited to 'src/pugixml.hpp')
-rw-r--r--src/pugixml.hpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/pugixml.hpp b/src/pugixml.hpp
index 8a781ea..0ca0e6f 100644
--- a/src/pugixml.hpp
+++ b/src/pugixml.hpp
@@ -308,14 +308,17 @@ namespace pugi
const char_t* name() const;
const char_t* value() const;
- // Get attribute value as a number, or 0 if conversion did not succeed or attribute is empty
- int as_int() const;
- unsigned int as_uint() const;
- double as_double() const;
- float as_float() const;
+ // Get attribute value, or the default value if attribute is empty
+ const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
- // Get attribute value as bool (returns true if first character is in '1tTyY' set), or false if attribute is empty
- bool as_bool() const;
+ // Get attribute value as a number, or the default value if conversion did not succeed or attribute is empty
+ int as_int(int def = 0) const;
+ unsigned int as_uint(unsigned int def = 0) const;
+ double as_double(double def = 0) const;
+ float as_float(float def = 0) const;
+
+ // Get attribute value as bool (returns true if first character is in '1tTyY' set), or the default value if attribute is empty
+ bool as_bool(bool def = false) const;
// Set attribute name/value (returns false if attribute is empty or there is not enough memory)
bool set_name(const char_t* rhs);
@@ -613,14 +616,17 @@ namespace pugi
// Get text, or "" if object is empty
const char_t* get() const;
- // Get text as a number, or 0 if conversion did not succeed or object is empty
- int as_int() const;
- unsigned int as_uint() const;
- double as_double() const;
- float as_float() const;
+ // Get text, or the default value if object is empty
+ const char_t* as_string(const char_t* def = PUGIXML_TEXT("")) const;
+
+ // Get text as a number, or the default value if conversion did not succeed or object is empty
+ int as_int(int def = 0) const;
+ unsigned int as_uint(unsigned int def = 0) const;
+ double as_double(double def = 0) const;
+ float as_float(float def = 0) const;
- // Get text as bool (returns true if first character is in '1tTyY' set), or false if object is empty
- bool as_bool() const;
+ // Get text as bool (returns true if first character is in '1tTyY' set), or the default value if object is empty
+ bool as_bool(bool def = false) const;
// Set text (returns false if object is empty or there is not enough memory)
bool set(const char_t* rhs);