XMLAttr.hpp

Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  * 
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  * 
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 /*
00019  * $Id: XMLAttr.hpp 678709 2008-07-22 10:56:56Z borisk $
00020  */
00021 
00022 #if !defined(XERCESC_INCLUDE_GUARD_XMLATTR_HPP)
00023 #define XERCESC_INCLUDE_GUARD_XMLATTR_HPP
00024 
00025 #include <xercesc/util/PlatformUtils.hpp>
00026 #include <xercesc/util/QName.hpp>
00027 #include <xercesc/framework/XMLAttDef.hpp>
00028 #include <xercesc/validators/datatype/DatatypeValidator.hpp>
00029 
00030 XERCES_CPP_NAMESPACE_BEGIN
00031 
00053 class XMLPARSER_EXPORT XMLAttr : public XMemory
00054 {
00055 public:
00056     // -----------------------------------------------------------------------
00057     //  Constructors and Destructor
00058     // -----------------------------------------------------------------------
00061 
00069     XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
00070 
00103     XMLAttr
00104     (
00105           const unsigned int        uriId
00106         , const XMLCh* const        attrName
00107         , const XMLCh* const        attrPrefix
00108         , const XMLCh* const        attrValue
00109         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00110         , const bool                specified = true
00111         , MemoryManager* const      manager = XMLPlatformUtils::fgMemoryManager
00112         , DatatypeValidator * datatypeValidator = 0
00113         , const bool isSchema = false
00114     );
00115 
00144     XMLAttr
00145     (
00146         const unsigned int uriId
00147         , const XMLCh* const rawName
00148         , const XMLCh* const attrValue
00149         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00150         , const bool specified = true
00151         , MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
00152         , DatatypeValidator * datatypeValidator = 0
00153         , const bool isSchema = false
00154     );
00155 
00157 
00160     ~XMLAttr();
00162 
00163 
00164     // -----------------------------------------------------------------------
00165     //  Getter methods
00166     // -----------------------------------------------------------------------
00167 
00170 
00174     QName* getAttName() const;
00175 
00180     const XMLCh* getName() const;
00181 
00186     const XMLCh* getPrefix() const;
00187 
00193     const XMLCh* getQName() const;
00194 
00199     bool getSpecified() const;
00200 
00205     XMLAttDef::AttTypes getType() const;
00206 
00212     const XMLCh* getValue() const;
00213 
00218     unsigned int getURIId() const;
00219 
00221 
00222 
00223     // -----------------------------------------------------------------------
00224     //  Setter methods
00225     // -----------------------------------------------------------------------
00226 
00229 
00258     void set
00259     (
00260         const   unsigned int        uriId
00261         , const XMLCh* const        attrName
00262         , const XMLCh* const        attrPrefix
00263         , const XMLCh* const        attrValue
00264         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00265         , DatatypeValidator * datatypeValidator = 0
00266         , const bool isSchema = false
00267     );
00268 
00292     void set
00293     (
00294         const   unsigned int        uriId
00295         , const XMLCh* const        attrRawName
00296         , const XMLCh* const        attrValue
00297         , const XMLAttDef::AttTypes type = XMLAttDef::CData
00298         , DatatypeValidator * datatypeValidator = 0
00299         , const bool isSchema = false
00300     );
00301 
00316     void setName
00317     (
00318         const   unsigned int        uriId
00319         , const XMLCh* const        attrName
00320         , const XMLCh* const        attrPrefix
00321     );
00322 
00330     void setSpecified(const bool newValue);
00331 
00340     void setType(const XMLAttDef::AttTypes newType);
00341 
00349     void setValue(const XMLCh* const newValue);
00350 
00358     void setURIId(const unsigned int uriId);
00359 
00361 
00362 
00363 
00364 private :
00365     // -----------------------------------------------------------------------
00366     //  Unimplemented constructors and operators
00367     // -----------------------------------------------------------------------
00368     XMLAttr(const XMLAttr&);
00369     XMLAttr& operator=(const XMLAttr&);
00370 
00371 
00372     // -----------------------------------------------------------------------
00373     //  Private, helper methods
00374     // -----------------------------------------------------------------------
00375     void cleanUp();
00376 
00377 
00378     // -----------------------------------------------------------------------
00379     //  Private instance variables
00380     //
00381     //  fAttName
00382     //      The Attribute Name;
00383     //
00384     //  fSpecified
00385     //      True if this attribute appeared in the element; else, false if
00386     //      it was defaulted from an AttDef.
00387     //
00388     //  fType
00389     //      The attribute type enum value for this attribute. Indicates what
00390     //      type of attribute it was.
00391     //
00392     //  fValue
00393     //  fValueBufSz
00394     //      The attribute value that was given in the attribute instance, and
00395     //      its current buffer size (minus one, where the null is.)
00396     //
00397     //  fMemoryManager
00398     //      The memory manager used for dynamic memory allocation/deallocation
00399     // -----------------------------------------------------------------------
00400     bool                fSpecified;
00401     XMLAttDef::AttTypes fType;
00402     XMLSize_t           fValueBufSz;
00403     XMLCh*              fValue;
00404     QName*              fAttName;
00405     MemoryManager*      fMemoryManager;   
00406 };
00407 
00408 // ---------------------------------------------------------------------------
00409 //  XMLAttr: Constructors and Destructor
00410 // ---------------------------------------------------------------------------
00411 inline XMLAttr::~XMLAttr()
00412 {
00413     cleanUp();
00414 }
00415 
00416 
00417 // ---------------------------------------------------------------------------
00418 //  XMLAttr: Getter methods
00419 // ---------------------------------------------------------------------------
00420 inline QName* XMLAttr::getAttName() const
00421 {
00422     return fAttName;
00423 }
00424 
00425 inline const XMLCh* XMLAttr::getName() const
00426 {
00427     return fAttName->getLocalPart();
00428 }
00429 
00430 inline const XMLCh* XMLAttr::getPrefix() const
00431 {
00432     return fAttName->getPrefix();
00433 }
00434 
00435 inline bool XMLAttr::getSpecified() const
00436 {
00437     return fSpecified;
00438 }
00439 
00440 inline XMLAttDef::AttTypes XMLAttr::getType() const
00441 {
00442     return fType;
00443 }
00444 
00445 inline const XMLCh* XMLAttr::getValue() const
00446 {
00447     return fValue;
00448 }
00449 
00450 inline unsigned int XMLAttr::getURIId() const
00451 {
00452     return fAttName->getURI();
00453 }
00454 
00455 // ---------------------------------------------------------------------------
00456 //  XMLAttr: Setter methods
00457 // ---------------------------------------------------------------------------
00458 inline void XMLAttr::set(const  unsigned int        uriId
00459                         , const XMLCh* const        attrName
00460                         , const XMLCh* const        attrPrefix
00461                         , const XMLCh* const        attrValue
00462                         , const XMLAttDef::AttTypes type
00463                         , DatatypeValidator * /*datatypeValidator */
00464                         , const bool /*isSchema*/ )
00465 {
00466     // Set the name info and the value via their respective calls
00467     fAttName->setName(attrPrefix, attrName, uriId);
00468     setValue(attrValue);
00469 
00470     // And store the type
00471     fType = type;
00472 }
00473 
00474 inline void XMLAttr::set(const  unsigned int        uriId
00475                         , const XMLCh* const        attrRawName
00476                         , const XMLCh* const        attrValue
00477                         , const XMLAttDef::AttTypes type
00478                         , DatatypeValidator * /*datatypeValidator */
00479                         , const bool /*isSchema*/ )
00480 {
00481     // Set the name info and the value via their respective calls
00482     fAttName->setName(attrRawName, uriId);
00483     setValue(attrValue);
00484 
00485     // And store the type
00486     fType = type;
00487 }
00488 
00489 inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
00490 {
00491     fType = newValue;
00492 }
00493 
00494 inline void XMLAttr::setSpecified(const bool newValue)
00495 {
00496     fSpecified = newValue;
00497 }
00498 
00499 XERCES_CPP_NAMESPACE_END
00500 
00501 #endif

Generated on Wed Sep 24 16:36:33 2008 for Xerces-C++ by  doxygen 1.5.4