[111] | 1 | // file : xsd/cxx/parser/substitution-map.txx |
---|
| 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 | namespace xsd |
---|
| 7 | { |
---|
| 8 | namespace cxx |
---|
| 9 | { |
---|
| 10 | namespace parser |
---|
| 11 | { |
---|
| 12 | template <typename C> |
---|
| 13 | bool substitution_map<C>:: |
---|
| 14 | check_ (const ro_string<C>& ns, |
---|
| 15 | const ro_string<C>& name, |
---|
| 16 | const C* root_ns, |
---|
| 17 | const C* root_name, |
---|
| 18 | const ro_string<C>** type) const |
---|
| 19 | { |
---|
| 20 | key k (ns, name); |
---|
| 21 | typename map::const_iterator i (map_.find (k)); |
---|
| 22 | |
---|
| 23 | if (i == map_.end ()) |
---|
| 24 | return false; |
---|
| 25 | |
---|
| 26 | const value& v (i->second); |
---|
| 27 | |
---|
| 28 | bool r (false); |
---|
| 29 | |
---|
| 30 | if (v.name () == root_name && v.ns () == root_ns) |
---|
| 31 | r = true; |
---|
| 32 | else |
---|
| 33 | r = check_ (v.ns (), v.name (), root_ns, root_name, 0); |
---|
| 34 | |
---|
| 35 | if (r && type != 0 && *type == 0) |
---|
| 36 | *type = &v.type (); |
---|
| 37 | |
---|
| 38 | return r; |
---|
| 39 | } |
---|
| 40 | |
---|
| 41 | // substitution_map_init |
---|
| 42 | // |
---|
| 43 | template<typename C> |
---|
| 44 | substitution_map_init<C>:: |
---|
| 45 | substitution_map_init () |
---|
| 46 | { |
---|
| 47 | if (count == 0) |
---|
| 48 | map = new substitution_map<C>; |
---|
| 49 | |
---|
| 50 | ++count; |
---|
| 51 | } |
---|
| 52 | |
---|
| 53 | template<typename C> |
---|
| 54 | substitution_map_init<C>:: |
---|
| 55 | ~substitution_map_init () |
---|
| 56 | { |
---|
| 57 | if (--count == 0) |
---|
| 58 | delete map; |
---|
| 59 | } |
---|
| 60 | |
---|
| 61 | // substitution_map_entry |
---|
| 62 | // |
---|
| 63 | template<typename C> |
---|
| 64 | substitution_map_entry<C>:: |
---|
| 65 | substitution_map_entry (const C* member_ns, |
---|
| 66 | const C* member_name, |
---|
| 67 | const C* root_ns, |
---|
| 68 | const C* root_name, |
---|
| 69 | const C* member_type) |
---|
| 70 | { |
---|
| 71 | substitution_map_instance<C> ().insert ( |
---|
| 72 | member_ns, member_name, root_ns, root_name, member_type); |
---|
| 73 | } |
---|
| 74 | } |
---|
| 75 | } |
---|
| 76 | } |
---|