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$
*/
#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
PlatformUtils.hpp
QName.hpp
XMLAttDef.hpp
XMLPARSER_EXPORT
#define XMLPARSER_EXPORT
Definition XercesDefs.hpp:163
XERCES_CPP_NAMESPACE_BEGIN
#define XERCES_CPP_NAMESPACE_BEGIN
Definition XercesDefs.hpp:112
XERCES_CPP_NAMESPACE_END
#define XERCES_CPP_NAMESPACE_END
Definition XercesDefs.hpp:113
XMLSize_t
size_t XMLSize_t
Definition Xerces_autoconf_config.hpp:112
XMLCh
char16_t XMLCh
Definition Xerces_autoconf_config.hpp:120
MemoryManager
Configurable memory manager.
Definition MemoryManager.hpp:40
QName
Definition QName.hpp:35
XMLAttDef::AttTypes
AttTypes
Definition XMLAttDef.hpp:72
XMLAttDef::CData
@ CData
Definition XMLAttDef.hpp:73
XMLAttr::getName
const XMLCh * getName() const
This method gets a const pointer to the name of the attribute.
Definition XMLAttr.hpp:425
XMLAttr::XMLAttr
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)
This is the primary constructor which takes all of the information required to construct a complete a...
XMLAttr::getValue
const XMLCh * getValue() const
This method will get the value of the attribute.
Definition XMLAttr.hpp:445
XMLAttr::setType
void setType(const XMLAttDef::AttTypes newType)
This method will update the attribute type of the object.
Definition XMLAttr.hpp:489
XMLAttr::getURIId
unsigned int getURIId() const
This method will get the id of the URI that this attribute's prefix mapped to.
Definition XMLAttr.hpp:450
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::getType
XMLAttDef::AttTypes getType() const
This method will get the type of the attribute.
Definition XMLAttr.hpp:440
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
XMLAttr::setName
void setName(const unsigned int uriId, const XMLCh *const attrName, const XMLCh *const attrPrefix)
This method will update just the name related fields of the attribute object.
XMLAttr::getQName
const XMLCh * getQName() const
This method will get the QName of this attribute, which will be the prefix if any,...
XMLAttr::setSpecified
void setSpecified(const bool newValue)
This method will update the specified state of the object.
Definition XMLAttr.hpp:494
XMLAttr::~XMLAttr
~XMLAttr()
Definition XMLAttr.hpp:411
XMLAttr::setURIId
void setURIId(const unsigned int uriId)
This method will set the URI id field of this attribute.
XMLAttr::XMLAttr
XMLAttr(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
The default constructor just setsup an empty attribute to be filled in the later.
XMLAttr::setValue
void setValue(const XMLCh *const newValue)
This method will update the value field of the attribute.
XMLAttr::getAttName
QName * getAttName() const
This method returns the attribute name in a QName format.
Definition XMLAttr.hpp:420
XMLAttr::XMLAttr
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)
This is the primary constructor which takes all of the information required to construct a complete a...
XMLAttr::getSpecified
bool getSpecified() const
This method will get the specified flag, which indicates whether the attribute was explicitly specifi...
Definition XMLAttr.hpp:435
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition PlatformUtils.hpp:121
XMemory::XMemory
XMemory()
Protected default constructor.
Definition XMemory.hpp:130