aboutsummaryrefslogtreecommitdiff
path: root/cutl/xml/value-traits.txx
diff options
context:
space:
mode:
authorBoris Kolpackov <boris@codesynthesis.com>2013-03-13 12:42:37 +0200
committerBoris Kolpackov <boris@codesynthesis.com>2013-03-13 12:42:37 +0200
commitce3dfdff0d03697bf0c9e0cc9fb45dc6ef7c4ba9 (patch)
tree8aee46f0a3382e300f5970322933edb638709e52 /cutl/xml/value-traits.txx
parent29aff5bf19aa23c784bb09b74dc388ccb5f495e2 (diff)
Add support for XML serializing values other than std::string
Diffstat (limited to 'cutl/xml/value-traits.txx')
-rw-r--r--cutl/xml/value-traits.txx24
1 files changed, 24 insertions, 0 deletions
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 <sstream>
+
+#include <cutl/xml/parser.hxx>
+#include <cutl/xml/serializer.hxx>
+
+namespace cutl
+{
+ namespace xml
+ {
+ 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");
+ return os.str ();
+ }
+ }
+}