[111] | 1 | // file : xsd/cxx/xml/qualified-name.hxx |
---|
| 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 | #ifndef XSD_CXX_XML_QUALIFIED_NAME_HXX |
---|
| 7 | #define XSD_CXX_XML_QUALIFIED_NAME_HXX |
---|
| 8 | |
---|
| 9 | #include <string> |
---|
| 10 | |
---|
| 11 | namespace xsd |
---|
| 12 | { |
---|
| 13 | namespace cxx |
---|
| 14 | { |
---|
| 15 | namespace xml |
---|
| 16 | { |
---|
| 17 | template <typename C> |
---|
| 18 | struct qualified_name |
---|
| 19 | { |
---|
| 20 | qualified_name (const C* name, |
---|
| 21 | const C* namespace_) |
---|
| 22 | : name_ (name), namespace__ (namespace_) |
---|
| 23 | { |
---|
| 24 | } |
---|
| 25 | |
---|
| 26 | qualified_name (const std::basic_string<C>& name, |
---|
| 27 | const std::basic_string<C>& namespace_) |
---|
| 28 | : name_ (name), namespace__ (namespace_) |
---|
| 29 | { |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | qualified_name (const C* name) |
---|
| 33 | : name_ (name) |
---|
| 34 | { |
---|
| 35 | } |
---|
| 36 | |
---|
| 37 | qualified_name (const std::basic_string<C>& name) |
---|
| 38 | : name_ (name) |
---|
| 39 | { |
---|
| 40 | } |
---|
| 41 | |
---|
| 42 | const std::basic_string<C>& |
---|
| 43 | name () const |
---|
| 44 | { |
---|
| 45 | return name_; |
---|
| 46 | } |
---|
| 47 | |
---|
| 48 | const std::basic_string<C>& |
---|
| 49 | namespace_ () const |
---|
| 50 | { |
---|
| 51 | return namespace__; |
---|
| 52 | } |
---|
| 53 | |
---|
| 54 | private: |
---|
| 55 | std::basic_string<C> name_; |
---|
| 56 | std::basic_string<C> namespace__; |
---|
| 57 | }; |
---|
| 58 | |
---|
| 59 | template <typename C> |
---|
| 60 | inline bool |
---|
| 61 | operator== (const qualified_name<C>& x, const qualified_name<C>& y) |
---|
| 62 | { |
---|
| 63 | return x.name () == y.name () && x.namespace_ () == y.namespace_ (); |
---|
| 64 | } |
---|
| 65 | |
---|
| 66 | template <typename C> |
---|
| 67 | inline bool |
---|
| 68 | operator!= (const qualified_name<C>& x, const qualified_name<C>& y) |
---|
| 69 | { |
---|
| 70 | return !(x == y); |
---|
| 71 | } |
---|
| 72 | |
---|
| 73 | template <typename C> |
---|
| 74 | inline bool |
---|
| 75 | operator< (const qualified_name<C>& x, const qualified_name<C>& y) |
---|
| 76 | { |
---|
| 77 | int r (x.name ().compare (y.name ())); |
---|
| 78 | return (r < 0) || (r == 0 && x.namespace_ () < y.namespace_ ()); |
---|
| 79 | } |
---|
| 80 | } |
---|
| 81 | } |
---|
| 82 | } |
---|
| 83 | |
---|
| 84 | #endif // XSD_CXX_XML_QUALIFIED_NAME_HXX |
---|