29 #ifndef Pt_Xml_Namespace_h
30 #define Pt_Xml_Namespace_h
32 #include <Pt/Xml/Api.h>
33 #include <Pt/String.h>
85 {
return _prefix.
empty(); }
90 {
return _uri.
empty(); }
101 class NamespaceMapping
107 Entry(
const Namespace& ns,
bool mapped)
112 bool isMapped()
const
115 bool isUnmapped()
const
116 {
return ! _mapped; }
118 const String& namespaceUri()
const
119 {
return _ns->namespaceUri(); }
121 const String& prefix()
const
122 {
return _ns->prefix(); }
125 const Namespace* _ns;
129 typedef const Entry* ConstIterator;
130 typedef Entry* Iterator;
137 { _entries.clear(); }
139 std::size_t size()
const
140 {
return _entries.size(); }
142 std::size_t empty()
const
143 {
return _entries.empty(); }
145 ConstIterator begin()
const
146 {
return _entries.empty() ? 0 : &_entries[0]; }
148 ConstIterator end()
const
149 {
return _entries.empty() ? 0 : &_entries[ _entries.size() ]; }
152 {
return _entries.empty() ? 0 : &_entries[0]; }
155 {
return _entries.empty() ? 0 : &_entries[ _entries.size() ]; }
157 void addMapped(
const Namespace& ns)
158 { _entries.push_back( Entry(ns,
true) ); }
160 void addUnmapped(
const Namespace& ns)
161 { _entries.push_back( Entry(ns,
false) ); }
164 std::vector<Entry> _entries;
171 #endif // Pt_Xml_Namespace_h
A namespace used in an XML document.
Definition: Namespace.h:46
bool isUnset() const
Returns true if explicitly unset.
Definition: Namespace.h:89
void setNamespaceUri(const String &uri)
Sets the URI of the namespace.
Definition: Namespace.h:79
bool empty() const
Returns true if empty.
Definition: String.h:244
bool isDefaultNamespace() const
Returns true if this is the default namespace.
Definition: Namespace.h:84
const String & namespaceUri() const
Returns the namespace URI.
Definition: Namespace.h:74
std::size_t depth() const
Returns the scope depth of the namespace.
Definition: Namespace.h:59
Unicode capable basic_string.
Definition: String.h:42
Namespace(std::size_t depth, const String &prefix, const String &uri)
Constructs a Namespace with scope depth, name and prefix.
Definition: Namespace.h:51
const String & prefix() const
Returns the prefix of this namespace.
Definition: Namespace.h:64
void setPrefix(const String &prefix)
Sets the prefix of this namespace.
Definition: Namespace.h:69