xerces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From amass...@apache.org
Subject svn commit: r652574 - in /xerces/c/trunk/src/xercesc/framework/psvi: PSVIAttributeList.cpp PSVIAttributeList.hpp
Date Thu, 01 May 2008 16:54:41 GMT
Author: amassari
Date: Thu May  1 09:54:41 2008
New Revision: 652574

URL: http://svn.apache.org/viewvc?rev=652574&view=rev
Log:
Rewrite the storage mechanism to avoid cast (XERCESC-1678)

Modified:
    xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.cpp
    xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.hpp

Modified: xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.cpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.cpp?rev=652574&r1=652573&r2=652574&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.cpp (original)
+++ xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.cpp Thu May  1 09:54:41 2008
@@ -26,15 +26,11 @@
 XERCES_CPP_NAMESPACE_BEGIN
 
 PSVIAttributeList::PSVIAttributeList( MemoryManager* const manager ):  
-        fMemoryManager(manager)
-        , fAttrList(0)
-        , fAttrNameList(0)
-        , fAttrNSList(0)
-        , fAttrPos(0)
-{
-    fAttrList= new (fMemoryManager) RefVectorOf<PSVIAttribute> (10, true, fMemoryManager);
-    fAttrNameList= new (fMemoryManager) RefArrayVectorOf<XMLCh> (10, false, fMemoryManager);
-    fAttrNSList= new (fMemoryManager) RefArrayVectorOf<XMLCh> (10, false, fMemoryManager);
+    fMemoryManager(manager)
+  , fAttrList(0)
+  , fAttrPos(0)
+{
+    fAttrList= new (fMemoryManager) RefVectorOf<PSVIAttributeStorage> (10, true, fMemoryManager);
 }
 
 /*
@@ -58,7 +54,7 @@
 {
     if(index >= fAttrPos)
         return 0;
-    return fAttrList->elementAt(index);
+    return fAttrList->elementAt(index)->fPSVIAttribute;
 }
 
 /*
@@ -74,7 +70,7 @@
     
     if(index >= fAttrPos)
         return 0;
-    return fAttrNameList->elementAt(index);
+    return fAttrList->elementAt(index)->fAttributeName;
 }
 
 /*
@@ -89,7 +85,7 @@
 {
     if(index >= fAttrPos)
         return 0;
-    return fAttrNSList->elementAt(index);
+    return fAttrList->elementAt(index)->fAttributeNamespace;
 }
 
 /*
@@ -103,9 +99,10 @@
                 , const XMLCh * attrNamespace)
 {
     for (unsigned int index=0; index < fAttrPos; index++) {
-        if (XMLString::equals(attrName,fAttrNameList->elementAt(index))
-                && XMLString::equals(attrNamespace,fAttrNSList->elementAt(index)))
-            return fAttrList->elementAt(index);
+        PSVIAttributeStorage* storage = fAttrList->elementAt(index);
+        if (XMLString::equals(attrName,storage->fAttributeName) && 
+            XMLString::equals(attrNamespace,storage->fAttributeNamespace))
+            return storage->fPSVIAttribute;
     }
     return 0;
 }

Modified: xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.hpp
URL: http://svn.apache.org/viewvc/xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.hpp?rev=652574&r1=652573&r2=652574&view=diff
==============================================================================
--- xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.hpp (original)
+++ xerces/c/trunk/src/xercesc/framework/psvi/PSVIAttributeList.hpp Thu May  1 09:54:41 2008
@@ -24,7 +24,7 @@
 
 #include <xercesc/util/PlatformUtils.hpp>
 #include <xercesc/framework/psvi/PSVIAttribute.hpp>
-#include <xercesc/util/ValueVectorOf.hpp>
+#include <xercesc/util/RefVectorOf.hpp>
 
 XERCES_CPP_NAMESPACE_BEGIN
 
@@ -36,6 +36,25 @@
  * under what conditions it may be relied upon to have meaningful contents.
  */
 
+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
 {
@@ -153,47 +172,37 @@
     //  handler to provide dynamically-need memory
     // fAttrList
     //  list of PSVIAttributes contained by this object
-    // fAttrNameList
-    //  list of the names of the initialized PSVIAttribute objects contained
-    //  in this listing
-    // fAttrNSList
-    //  list of the namespaces of the initialized PSVIAttribute objects contained
-    //  in this listing
     // fAttrPos
     //  current number of initialized PSVIAttributes in fAttrList
-    MemoryManager*                  fMemoryManager;    
-    RefVectorOf<PSVIAttribute>*     fAttrList;
-    RefArrayVectorOf<XMLCh>*        fAttrNameList;
-    RefArrayVectorOf<XMLCh>*        fAttrNSList;
-    unsigned int                    fAttrPos;
+    MemoryManager*                      fMemoryManager;    
+    RefVectorOf<PSVIAttributeStorage>*  fAttrList;
+    unsigned int                        fAttrPos;
 };
+
 inline PSVIAttributeList::~PSVIAttributeList() 
 {
     delete fAttrList;
-    delete fAttrNameList;
-    delete fAttrNSList;
 }
 
 inline PSVIAttribute *PSVIAttributeList::getPSVIAttributeToFill(
             const XMLCh *attrName
             , const XMLCh * attrNS)
 {
-    PSVIAttribute *retAttr = 0;
+    PSVIAttributeStorage* storage = 0;
     if(fAttrPos == fAttrList->size())
     {
-        retAttr = new (fMemoryManager)PSVIAttribute(fMemoryManager);
-        fAttrList->addElement(retAttr);
-        fAttrNameList->addElement((XMLCh *)attrName);
-        fAttrNSList->addElement((XMLCh *)attrNS);
+        storage = new (fMemoryManager) PSVIAttributeStorage();
+        storage->fPSVIAttribute = new (fMemoryManager) PSVIAttribute(fMemoryManager);
+        fAttrList->addElement(storage);
     }
     else
     {
-        retAttr = fAttrList->elementAt(fAttrPos);
-        fAttrNameList->setElementAt((XMLCh *)attrName, fAttrPos);
-        fAttrNSList->setElementAt((XMLCh *)attrNS, fAttrPos);
+        storage = fAttrList->elementAt(fAttrPos);
     }
+    storage->fAttributeName = attrName;
+    storage->fAttributeNamespace = attrNS;
     fAttrPos++;
-    return retAttr;
+    return storage->fPSVIAttribute;
 }
 
 inline void PSVIAttributeList::reset()



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xerces.apache.org
For additional commands, e-mail: commits-help@xerces.apache.org


Mime
View raw message