Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / ace / XML_Utils / XML_Helper.h
blob71126ac615c95a0f08300a591f486254456f9b4e
1 //============================================================
2 /**
3 * @file XML_Helper.h
5 * @brief Some helper functions for XML
7 * @author Bala Natarajan <bala@dre.vanderbilt.edu>
8 * @author William R. Otte <wotte@dre.vanderbilt.edu>
9 */
10 //============================================================
11 #ifndef ACE_XML_HELPER_H
12 #define ACE_XML_HELPER_H
13 #include /**/ "ace/pre.h"
15 #if !defined (ACE_LACKS_PRAGMA_ONCE)
16 # pragma once
17 #endif /* ACE_LACKS_PRAGMA_ONCE */
19 #include "XML_Error_Handler.h"
20 #include "XML_Schema_Resolver.h"
22 #include "xercesc/util/XercesDefs.hpp"
23 #include "xercesc/parsers/XercesDOMParser.hpp"
25 #include <memory>
27 namespace XERCES_CPP_NAMESPACE
29 class DOMDocument;
30 class DOMWriter;
31 class DOMImplementation;
32 class DOMDocumentType;
35 namespace XML
37 /**
38 * @class XML_Helper
40 * @brief Helper class for some routine XML stuff.
42 template <typename Resolver = XML_Schema_Resolver <>,
43 typename Error_Handler = XML_Error_Handler>
44 class XML_Helper
46 public:
47 XML_Helper (Resolver *resolver = nullptr, Error_Handler *eh = nullptr);
49 ~XML_Helper ();
51 /// Create a DOM tree
52 XERCES_CPP_NAMESPACE::DOMDocument *
53 create_dom (const ACE_TCHAR *uri) const;
55 XERCES_CPP_NAMESPACE::DOMDocument *
56 create_dom (const ACE_TCHAR *root,
57 const ACE_TCHAR *ns,
58 XERCES_CPP_NAMESPACE::DOMDocumentType * doctype = 0) const;
60 XERCES_CPP_NAMESPACE::DOMDocumentType *
61 create_doctype (const ACE_TCHAR *qn,
62 const ACE_TCHAR *pid,
63 const ACE_TCHAR *sid) const;
65 /// Writes out a DOMDocument to an XML file
66 bool write_DOM (XERCES_CPP_NAMESPACE::DOMDocument *doc,
67 const ACE_TCHAR *file) const;
69 bool is_initialized () const;
71 /// Terminate the parser
72 void terminate_parser ();
74 Resolver &get_resolver ();
76 Error_Handler &get_error_handler ();
78 protected:
79 /// Initialize the parser
80 void init_parser ();
82 private:
83 bool initialized_ { false };
84 XERCES_CPP_NAMESPACE::DOMImplementation *impl_ {};
85 mutable std::unique_ptr<XERCES_CPP_NAMESPACE::XercesDOMParser> parser_;
87 Resolver *resolver_;
88 bool release_resolver_ { false };
89 Error_Handler *e_handler_;
90 bool release_e_handler_ { false };
94 #include "XML_Helper.tpp"
96 #include /**/ "ace/post.h"
97 #endif/*ACE_XML_HELPER_H*/