From ce3dfdff0d03697bf0c9e0cc9fb45dc6ef7c4ba9 Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Wed, 13 Mar 2013 12:42:37 +0200 Subject: Add support for XML serializing values other than std::string --- cutl/xml/value-traits.txx | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 cutl/xml/value-traits.txx (limited to 'cutl/xml/value-traits.txx') diff --git a/cutl/xml/value-traits.txx b/cutl/xml/value-traits.txx new file mode 100644 index 0000000..000d6be --- /dev/null +++ b/cutl/xml/value-traits.txx @@ -0,0 +1,24 @@ +// 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 + 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"); + return os.str (); + } + } +} -- cgit v1.1