summaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/xml/elements.hxx
blob: 087020961f2c583b27d5494ca9dda9fa79c6d369 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// file      : xsd/cxx/xml/elements.hxx
// copyright : Copyright (c) 2005-2017 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

#ifndef XSD_CXX_XML_ELEMENTS_HXX
#define XSD_CXX_XML_ELEMENTS_HXX

#include <string>

#include <xercesc/util/XercesVersion.hpp>
#include <xercesc/util/PlatformUtils.hpp>

#if _XERCES_VERSION < 30000
#  error Xerces-C++ 2-series is not supported
#endif

namespace xsd
{
  namespace cxx
  {
    namespace xml
    {
      template <typename C>
      class properties
      {
      public:
        struct argument {};


        // Schema location properties. Note that all locations are
        // relative to an instance document unless they are full
        // URIs. For example if you want to use a local schema then
        // you will need to use 'file:///absolute/path/to/your/schema'.
        //

        // Add a location for a schema with a target namespace.
        //
        void
        schema_location (const std::basic_string<C>& namespace_,
                         const std::basic_string<C>& location);

        // Add a location for a schema without a target namespace.
        //
        void
        no_namespace_schema_location (const std::basic_string<C>& location);

      public:
        const std::basic_string<C>&
        schema_location () const
        {
          return schema_location_;
        }

        const std::basic_string<C>&
        no_namespace_schema_location () const
        {
          return no_namespace_schema_location_;
        }

      private:
        std::basic_string<C> schema_location_;
        std::basic_string<C> no_namespace_schema_location_;
      };


      //
      //

      template <typename C>
      std::basic_string<C>
      prefix (const std::basic_string<C>& n);

      template <typename C>
      std::basic_string<C>
      uq_name (const std::basic_string<C>& n);


      //
      //

      inline void
      initialize ()
      {
        xercesc::XMLPlatformUtils::Initialize ();
      }

      inline void
      terminate ()
      {
        xercesc::XMLPlatformUtils::Terminate ();
      }

      struct auto_initializer
      {
        auto_initializer (bool initialize = true, bool terminate = true)
            : terminate_ (initialize && terminate)
        {
          if (initialize)
            xml::initialize ();
        }

        ~auto_initializer ()
        {
          if (terminate_)
            terminate ();
        }

      private:
        bool terminate_;
      };
    }
  }
}

#include <xsd/cxx/xml/elements.txx>

#endif  // XSD_CXX_XML_ELEMENTS_HXX