From 8286ac511144e4f17d34eac9affb97e50646344a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 15:25:44 +0200 Subject: Imported Upstream version 4.0.0 --- libcutl/cutl/xml/value-traits.txx | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 libcutl/cutl/xml/value-traits.txx (limited to 'libcutl/cutl/xml/value-traits.txx') diff --git a/libcutl/cutl/xml/value-traits.txx b/libcutl/cutl/xml/value-traits.txx new file mode 100644 index 0000000..4868dba --- /dev/null +++ b/libcutl/cutl/xml/value-traits.txx @@ -0,0 +1,35 @@ +// file : cutl/xml/value-traits.txx +// copyright : Copyright (c) 2009-2013 Code Synthesis Tools CC +// license : MIT; see accompanying LICENSE file + +#include + +#include +#include + +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, "invalid value"); + return os.str (); + } + } +} -- cgit v1.2.3