2 * Copyright 2001-2006 Internet2
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
20 * Representing XML namespace attributes
\r
23 #if !defined(__xmltooling_namespace_h__)
\r
24 #define __xmltooling_namespace_h__
\r
26 #include <xmltooling/unicode.h>
\r
28 namespace xmltooling {
\r
31 * A data structure for encapsulating XML Namespace attributes
\r
33 class XMLTOOL_API Namespace
\r
38 * @param uri namespace URI
\r
39 * @param prefix namespace prefix (without the colon)
\r
40 * @param alwaysDeclare true iff the namespace should always be declared regardless of in-scope declarations
\r
42 Namespace(const XMLCh* uri=NULL, const XMLCh* prefix=NULL, bool alwaysDeclare=false);
\r
45 #ifndef HAVE_GOOD_STL
\r
47 * Deep copy constructor
\r
49 Namespace(const Namespace& src);
\r
52 * Deep assignment operator
\r
54 Namespace& operator=(const Namespace& src);
\r
57 #ifdef HAVE_GOOD_STL
\r
59 * Returns the namespace prefix
\r
60 * @return Null-terminated Unicode string containing the prefix, without the colon
\r
62 const XMLCh* getNamespacePrefix() const { return m_prefix.c_str(); }
\r
65 * Returns the namespace URI
\r
66 * @return Null-terminated Unicode string containing the URI
\r
68 const XMLCh* getNamespaceURI() const { return m_uri.c_str(); }
\r
71 * Returns the namespace prefix
\r
72 * @return Null-terminated Unicode string containing the prefix, without the colon
\r
74 const XMLCh* getNamespacePrefix() const { return m_prefix; }
\r
77 * Returns the namespace URI
\r
78 * @return Null-terminated Unicode string containing the URI
\r
80 const XMLCh* getNamespaceURI() const { return m_uri; }
\r
84 * Returns true iff the namespace should always be declared regardless of in-scope declarations
\r
85 * @return the alwaysDeclared setting
\r
87 const bool alwaysDeclare() const { return m_pinned; }
\r
90 * Sets the namespace prefix
\r
91 * @param prefix Null-terminated Unicode string containing the prefix, without the colon
\r
93 void setNamespacePrefix(const XMLCh* prefix);
\r
96 * Sets the namespace URI
\r
97 * @param uri Null-terminated Unicode string containing the URI
\r
99 void setNamespaceURI(const XMLCh* uri);
\r
102 * Sets the alwaysDeclared property
\r
103 * @param alwaysDeclare true iff the namespace should always be declared regardless of in-scope declarations
\r
105 void setAlwaysDeclare(bool alwaysDeclare) { m_pinned = alwaysDeclare; }
\r
109 #ifdef HAVE_GOOD_STL
\r
119 * Returns true iff op1's namespace lexically compares less than op2's namespace,
\r
120 * or if equal, iff op1's prefix lexically compares less than op2's prefix.
\r
122 * Needed for use with sorted STL containers.
\r
124 * @param op1 First namspace to compare
\r
125 * @param op2 Second namespace to compare
\r
127 extern XMLTOOL_API bool operator<(const Namespace& op1, const Namespace& op2);
\r
129 #ifndef HAVE_GOOD_STL
\r
131 * Returns true iff op1's namespace and prefix are equal to op2's namespace and prefix.
\r
132 * @param op1 First namspace to compare
\r
133 * @param op2 Second namespace to compare
\r
135 extern XMLTOOL_API bool operator==(const Namespace& op1, const Namespace& op2);
\r
140 #endif /* __xmltooling_namespace_h__ */
\r