XMLAttr.hpp
Go to the documentation of this file.
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/*
* $Id: XMLAttr.hpp 932889 2010-04-11 13:10:10Z borisk $
*/
#if !defined(XERCESC_INCLUDE_GUARD_XMLATTR_HPP)
#define XERCESC_INCLUDE_GUARD_XMLATTR_HPP
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/util/QName.hpp>
#include <xercesc/framework/XMLAttDef.hpp>
#include <xercesc/validators/datatype/DatatypeValidator.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLPARSER_EXPORT XMLAttr : public XMemory
{
public:
// -----------------------------------------------------------------------
// Constructors and Destructor
// -----------------------------------------------------------------------
XMLAttr(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
XMLAttr
(
const unsigned int uriId
, const XMLCh* const attrName
, const XMLCh* const attrPrefix
, const XMLCh* const attrValue
, const XMLAttDef::AttTypes type = XMLAttDef::CData
, const bool specified = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, DatatypeValidator * datatypeValidator = 0
, const bool isSchema = false
);
XMLAttr
(
const unsigned int uriId
, const XMLCh* const rawName
, const XMLCh* const attrValue
, const XMLAttDef::AttTypes type = XMLAttDef::CData
, const bool specified = true
, MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager
, DatatypeValidator * datatypeValidator = 0
, const bool isSchema = false
);
~XMLAttr();
// -----------------------------------------------------------------------
// Getter methods
// -----------------------------------------------------------------------
QName* getAttName() const;
const XMLCh* getName() const;
const XMLCh* getPrefix() const;
const XMLCh* getQName() const;
bool getSpecified() const;
XMLAttDef::AttTypes getType() const;
const XMLCh* getValue() const;
unsigned int getURIId() const;
// -----------------------------------------------------------------------
// Setter methods
// -----------------------------------------------------------------------
void set
(
const unsigned int uriId
, const XMLCh* const attrName
, const XMLCh* const attrPrefix
, const XMLCh* const attrValue
, const XMLAttDef::AttTypes type = XMLAttDef::CData
, DatatypeValidator * datatypeValidator = 0
, const bool isSchema = false
);
void set
(
const unsigned int uriId
, const XMLCh* const attrRawName
, const XMLCh* const attrValue
, const XMLAttDef::AttTypes type = XMLAttDef::CData
, DatatypeValidator * datatypeValidator = 0
, const bool isSchema = false
);
void setName
(
const unsigned int uriId
, const XMLCh* const attrName
, const XMLCh* const attrPrefix
);
void setSpecified(const bool newValue);
void setType(const XMLAttDef::AttTypes newType);
void setValue(const XMLCh* const newValue);
void setURIId(const unsigned int uriId);
private :
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
XMLAttr(const XMLAttr&);
XMLAttr& operator=(const XMLAttr&);
// -----------------------------------------------------------------------
// Private, helper methods
// -----------------------------------------------------------------------
void cleanUp();
// -----------------------------------------------------------------------
// Private instance variables
//
// fAttName
// The Attribute Name;
//
// fSpecified
// True if this attribute appeared in the element; else, false if
// it was defaulted from an AttDef.
//
// fType
// The attribute type enum value for this attribute. Indicates what
// type of attribute it was.
//
// fValue
// fValueBufSz
// The attribute value that was given in the attribute instance, and
// its current buffer size (minus one, where the null is.)
//
// fMemoryManager
// The memory manager used for dynamic memory allocation/deallocation
// -----------------------------------------------------------------------
bool fSpecified;
XMLAttDef::AttTypes fType;
XMLSize_t fValueBufSz;
XMLCh* fValue;
QName* fAttName;
MemoryManager* fMemoryManager;
};
// ---------------------------------------------------------------------------
// XMLAttr: Constructors and Destructor
// ---------------------------------------------------------------------------
inline XMLAttr::~XMLAttr()
{
cleanUp();
}
// ---------------------------------------------------------------------------
// XMLAttr: Getter methods
// ---------------------------------------------------------------------------
inline QName* XMLAttr::getAttName() const
{
return fAttName;
}
inline const XMLCh* XMLAttr::getName() const
{
return fAttName->getLocalPart();
}
inline const XMLCh* XMLAttr::getPrefix() const
{
return fAttName->getPrefix();
}
inline bool XMLAttr::getSpecified() const
{
return fSpecified;
}
inline XMLAttDef::AttTypes XMLAttr::getType() const
{
return fType;
}
inline const XMLCh* XMLAttr::getValue() const
{
return fValue;
}
inline unsigned int XMLAttr::getURIId() const
{
return fAttName->getURI();
}
// ---------------------------------------------------------------------------
// XMLAttr: Setter methods
// ---------------------------------------------------------------------------
inline void XMLAttr::set(const unsigned int uriId
, const XMLCh* const attrName
, const XMLCh* const attrPrefix
, const XMLCh* const attrValue
, const XMLAttDef::AttTypes type
, DatatypeValidator * /*datatypeValidator */
, const bool /*isSchema*/ )
{
// Set the name info and the value via their respective calls
fAttName->setName(attrPrefix, attrName, uriId);
setValue(attrValue);
// And store the type
fType = type;
}
inline void XMLAttr::set(const unsigned int uriId
, const XMLCh* const attrRawName
, const XMLCh* const attrValue
, const XMLAttDef::AttTypes type
, DatatypeValidator * /*datatypeValidator */
, const bool /*isSchema*/ )
{
// Set the name info and the value via their respective calls
fAttName->setName(attrRawName, uriId);
setValue(attrValue);
// And store the type
fType = type;
}
inline void XMLAttr::setType(const XMLAttDef::AttTypes newValue)
{
fType = newValue;
}
inline void XMLAttr::setSpecified(const bool newValue)
{
fSpecified = newValue;
}
XERCES_CPP_NAMESPACE_END
#endif
XMLAttr::setType
void setType(const XMLAttDef::AttTypes newType)
This method will update the attribute type of the object.
Definition: XMLAttr.hpp:489
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:40
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMLAttr::getSpecified
bool getSpecified() const
This method will get the specified flag, which indicates whether the attribute was explicitly specifi...
Definition: XMLAttr.hpp:435
XMLAttr::getType
XMLAttDef::AttTypes getType() const
This method will get the type of the attribute.
Definition: XMLAttr.hpp:440
XMLAttr::getName
const XMLCh * getName() const
This method gets a const pointer to the name of the attribute.
Definition: XMLAttr.hpp:425
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition: XercesDefs.hpp:163
XMLAttr
This class defines the information about an attribute that will come out of the scanner during parsin...
Definition: XMLAttr.hpp:53
XMLAttr::getAttName
QName * getAttName() const
This method returns the attribute name in a QName format.
Definition: XMLAttr.hpp:420
XMLAttDef::CData
Definition: XMLAttDef.hpp:73
XMLAttr::getPrefix
const XMLCh * getPrefix() const
This method will get a const pointer to the prefix string of this attribute.
Definition: XMLAttr.hpp:430
XMLAttr::set
void set(const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix, const XMLCh *const attrValue, const XMLAttDef::AttTypes type=XMLAttDef::CData, DatatypeValidator *datatypeValidator=0, const bool isSchema=false)
This method is called to set up a default constructed object after the fact, or to reuse a previously...
Definition: XMLAttr.hpp:458
PlatformUtils.hpp
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:39
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
QName
Definition: QName.hpp:34
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition: XercesDefs.hpp:112
XMLAttDef.hpp
XMLAttDef::AttTypes
AttTypes
Definition: XMLAttDef.hpp:71
XMLAttr::setSpecified
void setSpecified(const bool newValue)
This method will update the specified state of the object.
Definition: XMLAttr.hpp:494
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:112
XMLAttr::getURIId
unsigned int getURIId() const
This method will get the id of the URI that this attribute&#39;s prefix mapped to.
Definition: XMLAttr.hpp:450
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition: XercesDefs.hpp:113
QName.hpp
XMLAttr::getValue
const XMLCh * getValue() const
This method will get the value of the attribute.
Definition: XMLAttr.hpp:445
XMLAttr::~XMLAttr
~XMLAttr()
Definition: XMLAttr.hpp:411