// file : xsd/cxx/xml/dom/serialization-source.hxx // author : Boris Kolpackov // copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC // license : GNU GPL v2 + exceptions; see accompanying LICENSE file #ifndef XSD_CXX_XML_DOM_SERIALIZATION_SOURCE_HXX #define XSD_CXX_XML_DOM_SERIALIZATION_SOURCE_HXX #include #include #include #include #include #include #include // XMLFormatTarget, XMLFormatter #include #include #include // name #include namespace xsd { namespace cxx { namespace xml { namespace dom { // // template xercesc::DOMAttr& create_attribute (const C* name, xercesc::DOMElement&); template xercesc::DOMAttr& create_attribute (const C* name, const C* ns, xercesc::DOMElement&); template xercesc::DOMElement& create_element (const C* name, xercesc::DOMElement&); template xercesc::DOMElement& create_element (const C* name, const C* ns, xercesc::DOMElement&); // Serialization flags. // const unsigned long no_xml_declaration = 0x00010000UL; const unsigned long dont_pretty_print = 0x00020000UL; template xml::dom::auto_ptr serialize (const std::basic_string& root_element, const std::basic_string& root_element_namespace, const namespace_infomap& map, unsigned long flags); // This one helps Sun C++ to overcome its fears. // template inline xml::dom::auto_ptr serialize (const C* root_element, const C* root_element_namespace, const namespace_infomap& map, unsigned long flags) { return serialize (std::basic_string (root_element), std::basic_string (root_element_namespace), map, flags); } // // template bool serialize (xercesc::XMLFormatTarget& target, const xercesc::DOMDocument& doc, const std::basic_string& enconding, error_handler& eh, unsigned long flags); template bool serialize (xercesc::XMLFormatTarget& target, const xercesc::DOMDocument& doc, const std::basic_string& enconding, xercesc::DOMErrorHandler& eh, unsigned long flags); // // class ostream_format_target: public xercesc::XMLFormatTarget { public: ostream_format_target (std::ostream& os) : os_ (os) { } public: // I know, some of those consts are stupid. But that's what // Xerces folks put into their interfaces and VC-7.1 thinks // there are different signatures if one strips this fluff off. // virtual void writeChars (const XMLByte* const buf, #if _XERCES_VERSION >= 30000 const XMLSize_t size, #else const unsigned int size, #endif xercesc::XMLFormatter* const) { // Ignore the data if there was a stream failure and // the stream is not using exceptions. // if (!(os_.bad () || os_.fail ())) { os_.write (reinterpret_cast (buf), static_cast (size)); } } virtual void flush () { // Ignore the flush request if there was a stream failure // and the stream is not using exceptions. // if (!(os_.bad () || os_.fail ())) { os_.flush (); } } private: std::ostream& os_; }; } } } } #include #endif // XSD_CXX_XML_DOM_SERIALIZATION_SOURCE_HXX