aboutsummaryrefslogtreecommitdiff
path: root/libxsde/xsde/cxx/parser/substitution-map.ixx
blob: 8cc0cc5a10e158996a89744238db83ca8bda3325 (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
// file      : xsde/cxx/parser/substitution-map.ixx
// copyright : Copyright (c) 2005-2011 Code Synthesis Tools CC
// license   : GNU GPL v2 + exceptions; see accompanying LICENSE file

namespace xsde
{
  namespace cxx
  {
    namespace parser
    {
      inline substitution_map::
      substitution_map (size_t buckets)
          : hashmap (buckets, sizeof (value)), callback_ (0)
      {
      }

      inline void substitution_map::
      insert (const char* member,
              const char* root,
              const char* type)
      {
        value v;
        v.root_ = root;
        v.type_ = type;
        hashmap::insert (member, &v);
      }

      inline void substitution_map::
      callback (callback_func c)
      {
        callback_ = c;
      }

      inline bool substitution_map::
      check (const ro_string& member_ns,
             const ro_string& member_name,
             const char* root,
             const char*& type) const
      {

        return !empty () || callback_ != 0
          ? check_ (member_ns, member_name, root, &type)
          : false;
      }

      inline bool substitution_map::
      check (const ro_string& member_ns,
             const ro_string& member_name,
             const char* root_ns,
             const char* root_name,
             const char*& type) const
      {
        return !empty () || callback_ != 0
          ? check_ (member_ns, member_name, root_ns, root_name, &type)
          : false;
      }

      inline bool substitution_map::
      check (const ro_string& member_ns,
             const ro_string& member_name,
             const char* root) const
      {

        return !empty () || callback_ != 0
          ? check_ (member_ns, member_name, root, 0)
          : false;
      }

      inline substitution_map&
      substitution_map_instance ()
      {
        return *substitution_map_init::map;
      }
    }
  }
}