aboutsummaryrefslogtreecommitdiff
path: root/libxsd/xsd/cxx/tree/element-map.txx
blob: 8b32d2f746c1cfe512cb974b71d4c3f9e203d3a7 (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
// file      : xsd/cxx/tree/element-map.txx
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

namespace xsd
{
  namespace cxx
  {
    namespace tree
    {
      // element_map
      //
      template <typename C, typename T>
      void element_map<C, T>::
      register_parser (const qualified_name& n, parser p)
      {
        (*map_)[n].parser_ = p;
      }

      template <typename C, typename T>
      void element_map<C, T>::
      register_serializer (const qualified_name& n, serializer s)
      {
        (*map_)[n].serializer_ = s;
      }

      // element_map_init
      //
      template <typename C, typename T>
      element_map_init<C, T>::
      element_map_init ()
      {
        if (element_map<C, T>::count_ == 0)
          element_map<C, T>::map_ = new typename element_map<C, T>::map;

        ++element_map<C, T>::count_;
      }

      template <typename C, typename T>
      element_map_init<C, T>::
      ~element_map_init ()
      {
        if (--element_map<C, T>::count_ == 0)
          delete element_map<C, T>::map_;
      }

      // parser_init
      //
      template<typename T, typename C, typename B>
      parser_init<T, C, B>::
      parser_init (const std::basic_string<C>& name,
                   const std::basic_string<C>& ns)
      {
        element_map<C, B>::register_parser (
          xml::qualified_name<C> (name, ns), &parser_impl<T, C, B>);
      }

      // serializer_init
      //
      template<typename T, typename C, typename B>
      serializer_init<T, C, B>::
      serializer_init (const std::basic_string<C>& name,
                   const std::basic_string<C>& ns)
      {
        element_map<C, B>::register_serializer (
          xml::qualified_name<C> (name, ns), &serializer_impl<T, C, B>);
      }
    }
  }
}