PSVIAttributeList.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_PSVIATTRIBUTE_LIST_HPP)
#define XERCESC_INCLUDE_GUARD_PSVIATTRIBUTE_LIST_HPP
#include <xercesc/util/PlatformUtils.hpp>
#include <xercesc/framework/psvi/PSVIAttribute.hpp>
#include <xercesc/util/RefVectorOf.hpp>
XERCES_CPP_NAMESPACE_BEGIN
class XMLPARSER_EXPORT PSVIAttributeStorage : public XMemory
{
public:
PSVIAttributeStorage() :
fPSVIAttribute(0)
, fAttributeName(0)
, fAttributeNamespace(0)
{
}
~PSVIAttributeStorage()
{
delete fPSVIAttribute;
}
PSVIAttribute* fPSVIAttribute;
const XMLCh* fAttributeName;
const XMLCh* fAttributeNamespace;
};
class XMLPARSER_EXPORT PSVIAttributeList : public XMemory
{
public:
// Constructors and Destructor
// -----------------------------------------------------------------------
PSVIAttributeList( MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
~PSVIAttributeList();
//---------------------
/*
* Get the number of attributes whose PSVI contributions
* are contained in this list.
*/
XMLSize_t getLength() const;
/*
* Get the PSVI contribution of attribute at position i
* in this list. Indices start from 0.
* @param index index from which the attribute PSVI contribution
* is to come.
* @return PSVIAttribute containing the attributes PSVI contributions;
* null is returned if the index is out of range.
*/
PSVIAttribute *getAttributePSVIAtIndex(const XMLSize_t index);
/*
* Get local part of attribute name at position index in the list.
* Indices start from 0.
* @param index index from which the attribute name
* is to come.
* @return local part of the attribute's name; null is returned if the index
* is out of range.
*/
const XMLCh *getAttributeNameAtIndex(const XMLSize_t index);
/*
* Get namespace of attribute at position index in the list.
* Indices start from 0.
* @param index index from which the attribute namespace
* is to come.
* @return namespace of the attribute;
* null is returned if the index is out of range.
*/
const XMLCh *getAttributeNamespaceAtIndex(const XMLSize_t index);
/*
* Get the PSVI contribution of attribute with given
* local name and namespace.
* @param attrName local part of the attribute's name
* @param attrNamespace namespace of the attribute
* @return null if the attribute PSVI does not exist
*/
PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
, const XMLCh * attrNamespace);
//----------------------------------
PSVIAttribute *getPSVIAttributeToFill(
const XMLCh * attrName
, const XMLCh * attrNS);
void reset();
private:
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
PSVIAttributeList(const PSVIAttributeList&);
PSVIAttributeList & operator=(const PSVIAttributeList &);
// -----------------------------------------------------------------------
// data members
// -----------------------------------------------------------------------
// fMemoryManager
// handler to provide dynamically-need memory
// fAttrList
// list of PSVIAttributes contained by this object
// fAttrPos
// current number of initialized PSVIAttributes in fAttrList
MemoryManager* fMemoryManager;
RefVectorOf<PSVIAttributeStorage>* fAttrList;
XMLSize_t fAttrPos;
};
inline PSVIAttributeList::~PSVIAttributeList()
{
delete fAttrList;
}
inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
const XMLCh *attrName
, const XMLCh * attrNS)
{
PSVIAttributeStorage* storage = 0;
if(fAttrPos == fAttrList->size())
{
storage = new (fMemoryManager) PSVIAttributeStorage();
storage->fPSVIAttribute = new (fMemoryManager) PSVIAttribute(fMemoryManager);
fAttrList->addElement(storage);
}
else
{
storage = fAttrList->elementAt(fAttrPos);
}
storage->fAttributeName = attrName;
storage->fAttributeNamespace = attrNS;
fAttrPos++;
return storage->fPSVIAttribute;
}
inline void PSVIAttributeList::reset()
{
fAttrPos = 0;
}
XERCES_CPP_NAMESPACE_END
#endif
PSVIAttribute.hpp
PlatformUtils.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
XMLCh
uint16_t XMLCh
Definition: Xerces_autoconf_config.hpp:120
XMLSize_t
size_t XMLSize_t
Definition: Xerces_autoconf_config.hpp:112
MemoryManager
Configurable memory manager.
Definition: MemoryManager.hpp:40
PSVIAttributeList
Definition: PSVIAttributeList.hpp:60
PSVIAttributeList::reset
void reset()
reset the list
Definition: PSVIAttributeList.hpp:208
PSVIAttributeList::getAttributeNamespaceAtIndex
const XMLCh * getAttributeNamespaceAtIndex(const XMLSize_t index)
PSVIAttributeList::PSVIAttributeList
PSVIAttributeList(MemoryManager *const manager=XMLPlatformUtils::fgMemoryManager)
The default constructor.
PSVIAttributeList::getAttributePSVIByName
PSVIAttribute * getAttributePSVIByName(const XMLCh *attrName, const XMLCh *attrNamespace)
PSVIAttributeList::getAttributePSVIAtIndex
PSVIAttribute * getAttributePSVIAtIndex(const XMLSize_t index)
PSVIAttributeList::getAttributeNameAtIndex
const XMLCh * getAttributeNameAtIndex(const XMLSize_t index)
PSVIAttributeList::~PSVIAttributeList
~PSVIAttributeList()
Definition: PSVIAttributeList.hpp:182
PSVIAttributeList::getPSVIAttributeToFill
PSVIAttribute * getPSVIAttributeToFill(const XMLCh *attrName, const XMLCh *attrNS)
methods needed by implementation
Definition: PSVIAttributeList.hpp:187
PSVIAttributeList::getLength
XMLSize_t getLength() const
PSVIAttributeStorage
A container for the PSVI contributions to attributes that occur on a particular element.
Definition: PSVIAttributeList.hpp:40
PSVIAttributeStorage::fAttributeNamespace
const XMLCh * fAttributeNamespace
Definition: PSVIAttributeList.hpp:56
PSVIAttributeStorage::PSVIAttributeStorage
PSVIAttributeStorage()
Definition: PSVIAttributeList.hpp:42
PSVIAttributeStorage::fAttributeName
const XMLCh * fAttributeName
Definition: PSVIAttributeList.hpp:55
PSVIAttributeStorage::~PSVIAttributeStorage
~PSVIAttributeStorage()
Definition: PSVIAttributeList.hpp:49
PSVIAttributeStorage::fPSVIAttribute
PSVIAttribute * fPSVIAttribute
Definition: PSVIAttributeList.hpp:54
PSVIAttribute
Definition: PSVIAttribute.hpp:42
XMLPlatformUtils::fgMemoryManager
static MemoryManager * fgMemoryManager
The configurable memory manager.
Definition: PlatformUtils.hpp:121
XMemory
This class makes it possible to override the C++ memory management by adding new/delete operators to ...
Definition: XMemory.hpp:41