aboutsummaryrefslogtreecommitdiff
path: root/cutl/xml/value-traits.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-03-15 08:22:58 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-03-15 08:22:58 +0200
commit927b97baaaf69e318ff7a0ce76d096375ec09da2 (patch)
tree074d633c92c99ec541e7f0631c2fd2a6c5378689 /cutl/xml/value-traits.txx
parent6664a24b003f3959e2efe2893628f725a5f6746f (diff)
Add support for returning XML attributes as map
Diffstat (limited to 'cutl/xml/value-traits.txx')
-rw-r--r--cutl/xml/value-traits.txx13
1 files changed, 12 insertions, 1 deletions
diff --git a/cutl/xml/value-traits.txx b/cutl/xml/value-traits.txx
index 000d6be..4868dba 100644
--- a/cutl/xml/value-traits.txx
+++ b/cutl/xml/value-traits.txx
@@ -12,12 +12,23 @@ namespace cutl
namespace xml
{
template <typename T>
+ T default_value_traits<T>::
+ parse (std::string s, const parser& p)
+ {
+ T r;
+ std::istringstream is (s);
+ if (!(is >> r && is.eof ()) )
+ throw parsing (p, "invalid value '" + s + "'");
+ return r;
+ }
+
+ template <typename T>
std::string default_value_traits<T>::
serialize (const T& v, const serializer& s)
{
std::ostringstream os;
if (!(os << v))
- throw serialization (s.output_name (), "invalid value");
+ throw serialization (s, "invalid value");
return os.str ();
}
}