aboutsummaryrefslogtreecommitdiff
path: root/cutl/xml/value-traits.txx
diff options
context:
space:
mode:
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 ();
}
}