blob: b3fc35a604def7238473b6cdb7243399d1a43fc5 (
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
|
// file : xsd/cxx/parser/validating/inheritance-map.hxx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2009 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#ifndef XSD_CXX_PARSER_VALIDATING_INHERITANCE_MAP_HXX
#define XSD_CXX_PARSER_VALIDATING_INHERITANCE_MAP_HXX
#include <map>
#include <cstddef> // std::size_t
#include <xsd/cxx/ro-string.hxx>
namespace xsd
{
namespace cxx
{
namespace parser
{
namespace validating
{
template <typename C>
struct string_comparison
{
bool
operator() (const C* x, const C* y) const
{
ro_string<C> s (x);
return s.compare (y) < 0;
}
};
template <typename C>
struct inheritance_map
{
void
insert (const C* derived, const C* base)
{
map_[derived] = base;
}
void
erase (const C* derived)
{
map_.erase (derived);
}
bool
check (const C* derived, const ro_string<C>& base) const;
private:
typedef std::map<const C*, const C*, string_comparison<C> > map;
map map_;
};
// Translation unit initializer.
//
template<typename C>
struct inheritance_map_init
{
static inheritance_map<C>* map;
static std::size_t count;
inheritance_map_init ();
~inheritance_map_init ();
};
template<typename C>
inheritance_map<C>* inheritance_map_init<C>::map = 0;
template<typename C>
std::size_t inheritance_map_init<C>::count = 0;
template<typename C>
inline inheritance_map<C>&
inheritance_map_instance ()
{
return *inheritance_map_init<C>::map;
}
// Map entry initializer.
//
template<typename C>
struct inheritance_map_entry
{
inheritance_map_entry (const C* derived, const C* base);
~inheritance_map_entry ();
private:
const C* derived_;
};
}
}
}
}
#include <xsd/cxx/parser/validating/inheritance-map.txx>
#endif // XSD_CXX_PARSER_VALIDATING_INHERITANCE_MAP_HXX
|