You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by ca...@apache.org on 2004/05/04 21:02:41 UTC
cvs commit: xml-xerces/c/src/xercesc/framework/psvi XSAttributeDeclaration.cpp XSAttributeDeclaration.hpp XSElementDeclaration.cpp XSElementDeclaration.hpp XSModel.cpp XSModel.hpp XSObject.cpp XSObject.hpp
cargilld 2004/05/04 12:02:41
Modified: c/src/xercesc/framework/psvi XSAttributeDeclaration.cpp
XSAttributeDeclaration.hpp XSElementDeclaration.cpp
XSElementDeclaration.hpp XSModel.cpp XSModel.hpp
XSObject.cpp XSObject.hpp
Log:
Enable IDs to work on all kinds of schema components
Revision Changes Path
1.13 +4 -7 xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.cpp
Index: XSAttributeDeclaration.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.cpp,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -r1.12 -r1.13
--- XSAttributeDeclaration.cpp 29 Jan 2004 11:46:30 -0000 1.12
+++ XSAttributeDeclaration.cpp 4 May 2004 19:02:40 -0000 1.13
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.13 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.12 2004/01/29 11:46:30 cargilld
* Code cleanup changes to get rid of various compiler diagnostic messages.
*
@@ -121,8 +124,7 @@
: XSObject(XSConstants::ATTRIBUTE_DECLARATION, xsModel, manager)
, fAttDef(attDef)
, fTypeDefinition(typeDef)
- , fAnnotation(annot)
- , fId(0)
+ , fAnnotation(annot)
, fScope(scope)
, fEnclosingCTDefinition(enclosingCTDefinition)
{
@@ -149,11 +151,6 @@
XSNamespaceItem *XSAttributeDeclaration::getNamespaceItem()
{
return fXSModel->getNamespaceItem(getNamespace());
-}
-
-unsigned int XSAttributeDeclaration::getId() const
-{
- return fId;
}
// ---------------------------------------------------------------------------
1.9 +3 -17 xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.hpp
Index: XSAttributeDeclaration.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAttributeDeclaration.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSAttributeDeclaration.hpp 24 Dec 2003 17:42:02 -0000 1.8
+++ XSAttributeDeclaration.hpp 4 May 2004 19:02:40 -0000 1.9
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.9 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.8 2003/12/24 17:42:02 knoaman
* Misc. PSVI updates
*
@@ -169,13 +172,6 @@
*/
XSNamespaceItem* getNamespaceItem();
- /**
- * Return a unique identifier for a component within this XSModel, to
- * optimize querying.
- * @return id unique for this type of component within this XSModel.
- */
- unsigned int getId() const;
-
//@}
/** @name XSAttributeDeclaration methods **/
@@ -222,10 +218,6 @@
/** methods needed by implementation */
//@{
- /**
- * Set the id to be returned on getId().
- */
- void setId(unsigned int id);
bool getRequired() const;
//@}
@@ -249,7 +241,6 @@
SchemaAttDef* fAttDef;
XSSimpleTypeDefinition* fTypeDefinition;
XSAnnotation* fAnnotation;
- unsigned int fId;
XSConstants::SCOPE fScope;
XSComplexTypeDefinition* fEnclosingCTDefinition;
};
@@ -260,11 +251,6 @@
inline XSSimpleTypeDefinition* XSAttributeDeclaration::getTypeDefinition() const
{
return fTypeDefinition;
-}
-
-inline void XSAttributeDeclaration::setId(unsigned int id)
-{
- fId = id;
}
inline XSAnnotation *XSAttributeDeclaration::getAnnotation() const
1.11 +3 -6 xml-xerces/c/src/xercesc/framework/psvi/XSElementDeclaration.cpp
Index: XSElementDeclaration.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSElementDeclaration.cpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSElementDeclaration.cpp 15 Dec 2003 17:23:48 -0000 1.10
+++ XSElementDeclaration.cpp 4 May 2004 19:02:40 -0000 1.11
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.11 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.10 2003/12/15 17:23:48 cargilld
* psvi updates; cleanup revisits and bug fixes
*
@@ -119,7 +122,6 @@
: XSObject(XSConstants::ELEMENT_DECLARATION, xsModel, manager)
, fDisallowedSubstitutions(0)
, fSubstitutionGroupExclusions(0)
- , fId(0)
, fScope(elemScope)
, fSchemaElementDecl(schemaElementDecl)
, fTypeDefinition(typeDefinition)
@@ -177,11 +179,6 @@
XSNamespaceItem *XSElementDeclaration::getNamespaceItem()
{
return fXSModel->getNamespaceItem(getNamespace());
-}
-
-unsigned int XSElementDeclaration::getId() const
-{
- return fId;
}
1.10 +4 -18 xml-xerces/c/src/xercesc/framework/psvi/XSElementDeclaration.hpp
Index: XSElementDeclaration.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSElementDeclaration.hpp,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- XSElementDeclaration.hpp 24 Dec 2003 17:42:02 -0000 1.9
+++ XSElementDeclaration.hpp 4 May 2004 19:02:40 -0000 1.10
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.10 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.9 2003/12/24 17:42:02 knoaman
* Misc. PSVI updates
*
@@ -176,13 +179,6 @@
*/
XSNamespaceItem *getNamespaceItem();
- /**
- * Return a unique identifier for a component within this XSModel, to
- * optimize querying.
- * @return id unique for this type of component within this XSModel.
- */
- unsigned int getId() const;
-
//@}
//---------------------
@@ -297,10 +293,6 @@
/** methods needed by implementation */
//@{
- /**
- * Set the id to be returned on getId().
- */
- void setId(unsigned int id);
void setTypeDefinition(XSTypeDefinition* typeDefinition);
@@ -322,8 +314,7 @@
// data members
// -----------------------------------------------------------------------
short fDisallowedSubstitutions;
- short fSubstitutionGroupExclusions;
- unsigned int fId;
+ short fSubstitutionGroupExclusions;
XSConstants::SCOPE fScope;
SchemaElementDecl* fSchemaElementDecl;
XSTypeDefinition* fTypeDefinition;
@@ -361,11 +352,6 @@
inline XSAnnotation *XSElementDeclaration::getAnnotation() const
{
return fAnnotation;
-}
-
-inline void XSElementDeclaration::setId(unsigned int id)
-{
- fId = id;
}
inline XSConstants::SCOPE XSElementDeclaration::getScope() const
1.21 +23 -34 xml-xerces/c/src/xercesc/framework/psvi/XSModel.cpp
Index: XSModel.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSModel.cpp,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- XSModel.cpp 5 Feb 2004 18:09:53 -0000 1.20
+++ XSModel.cpp 4 May 2004 19:02:40 -0000 1.21
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.21 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.20 2004/02/05 18:09:53 cargilld
* Fix a seg fault with PSVI and set basetype of anysimpletype to be anytype.
*
@@ -149,8 +152,6 @@
: fMemoryManager(manager)
, fNamespaceStringList(0)
, fXSNamespaceItemList(0)
- , fElementDeclarationVector(0)
- , fAttributeDeclarationVector(0)
, fURIStringPool(0)
, fXSAnnotationList(0)
, fHashNamespace(0)
@@ -195,13 +196,12 @@
fComponentMap[i] = 0;
break;
}
+ fIdVector[i] = new (fMemoryManager) RefVectorOf<XSObject>(30, false, fMemoryManager);
}
fNamespaceStringList = new (manager) RefArrayVectorOf <XMLCh>(10, true, manager);
fXSNamespaceItemList = new (manager) RefVectorOf <XSNamespaceItem>(10, true, manager);
fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (10, false, manager);
- fElementDeclarationVector = new (manager) RefVectorOf<XSElementDeclaration> (30, false, manager);
- fAttributeDeclarationVector = new (manager) RefVectorOf<XSAttributeDeclaration> (20, false, manager);
fHashNamespace = new (manager) RefHashTableOf<XSNamespaceItem> (11, false, manager);
// Loop through all grammars in the grammar pool to create the XSNamespaceItem's
@@ -262,8 +262,6 @@
: fMemoryManager(manager)
, fNamespaceStringList(0)
, fXSNamespaceItemList(0)
- , fElementDeclarationVector(0)
- , fAttributeDeclarationVector(0)
, fURIStringPool(0)
, fXSAnnotationList(0)
, fHashNamespace(0)
@@ -309,14 +307,13 @@
fComponentMap[i] = 0;
break;
}
+ fIdVector[i] = new (fMemoryManager) RefVectorOf<XSObject>(30, false, fMemoryManager);
}
fNamespaceStringList = new (manager) RefArrayVectorOf <XMLCh>(10, true, manager);
fXSNamespaceItemList = new (manager) RefVectorOf <XSNamespaceItem>(10, false, manager);
fDeleteNamespace = new (manager) RefVectorOf <XSNamespaceItem>(10, true, manager);
- fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (10, false, manager);
- fElementDeclarationVector = new (manager) RefVectorOf<XSElementDeclaration> (30, false, manager);
- fAttributeDeclarationVector = new (manager) RefVectorOf<XSAttributeDeclaration> (20, false, manager);
+ fXSAnnotationList = new (manager) RefVectorOf <XSAnnotation> (10, false, manager);
fHashNamespace = new (manager) RefHashTableOf<XSNamespaceItem> (11, false, manager);
if (fParent)
@@ -357,16 +354,12 @@
}
break;
}
+ for (unsigned int j=0; j<fParent->fIdVector[i]->size(); j++)
+ {
+ fIdVector[i]->addElement(fParent->fIdVector[i]->elementAt(j));
+ }
}
- for (i=0; i<fParent->fElementDeclarationVector->size(); i++)
- {
- fElementDeclarationVector->addElement(fParent->fElementDeclarationVector->elementAt(i));
- }
- for (i=0; i<fParent->fAttributeDeclarationVector->size(); i++)
- {
- fAttributeDeclarationVector->addElement(fParent->fAttributeDeclarationVector->elementAt(i));
- }
for (i=0; i<fParent->fXSAnnotationList->size(); i++)
{
fXSAnnotationList->addElement(fParent->fXSAnnotationList->elementAt(i));
@@ -446,6 +439,7 @@
delete fComponentMap[i];
break;
}
+ delete fIdVector[i];
}
delete fNamespaceStringList;
@@ -453,8 +447,6 @@
delete fXSAnnotationList;
delete fHashNamespace;
delete fObjFactory;
- delete fElementDeclarationVector;
- delete fAttributeDeclarationVector;
if (fDeleteNamespace)
delete fDeleteNamespace;
@@ -466,6 +458,14 @@
// ---------------------------------------------------------------------------
// XSModel: Helper methods
// ---------------------------------------------------------------------------
+void XSModel::addComponentToIdVector(XSObject* const component,
+ int componentIndex)
+{
+ component->setId(fIdVector[componentIndex]->size());
+ fIdVector[componentIndex]->addElement(component);
+}
+
+
void XSModel::addComponentToNamespace(XSNamespaceItem* const namespaceItem,
XSObject* const component,
int componentIndex,
@@ -550,8 +550,6 @@
(SchemaAttDef*) &(attrEnum.nextElement()), this
);
- xsAttrDecl->setId(fAttributeDeclarationVector->size());
- fAttributeDeclarationVector->addElement(xsAttrDecl);
addComponentToNamespace
(
namespaceItem, xsAttrDecl, XSConstants::ATTRIBUTE_DECLARATION - 1
@@ -570,8 +568,6 @@
&curElem, this
);
- xsElemDecl->setId(fElementDeclarationVector->size());
- fElementDeclarationVector->addElement(xsElemDecl);
addComponentToNamespace
(
namespaceItem, xsElemDecl, XSConstants::ELEMENT_DECLARATION -1
@@ -665,6 +661,7 @@
{
fXSAnnotationList->addElement(annot);
namespaceItem->fXSAnnotationList->addElement(annot);
+ addComponentToIdVector(annot, XSConstants::ANNOTATION);
annot = annot->getNext();
} // end of annotation loop
}
@@ -870,17 +867,9 @@
XSObject *XSModel::getXSObjectById(unsigned int compId
, XSConstants::COMPONENT_TYPE compType)
{
- // only elements & attributes have id's
- switch(compType) {
- case XSConstants::ELEMENT_DECLARATION:
- if (compId < fElementDeclarationVector->size())
- return fElementDeclarationVector->elementAt(compId);
- break;
- case XSConstants::ATTRIBUTE_DECLARATION:
- if (compId < fAttributeDeclarationVector->size())
- return fAttributeDeclarationVector->elementAt(compId);
- break;
- }
+ if (compId < fIdVector[compType -1]->size())
+ return fIdVector[compType -1]->elementAt(compId);
+
return 0;
}
1.11 +11 -2 xml-xerces/c/src/xercesc/framework/psvi/XSModel.hpp
Index: XSModel.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSModel.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSModel.hpp 24 Dec 2003 17:42:02 -0000 1.10
+++ XSModel.hpp 4 May 2004 19:02:40 -0000 1.11
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.11 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.10 2003/12/24 17:42:02 knoaman
* Misc. PSVI updates
*
@@ -337,6 +340,12 @@
, bool addToXSModel = true
);
+ void addComponentToIdVector
+ (
+ XSObject* const component
+ , int componentIndex
+ );
+
// -----------------------------------------------------------------------
// Unimplemented constructors and operators
// -----------------------------------------------------------------------
@@ -345,6 +354,7 @@
protected:
friend class XSObjectFactory;
+ friend class XSObject;
// -----------------------------------------------------------------------
// data members
@@ -356,8 +366,7 @@
StringList* fNamespaceStringList;
XSNamespaceItemList* fXSNamespaceItemList;
- RefVectorOf<XSElementDeclaration>* fElementDeclarationVector;
- RefVectorOf<XSAttributeDeclaration>* fAttributeDeclarationVector;
+ RefVectorOf<XSObject>* fIdVector[XSConstants::MULTIVALUE_FACET];
/* Need a XSNamedMap for each component top-level?
ATTRIBUTE_DECLARATION = 1,
1.9 +14 -1 xml-xerces/c/src/xercesc/framework/psvi/XSObject.cpp
Index: XSObject.cpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSObject.cpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- XSObject.cpp 21 Nov 2003 17:34:04 -0000 1.8
+++ XSObject.cpp 4 May 2004 19:02:40 -0000 1.9
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.9 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.8 2003/11/21 17:34:04 knoaman
* PSVI update
*
@@ -86,6 +89,7 @@
*/
#include <xercesc/framework/psvi/XSObject.hpp>
+#include <xercesc/framework/psvi/XSModel.hpp>
XERCES_CPP_NAMESPACE_BEGIN
@@ -98,7 +102,12 @@
: fComponentType(compType)
, fXSModel(xsModel)
, fMemoryManager(manager)
+ , fId(0)
{
+ if (xsModel)
+ {
+ xsModel->addComponentToIdVector(this, compType-1);
+ }
}
XSObject::~XSObject()
@@ -125,9 +134,13 @@
unsigned int XSObject::getId() const
{
- return 0;
+ return fId;
}
+inline void XSObject::setId(unsigned int id)
+{
+ fId = id;
+}
XERCES_CPP_NAMESPACE_END
1.11 +10 -2 xml-xerces/c/src/xercesc/framework/psvi/XSObject.hpp
Index: XSObject.hpp
===================================================================
RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSObject.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- XSObject.hpp 1 Dec 2003 23:23:26 -0000 1.10
+++ XSObject.hpp 4 May 2004 19:02:40 -0000 1.11
@@ -56,6 +56,9 @@
/*
* $Log$
+ * Revision 1.11 2004/05/04 19:02:40 cargilld
+ * Enable IDs to work on all kinds of schema components
+ *
* Revision 1.10 2003/12/01 23:23:26 neilg
* fix for bug 25118; thanks to Jeroen Witmond
*
@@ -186,8 +189,12 @@
/** methods needed by implementation */
//@{
-
+ /**
+ * Set the id to be returned on getId().
+ */
+ void setId(unsigned int id);
//@}
+
private:
// -----------------------------------------------------------------------
@@ -208,6 +215,7 @@
XSConstants::COMPONENT_TYPE fComponentType;
XSModel* fXSModel;
MemoryManager* fMemoryManager;
+ unsigned int fId;
};
inline XSConstants::COMPONENT_TYPE XSObject::getType() const
---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-cvs-help@xml.apache.org