diff options
Diffstat (limited to 'examples/cxx/tree/streaming/serializer.hxx')
-rw-r--r-- | examples/cxx/tree/streaming/serializer.hxx | 54 |
1 files changed, 50 insertions, 4 deletions
diff --git a/examples/cxx/tree/streaming/serializer.hxx b/examples/cxx/tree/streaming/serializer.hxx index 6ff0114..48a06bf 100644 --- a/examples/cxx/tree/streaming/serializer.hxx +++ b/examples/cxx/tree/streaming/serializer.hxx @@ -12,12 +12,15 @@ #include <xercesc/dom/DOMElement.hpp> #include <xsd/cxx/xml/dom/auto-ptr.hxx> +#include <xsd/cxx/xml/dom/serialization-header.hxx> // namespace_infomap class serializer_impl; class serializer { public: + typedef xsd::cxx::xml::dom::namespace_infomap<char> namespace_infomap; + ~serializer (); serializer (); @@ -34,12 +37,29 @@ public: next (const std::string& name, const T& x); // Serialize next object model fragment into an element with the specified + // name and namespace declarations. + // + template <typename T> + void + next (const std::string& name, const namespace_infomap&, const T& x); + + // Serialize next object model fragment into an element with the specified // namespace and qualified name. // template <typename T> void next (const std::string& ns, const std::string& name, const T& x); + // Serialize next object model fragment into an element with the specified + // namespace and qualified name as well as namespace declarations. + // + template <typename T> + void + next (const std::string& ns, + const std::string& name, + const namespace_infomap&, + const T& x); + private: serializer (const serializer&); @@ -48,10 +68,12 @@ private: private: xercesc::DOMElement* - create (const std::string& name); + create (const std::string& name, const namespace_infomap&); xercesc::DOMElement* - create (const std::string& ns, const std::string& name); + create (const std::string& ns, + const std::string& name, + const namespace_infomap&); void serialize (xercesc::DOMElement&); @@ -64,7 +86,17 @@ template <typename T> inline void serializer:: next (const std::string& name, const T& x) { - xsd::cxx::xml::dom::auto_ptr<xercesc::DOMElement> e (create (name)); + xsd::cxx::xml::dom::auto_ptr<xercesc::DOMElement> e ( + create (name, namespace_infomap ())); + *e << x; + serialize (*e); +} + +template <typename T> +inline void serializer:: +next (const std::string& name, const namespace_infomap& map, const T& x) +{ + xsd::cxx::xml::dom::auto_ptr<xercesc::DOMElement> e (create (name, map)); *e << x; serialize (*e); } @@ -73,7 +105,21 @@ template <typename T> inline void serializer:: next (const std::string& ns, const std::string& name, const T& x) { - xsd::cxx::xml::dom::auto_ptr<xercesc::DOMElement> e (create (ns, name)); + xsd::cxx::xml::dom::auto_ptr<xercesc::DOMElement> e ( + create (ns, name, namespace_infomap ())); + + *e << x; + serialize (*e); +} + +template <typename T> +inline void serializer:: +next (const std::string& ns, + const std::string& name, + const namespace_infomap& map, + const T& x) +{ + xsd::cxx::xml::dom::auto_ptr<xercesc::DOMElement> e (create (ns, name, map)); *e << x; serialize (*e); } |