diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2014-05-08 17:50:12 -0700 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2014-05-08 17:50:12 -0700 |
commit | fec681be83c91268ee4db97f34ce4e47179316dd (patch) | |
tree | b59a2bc6a916225a989015a2f33168b8d35b0946 /xml/serializer.ixx | |
parent | a6e24513d89067c16a3df214a7e2679e1f1675f1 (diff) |
Add helpers for serializing elements with simple content
Diffstat (limited to 'xml/serializer.ixx')
-rw-r--r-- | xml/serializer.ixx | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/xml/serializer.ixx b/xml/serializer.ixx index d329bbd..81631f2 100644 --- a/xml/serializer.ixx +++ b/xml/serializer.ixx @@ -19,6 +19,55 @@ namespace xml } inline void serializer:: + element (const std::string& v) + { + if (!v.empty ()) + characters (v); + + end_element (); + } + + template <typename T> + inline void serializer:: + element (const T& v) + { + element (value_traits<T>::serialize (v, *this)); + } + + inline void serializer:: + element (const std::string& n, const std::string& v) + { + element (std::string (), n, v); + } + + template <typename T> + inline void serializer:: + element (const std::string& n, const T& v) + { + element (n, value_traits<T>::serialize (v, *this)); + } + + inline void serializer:: + element (const qname_type& qn, const std::string& v) + { + element (qn.namespace_ (), qn.name (), v); + } + + template <typename T> + inline void serializer:: + element (const qname_type& qn, const T& v) + { + element (qn, value_traits<T>::serialize (v, *this)); + } + + template <typename T> + inline void serializer:: + element (const std::string& ns, const std::string& n, const T& v) + { + element (ns, n, value_traits<T>::serialize (v, *this)); + } + + inline void serializer:: start_attribute (const qname_type& qname) { start_attribute (qname.namespace_ (), qname.name ()); |