From 2615896faa646e5830abf2c269150e1165c66515 Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Fri, 18 Dec 2020 18:48:46 +0300 Subject: Switch to build2 --- libxsd/libxsd/cxx/parser/substitution-map.txx | 82 +++++++++++++++++++++++++++ 1 file changed, 82 insertions(+) create mode 100644 libxsd/libxsd/cxx/parser/substitution-map.txx (limited to 'libxsd/libxsd/cxx/parser/substitution-map.txx') diff --git a/libxsd/libxsd/cxx/parser/substitution-map.txx b/libxsd/libxsd/cxx/parser/substitution-map.txx new file mode 100644 index 0000000..1b7705b --- /dev/null +++ b/libxsd/libxsd/cxx/parser/substitution-map.txx @@ -0,0 +1,82 @@ +// file : libxsd/cxx/parser/substitution-map.txx +// license : GNU GPL v2 + exceptions; see accompanying LICENSE file + +namespace xsd +{ + namespace cxx + { + namespace parser + { + template + bool substitution_map:: + check_ (const ro_string& ns, + const ro_string& name, + const C* root_ns, + const C* root_name, + const ro_string** type) const + { + key k (ns, name); + typename map::const_iterator i (map_.find (k)); + + if (i == map_.end ()) + return false; + + const value& v (i->second); + + bool r (false); + + if (v.name () == root_name && v.ns () == root_ns) + r = true; + else + r = check_ (v.ns (), v.name (), root_ns, root_name, 0); + + if (r && type != 0 && *type == 0) + *type = &v.type (); + + return r; + } + + // substitution_map_init + // + template + substitution_map_init:: + substitution_map_init () + { + if (count == 0) + map = new substitution_map; + + ++count; + } + + template + substitution_map_init:: + ~substitution_map_init () + { + if (--count == 0) + delete map; + } + + // substitution_map_entry + // + template + substitution_map_entry:: + substitution_map_entry (const C* member_ns, + const C* member_name, + const C* root_ns, + const C* root_name, + const C* member_type) + : member_ns_ (member_ns), member_name_ (member_name) + { + substitution_map_instance ().insert ( + member_ns, member_name, root_ns, root_name, member_type); + } + + template + substitution_map_entry:: + ~substitution_map_entry () + { + substitution_map_instance ().erase (member_ns_, member_name_); + } + } + } +} -- cgit v1.1