00001 #ifndef _IT_BUS_QNAME_H_
00002 #define _IT_BUS_QNAME_H_
00003
00004
00005
00006
00007 #include <it_bus/types.h>
00008
00009 #ifndef IT_IOSTREAMS_FREE
00010 #include <it_cal/iostream.h>
00011 #endif
00012
00013 #include <it_cal/stdexcept.h>
00014 #include <it_dsa/hash_map.h>
00015
00016 namespace IT_Bus
00017 {
00018 struct QNameBody;
00019
00020 class PrefixResolver;
00021
00022
00027 class IT_AFC_API QName
00028 {
00029 public:
00030
00034 QName();
00035
00039 QName(
00040 const QName& name
00041 );
00042
00053 QName(
00054 const String& namespace_prefix,
00055 const String& local_part,
00056 const String& namespace_uri
00057 );
00058
00067 QName(
00068 const String& raw_name,
00069 const String& namespace_uri = String::EMPTY
00070 );
00071
00075 ~QName();
00076
00086 void
00087 assign(
00088 const String& raw_name,
00089 const String& namespace_uri = String::EMPTY
00090 );
00091
00095 QName& operator=(
00096 const QName& rhs
00097 );
00098
00104 const String &
00105 get_namespace_prefix() const;
00106
00112 const String &
00113 get_local_part() const;
00114
00120 const String &
00121 get_namespace_uri() const;
00122
00128 const String
00129 get_raw_name() const;
00130
00138 const String
00139 get_raw_name(
00140 const PrefixResolver& resolver
00141 ) const;
00142
00152 const String
00153 to_string() const;
00154
00159 const String
00160 get_as_string_uri() const;
00161
00169 const String
00170 get_as_canonical_string() const;
00171
00179 bool
00180 has_unresolved_prefix() const;
00181
00182 size_t
00183 get_hash_code() const;
00184
00188 bool
00189 operator ==(
00190 const QName& rhs
00191 ) const;
00192
00196 bool
00197 operator !=(
00198 const QName& rhs
00199 ) const;
00200
00204 bool
00205 empty() const;
00206
00212 void
00213 set_local_part(
00214 const String&
00215 );
00216
00222 void
00223 set_namespace_prefix(
00224 const String&
00225 );
00226
00232 void
00233 set_namespace_uri(
00234 const String&
00235 );
00236
00243 static QName
00244 make_qname_from_canonical_string(
00245 const String qname_str
00246 ) throw((IT_Bus::Exception));
00247
00248 static const QName EMPTY_QNAME;
00249
00250 static const QName ITEM_QNAME;
00251
00252 private:
00253
00254 void
00255 assign_internal(
00256 const String& raw_name,
00257 const String& namespace_uri = String::EMPTY
00258 );
00259
00260 void set_hash();
00261
00262 QNameBody* m_body;
00263 };
00264
00265
00266 class IT_AFC_API QNameHash
00267 {
00268 public:
00269 QNameHash() {}
00270 ~QNameHash() {}
00271
00272 size_t
00273 operator()(
00274 const QName& to_hash
00275 );
00276 };
00277
00278 inline size_t
00279 QNameHash::operator()(
00280 const QName& to_hash
00281 )
00282 {
00283 return to_hash.get_hash_code();
00284 }
00285
00286
00287 class IT_AFC_API QNameEq
00288 {
00289 public:
00290 QNameEq() {}
00291 ~QNameEq() {}
00292
00293 IT_Bool
00294 operator()(
00295 const QName& a1,
00296 const QName& s2
00297 );
00298 };
00299
00300 inline IT_Bool
00301 QNameEq::operator()(
00302 const QName& s1,
00303 const QName& s2
00304 )
00305 {
00306 return s1 == s2;
00307 }
00308
00309 template <class T>
00310 class QNameHashMap : public IT_HashMap<QName, T, QNameHash, QNameEq>
00311 {
00312 };
00313
00314
00315 class IT_AFC_API ResolverQNameFactory
00316 {
00317 public:
00318 static QName
00319 create(
00320 const String& prefix,
00321 const String& local_part,
00322 const PrefixResolver& prefix_resolver
00323 );
00324
00325 static QName
00326 create(
00327 const String& raw_name,
00328 const PrefixResolver& prefix_resolver
00329 );
00330 };
00331 }
00332
00333 #ifndef IT_IOSTREAMS_FREE
00334 inline IT_ostream& operator<< (IT_ostream& os, const IT_Bus::QName& name)
00335 {
00336 return os << name.to_string();
00337 }
00338 #endif
00339
00340 #endif