/usr/include/xsd/cxx/tree/comparison-map.txx is in xsdcxx 3.3.0.1-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | // file : xsd/cxx/tree/comparison-map.txx
// author : Boris Kolpackov <boris@codesynthesis.com>
// copyright : Copyright (c) 2005-2010 Code Synthesis Tools CC
// license : GNU GPL v2 + exceptions; see accompanying LICENSE file
#include <xsd/cxx/tree/types.hxx>
namespace xsd
{
namespace cxx
{
namespace tree
{
// comparison_map
//
template <typename C>
comparison_map<C>::
comparison_map ()
{
// anyType and anySimpleType.
//
//register_type (
// typeid (type),
// &comparator_impl<type>,
// false);
typedef simple_type<type> simple_type;
//register_type (
// typeid (simple_type),
// &comparator_impl<simple_type>,
// false);
// Strings
//
typedef string<C, simple_type> string;
register_type (
typeid (string),
&comparator_impl<string>,
false);
typedef normalized_string<C, string> normalized_string;
register_type (
typeid (normalized_string),
&comparator_impl<normalized_string>,
false);
typedef token<C, normalized_string> token;
register_type (
typeid (token),
&comparator_impl<token>,
false);
typedef name<C, token> name;
register_type (
typeid (name),
&comparator_impl<name>,
false);
typedef nmtoken<C, token> nmtoken;
register_type (
typeid (nmtoken),
&comparator_impl<nmtoken>,
false);
typedef nmtokens<C, simple_type, nmtoken> nmtokens;
register_type (
typeid (nmtokens),
&comparator_impl<nmtokens>,
false);
typedef ncname<C, name> ncname;
register_type (
typeid (ncname),
&comparator_impl<ncname>,
false);
typedef language<C, token> language;
register_type (
typeid (language),
&comparator_impl<language>,
false);
// ID/IDREF.
//
typedef id<C, ncname> id;
register_type (
typeid (id),
&comparator_impl<id>,
false);
typedef idref<C, ncname, type> idref;
register_type (
typeid (idref),
&comparator_impl<idref>,
false);
typedef idrefs<C, simple_type, idref> idrefs;
register_type (
typeid (idrefs),
&comparator_impl<idrefs>,
false);
// URI.
//
typedef uri<C, simple_type> uri;
register_type (
typeid (uri),
&comparator_impl<uri>,
false);
// Qualified name.
//
typedef qname<C, simple_type, uri, ncname> qname;
register_type (
typeid (qname),
&comparator_impl<qname>,
false);
// Binary.
//
typedef base64_binary<C, simple_type> base64_binary;
register_type (
typeid (base64_binary),
&comparator_impl<base64_binary>,
false);
typedef hex_binary<C, simple_type> hex_binary;
register_type (
typeid (hex_binary),
&comparator_impl<hex_binary>,
false);
// Date/time.
//
typedef gday<C, simple_type> gday;
register_type (
typeid (gday),
&comparator_impl<gday>,
false);
typedef gmonth<C, simple_type> gmonth;
register_type (
typeid (gmonth),
&comparator_impl<gmonth>,
false);
typedef gyear<C, simple_type> gyear;
register_type (
typeid (gyear),
&comparator_impl<gyear>,
false);
typedef gmonth_day<C, simple_type> gmonth_day;
register_type (
typeid (gmonth_day),
&comparator_impl<gmonth_day>,
false);
typedef gyear_month<C, simple_type> gyear_month;
register_type (
typeid (gyear_month),
&comparator_impl<gyear_month>,
false);
typedef date<C, simple_type> date;
register_type (
typeid (date),
&comparator_impl<date>,
false);
typedef time<C, simple_type> time;
register_type (
typeid (time),
&comparator_impl<time>,
false);
typedef date_time<C, simple_type> date_time;
register_type (
typeid (date_time),
&comparator_impl<date_time>,
false);
typedef duration<C, simple_type> duration;
register_type (
typeid (duration),
&comparator_impl<duration>,
false);
// Entity.
//
typedef entity<C, ncname> entity;
register_type (
typeid (entity),
&comparator_impl<entity>,
false);
typedef entities<C, simple_type, entity> entities;
register_type (
typeid (entities),
&comparator_impl<entities>,
false);
}
template <typename C>
void comparison_map<C>::
register_type (const type_id& tid, comparator c, bool override)
{
if (override || type_map_.find (&tid) == type_map_.end ())
type_map_[&tid] = c;
}
template <typename C>
void comparison_map<C>::
unregister_type (const type_id& tid)
{
type_map_.erase (&tid);
}
template <typename C>
bool comparison_map<C>::
compare (const type& x, const type& y)
{
const type_id& xi (typeid (x));
if (xi != typeid (y))
return false;
if (comparator c = find (xi))
return c (x, y);
else
throw no_type_info<C> (std::basic_string<C> (),
std::basic_string<C> ()); // @@ TODO
}
template <typename C>
typename comparison_map<C>::comparator
comparison_map<C>::
find (const type_id& tid) const
{
typename type_map::const_iterator i (type_map_.find (&tid));
return i == type_map_.end () ? 0 : i->second;
}
// comparison_plate
//
template<unsigned long id, typename C>
comparison_plate<id, C>::
comparison_plate ()
{
if (count == 0)
map = new comparison_map<C>;
++count;
}
template<unsigned long id, typename C>
comparison_plate<id, C>::
~comparison_plate ()
{
if (--count == 0)
delete map;
}
//
//
template<typename T>
bool
comparator_impl (const type& x, const type& y)
{
return static_cast<const T&> (x) == static_cast<const T&> (y);
}
// comparison_initializer
//
template<unsigned long id, typename C, typename T>
comparison_initializer<id, C, T>::
comparison_initializer ()
{
comparison_map_instance<id, C> ().register_type (
typeid (T), &comparator_impl<T>);
}
template<unsigned long id, typename C, typename T>
comparison_initializer<id, C, T>::
~comparison_initializer ()
{
comparison_map_instance<id, C> ().unregister_type (typeid (T));
}
}
}
}
|