| 1 | // file : xsd/cxx/xml/elements.hxx |
|---|
| 2 | // author : Boris Kolpackov <boris@codesynthesis.com> |
|---|
| 3 | // copyright : Copyright (c) 2005-2008 Code Synthesis Tools CC |
|---|
| 4 | // license : GNU GPL v2 + exceptions; see accompanying LICENSE file |
|---|
| 5 | |
|---|
| 6 | #ifndef XSD_CXX_XML_ELEMENTS_HXX |
|---|
| 7 | #define XSD_CXX_XML_ELEMENTS_HXX |
|---|
| 8 | |
|---|
| 9 | #include <string> |
|---|
| 10 | |
|---|
| 11 | #include <xercesc/util/PlatformUtils.hpp> |
|---|
| 12 | |
|---|
| 13 | namespace xsd |
|---|
| 14 | { |
|---|
| 15 | namespace cxx |
|---|
| 16 | { |
|---|
| 17 | namespace xml |
|---|
| 18 | { |
|---|
| 19 | template <typename C> |
|---|
| 20 | class properties |
|---|
| 21 | { |
|---|
| 22 | public: |
|---|
| 23 | struct argument {}; |
|---|
| 24 | |
|---|
| 25 | |
|---|
| 26 | // Schema location properties. Note that all locations are |
|---|
| 27 | // relative to an instance document unless they are full |
|---|
| 28 | // URIs. For example if you want to use a local schema then |
|---|
| 29 | // you will need to use 'file:///absolute/path/to/your/schema'. |
|---|
| 30 | // |
|---|
| 31 | |
|---|
| 32 | // Add a location for a schema with a target namespace. |
|---|
| 33 | // |
|---|
| 34 | void |
|---|
| 35 | schema_location (const std::basic_string<C>& namespace_, |
|---|
| 36 | const std::basic_string<C>& location); |
|---|
| 37 | |
|---|
| 38 | // Add a location for a schema without a target namespace. |
|---|
| 39 | // |
|---|
| 40 | void |
|---|
| 41 | no_namespace_schema_location (const std::basic_string<C>& location); |
|---|
| 42 | |
|---|
| 43 | public: |
|---|
| 44 | const std::basic_string<C>& |
|---|
| 45 | schema_location () const |
|---|
| 46 | { |
|---|
| 47 | return schema_location_; |
|---|
| 48 | } |
|---|
| 49 | |
|---|
| 50 | const std::basic_string<C>& |
|---|
| 51 | no_namespace_schema_location () const |
|---|
| 52 | { |
|---|
| 53 | return no_namespace_schema_location_; |
|---|
| 54 | } |
|---|
| 55 | |
|---|
| 56 | private: |
|---|
| 57 | std::basic_string<C> schema_location_; |
|---|
| 58 | std::basic_string<C> no_namespace_schema_location_; |
|---|
| 59 | }; |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | // |
|---|
| 63 | // |
|---|
| 64 | |
|---|
| 65 | template <typename C> |
|---|
| 66 | std::basic_string<C> |
|---|
| 67 | prefix (const std::basic_string<C>& n); |
|---|
| 68 | |
|---|
| 69 | template <typename C> |
|---|
| 70 | std::basic_string<C> |
|---|
| 71 | uq_name (const std::basic_string<C>& n); |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | // |
|---|
| 75 | // |
|---|
| 76 | |
|---|
| 77 | inline void |
|---|
| 78 | initialize () |
|---|
| 79 | { |
|---|
| 80 | xercesc::XMLPlatformUtils::Initialize (); |
|---|
| 81 | } |
|---|
| 82 | |
|---|
| 83 | inline void |
|---|
| 84 | terminate () |
|---|
| 85 | { |
|---|
| 86 | xercesc::XMLPlatformUtils::Terminate (); |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | struct auto_initializer |
|---|
| 90 | { |
|---|
| 91 | auto_initializer (bool initialize = true, bool terminate = true) |
|---|
| 92 | : terminate_ (initialize && terminate) |
|---|
| 93 | { |
|---|
| 94 | if (initialize) |
|---|
| 95 | xml::initialize (); |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | ~auto_initializer () |
|---|
| 99 | { |
|---|
| 100 | if (terminate_) |
|---|
| 101 | terminate (); |
|---|
| 102 | } |
|---|
| 103 | |
|---|
| 104 | private: |
|---|
| 105 | bool terminate_; |
|---|
| 106 | }; |
|---|
| 107 | } |
|---|
| 108 | } |
|---|
| 109 | } |
|---|
| 110 | |
|---|
| 111 | #include <xsd/cxx/xml/elements.txx> |
|---|
| 112 | |
|---|
| 113 | #endif // XSD_CXX_XML_ELEMENTS_HXX |
|---|