summaryrefslogtreecommitdiff
path: root/src/pugixml.hpp
diff options
context:
space:
mode:
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);