00001 /* 00002 * The Apache Software License, Version 1.1 00003 * 00004 * Copyright (c) 2001 The Apache Software Foundation. All rights 00005 * reserved. 00006 * 00007 * Redistribution and use in source and binary forms, with or without 00008 * modification, are permitted provided that the following conditions 00009 * are met: 00010 * 00011 * 1. Redistributions of source code must retain the above copyright 00012 * notice, this list of conditions and the following disclaimer. 00013 * 00014 * 2. Redistributions in binary form must reproduce the above copyright 00015 * notice, this list of conditions and the following disclaimer in 00016 * the documentation and/or other materials provided with the 00017 * distribution. 00018 * 00019 * 3. The end-user documentation included with the redistribution, 00020 * if any, must include the following acknowledgment: 00021 * "This product includes software developed by the 00022 * Apache Software Foundation (http://www.apache.org/)." 00023 * Alternately, this acknowledgment may appear in the software itself, 00024 * if and wherever such third-party acknowledgments normally appear. 00025 * 00026 * 4. The names "Xerces" and "Apache Software Foundation" must 00027 * not be used to endorse or promote products derived from this 00028 * software without prior written permission. For written 00029 * permission, please contact apache\@apache.org. 00030 * 00031 * 5. Products derived from this software may not be called "Apache", 00032 * nor may "Apache" appear in their name, without prior written 00033 * permission of the Apache Software Foundation. 00034 * 00035 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 00036 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 00037 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00038 * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR 00039 * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 00040 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 00041 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 00042 * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00043 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 00044 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 00045 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 00046 * SUCH DAMAGE. 00047 * ==================================================================== 00048 * 00049 * This software consists of voluntary contributions made by many 00050 * individuals on behalf of the Apache Software Foundation, and was 00051 * originally based on software copyright (c) 2001, International 00052 * Business Machines, Inc., http://www.ibm.com . For more information 00053 * on the Apache Software Foundation, please see 00054 * <http://www.apache.org/>. 00055 */ 00056 00057 /* 00058 * $Log: QName.hpp,v $ 00059 * Revision 1.1 2002/05/11 21:08:22 bhavani 00060 * CR#CR062582# adding xercesc 1.7 file 00061 * 00062 * Revision 1.1.1.1 2002/02/01 22:22:11 peiyongz 00063 * sane_include 00064 * 00065 * Revision 1.8 2001/12/06 17:48:36 tng 00066 * Performance Enhancement. Added setNPrefix and setNLocalPart methods that allow code to take advantage of the fact that it knows the length of the prefix and local name, when possible. That can avoid a copy of the prefix into a null-terminated temporary variable before copying into the fPrefix. 00067 * Also changed the getRawName method so that it would simply return the local part when there is no prefix, instead of allocating another buffer to copy the local part into the fRawName. 00068 * When there is a prefix, changed the getRawName to copy the prefix and local part into the fRawName using XMLString::moveChars instead of using XMLString::copyString and XMLString::catString. The catString method has to loop past the prefix portion of the fRawName, which seems like a waste. 00069 * By Henry Zongaro. 00070 * 00071 * Revision 1.7 2001/07/24 18:31:47 knoaman 00072 * Added support for <group> + extra constraint checking for complexType 00073 * 00074 * Revision 1.6 2001/05/11 13:26:28 tng 00075 * Copyright update. 00076 * 00077 * Revision 1.5 2001/04/19 18:17:10 tng 00078 * Schema: SchemaValidator update, and use QName in Content Model 00079 * 00080 * Revision 1.4 2001/03/21 21:56:12 tng 00081 * Schema: Add Schema Grammar, Schema Validator, and split the DTDValidator into DTDValidator, DTDScanner, and DTDGrammar. 00082 * 00083 * Revision 1.3 2001/02/27 14:48:39 tng 00084 * Schema: Add CMAny and ContentLeafNameTypeVector, by Pei Yong Zhang 00085 * 00086 * Revision 1.2 2001/02/26 21:56:16 tng 00087 * Schema: QName can also be constructed with rawName. 00088 * 00089 * Revision 1.1 2001/02/26 19:44:25 tng 00090 * Schema: add utility class QName, by Pei Yong Zhang. 00091 * 00092 */ 00093 00094 #if !defined(QNAME_HPP) 00095 #define QNAME_HPP 00096 00097 #include <xercesc/util/XMLString.hpp> 00098 #include <xercesc/util/XMLUniDefs.hpp> 00099 #include <xercesc/util/XMLUni.hpp> 00100 00101 class XMLUTIL_EXPORT QName 00102 { 00103 public : 00104 // ----------------------------------------------------------------------- 00105 // Contructors and Destructor 00106 // ----------------------------------------------------------------------- 00108 QName(); 00109 00111 QName 00112 ( const XMLCh* const prefix 00113 , const XMLCh* const localPart 00114 , const unsigned int uriId 00115 ); 00116 00118 QName 00119 ( const XMLCh* const rawName 00120 , const unsigned int uriId 00121 ); 00122 00124 QName(const QName* const qname); 00125 00126 ~QName(); 00127 00128 // ----------------------------------------------------------------------- 00129 // Getters 00130 // ----------------------------------------------------------------------- 00131 const XMLCh* getPrefix() const; 00132 XMLCh* getPrefix(); 00133 00134 const XMLCh* getLocalPart() const; 00135 XMLCh* getLocalPart(); 00136 00137 const unsigned int getURI() const; 00138 unsigned int getURI(); 00139 00140 const XMLCh* getRawName() const; 00141 XMLCh* getRawName(); 00142 00143 // ----------------------------------------------------------------------- 00144 // Setters 00145 // ----------------------------------------------------------------------- 00146 void setName 00147 ( 00148 const XMLCh* const prefix 00149 , const XMLCh* const localPart 00150 , const unsigned int uriId 00151 ); 00152 00153 void setName 00154 ( 00155 const XMLCh* const rawName 00156 , const unsigned int uriId 00157 ); 00158 00159 void setPrefix(const XMLCh*) ; 00160 void setLocalPart(const XMLCh*) ; 00161 void setNPrefix(const XMLCh*, const unsigned int) ; 00162 void setNLocalPart(const XMLCh*, const unsigned int) ; 00163 void setURI(const unsigned int) ; 00164 00165 void setValues(const QName& qname); 00166 00167 // ----------------------------------------------------------------------- 00168 // comparison 00169 // ----------------------------------------------------------------------- 00170 bool operator==(const QName&); 00171 00172 // ----------------------------------------------------------------------- 00173 // Misc 00174 // ----------------------------------------------------------------------- 00175 void cleanUp(); 00176 00177 private : 00178 00179 // ----------------------------------------------------------------------- 00180 // Private instance variables 00181 // 00182 // We copy the followings from XMLAttr.hpp, but stick to Java version's 00183 // naming convention 00184 // 00185 // fPrefix 00186 // fPrefixBufSz 00187 // The prefix that was applied to this attribute's name, and the 00188 // current size of the buffer (minus one for the null.) Prefixes 00189 // really don't matter technically but it might be required for 00190 // pratical reasons, to recreate the original document for instance. 00191 // 00192 // fLocalPart 00193 // fLocalPartBufSz 00194 // The base part of the name of the attribute, and the current size 00195 // of the buffer (minus one, where the null is.) 00196 // 00197 // fRawName 00198 // fRawNameBufSz 00199 // This is the QName form of the name, which is faulted in (from the 00200 // prefix and name) upon request. The size field indicates the 00201 // current size of the buffer (minus one for the null.) It will be 00202 // zero until fauled in. 00203 // 00204 // fURIId 00205 // The id of the URI that this attribute belongs to. 00206 // ----------------------------------------------------------------------- 00207 XMLCh* fPrefix; 00208 unsigned int fPrefixBufSz; 00209 XMLCh* fLocalPart; 00210 unsigned int fLocalPartBufSz; 00211 XMLCh* fRawName; 00212 unsigned int fRawNameBufSz; 00213 unsigned int fURIId; 00214 00215 }; 00216 00217 // --------------------------------------------------------------------------- 00218 // QName: Getter methods 00219 // --------------------------------------------------------------------------- 00220 inline const XMLCh* QName::getPrefix() const 00221 { 00222 return fPrefix; 00223 } 00224 00225 inline XMLCh* QName::getPrefix() 00226 { 00227 return fPrefix; 00228 } 00229 00230 inline const XMLCh* QName::getLocalPart() const 00231 { 00232 return fLocalPart; 00233 } 00234 00235 inline XMLCh* QName::getLocalPart() 00236 { 00237 return fLocalPart; 00238 } 00239 00240 inline const unsigned int QName::getURI() const 00241 { 00242 return fURIId; 00243 } 00244 00245 inline unsigned int QName::getURI() 00246 { 00247 return fURIId; 00248 } 00249 00250 // --------------------------------------------------------------------------- 00251 // QName: Setter methods 00252 // --------------------------------------------------------------------------- 00253 inline void QName::setURI(const unsigned int uriId) 00254 { 00255 fURIId = uriId; 00256 } 00257 #endif