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 QNames
\r
23 #if !defined(__xmltooling_qname_h__)
\r
24 #define __xmltooling_qname_h__
\r
26 #include <algorithm>
\r
27 #include <xmltooling/unicode.h>
\r
29 namespace xmltooling {
\r
32 * A data structure for encapsulating XML QNames.
\r
33 * The Xerces class is too limited to use at the moment.
\r
35 class XMLTOOL_API QName
\r
40 * @param uri namespace URI
\r
41 * @param localPart local name
\r
42 * @param prefix namespace prefix (without the colon)
\r
44 QName(const XMLCh* uri=NULL, const XMLCh* localPart=NULL, const XMLCh* prefix=NULL);
\r
47 #ifndef HAVE_GOOD_STL
\r
49 * Deep copy constructor
\r
51 QName(const QName& src);
\r
54 * Deep assignment operator
\r
56 QName& operator=(const QName& src);
\r
59 #ifdef HAVE_GOOD_STL
\r
61 * Returns the namespace prefix
\r
62 * @return Null-terminated Unicode string containing the prefix, without the colon
\r
64 const XMLCh* getPrefix() const { return m_prefix.c_str(); }
\r
67 * Returns the namespace URI
\r
68 * @return Null-terminated Unicode string containing the URI
\r
70 const XMLCh* getNamespaceURI() const { return m_uri.c_str(); }
\r
73 * Returns the local part of the name
\r
74 * @return Null-terminated Unicode string containing the local name
\r
76 const XMLCh* getLocalPart() const { return m_local.c_str(); }
\r
79 * Returns the namespace prefix
\r
80 * @return Null-terminated Unicode string containing the prefix, without the colon
\r
82 const XMLCh* getPrefix() const { return m_prefix; }
\r
85 * Returns the namespace URI
\r
86 * @return Null-terminated Unicode string containing the URI
\r
88 const XMLCh* getNamespaceURI() const { return m_uri; }
\r
91 * Returns the local part of the name
\r
92 * @return Null-terminated Unicode string containing the local name
\r
94 const XMLCh* getLocalPart() const { return m_local; }
\r
98 * Sets the namespace prefix
\r
99 * @param prefix Null-terminated Unicode string containing the prefix, without the colon
\r
101 void setPrefix(const XMLCh* prefix);
\r
104 * Sets the namespace URI
\r
105 * @param uri Null-terminated Unicode string containing the URI
\r
107 void setNamespaceURI(const XMLCh* uri);
\r
110 * Sets the local part of the name
\r
111 * @param localPart Null-terminated Unicode string containing the local name
\r
113 void setLocalPart(const XMLCh* localPart);
\r
116 * Gets a string representation of the QName for logging, etc.
\r
117 * Format is prefix:localPart or {namespaceURI}localPart if no prefix.
\r
119 * @return the string representation
\r
121 std::string toString() const;
\r
124 #ifdef HAVE_GOOD_STL
\r
136 * Returns true iff op1's namespace lexically compares less than op2's namespace,
\r
137 * or if equal, iff op1's prefix lexically compares less than op2's prefix.
\r
139 * Needed for use with sorted STL containers.
\r
141 * @param op1 First qname to compare
\r
142 * @param op2 Second qname to compare
\r
144 extern XMLTOOL_API bool operator<(const QName& op1, const QName& op2);
\r
146 #ifndef HAVE_GOOD_STL
\r
148 * Returns true iff op1's components are equal to op2's components.
\r
149 * @param op1 First qname to compare
\r
150 * @param op2 Second qname to compare
\r
152 extern XMLTOOL_API bool operator==(const QName& op1, const QName& op2);
\r
157 #endif /* __xmltooling_qname_h__ */
\r