From 927b97baaaf69e318ff7a0ce76d096375ec09da2 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Fri, 15 Mar 2013 08:22:58 +0200 Subject: Add support for returning XML attributes as map --- cutl/xml/value-traits.txx | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'cutl/xml/value-traits.txx') 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 + T default_value_traits:: + 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 std::string default_value_traits:: 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 (); } } -- cgit v1.1