neilg 2003/11/26 08:20:37
Modified: c/src/xercesc/framework/psvi PSVIAttributeList.cpp
PSVIAttributeList.hpp
Log:
more complete implementation of PSVIAttributeList; remove some problematic const-ness
Revision Changes Path
1.3 +16 -9 xml-xerces/c/src/xercesc/framework/psvi/PSVIAttributeList.cpp
Index: PSVIAttributeList.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIAttributeList.cpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PSVIAttributeList.cpp 6 Nov 2003 15:30:04 -0000 1.2
+++ PSVIAttributeList.cpp 26 Nov 2003 16:20:37 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/11/26 16:20:37 neilg
+ * more complete implementation of PSVIAttributeList; remove some problematic
const-ness
+ *
* Revision 1.2 2003/11/06 15:30:04 neilg
* first part of PSVI/schema component model implementation, thanks to David
Cargill. This covers setting the PSVIHandler on parser objects, as well as
implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of
XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and
XSAttributeUse.
*
@@ -72,7 +75,9 @@
PSVIAttributeList::PSVIAttributeList( MemoryManager* const manager ):
fMemoryManager(manager)
+ , fAttrPos(0)
{
+ fAttrList = new (fMemoryManager) ValueVectorOf<PSVIAttribute*> (10,
fMemoryManager, true);
}
/*
@@ -81,7 +86,7 @@
*/
const unsigned int PSVIAttributeList::getLength() const
{
- return fAttrList->size();
+ return fAttrPos+1;
}
/*
@@ -92,8 +97,10 @@
* @return PSVIAttribute containing the attributes PSVI contributions;
* null is returned if the index is out of range.
*/
-const PSVIAttribute *PSVIAttributeList::getAttributePSVIAtIndex(const unsigned int
index)
+PSVIAttribute *PSVIAttributeList::getAttributePSVIAtIndex(const unsigned int index)
{
+ if(index >= fAttrPos)
+ return 0;
return fAttrList->elementAt(index);
}
@@ -108,8 +115,8 @@
const XMLCh *PSVIAttributeList::getAttributeNameAtIndex(const unsigned int index)
{
- //PSVIAttribute* PSVIAttr= fAttrList->elementAt(index);
- //XSAttributeDeclaration* XSAttrDecl =
fAttrList->elementAt(index)->getAttributeDeclaration();
+ if(index >= fAttrPos)
+ return 0;
return fAttrList->elementAt(index)->getAttributeDeclaration()->getName();
}
@@ -123,8 +130,8 @@
*/
const XMLCh *PSVIAttributeList::getAttributeNamespaceAtIndex(const unsigned int
index)
{
- //PSVIAttribute* PSVIAttr= fAttrList->elementAt(index);
- //XSAttributeDeclaration* XSAttrDecl =
fAttrList->elementAt(index)->getAttributeDeclaration();
+ if(index >= fAttrPos)
+ return 0;
return fAttrList->elementAt(index)->getAttributeDeclaration()->getNamespace();
}
@@ -135,10 +142,10 @@
* @param attrNamespace namespace of the attribute
* @return null if the attribute PSVI does not exist
*/
-const PSVIAttribute *PSVIAttributeList::getAttributePSVIByName(const XMLCh *attrName
+PSVIAttribute *PSVIAttributeList::getAttributePSVIByName(const XMLCh *attrName
, const XMLCh * attrNamespace)
{
- for (unsigned int index=0; index < fAttrList->size(); index++) {
+ for (unsigned int index=0; index <= fAttrPos; index++) {
PSVIAttribute* PSVIAttr= fAttrList->elementAt(index);
if
(XMLString::equals(attrName,PSVIAttr->getAttributeDeclaration()->getName()) &&
XMLString::equals(attrNamespace,PSVIAttr->getAttributeDeclaration()->getNamespace())) {
1.3 +48 -4 xml-xerces/c/src/xercesc/framework/psvi/PSVIAttributeList.hpp
Index: PSVIAttributeList.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/PSVIAttributeList.hpp,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- PSVIAttributeList.hpp 6 Nov 2003 15:30:04 -0000 1.2
+++ PSVIAttributeList.hpp 26 Nov 2003 16:20:37 -0000 1.3
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.3 2003/11/26 16:20:37 neilg
+ * more complete implementation of PSVIAttributeList; remove some problematic
const-ness
+ *
* Revision 1.2 2003/11/06 15:30:04 neilg
* first part of PSVI/schema component model implementation, thanks to David
Cargill. This covers setting the PSVIHandler on parser objects, as well as
implementing XSNotation, XSSimpleTypeDefinition, XSIDCDefinition, and most of
XSWildcard, XSComplexTypeDefinition, XSElementDeclaration, XSAttributeDeclaration and
XSAttributeUse.
*
@@ -124,7 +127,7 @@
* @return PSVIAttribute containing the attributes PSVI contributions;
* null is returned if the index is out of range.
*/
- const PSVIAttribute *getAttributePSVIAtIndex(const unsigned int index);
+ PSVIAttribute *getAttributePSVIAtIndex(const unsigned int index);
/*
* Get local part of attribute name at position index in the list.
@@ -153,7 +156,7 @@
* @param attrNamespace namespace of the attribute
* @return null if the attribute PSVI does not exist
*/
- const PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
+ PSVIAttribute *getAttributePSVIByName(const XMLCh *attrName
, const XMLCh * attrNamespace);
//@}
@@ -163,6 +166,18 @@
//@{
+ /**
+ * returns a PSVI attribute of undetermined state and
+ * makes that object part of the internal list. Intended to be called
+ * during validation of an element.
+ */
+ PSVIAttribute *getPSVIAttributeToFill();
+
+ /**
+ * reset the list
+ */
+ void reset();
+
//@}
private:
@@ -179,10 +194,39 @@
// -----------------------------------------------------------------------
// fMemoryManager
// handler to provide dynamically-need memory
+ // fAttrList
+ // list of PSVIAttributes contained by this object
+ // fAttrPos
+ // current number of valid PSVIAttributes in fAttrList
MemoryManager* fMemoryManager;
ValueVectorOf<PSVIAttribute*>* fAttrList;
+ unsigned int fAttrPos;
};
-inline PSVIAttributeList::~PSVIAttributeList() {}
+inline PSVIAttributeList::~PSVIAttributeList()
+{
+ delete fAttrList;
+}
+
+inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill()
+{
+ PSVIAttribute *retAttr = 0;
+ if(fAttrPos+1 == fAttrList->size())
+ {
+ retAttr = new (fMemoryManager)PSVIAttribute(fMemoryManager);
+ fAttrList->addElement(retAttr);
+ }
+ else
+ {
+ retAttr = fAttrList->elementAt(fAttrPos);
+ }
+ fAttrPos++;
+ return retAttr;
+}
+
+inline void PSVIAttributeList::reset()
+{
+ fAttrPos = 0;
+}
XERCES_CPP_NAMESPACE_END
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]