GME  13
XTemplateSerializer.cpp
Go to the documentation of this file.
00001 /*
00002  * Licensed to the Apache Software Foundation (ASF) under one or more
00003  * contributor license agreements.  See the NOTICE file distributed with
00004  * this work for additional information regarding copyright ownership.
00005  * The ASF licenses this file to You under the Apache License, Version 2.0
00006  * (the "License"); you may not use this file except in compliance with
00007  * the License.  You may obtain a copy of the License at
00008  *
00009  *      http://www.apache.org/licenses/LICENSE-2.0
00010  *
00011  * Unless required by applicable law or agreed to in writing, software
00012  * distributed under the License is distributed on an "AS IS" BASIS,
00013  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00014  * See the License for the specific language governing permissions and
00015  * limitations under the License.
00016  */
00017 
00018 
00019 
00020 // ---------------------------------------------------------------------------
00021 //  Includes
00022 // ---------------------------------------------------------------------------
00023 #include <xercesc/internal/XTemplateSerializer.hpp>
00024 #include <xercesc/framework/XMLGrammarPool.hpp>
00025 #include <xercesc/validators/common/Grammar.hpp>
00026 
00027 #include <stdio.h>
00028 #include <stdlib.h>
00029 #include <assert.h>
00030 
00031 XERCES_CPP_NAMESPACE_BEGIN
00032 
00033 /***
00034  * internal class meant to be comsumed by XTemplateSerializer only
00035  * the size can not grow
00036  ***/
00037 #ifdef XERCES_DEBUG_SORT_GRAMMAR
00038 
00039 class KeySet : public XMemory
00040 {
00041 public:
00042     // -----------------------------------------------------------------------
00043     //  Contructors and Destructor
00044     // -----------------------------------------------------------------------
00045     KeySet
00046     (
00047       const XMLCh* const         strKey
00048     , const int                  intKey1
00049     , const int                  intKey2
00050     ,       MemoryManager* const manager
00051     );
00052 
00053     ~KeySet();
00054 
00055     // -----------------------------------------------------------------------
00056     //  Public operators
00057     // -----------------------------------------------------------------------
00058     inline void getKeys(const XMLCh*&, int&, int&) const;
00059            void print() const;
00060 
00061     // -----------------------------------------------------------------------
00062     //  Unimplemented constructors and operators
00063     // -----------------------------------------------------------------------
00064     KeySet(const KeySet&);
00065     KeySet& operator=(const KeySet&);
00066 
00067     // -----------------------------------------------------------------------
00068     //  Data members
00069     //  reference only
00070     // -----------------------------------------------------------------------
00071     const XMLCh* const    fStrKey;
00072     const int             fIntKey1;
00073     const int             fIntKey2;
00074           MemoryManager*  fMemoryManager;
00075 
00076 };
00077 
00078 KeySet::KeySet(const XMLCh* const         strKey
00079              , const int                  intKey1
00080              , const int                  intKey2
00081              ,       MemoryManager* const manager)
00082 :fStrKey(strKey)
00083 ,fIntKey1(intKey1)
00084 ,fIntKey2(intKey2)
00085 ,fMemoryManager(manager)
00086 {
00087 }
00088 
00089 KeySet::~KeySet()
00090 {
00091 }
00092 
00093 inline
00094 void KeySet::getKeys(const XMLCh*& strKey, int& intKey1, int& intKey2) const
00095 {
00096     strKey  = fStrKey;
00097     intKey1 = fIntKey1;
00098     intKey2 = fIntKey2;
00099 }
00100 
00101 void KeySet::print() const
00102 {
00103     char* tmpStr = XMLString::transcode(fStrKey, fMemoryManager);
00104     printf("tmpStr=<%s>, intKey1=<%d>, intKey2=<%d>\n", tmpStr, fIntKey1, fIntKey2);
00105     XMLString::release(&tmpStr, fMemoryManager);
00106 }
00107 
00108 static int compareKeySet(const void* keyl, const void* keyr)
00109 {
00110     const KeySet* pairl=*(const KeySet**)keyl;
00111     const KeySet* pairr=*(const KeySet**)keyr;
00112 
00113     const XMLCh* strKeyl   = 0;
00114     int          intKeyl_1 = 0;
00115     int          intKeyl_2 = 0;
00116     pairl->getKeys(strKeyl, intKeyl_1, intKeyl_2);
00117 
00118     const XMLCh* strKeyr   = 0;
00119     int          intKeyr_1 = 0;
00120     int          intKeyr_2 = 0;
00121     pairr->getKeys(strKeyr, intKeyr_1, intKeyr_2);
00122 
00123     int compareValue = XMLString::compareString(strKeyl, strKeyr);
00124 
00125     if (compareValue !=0)
00126         return compareValue;
00127 
00128     compareValue = intKeyl_1 - intKeyr_1;
00129     if (compareValue !=0)
00130         return compareValue;
00131 
00132     return (intKeyl_2 - intKeyr_2);
00133 
00134 }
00135 
00136 class SortArray : public XMemory
00137 {
00138 private :
00139     // -----------------------------------------------------------------------
00140     //  Contructors and Destructor
00141     // -----------------------------------------------------------------------
00142     SortArray
00143     (
00144           const XMLSize_t            size
00145         ,       MemoryManager* const manager
00146     );
00147 
00148         ~SortArray();
00149 
00150     // -----------------------------------------------------------------------
00151     //  Public operators
00152     // -----------------------------------------------------------------------
00153     inline const KeySet* elementAt(const XMLSize_t index)       const;
00154            void  addElement(const KeySet* const keySet);
00155            void  sort();
00156            void  dump() const;
00157 
00158     // -----------------------------------------------------------------------
00159     //  Unimplemented constructors and operators
00160     // -----------------------------------------------------------------------
00161     SortArray(const SortArray&);
00162     SortArray& operator=(const SortArray&);
00163 
00164     // -----------------------------------------------------------------------
00165     //  Data members
00166     // -----------------------------------------------------------------------
00167           XMLSize_t       fCur;      //point to the current available slot
00168           XMLSize_t       fSize;
00169     const KeySet**        fElemList;  //owning objects
00170           MemoryManager*  fMemoryManager;
00171 
00172     friend class XTemplateSerializer;
00173 
00174 };
00175 
00176 SortArray::SortArray(const XMLSize_t            size
00177                    ,       MemoryManager* const manager )
00178 :fCur(0)
00179 ,fSize(size)
00180 ,fMemoryManager(manager)
00181 {
00182     fElemList = (const KeySet**) fMemoryManager->allocate(size * sizeof (KeySet*));
00183 }
00184 
00185 SortArray::~SortArray()
00186 {
00187     for (XMLSize_t i=0; i< fSize; i++)
00188         delete fElemList[i];
00189 
00190     fMemoryManager->deallocate(fElemList);
00191 }
00192 
00193 inline
00194 const KeySet* SortArray::elementAt(const XMLSize_t index) const
00195 {
00196     assert(index < fCur);
00197     return fElemList[index];
00198 }
00199 
00200 void SortArray::addElement(const KeySet* const keySet)
00201 {
00202     assert(fCur < fSize);
00203     fElemList[fCur++]=keySet;
00204 }
00205 
00206 void SortArray::sort()
00207 {
00208     assert(fCur == fSize);
00209     //dump();
00210     qsort(fElemList, fSize, sizeof (KeySet*), compareKeySet);
00211     //dump();
00212 }
00213 
00214 void  SortArray::dump() const
00215 {
00216     printf("\n fSize=<%d>, fCur=<%d>\n", fSize, fCur);
00217     for (XMLSize_t i = 0; i < fCur; i++)
00218         fElemList[i]->print();
00219 }
00220 
00221 #define GET_NEXT_KEYSET()                            \
00222     const KeySet* keySet  = sortArray.elementAt(i);  \
00223     const XMLCh*  strKey  = 0;                       \
00224     int           intKey1 = 0;                       \
00225     int           intKey2 = 0;                       \
00226     keySet->getKeys(strKey, intKey1, intKey2);
00227 
00228 #define SORT_KEYSET_ONEKEY(MM)                                   \
00229    SortArray sortArray(itemNumber, MM);                          \
00230    while (e.hasMoreElements())                                   \
00231    {                                                             \
00232        KeySet* keySet = new (MM) KeySet((XMLCh*) e.nextElementKey(), 0, 0, MM); \
00233        sortArray.addElement(keySet);                             \
00234    }                                                             \
00235    sortArray.sort();
00236 
00237 #define SORT_KEYSET_TWOKEYS(MM)                                  \
00238    SortArray sortArray(itemNumber, MM);                          \
00239    while (e.hasMoreElements())                                   \
00240    {                                                             \
00241        XMLCh*     strKey;                                        \
00242        int        intKey;                                        \
00243        e.nextElementKey((void*&)strKey, intKey);                 \
00244        KeySet* keySet = new (MM) KeySet(strKey, intKey, 0, MM);  \
00245        sortArray.addElement(keySet);                             \
00246    }                                                             \
00247    sortArray.sort();
00248 
00249 #endif
00250 
00251 /**********************************************************
00252  *
00253  * ValueVectorOf
00254  *
00255  *   SchemaElementDecl*
00256  *   unsigned int
00257  *
00258  ***********************************************************/
00259 void XTemplateSerializer::storeObject(ValueVectorOf<SchemaElementDecl*>* const objToStore
00260                                     , XSerializeEngine&                        serEng)
00261 {
00262     if (serEng.needToStoreObject(objToStore))
00263     {
00264         XMLSize_t vectorSize = objToStore->size();
00265         serEng.writeSize (vectorSize);
00266 
00267         for ( XMLSize_t i = 0; i < vectorSize; i++)
00268         {
00269             SchemaElementDecl*& data = objToStore->elementAt(i);
00270             serEng<<data;
00271         }
00272     }
00273 }
00274 
00275 void XTemplateSerializer::loadObject(ValueVectorOf<SchemaElementDecl*>**       objToLoad
00276                                    , int                                       initSize
00277                                    , bool                                      toCallDestructor
00278                                    , XSerializeEngine&                         serEng)
00279 {
00280     if (serEng.needToLoadObject((void**)objToLoad))
00281     {
00282         if (!*objToLoad)
00283         {
00284             if (initSize < 0)
00285                 initSize = 16;
00286 
00287             *objToLoad = new (serEng.getMemoryManager())
00288                              ValueVectorOf<SchemaElementDecl*>(
00289                                                                initSize
00290                                                              , serEng.getMemoryManager()
00291                                                              , toCallDestructor
00292                                                              );
00293         }
00294 
00295         serEng.registerObject(*objToLoad);
00296 
00297         XMLSize_t vectorSize = 0;
00298         serEng.readSize (vectorSize);
00299 
00300         for (XMLSize_t i = 0; i < vectorSize; i++)
00301         {
00302             SchemaElementDecl* data;
00303             serEng>>data;
00304             (*objToLoad)->addElement(data);
00305         }
00306     }
00307 }
00308 
00309 void XTemplateSerializer::storeObject(ValueVectorOf<unsigned int>* const objToStore
00310                                     , XSerializeEngine&                  serEng)
00311 {
00312     if (serEng.needToStoreObject(objToStore))
00313     {
00314         XMLSize_t vectorSize = objToStore->size();
00315         serEng.writeSize (vectorSize);
00316 
00317         for (XMLSize_t i = 0; i < vectorSize; i++)
00318         {
00319             unsigned int& data = objToStore->elementAt(i);
00320             serEng<<data;
00321         }
00322     }
00323 }
00324 
00325 void XTemplateSerializer::loadObject(ValueVectorOf<unsigned int>**       objToLoad
00326                                    , int                                 initSize
00327                                    , bool                                toCallDestructor
00328                                    , XSerializeEngine&                   serEng)
00329 {
00330     if (serEng.needToLoadObject((void**)objToLoad))
00331     {
00332         if (!*objToLoad)
00333         {
00334             if (initSize < 0)
00335                 initSize = 16;
00336 
00337             *objToLoad = new (serEng.getMemoryManager())
00338                              ValueVectorOf<unsigned int>(
00339                                                          initSize
00340                                                        , serEng.getMemoryManager()
00341                                                        , toCallDestructor
00342                                                        );
00343         }
00344 
00345         serEng.registerObject(*objToLoad);
00346 
00347         XMLSize_t vectorSize = 0;
00348         serEng.readSize (vectorSize);
00349 
00350         for (XMLSize_t i = 0; i < vectorSize; i++)
00351         {
00352             unsigned int data;
00353             serEng>>data;
00354             (*objToLoad)->addElement(data);
00355         }
00356     }
00357 
00358 }
00359 
00360 /**********************************************************
00361  *
00362  * RefArrayVectorOf
00363  *
00364  *   XMLCh
00365  *
00366  ***********************************************************/
00367 
00368 void XTemplateSerializer::storeObject(RefArrayVectorOf<XMLCh>* const objToStore
00369                                     , XSerializeEngine&              serEng)
00370 {
00371     if (serEng.needToStoreObject(objToStore))
00372     {
00373         XMLSize_t vectorSize = objToStore->size();
00374         serEng.writeSize (vectorSize);
00375 
00376         for (XMLSize_t i = 0; i < vectorSize; i++)
00377         {
00378             serEng.writeString(objToStore->elementAt(i));
00379         }
00380     }
00381 
00382 }
00383 
00384 void XTemplateSerializer::loadObject(RefArrayVectorOf<XMLCh>**  objToLoad
00385                                    , int                        initSize
00386                                    , bool                       toAdopt
00387                                    , XSerializeEngine&          serEng)
00388 {
00389 
00390     if (serEng.needToLoadObject((void**)objToLoad))
00391     {
00392         if (!*objToLoad)
00393         {
00394             if (initSize < 0)
00395                 initSize = 16;
00396 
00397             *objToLoad = new (serEng.getMemoryManager())
00398                              RefArrayVectorOf<XMLCh>(
00399                                                      initSize
00400                                                    , toAdopt
00401                                                    , serEng.getMemoryManager()
00402                                                    );
00403         }
00404 
00405         serEng.registerObject(*objToLoad);
00406 
00407         XMLSize_t vectorSize = 0;
00408         serEng.readSize (vectorSize);
00409 
00410         for (XMLSize_t i = 0; i < vectorSize; i++)
00411         {
00412             XMLCh* data;
00413             serEng.readString(data);
00414             (*objToLoad)->addElement(data);
00415         }
00416     }
00417 
00418 }
00419 
00420 /**********************************************************
00421  *
00422  * RefVectorOf
00423  *
00424  *   SchemaAttDef
00425  *   SchemaElementDecl
00426  *   ContentSpecNode
00427  *   IC_Field
00428  *   DatatypeValidator
00429  *   IdentityConstraint
00430  *   XMLNumber
00431  *   XercesLocationPath
00432  *   XercesStep
00433  *
00434  ***********************************************************/
00435 
00436 void XTemplateSerializer::storeObject(RefVectorOf<SchemaAttDef>* const objToStore
00437                                     , XSerializeEngine&                serEng)
00438 {
00439 
00440     if (serEng.needToStoreObject(objToStore))
00441     {
00442 
00443         XMLSize_t vectorLength = objToStore->size();
00444         serEng.writeSize (vectorLength);
00445 
00446         for ( XMLSize_t i = 0; i < vectorLength; i++)
00447         {
00448             SchemaAttDef* data = objToStore->elementAt(i);
00449             serEng<<data;
00450         }
00451 
00452     }
00453 
00454 }
00455 
00456 void XTemplateSerializer::loadObject(RefVectorOf<SchemaAttDef>** objToLoad
00457                                    , int                         initSize
00458                                    , bool                        toAdopt
00459                                    , XSerializeEngine&           serEng)
00460 {
00461 
00462     if (serEng.needToLoadObject((void**)objToLoad))
00463     {
00464 
00465         if (!*objToLoad)
00466         {
00467             if (initSize < 0)
00468                 initSize = 16;
00469 
00470             *objToLoad = new (serEng.getMemoryManager())
00471                              RefVectorOf<SchemaAttDef>(
00472                                                        initSize
00473                                                      , toAdopt
00474                                                      , serEng.getMemoryManager()
00475                                                      );
00476         }
00477 
00478         serEng.registerObject(*objToLoad);
00479 
00480         XMLSize_t vectorLength = 0;
00481         serEng.readSize (vectorLength);
00482         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00483         {
00484             SchemaAttDef* data;
00485             serEng>>data;
00486             (*objToLoad)->addElement(data);
00487         }
00488 
00489     }
00490 
00491 }
00492 
00493 void XTemplateSerializer::storeObject(RefVectorOf<SchemaElementDecl>* const objToStore
00494                                     , XSerializeEngine&                     serEng)
00495 {
00496 
00497     if (serEng.needToStoreObject(objToStore))
00498     {
00499 
00500         XMLSize_t vectorLength = objToStore->size();
00501         serEng.writeSize (vectorLength);
00502 
00503         for ( XMLSize_t i = 0; i < vectorLength; i++)
00504         {
00505             SchemaElementDecl* data = objToStore->elementAt(i);
00506             serEng<<data;
00507         }
00508 
00509     }
00510 
00511 }
00512 
00513 void XTemplateSerializer::loadObject(RefVectorOf<SchemaElementDecl>** objToLoad
00514                                    , int                              initSize
00515                                    , bool                             toAdopt
00516                                    , XSerializeEngine&                serEng)
00517 {
00518 
00519     if (serEng.needToLoadObject((void**)objToLoad))
00520     {
00521         if (!*objToLoad)
00522         {
00523             if (initSize < 0)
00524                 initSize = 16;
00525 
00526             *objToLoad = new (serEng.getMemoryManager())
00527                              RefVectorOf<SchemaElementDecl>(
00528                                                             initSize
00529                                                           , toAdopt
00530                                                           , serEng.getMemoryManager()
00531                                                           );
00532         }
00533 
00534         serEng.registerObject(*objToLoad);
00535 
00536         XMLSize_t vectorLength = 0;
00537         serEng.readSize (vectorLength);
00538         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00539         {
00540             SchemaElementDecl* data;
00541             serEng>>data;
00542             (*objToLoad)->addElement(data);
00543         }
00544     }
00545 
00546 }
00547 
00548 void XTemplateSerializer::storeObject(RefVectorOf<ContentSpecNode>* const objToStore
00549                                     , XSerializeEngine&                   serEng)
00550 {
00551 
00552     if (serEng.needToStoreObject(objToStore))
00553     {
00554         XMLSize_t vectorLength = objToStore->size();
00555         serEng.writeSize (vectorLength);
00556 
00557         for ( XMLSize_t i = 0; i < vectorLength; i++)
00558         {
00559             ContentSpecNode* data = objToStore->elementAt(i);
00560             serEng<<data;
00561         }
00562     }
00563 
00564 }
00565 
00566 void XTemplateSerializer::loadObject(RefVectorOf<ContentSpecNode>** objToLoad
00567                                    , int                            initSize
00568                                    , bool                           toAdopt
00569                                    , XSerializeEngine&              serEng)
00570 {
00571 
00572     if (serEng.needToLoadObject((void**)objToLoad))
00573     {
00574         if (!*objToLoad)
00575         {
00576             if (initSize < 0)
00577                 initSize = 16;
00578 
00579             *objToLoad = new (serEng.getMemoryManager())
00580                              RefVectorOf<ContentSpecNode>(
00581                                                           initSize
00582                                                         , toAdopt
00583                                                         , serEng.getMemoryManager()
00584                                                         );
00585         }
00586 
00587         serEng.registerObject(*objToLoad);
00588 
00589         XMLSize_t vectorLength = 0;
00590         serEng.readSize (vectorLength);
00591         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00592         {
00593             ContentSpecNode* data;
00594             serEng>>data;
00595             (*objToLoad)->addElement(data);
00596         }
00597     }
00598 
00599 }
00600 
00601 void XTemplateSerializer::storeObject(RefVectorOf<IC_Field>* const objToStore
00602                                     , XSerializeEngine&            serEng)
00603 {
00604 
00605     if (serEng.needToStoreObject(objToStore))
00606     {
00607         XMLSize_t vectorLength = objToStore->size();
00608         serEng.writeSize (vectorLength);
00609 
00610         for ( XMLSize_t i = 0; i < vectorLength; i++)
00611         {
00612             IC_Field* data = objToStore->elementAt(i);
00613             serEng<<data;
00614         }
00615     }
00616 
00617 }
00618 
00619 void XTemplateSerializer::loadObject(RefVectorOf<IC_Field>** objToLoad
00620                                    , int                     initSize
00621                                    , bool                    toAdopt
00622                                    , XSerializeEngine&       serEng)
00623 {
00624 
00625     if (serEng.needToLoadObject((void**)objToLoad))
00626     {
00627         if (!*objToLoad)
00628         {
00629             if (initSize < 0)
00630                 initSize = 16;
00631 
00632             *objToLoad = new (serEng.getMemoryManager())
00633                              RefVectorOf<IC_Field>(
00634                                                    initSize
00635                                                  , toAdopt
00636                                                  , serEng.getMemoryManager()
00637                                                  );
00638         }
00639 
00640         serEng.registerObject(*objToLoad);
00641 
00642         XMLSize_t vectorLength = 0;
00643         serEng.readSize (vectorLength);
00644         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00645         {
00646             IC_Field* data;
00647             serEng>>data;
00648             (*objToLoad)->addElement(data);
00649         }
00650     }
00651 
00652 }
00653 
00654 void XTemplateSerializer::storeObject(RefVectorOf<DatatypeValidator>* const objToStore
00655                                     , XSerializeEngine&                      serEng)
00656 {
00657 
00658     if (serEng.needToStoreObject(objToStore))
00659     {
00660         XMLSize_t vectorLength = objToStore->size();
00661         serEng.writeSize (vectorLength);
00662 
00663         for ( XMLSize_t i = 0; i < vectorLength; i++)
00664         {
00665             DatatypeValidator* data = objToStore->elementAt(i);
00666             DatatypeValidator::storeDV(serEng, data);
00667         }
00668     }
00669 
00670 }
00671 
00672 void XTemplateSerializer::loadObject(RefVectorOf<DatatypeValidator>** objToLoad
00673                                    , int                               initSize
00674                                    , bool                              toAdopt
00675                                    , XSerializeEngine&                 serEng)
00676 {
00677 
00678     if (serEng.needToLoadObject((void**)objToLoad))
00679     {
00680         if (!*objToLoad)
00681         {
00682             if (initSize < 0)
00683                 initSize = 16;
00684 
00685             *objToLoad = new (serEng.getMemoryManager())
00686                              RefVectorOf<DatatypeValidator>(
00687                                                             initSize
00688                                                           , toAdopt
00689                                                           , serEng.getMemoryManager()
00690                                                            );
00691         }
00692 
00693         serEng.registerObject(*objToLoad);
00694 
00695         XMLSize_t vectorLength = 0;
00696         serEng.readSize (vectorLength);
00697         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00698         {
00699             DatatypeValidator*  data;
00700             data = DatatypeValidator::loadDV(serEng);
00701             (*objToLoad)->addElement(data);
00702         }
00703     }
00704 
00705 }
00706 
00707 void XTemplateSerializer::storeObject(RefVectorOf<IdentityConstraint>* const objToStore
00708                                     , XSerializeEngine&                       serEng)
00709 {
00710 
00711     if (serEng.needToStoreObject(objToStore))
00712     {
00713         XMLSize_t vectorLength = objToStore->size();
00714         serEng.writeSize (vectorLength);
00715 
00716         for ( XMLSize_t i = 0; i < vectorLength; i++)
00717         {
00718             IdentityConstraint* data = objToStore->elementAt(i);
00719             IdentityConstraint::storeIC(serEng, data);
00720         }
00721     }
00722 
00723 }
00724 
00725 void XTemplateSerializer::loadObject(RefVectorOf<IdentityConstraint>** objToLoad
00726                                    , int                                initSize
00727                                    , bool                               toAdopt
00728                                    , XSerializeEngine&                  serEng)
00729 {
00730 
00731     if (serEng.needToLoadObject((void**)objToLoad))
00732     {
00733         if (!*objToLoad)
00734         {
00735             if (initSize < 0)
00736                 initSize = 16;
00737 
00738             *objToLoad = new (serEng.getMemoryManager())
00739                              RefVectorOf<IdentityConstraint>(
00740                                                              initSize
00741                                                            , toAdopt
00742                                                            , serEng.getMemoryManager()
00743                                                             );
00744         }
00745 
00746         serEng.registerObject(*objToLoad);
00747 
00748         XMLSize_t vectorLength = 0;
00749         serEng.readSize (vectorLength);
00750         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00751         {
00752             IdentityConstraint*  data;
00753             data = IdentityConstraint::loadIC(serEng);
00754             (*objToLoad)->addElement(data);
00755         }
00756     }
00757 
00758 }
00759 
00760 void XTemplateSerializer::storeObject(RefVectorOf<XMLNumber>* const objToStore
00761                                     , XSerializeEngine&             serEng)
00762 {
00763 
00764     if (serEng.needToStoreObject(objToStore))
00765     {
00766         XMLSize_t vectorLength = objToStore->size();
00767         serEng.writeSize (vectorLength);
00768 
00769         for ( XMLSize_t i = 0; i < vectorLength; i++)
00770         {
00771             XMLNumber* data = objToStore->elementAt(i);
00772             serEng<<data;
00773         }
00774     }
00775 
00776 }
00777 
00778 void XTemplateSerializer::loadObject(RefVectorOf<XMLNumber>** objToLoad
00779                                    , int                       initSize
00780                                    , bool                      toAdopt
00781                                    , XMLNumber::NumberType     numType
00782                                    , XSerializeEngine&         serEng)
00783 {
00784 
00785     if (serEng.needToLoadObject((void**)objToLoad))
00786     {
00787         if (!*objToLoad)
00788         {
00789             if (initSize < 0)
00790                 initSize = 16;
00791 
00792             *objToLoad = new (serEng.getMemoryManager())
00793                              RefVectorOf<XMLNumber>(
00794                                                     initSize
00795                                                   , toAdopt
00796                                                   , serEng.getMemoryManager()
00797                                                    );
00798         }
00799 
00800         serEng.registerObject(*objToLoad);
00801 
00802         XMLSize_t vectorLength = 0;
00803         serEng.readSize (vectorLength);
00804         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00805         {
00806             XMLNumber*  data;
00807             data = XMLNumber::loadNumber(numType , serEng);
00808             (*objToLoad)->addElement(data);
00809         }
00810     }
00811 
00812 }
00813 
00814 void XTemplateSerializer::storeObject(RefVectorOf<XercesLocationPath>* const objToStore
00815                                     , XSerializeEngine&                      serEng)
00816 {
00817 
00818     if (serEng.needToStoreObject(objToStore))
00819     {
00820         XMLSize_t vectorLength = objToStore->size();
00821         serEng.writeSize (vectorLength);
00822 
00823         for ( XMLSize_t i = 0; i < vectorLength; i++)
00824         {
00825             XercesLocationPath* data = objToStore->elementAt(i);
00826             serEng<<data;
00827         }
00828     }
00829 
00830 }
00831 
00832 void XTemplateSerializer::loadObject(RefVectorOf<XercesLocationPath>** objToLoad
00833                                    , int                               initSize
00834                                    , bool                              toAdopt
00835                                    , XSerializeEngine&                 serEng)
00836 {
00837 
00838     if (serEng.needToLoadObject((void**)objToLoad))
00839     {
00840         if (!*objToLoad)
00841         {
00842             if (initSize < 0)
00843                 initSize = 16;
00844 
00845             *objToLoad = new (serEng.getMemoryManager())
00846                              RefVectorOf<XercesLocationPath>(
00847                                                              initSize
00848                                                            , toAdopt
00849                                                            , serEng.getMemoryManager()
00850                                                             );
00851         }
00852 
00853         serEng.registerObject(*objToLoad);
00854 
00855         XMLSize_t vectorLength = 0;
00856         serEng.readSize (vectorLength);
00857         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00858         {
00859             XercesLocationPath*  data;
00860             serEng>>data;
00861             (*objToLoad)->addElement(data);
00862         }
00863     }
00864 
00865 }
00866 
00867 void XTemplateSerializer::storeObject(RefVectorOf<XercesStep>* const objToStore
00868                                     , XSerializeEngine&              serEng)
00869 {
00870 
00871     if (serEng.needToStoreObject(objToStore))
00872     {
00873         XMLSize_t vectorLength = objToStore->size();
00874         serEng.writeSize (vectorLength);
00875 
00876         for (XMLSize_t i = 0; i < vectorLength; i++)
00877         {
00878             XercesStep* data = objToStore->elementAt(i);
00879             serEng<<data;
00880         }
00881     }
00882 
00883 }
00884 
00885 void XTemplateSerializer::loadObject(RefVectorOf<XercesStep>** objToLoad
00886                                    , int                       initSize
00887                                    , bool                      toAdopt
00888                                    , XSerializeEngine&         serEng)
00889 {
00890 
00891     if (serEng.needToLoadObject((void**)objToLoad))
00892     {
00893         if (!*objToLoad)
00894         {
00895             if (initSize < 0)
00896                 initSize = 16;
00897 
00898             *objToLoad = new (serEng.getMemoryManager())
00899                              RefVectorOf<XercesStep>(
00900                                                      initSize
00901                                                    , toAdopt
00902                                                    , serEng.getMemoryManager()
00903                                                     );
00904         }
00905 
00906         serEng.registerObject(*objToLoad);
00907 
00908         XMLSize_t vectorLength = 0;
00909         serEng.readSize (vectorLength);
00910         for (XMLSize_t i = 0 ; i < vectorLength; i++)
00911         {
00912             XercesStep*  data;
00913             serEng>>data;
00914             (*objToLoad)->addElement(data);
00915         }
00916     }
00917 
00918 }
00919 
00920 /**********************************************************
00921  *
00922  * RefHashTableOf
00923  *
00924  *   KVStringPair
00925  *   XMLAttDef
00926  *   DTDAttDef
00927  *   ComplexTypeInfo
00928  *   XercesGroupInfo
00929  *   XercesAttGroupInfo
00930  *   XMLRefInfo
00931  *   DatatypeValidator
00932  *   Grammar
00933  *   XSAnnotation
00934  *
00935  ***********************************************************/
00936 void XTemplateSerializer::storeObject(RefHashTableOf<KVStringPair>* const objToStore
00937                                     , XSerializeEngine&                    serEng)
00938 {
00939 
00940     if (serEng.needToStoreObject(objToStore))
00941     {
00942         serEng.writeSize (objToStore->getHashModulus());
00943 
00944         RefHashTableOfEnumerator<KVStringPair> e(objToStore, false, objToStore->getMemoryManager());
00945         XMLSize_t itemNumber = 0;
00946 
00947         while (e.hasMoreElements())
00948         {
00949             e.nextElement();
00950             itemNumber++;
00951         }
00952 
00953         serEng.writeSize (itemNumber);
00954         e.Reset();
00955 
00956 #ifdef XERCES_DEBUG_SORT_GRAMMAR
00957         //to sort the key
00958         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
00959 
00960         //to store the data
00961         for (XMLSize_t i=0; i < itemNumber; i++)
00962         {
00963             GET_NEXT_KEYSET()
00964 
00965             KVStringPair* data = objToStore->get(strKey);
00966             serEng<<data;
00967         }
00968 #else
00969         while (e.hasMoreElements())
00970         {
00971             KVStringPair* data = objToStore->get(e.nextElementKey());
00972             serEng<<data;
00973         }
00974 #endif
00975     }
00976 }
00977 
00978 void XTemplateSerializer::loadObject(RefHashTableOf<KVStringPair>** objToLoad
00979                                    , int
00980                                    , bool                           toAdopt
00981                                    , XSerializeEngine&              serEng)
00982 {
00983 
00984     if (serEng.needToLoadObject((void**)objToLoad))
00985     {
00986         XMLSize_t hashModulus;
00987         serEng.readSize (hashModulus);
00988 
00989         if (!*objToLoad)
00990         {
00991             *objToLoad = new (serEng.getMemoryManager())
00992                              RefHashTableOf<KVStringPair>(
00993                                                           hashModulus
00994                                                         , toAdopt
00995                                                         , serEng.getMemoryManager()
00996                                                          );
00997         }
00998 
00999         serEng.registerObject(*objToLoad);
01000 
01001         XMLSize_t itemNumber = 0;
01002         serEng.readSize (itemNumber);
01003 
01004         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01005         {
01006             KVStringPair*  data;
01007             serEng>>data;
01008 
01009             (*objToLoad)->put((void*)data->getKey(), data);
01010         }
01011     }
01012 }
01013 
01014 void XTemplateSerializer::storeObject(RefHashTableOf<XMLAttDef>* const objToStore
01015                                     , XSerializeEngine&                serEng)
01016 {
01017     if (serEng.needToStoreObject(objToStore))
01018     {
01019         serEng.writeSize (objToStore->getHashModulus());
01020 
01021         RefHashTableOfEnumerator<XMLAttDef> e(objToStore, false, objToStore->getMemoryManager());
01022         XMLSize_t itemNumber = 0;
01023 
01024         while (e.hasMoreElements())
01025         {
01026             e.nextElement();
01027             itemNumber++;
01028         }
01029 
01030         serEng.writeSize (itemNumber);
01031         e.Reset();
01032 
01033 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01034         //to sort the key
01035         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01036 
01037         //to store the data
01038         for (XMLSize_t i=0; i < itemNumber; i++)
01039         {
01040             GET_NEXT_KEYSET()
01041 
01042             XMLAttDef* data = objToStore->get(strKey);
01043             serEng<<data;
01044         }
01045 #else
01046         while (e.hasMoreElements())
01047         {
01048             XMLAttDef* data = objToStore->get(e.nextElementKey());
01049             serEng<<data;
01050         }
01051 #endif
01052     }
01053 }
01054 
01055 void XTemplateSerializer::loadObject(RefHashTableOf<XMLAttDef>** objToLoad
01056                                    , int
01057                                    , bool                        toAdopt
01058                                    , XSerializeEngine&           serEng)
01059 {
01060 
01061     if (serEng.needToLoadObject((void**)objToLoad))
01062     {
01063 
01064         XMLSize_t hashModulus;
01065         serEng.readSize (hashModulus);
01066 
01067         if (!*objToLoad)
01068         {
01069             *objToLoad = new (serEng.getMemoryManager())
01070                              RefHashTableOf<XMLAttDef>(
01071                                                        hashModulus
01072                                                      , toAdopt
01073                                                      , serEng.getMemoryManager()
01074                                                       );
01075         }
01076 
01077         serEng.registerObject(*objToLoad);
01078 
01079         XMLSize_t itemNumber = 0;
01080         serEng.readSize (itemNumber);
01081 
01082         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01083         {
01084             //This is used solely by SchemaGrammar and by all means it must be
01085             //SchemaAttDef, ideally we may change it to RefHashTableOf<SchemaAttDef>
01086             //later on.
01087             //Affected files IGXMLScanner, SGXMLScanner, SchemaGrammar, TraverseSchema
01088             //XMLAttDef*  data;
01089             SchemaAttDef*  data;
01090             serEng>>data;
01091 
01092             (*objToLoad)->put((void*)data->getAttName()->getLocalPart(), data);
01093         }
01094     }
01095 }
01096 
01097 void XTemplateSerializer::storeObject(RefHashTableOf<DTDAttDef>* const objToStore
01098                                     , XSerializeEngine&                serEng)
01099 {
01100     if (serEng.needToStoreObject(objToStore))
01101     {
01102         serEng.writeSize (objToStore->getHashModulus());
01103 
01104         RefHashTableOfEnumerator<DTDAttDef> e(objToStore, false, objToStore->getMemoryManager());
01105         XMLSize_t itemNumber = 0;
01106 
01107         while (e.hasMoreElements())
01108         {
01109             e.nextElement();
01110             itemNumber++;
01111         }
01112 
01113         serEng.writeSize (itemNumber);
01114         e.Reset();
01115 
01116 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01117         //to sort the key
01118         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01119 
01120         //to store the data
01121         for (XMLSize_t i=0; i < itemNumber; i++)
01122         {
01123             GET_NEXT_KEYSET()
01124 
01125             DTDAttDef* data = objToStore->get(strKey);
01126             serEng<<data;
01127         }
01128 #else
01129         while (e.hasMoreElements())
01130         {
01131             DTDAttDef* data = objToStore->get(e.nextElementKey());
01132             serEng<<data;
01133         }
01134 #endif
01135     }
01136 }
01137 
01138 void XTemplateSerializer::loadObject(RefHashTableOf<DTDAttDef>** objToLoad
01139                                    , int
01140                                    , bool                        toAdopt
01141                                    , XSerializeEngine&           serEng)
01142 {
01143 
01144     if (serEng.needToLoadObject((void**)objToLoad))
01145     {
01146 
01147         XMLSize_t hashModulus;
01148         serEng.readSize (hashModulus);
01149 
01150         if (!*objToLoad)
01151         {
01152             *objToLoad = new (serEng.getMemoryManager())
01153                              RefHashTableOf<DTDAttDef>(
01154                                                        hashModulus
01155                                                      , toAdopt
01156                                                      , serEng.getMemoryManager()
01157                                                       );
01158         }
01159 
01160         serEng.registerObject(*objToLoad);
01161 
01162         XMLSize_t itemNumber = 0;
01163         serEng.readSize (itemNumber);
01164 
01165         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01166         {
01167             DTDAttDef*  data;
01168             serEng>>data;
01169 
01170             (*objToLoad)->put((void*)data->getFullName(), data);
01171         }
01172     }
01173 }
01174 
01175 void XTemplateSerializer::storeObject(RefHashTableOf<ComplexTypeInfo>* const objToStore
01176                                     , XSerializeEngine&                      serEng)
01177 {
01178     if (serEng.needToStoreObject(objToStore))
01179     {
01180         serEng.writeSize (objToStore->getHashModulus());
01181 
01182         RefHashTableOfEnumerator<ComplexTypeInfo> e(objToStore, false, objToStore->getMemoryManager());
01183         XMLSize_t itemNumber = 0;
01184 
01185         while (e.hasMoreElements())
01186         {
01187             e.nextElement();
01188             itemNumber++;
01189         }
01190 
01191         serEng.writeSize (itemNumber);
01192         e.Reset();
01193 
01194 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01195         //to sort the key
01196         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01197 
01198         //to store the data
01199         for (XMLSize_t i=0; i < itemNumber; i++)
01200         {
01201             GET_NEXT_KEYSET()
01202 
01203             ComplexTypeInfo* data = objToStore->get(strKey);
01204             serEng<<data;
01205         }
01206 #else
01207         while (e.hasMoreElements())
01208         {
01209             ComplexTypeInfo* data = objToStore->get(e.nextElementKey());
01210             serEng<<data;
01211         }
01212 #endif
01213     }
01214 }
01215 
01216 void XTemplateSerializer::loadObject(RefHashTableOf<ComplexTypeInfo>** objToLoad
01217                                    , int
01218                                    , bool                              toAdopt
01219                                    , XSerializeEngine&                 serEng)
01220 {
01221     if (serEng.needToLoadObject((void**)objToLoad))
01222     {
01223         XMLSize_t hashModulus;
01224         serEng.readSize (hashModulus);
01225 
01226         if (!*objToLoad)
01227         {
01228             *objToLoad = new (serEng.getMemoryManager())
01229                              RefHashTableOf<ComplexTypeInfo>(
01230                                                              hashModulus
01231                                                            , toAdopt
01232                                                            , serEng.getMemoryManager()
01233                                                            );
01234         }
01235 
01236         serEng.registerObject(*objToLoad);
01237 
01238         XMLSize_t itemNumber = 0;
01239         serEng.readSize (itemNumber);
01240 
01241         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01242         {
01243             ComplexTypeInfo*  data;
01244             serEng>>data;
01245 
01246            (*objToLoad)->put((void*)data->getTypeName(), data);
01247         }
01248     }
01249 }
01250 
01251 void XTemplateSerializer::storeObject(RefHashTableOf<XercesGroupInfo>* const objToStore
01252                                     , XSerializeEngine&                      serEng)
01253 {
01254     if (serEng.needToStoreObject(objToStore))
01255     {
01256         serEng.writeSize (objToStore->getHashModulus());
01257 
01258         RefHashTableOfEnumerator<XercesGroupInfo> e(objToStore, false, objToStore->getMemoryManager());
01259         XMLSize_t itemNumber = 0;
01260 
01261         while (e.hasMoreElements())
01262         {
01263             e.nextElement();
01264             itemNumber++;
01265         }
01266 
01267         serEng.writeSize (itemNumber);
01268         e.Reset();
01269 
01270 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01271         //to sort the key
01272         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01273 
01274         //to store the data
01275         for (XMLSize_t i=0; i < itemNumber; i++)
01276         {
01277             GET_NEXT_KEYSET()
01278 
01279             unsigned int id  = serEng.getStringPool()->getId(strKey);
01280             serEng<<id;
01281 
01282             XercesGroupInfo* data = objToStore->get(strKey);
01283             serEng<<data;
01284         }
01285 #else
01286         while (e.hasMoreElements())
01287         {
01288             XMLCh*       key = (XMLCh*) e.nextElementKey();
01289             unsigned int id  = serEng.getStringPool()->getId(key);
01290 
01291            // key = StringPool->getValueForId(XercesGroupInfo::getNameSpaceId())
01292            //     + chComma
01293            //     + StringPool->getValueForId(XercesGroupInfo::getNameId())
01294            //
01295            // and the key is guranteed in the StringPool
01296            //
01297            //
01298            //  if (id == 0)
01299            //  {
01300            //      throw exception
01301            //   }
01302            //
01303 
01304             serEng<<id;
01305 
01306             XercesGroupInfo* data = objToStore->get(key);
01307             serEng<<data;
01308         }
01309 #endif
01310     }
01311 }
01312 
01313 void XTemplateSerializer::loadObject(RefHashTableOf<XercesGroupInfo>** objToLoad
01314                                    , int
01315                                    , bool                              toAdopt
01316                                    , XSerializeEngine&                 serEng)
01317 {
01318     if (serEng.needToLoadObject((void**)objToLoad))
01319     {
01320         XMLSize_t hashModulus;
01321         serEng.readSize (hashModulus);
01322 
01323         if (!*objToLoad)
01324         {
01325             *objToLoad = new (serEng.getMemoryManager())
01326                              RefHashTableOf<XercesGroupInfo>(
01327                                                              hashModulus
01328                                                            , toAdopt
01329                                                            , serEng.getMemoryManager()
01330                                                            );
01331         }
01332 
01333         serEng.registerObject(*objToLoad);
01334 
01335         XMLSize_t itemNumber = 0;
01336         serEng.readSize (itemNumber);
01337 
01338         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01339         {
01340             unsigned int id;
01341             serEng>>id;
01342 
01343             XMLCh* key = (XMLCh*) serEng.getStringPool()->getValueForId(id);
01344 
01345             XercesGroupInfo*  data;
01346             serEng>>data;
01347 
01348             (*objToLoad)->put((void*)key, data);
01349         }
01350     }
01351 }
01352 
01353 void XTemplateSerializer::storeObject(RefHashTableOf<XercesAttGroupInfo>* const objToStore
01354                                     , XSerializeEngine&                         serEng)
01355 {
01356 
01357     if (serEng.needToStoreObject(objToStore))
01358     {
01359         serEng.writeSize (objToStore->getHashModulus());
01360 
01361         RefHashTableOfEnumerator<XercesAttGroupInfo> e(objToStore, false, objToStore->getMemoryManager());
01362         XMLSize_t itemNumber = 0;
01363 
01364         while (e.hasMoreElements())
01365         {
01366             e.nextElement();
01367             itemNumber++;
01368         }
01369 
01370         serEng.writeSize (itemNumber);
01371         e.Reset();
01372 
01373 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01374         //to sort the key
01375         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01376 
01377         //to store the data
01378         for (XMLSize_t i=0; i < itemNumber; i++)
01379         {
01380             GET_NEXT_KEYSET()
01381 
01382             XercesAttGroupInfo* data = objToStore->get(strKey);
01383             serEng<<data;
01384         }
01385 #else
01386         while (e.hasMoreElements())
01387         {
01388             XercesAttGroupInfo* data = objToStore->get(e.nextElementKey());
01389             serEng<<data;
01390         }
01391 #endif
01392     }
01393 }
01394 
01395 void XTemplateSerializer::loadObject(RefHashTableOf<XercesAttGroupInfo>** objToLoad
01396                                    , int
01397                                    , bool                                 toAdopt
01398                                    , XSerializeEngine&                    serEng)
01399 {
01400     if (serEng.needToLoadObject((void**)objToLoad))
01401     {
01402         XMLSize_t hashModulus;
01403         serEng.readSize (hashModulus);
01404 
01405         if (!*objToLoad)
01406         {
01407             *objToLoad = new (serEng.getMemoryManager())
01408                              RefHashTableOf<XercesAttGroupInfo>(
01409                                                                 hashModulus
01410                                                               , toAdopt
01411                                                               , serEng.getMemoryManager()
01412                                                               );
01413         }
01414 
01415         serEng.registerObject(*objToLoad);
01416 
01417         XMLSize_t itemNumber = 0;
01418         serEng.readSize (itemNumber);
01419 
01420         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01421         {
01422             XercesAttGroupInfo*  data;
01423             serEng>>data;
01424 
01425             XMLCh* key = (XMLCh*) serEng.getStringPool()->getValueForId(data->getNameId());
01426             (*objToLoad)->put((void*)key, data);
01427         }
01428     }
01429 }
01430 
01431 void XTemplateSerializer::storeObject(RefHashTableOf<XMLRefInfo>* const objToStore
01432                                     , XSerializeEngine&                 serEng)
01433 {
01434     if (serEng.needToStoreObject(objToStore))
01435     {
01436         serEng.writeSize (objToStore->getHashModulus());
01437 
01438         RefHashTableOfEnumerator<XMLRefInfo> e(objToStore, false, objToStore->getMemoryManager());
01439         XMLSize_t itemNumber = 0;
01440 
01441         while (e.hasMoreElements())
01442         {
01443             e.nextElement();
01444             itemNumber++;
01445         }
01446 
01447         serEng.writeSize (itemNumber);
01448         e.Reset();
01449 
01450 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01451         //to sort the key
01452         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01453 
01454         //to store the data
01455         for (XMLSize_t i=0; i < itemNumber; i++)
01456         {
01457             GET_NEXT_KEYSET()
01458 
01459             serEng.writeString(strKey);
01460 
01461             XMLRefInfo* data = objToStore->get(strKey);
01462             serEng<<data;
01463         }
01464 #else
01465         while (e.hasMoreElements())
01466         {
01467             XMLCh*     key  = (XMLCh*) e.nextElementKey();
01468             serEng.writeString(key);
01469 
01470             XMLRefInfo* data = objToStore->get(key);
01471             serEng<<data;
01472         }
01473 #endif
01474     }
01475 }
01476 
01477 void XTemplateSerializer::loadObject(RefHashTableOf<XMLRefInfo>** objToLoad
01478                                    , int
01479                                    , bool                         toAdopt
01480                                    , XSerializeEngine&            serEng)
01481 {
01482     if (serEng.needToLoadObject((void**)objToLoad))
01483     {
01484         XMLSize_t hashModulus;
01485         serEng.readSize (hashModulus);
01486 
01487         if (!*objToLoad)
01488         {
01489             *objToLoad = new (serEng.getMemoryManager())
01490                              RefHashTableOf<XMLRefInfo>(
01491                                                         hashModulus
01492                                                       , toAdopt
01493                                                       , serEng.getMemoryManager()
01494                                                       );
01495         }
01496 
01497         serEng.registerObject(*objToLoad);
01498 
01499         XMLSize_t itemNumber = 0;
01500         serEng.readSize (itemNumber);
01501 
01502         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01503         {
01504             XMLCh*      key;
01505             serEng.readString(key);
01506 
01507             XMLRefInfo*  data;
01508             serEng>>data;
01509 
01510             (*objToLoad)->put((void*)key, data);
01511         }
01512     }
01513 }
01514 
01515 void XTemplateSerializer::storeObject(RefHashTableOf<DatatypeValidator>* const objToStore
01516                                     , XSerializeEngine&                        serEng)
01517 {
01518 
01519     if (serEng.needToStoreObject(objToStore))
01520     {
01521 
01522         serEng.writeSize (objToStore->getHashModulus());
01523 
01524         RefHashTableOfEnumerator<DatatypeValidator> e(objToStore, false, objToStore->getMemoryManager());
01525         XMLSize_t itemNumber = 0;
01526 
01527         while (e.hasMoreElements())
01528         {
01529             e.nextElement();
01530             itemNumber++;
01531         }
01532 
01533         serEng.writeSize (itemNumber);
01534         e.Reset();
01535 
01536 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01537         //to sort the key
01538         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01539 
01540         //to store the data
01541         for (XMLSize_t i=0; i < itemNumber; i++)
01542         {
01543             GET_NEXT_KEYSET()
01544 
01545             DatatypeValidator* data = objToStore->get(strKey);
01546             DatatypeValidator::storeDV(serEng, data);
01547         }
01548 #else
01549         while (e.hasMoreElements())
01550         {
01551             /***
01552              * to do: verify valid id
01553              *
01554              *    XMLCh*  key = (XMLCh*) e.nextElementKey();
01555              *    unsigned int id = serEng.getStringPool()->getId(key);
01556              *    if (id == 0)
01557              *        throw exception
01558              ***/
01559             DatatypeValidator* data = objToStore->get(e.nextElementKey());
01560             DatatypeValidator::storeDV(serEng, data);
01561         }
01562 #endif
01563     }
01564 }
01565 
01566 void XTemplateSerializer::loadObject(RefHashTableOf<DatatypeValidator>** objToLoad
01567                                    , int
01568                                    , bool                                toAdopt
01569                                    , XSerializeEngine&                   serEng)
01570 {
01571     if (serEng.needToLoadObject((void**)objToLoad))
01572     {
01573         XMLSize_t hashModulus;
01574         serEng.readSize (hashModulus);
01575 
01576         if (!*objToLoad)
01577         {
01578             *objToLoad = new (serEng.getMemoryManager())
01579                              RefHashTableOf<DatatypeValidator>(
01580                                                                hashModulus
01581                                                              , toAdopt
01582                                                              , serEng.getMemoryManager()
01583                                                              );
01584         }
01585 
01586         serEng.registerObject(*objToLoad);
01587 
01588         XMLSize_t itemNumber = 0;
01589         serEng.readSize (itemNumber);
01590 
01591         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01592         {
01593             DatatypeValidator*  data;
01594             data = DatatypeValidator::loadDV(serEng);
01595 
01596             /***
01597              *   restore the key
01598              ***/
01599             XMLCh*       typeUri   = (XMLCh*) data->getTypeUri();
01600             XMLCh*       typeLocal = (XMLCh*) data->getTypeLocalName();
01601             XMLSize_t    uriLen    = XMLString::stringLen(typeUri);
01602             XMLSize_t    localLen  = XMLString::stringLen(typeLocal);
01603             XMLCh*       typeKey   = (XMLCh*) serEng.getMemoryManager()->allocate
01604                                      (
01605                                        (uriLen + localLen + 2) * sizeof(XMLCh)
01606                                      );
01607             // "typeuri,typeLocal"
01608             XMLString::moveChars(typeKey, typeUri, uriLen+1);
01609             typeKey[uriLen] = chComma;
01610             XMLString::moveChars(&typeKey[uriLen+1], typeLocal, localLen+1);
01611             typeKey[uriLen + localLen + 1] = chNull;
01612             ArrayJanitor<XMLCh> janName(typeKey, serEng.getMemoryManager());
01613 
01614             /*
01615              * get the string from string pool
01616              *
01617              *  to do:
01618              ***/
01619             unsigned int id = serEng.getStringPool()->getId(typeKey);
01620             XMLCh* refKey = (XMLCh*) serEng.getStringPool()->getValueForId(id);
01621 
01622             (*objToLoad)->put((void*)refKey, data);
01623         }
01624     }
01625 }
01626 
01627 void XTemplateSerializer::storeObject(RefHashTableOf<Grammar>* const objToStore
01628                                     , XSerializeEngine&              serEng)
01629 {
01630     if (serEng.needToStoreObject(objToStore))
01631     {
01632         serEng.writeSize (objToStore->getHashModulus());
01633 
01634         RefHashTableOfEnumerator<Grammar> e(objToStore, false, objToStore->getMemoryManager());
01635         XMLSize_t itemNumber = 0;
01636 
01637         while (e.hasMoreElements())
01638         {
01639             e.nextElement();
01640             itemNumber++;
01641         }
01642 
01643         serEng.writeSize (itemNumber);
01644         e.Reset();
01645 
01646 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01647         //to sort the key
01648         SORT_KEYSET_ONEKEY(serEng.getMemoryManager())
01649 
01650         //to store the data
01651         for (XMLSize_t i=0; i < itemNumber; i++)
01652         {
01653             GET_NEXT_KEYSET()
01654 
01655             Grammar* data = objToStore->get(strKey);
01656             Grammar::storeGrammar(serEng, data);
01657         }
01658 #else
01659         while (e.hasMoreElements())
01660         {
01661             Grammar* data = objToStore->get(e.nextElementKey());
01662             Grammar::storeGrammar(serEng, data);
01663         }
01664 #endif
01665 
01666     }
01667 }
01668 
01669 void XTemplateSerializer::loadObject(RefHashTableOf<Grammar>** objToLoad
01670                                    , int
01671                                    , bool                      toAdopt
01672                                    , XSerializeEngine&         serEng)
01673 {
01674     if (serEng.needToLoadObject((void**)objToLoad))
01675     {
01676         XMLSize_t hashModulus;
01677         serEng.readSize (hashModulus);
01678 
01679         if (!*objToLoad)
01680         {
01681             *objToLoad = new (serEng.getMemoryManager())
01682                              RefHashTableOf<Grammar>(
01683                                                      hashModulus
01684                                                    , toAdopt
01685                                                    , serEng.getMemoryManager()
01686                                                    );
01687         }
01688 
01689         serEng.registerObject(*objToLoad);
01690 
01691         XMLSize_t itemNumber = 0;
01692         serEng.readSize (itemNumber);
01693 
01694         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01695         {
01696             Grammar*  data;
01697             data = Grammar::loadGrammar(serEng);
01698 
01699             XMLCh* key = (XMLCh*) data->getGrammarDescription()->getGrammarKey();
01700             (*objToLoad)->put(key, data);
01701         }
01702     }
01703 }
01704 
01705 
01706 void XTemplateSerializer::storeObject(RefHashTableOf<XSAnnotation, PtrHasher>* const objToStore
01707                                     , XSerializeEngine&              serEng)
01708 {
01709     if (serEng.needToStoreObject(objToStore))
01710     {
01711         serEng.writeSize (objToStore->getHashModulus());
01712 
01713         RefHashTableOfEnumerator<XSAnnotation, PtrHasher> e(objToStore, false, objToStore->getMemoryManager());
01714 
01715 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01716         //get the total item number
01717         unsigned int   itemNumber = 0;
01718         while (e.hasMoreElements())
01719         {
01720             void* key = e.nextElementKey();
01721             XSerializeEngine::XSerializedObjectId_t keyId = serEng.lookupStorePool(key);
01722 
01723             if (keyId)
01724                 itemNumber++;
01725         }
01726 
01727         serEng.writeSize (itemNumber);
01728         e.Reset();
01729 
01730         //to sort the key
01731         //though keyId is not supposed to be involved in compare
01732         //we merely use the KeySet to encap both the string key and keyid
01733         SortArray sortArray(itemNumber, objToStore->getMemoryManager());
01734         while (e.hasMoreElements())
01735         {
01736             void* key = e.nextElementKey();
01737             XSerializeEngine::XSerializedObjectId_t keyId = serEng.lookupStorePool(key);
01738 
01739             if (keyId)
01740             {
01741                 KeySet* keySet =
01742                     new (objToStore->getMemoryManager()) KeySet((XMLCh*)key, keyId, 0, objToStore->getMemoryManager());
01743                 sortArray.addElement(keySet);
01744             }
01745 
01746         }
01747 
01748         sortArray.sort();
01749 
01750         //to store the data
01751         for (XMLSize_t i=0; i < itemNumber; i++)
01752         {
01753             GET_NEXT_KEYSET()
01754 
01755             XSerializeEngine::XSerializedObjectId_t keyId = (XSerializeEngine::XSerializedObjectId_t)intKey1;
01756             XSAnnotation* data = objToStore->get(strKey);
01757 
01758             serEng<<keyId;
01759             serEng<<data;
01760         }
01761 #else
01762         ValueVectorOf<XSerializeEngine::XSerializedObjectId_t> ids(16, serEng.getMemoryManager());
01763         ValueVectorOf<void*> keys(16, serEng.getMemoryManager());
01764 
01765         while (e.hasMoreElements())
01766         {
01767             void* key = e.nextElementKey();
01768             XSerializeEngine::XSerializedObjectId_t keyId = serEng.lookupStorePool(key);
01769 
01770             if (keyId)
01771             {
01772                 ids.addElement(keyId);
01773                 keys.addElement(key);
01774             }
01775         }
01776 
01777         XMLSize_t itemNumber = ids.size();
01778         serEng.writeSize (itemNumber);
01779 
01780         for (XMLSize_t i=0; i<itemNumber; i++)
01781         {
01782             XSerializeEngine::XSerializedObjectId_t keyId = ids.elementAt(i);
01783             XSAnnotation* data = objToStore->get(keys.elementAt(i));
01784             serEng<<keyId;
01785             serEng<<data;
01786         }
01787 #endif
01788     }
01789 }
01790 
01791 void XTemplateSerializer::loadObject(RefHashTableOf<XSAnnotation, PtrHasher>** objToLoad
01792                                    , int
01793                                    , bool                           toAdopt
01794                                    , XSerializeEngine&              serEng)
01795 {
01796     if (serEng.needToLoadObject((void**)objToLoad))
01797     {
01798         XMLSize_t hashModulus;
01799         serEng.readSize (hashModulus);
01800 
01801         if (!*objToLoad)
01802         {
01803             *objToLoad = new (serEng.getMemoryManager())
01804                               RefHashTableOf<XSAnnotation, PtrHasher>(
01805                               hashModulus
01806                             , toAdopt
01807                             , serEng.getMemoryManager()
01808                               );
01809         }
01810 
01811         serEng.registerObject(*objToLoad);
01812 
01813         XMLSize_t itemNumber = 0;
01814         serEng.readSize (itemNumber);
01815 
01816         XMLSize_t itemIndex;
01817         XSerializeEngine::XSerializedObjectId_t keyId;
01818         void* key;
01819         XSAnnotation*  data;
01820         if (!serEng.fGrammarPool->getIgnoreSerializedAnnotations()) {
01821             for (itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01822             {
01823                 serEng>>keyId;
01824                 key = serEng.lookupLoadPool(keyId);
01825                 serEng>>data;
01826                 (*objToLoad)->put(key, data);
01827             }
01828         }
01829         else {
01830             for (itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01831             {
01832                 serEng>>keyId;
01833                 key = serEng.lookupLoadPool(keyId);
01834                 serEng>>data;
01835                 delete data;
01836             }
01837         }
01838     }
01839 }
01840 
01841 /**********************************************************
01842  *
01843  * RefHash2KeysTableOf
01844  *
01845  *   SchemaAttDef
01846  *   ElemVector
01847  *
01848  ***********************************************************/
01849 void XTemplateSerializer::storeObject(RefHash2KeysTableOf<SchemaAttDef>* const objToStore
01850                                     , XSerializeEngine&                        serEng)
01851 {
01852     if (serEng.needToStoreObject(objToStore))
01853     {
01854         serEng.writeSize (objToStore->getHashModulus());
01855 
01856         XMLSize_t itemNumber = 0;
01857 
01858         RefHash2KeysTableOfEnumerator<SchemaAttDef> e(objToStore, false, objToStore->getMemoryManager());
01859 
01860         while (e.hasMoreElements())
01861         {
01862             e.nextElement();
01863             itemNumber++;
01864         }
01865 
01866         serEng.writeSize (itemNumber);
01867         e.Reset();
01868 
01869 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01870         //to sort the key
01871         SORT_KEYSET_TWOKEYS(serEng.getMemoryManager())
01872 
01873         //to store the data
01874         for (XMLSize_t i=0; i < itemNumber; i++)
01875         {
01876             GET_NEXT_KEYSET()
01877 
01878             SchemaAttDef* data = objToStore->get(strKey, intKey1);
01879             serEng<<data;
01880 
01881         }
01882 #else
01883 
01884         while (e.hasMoreElements())
01885         {
01886             void*       key1;
01887             int        key2;
01888             e.nextElementKey(key1, key2);
01889 
01890             SchemaAttDef* data = objToStore->get(key1, key2);
01891             serEng<<data;
01892 
01893         }
01894 #endif
01895     }
01896 
01897 }
01898 
01899 void XTemplateSerializer::loadObject(RefHash2KeysTableOf<SchemaAttDef>** objToLoad
01900                                    , int
01901                                    , bool                                toAdopt
01902                                    , XSerializeEngine&                   serEng)
01903 {
01904     if (serEng.needToLoadObject((void**)objToLoad))
01905     {
01906         XMLSize_t hashModulus;
01907         serEng.readSize (hashModulus);
01908 
01909         if (!*objToLoad)
01910         {
01911             *objToLoad = new (serEng.getMemoryManager())
01912                              RefHash2KeysTableOf<SchemaAttDef>(
01913                                                                hashModulus
01914                                                              , toAdopt
01915                                                              , serEng.getMemoryManager()
01916                                                              );
01917         }
01918 
01919         serEng.registerObject(*objToLoad);
01920 
01921         XMLSize_t itemNumber = 0;
01922         serEng.readSize (itemNumber);
01923 
01924         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
01925         {
01926             SchemaAttDef*  data;
01927             serEng>>data;
01928 
01929             XMLCh* key1 = data->getAttName()->getLocalPart();
01930             int    key2 = data->getAttName()->getURI();
01931             //key2==data->getId()
01932             (*objToLoad)->put((void*)key1, key2, data);
01933 
01934         }
01935 
01936     }
01937 
01938 }
01939 
01940 void XTemplateSerializer::storeObject(RefHash2KeysTableOf<ElemVector>* const objToStore
01941                                     , XSerializeEngine&                      serEng)
01942 {
01943     if (serEng.needToStoreObject(objToStore))
01944     {
01945         serEng.writeSize (objToStore->getHashModulus());
01946 
01947         XMLSize_t itemNumber = 0;
01948 
01949         RefHash2KeysTableOfEnumerator<ElemVector> e(objToStore, false, objToStore->getMemoryManager());
01950 
01951         while (e.hasMoreElements())
01952         {
01953             e.nextElement();
01954             itemNumber++;
01955         }
01956 
01957         serEng.writeSize (itemNumber);
01958         e.Reset();
01959 
01960 #ifdef XERCES_DEBUG_SORT_GRAMMAR
01961 
01962         //to sort the key
01963         SORT_KEYSET_TWOKEYS(serEng.getMemoryManager())
01964 
01965         //to store the data
01966         for (XMLSize_t i=0; i < itemNumber; i++)
01967         {
01968             GET_NEXT_KEYSET()
01969 
01970             serEng.writeString(strKey);
01971             serEng<<intKey1;
01972 
01973             ElemVector* data = objToStore->get(strKey, intKey1);
01974             storeObject(data, serEng);
01975         }
01976 #else
01977 
01978         while (e.hasMoreElements())
01979         {
01980             void*      key1;
01981             int        key2;
01982 
01983             e.nextElementKey(key1, key2);
01984             serEng.writeString((const XMLCh*)key1);
01985             serEng<<key2;
01986 
01987             ElemVector* data = objToStore->get(key1, key2);
01988             storeObject(data, serEng);
01989 
01990         }
01991 #endif
01992     }
01993 
01994 }
01995 
01996 void XTemplateSerializer::loadObject(RefHash2KeysTableOf<ElemVector>**      objToLoad
01997                                    , int
01998                                    , bool                                    toAdopt
01999                                    , XSerializeEngine&                       serEng)
02000 {
02001     if (serEng.needToLoadObject((void**)objToLoad))
02002     {
02003         XMLSize_t hashModulus;
02004         serEng.readSize (hashModulus);
02005 
02006         if (!*objToLoad)
02007         {
02008             *objToLoad = new (serEng.getMemoryManager())
02009                              RefHash2KeysTableOf<ElemVector>(
02010                                                                hashModulus
02011                                                              , toAdopt
02012                                                              , serEng.getMemoryManager()
02013                                                              );
02014         }
02015 
02016         serEng.registerObject(*objToLoad);
02017 
02018         XMLSize_t itemNumber = 0;
02019         serEng.readSize (itemNumber);
02020 
02021         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
02022         {
02023             XMLCh*      key1;
02024             serEng.readString(key1);
02025 
02026             int         key2;
02027             serEng>>key2;
02028 
02029             ElemVector*  data = 0;
02030 
02031             //don't call destructor
02032             loadObject(&data, 8, false, serEng);
02033 
02034             /***
02035              *
02036              *  There must be one element in the vector whose
02037              *  susbititutionGroupElem matches the (key1,key2)
02038              *
02039              ***/
02040 
02041             // bool FOUND=false;
02042 
02043             XMLSize_t vectorSize = data->size();
02044             for ( XMLSize_t i = 0; i < vectorSize; i++)
02045             {
02046                 SchemaElementDecl*& elem   = data->elementAt(i);
02047                 SchemaElementDecl*  subElem = elem->getSubstitutionGroupElem();
02048                 XMLCh* elemName = subElem->getBaseName();
02049                 int    uri      = subElem->getURI();
02050                 if (XMLString::equals(elemName, key1) &&
02051                     (uri == key2)                       )
02052                 {
02053                     //release the temp
02054                     serEng.getMemoryManager()->deallocate(key1);
02055                     key1 = elemName;
02056                     //FOUND=true;
02057                     break;
02058                 }
02059             }
02060 
02061             /***
02062              * if (!FOUND)
02063              * {
02064              *     throw exception
02065              * }
02066              ***/
02067 
02068             (*objToLoad)->put((void*)key1, key2, data);
02069 
02070         }
02071 
02072     }
02073 }
02074 
02075 /**********************************************************
02076  *
02077  * RefHash3KeysIdPool
02078  *
02079  *   SchemaElementDecl
02080  *
02081  *   maintain the same order through id
02082  ***********************************************************/
02083 void XTemplateSerializer::storeObject(RefHash3KeysIdPool<SchemaElementDecl>* const objToStore
02084                                     , XSerializeEngine&                            serEng)
02085 {
02086     if (serEng.needToStoreObject(objToStore))
02087     {
02088         serEng.writeSize (objToStore->getHashModulus());
02089 
02090         RefHash3KeysIdPoolEnumerator<SchemaElementDecl> e(objToStore, false, objToStore->getMemoryManager());
02091 
02092         serEng.writeSize (e.size());
02093 
02094         void*  strkey;
02095         int    key1;
02096         int    key2;
02097         /* Update to store key2 separately as for the putGroupElemDecl the key is not the
02098            enclosing scope but another value. */
02099         while (e.hasMoreKeys())
02100         {
02101             e.nextElementKey(strkey, key1, key2);
02102             serEng<<key2;
02103             SchemaElementDecl* data = objToStore->getByKey(strkey, key1, key2);
02104             serEng<<data;
02105         }
02106     }
02107 
02108 }
02109 
02110 void XTemplateSerializer::loadObject(RefHash3KeysIdPool<SchemaElementDecl>** objToLoad
02111                                    , int
02112                                    , bool                                    toAdopt
02113                                    , int                                     initSize2
02114                                    , XSerializeEngine&                       serEng)
02115 {
02116     if (serEng.needToLoadObject((void**)objToLoad))
02117     {
02118         XMLSize_t hashModulus;
02119         serEng.readSize (hashModulus);
02120 
02121         if (!*objToLoad)
02122         {
02123             *objToLoad = new (serEng.getMemoryManager())
02124                              RefHash3KeysIdPool<SchemaElementDecl>(
02125                                                                    hashModulus
02126                                                                  , toAdopt
02127                                                                  , initSize2
02128                                                                  , serEng.getMemoryManager());
02129         }
02130 
02131         serEng.registerObject(*objToLoad);
02132 
02133         XMLSize_t itemNumber = 0;
02134         serEng.readSize (itemNumber);
02135 
02136         int scopeKey;
02137         SchemaElementDecl*  elemDecl;
02138         for (XMLSize_t itemIndex = 0; itemIndex < itemNumber; itemIndex++)
02139         {
02140             serEng>>scopeKey;
02141             serEng>>elemDecl;
02142 
02143            (*objToLoad)->put(elemDecl->getBaseName()
02144                             , elemDecl->getURI()
02145                             , scopeKey
02146                             , elemDecl);
02147         }
02148 
02149     }
02150 
02151 }
02152 
02153 /**********************************************************
02154  *
02155  * NameIdPool
02156  *    no NameIdPool::nextElementKey()
02157  *
02158  *   DTDElementDecl
02159  *   DTDEntityDecl
02160  *   XMLNotationDecl
02161  *
02162  *   maintain the same order through id
02163  ***********************************************************/
02164 void XTemplateSerializer::storeObject(NameIdPool<DTDElementDecl>* const objToStore
02165                                     , XSerializeEngine&                 serEng)
02166 {
02167     if (serEng.needToStoreObject(objToStore))
02168     {
02169         NameIdPoolEnumerator<DTDElementDecl> e(objToStore, objToStore->getMemoryManager());
02170 
02171         serEng<<(unsigned int)e.size();
02172 
02173         while (e.hasMoreElements())
02174         {
02175             DTDElementDecl& data = e.nextElement();
02176             data.serialize(serEng);
02177         }
02178     }
02179 
02180 }
02181 
02182 void XTemplateSerializer::loadObject(NameIdPool<DTDElementDecl>** objToLoad
02183                                    , int                          initSize
02184                                    , int                          initSize2
02185                                    , XSerializeEngine&            serEng)
02186 {
02187     if (serEng.needToLoadObject((void**)objToLoad))
02188     {
02189         if (!*objToLoad)
02190         {
02191             if (initSize < 0)
02192                 initSize = 16;
02193 
02194             *objToLoad = new (serEng.getMemoryManager())
02195                              NameIdPool<DTDElementDecl>(
02196                                                         initSize
02197                                                       , initSize2
02198                                                       , serEng.getMemoryManager()
02199                                                       );
02200         }
02201 
02202         serEng.registerObject(*objToLoad);
02203 
02204         unsigned int itemNumber = 0;
02205         serEng >> itemNumber;
02206 
02207         for (unsigned int itemIndex = 0; itemIndex < itemNumber; itemIndex++)
02208         {
02209             DTDElementDecl*  data = new (serEng.getMemoryManager())
02210                                     DTDElementDecl(serEng.getMemoryManager());
02211             data->serialize(serEng);
02212             (*objToLoad)->put(data);
02213         }
02214     }
02215 }
02216 
02217 void XTemplateSerializer::storeObject(NameIdPool<DTDEntityDecl>* const objToStore
02218                                     , XSerializeEngine&                 serEng)
02219 {
02220     if (serEng.needToStoreObject(objToStore))
02221     {
02222         NameIdPoolEnumerator<DTDEntityDecl> e(objToStore, objToStore->getMemoryManager());
02223 
02224         serEng<<(unsigned int)e.size();
02225 
02226         while (e.hasMoreElements())
02227         {
02228             DTDEntityDecl& data = e.nextElement();
02229             data.serialize(serEng);
02230         }
02231     }
02232 }
02233 
02234 void XTemplateSerializer::loadObject(NameIdPool<DTDEntityDecl>** objToLoad
02235                                    , int                          initSize
02236                                    , int                          initSize2
02237                                    , XSerializeEngine&            serEng)
02238 {
02239     if (serEng.needToLoadObject((void**)objToLoad))
02240     {
02241         if (!*objToLoad)
02242         {
02243             if (initSize < 0)
02244                 initSize = 16;
02245 
02246             *objToLoad = new (serEng.getMemoryManager())
02247                              NameIdPool<DTDEntityDecl>(
02248                                                        initSize
02249                                                      , initSize2
02250                                                      , serEng.getMemoryManager()
02251                                                      );
02252         }
02253 
02254         serEng.registerObject(*objToLoad);
02255 
02256         unsigned int itemNumber = 0;
02257         serEng >> itemNumber;
02258 
02259         for (unsigned int itemIndex = 0; itemIndex < itemNumber; itemIndex++)
02260         {
02261             DTDEntityDecl*  data = new (serEng.getMemoryManager())
02262                                    DTDEntityDecl(serEng.getMemoryManager());
02263             data->serialize(serEng);
02264             (*objToLoad)->put(data);
02265         }
02266     }
02267 }
02268 
02269 void XTemplateSerializer::storeObject(NameIdPool<XMLNotationDecl>* const objToStore
02270                                     , XSerializeEngine&                  serEng)
02271 {
02272     if (serEng.needToStoreObject(objToStore))
02273     {
02274         NameIdPoolEnumerator<XMLNotationDecl> e(objToStore, objToStore->getMemoryManager());
02275 
02276         serEng<<(unsigned int)e.size();
02277 
02278         while (e.hasMoreElements())
02279         {
02280             XMLNotationDecl& data = e.nextElement();
02281             data.serialize(serEng);
02282         }
02283     }
02284 }
02285 
02286 void XTemplateSerializer::loadObject(NameIdPool<XMLNotationDecl>** objToLoad
02287                                    , int                          initSize
02288                                    , int                          initSize2
02289                                    , XSerializeEngine&            serEng)
02290 {
02291 
02292     if (serEng.needToLoadObject((void**)objToLoad))
02293     {
02294         if (!*objToLoad)
02295         {
02296             if (initSize < 0)
02297                 initSize = 16;
02298 
02299             *objToLoad = new (serEng.getMemoryManager())
02300                              NameIdPool<XMLNotationDecl>(
02301                                                          initSize
02302                                                        , initSize2
02303                                                        , serEng.getMemoryManager()
02304                                                        );
02305         }
02306 
02307         serEng.registerObject(*objToLoad);
02308 
02309         unsigned int itemNumber = 0;
02310         serEng >> itemNumber;
02311 
02312         for (unsigned int itemIndex = 0; itemIndex < itemNumber; itemIndex++)
02313         {
02314             XMLNotationDecl*  data = new (serEng.getMemoryManager())
02315                                      XMLNotationDecl(serEng.getMemoryManager());
02316             data->serialize(serEng);
02317             (*objToLoad)->put(data);
02318         }
02319     }
02320 }
02321 
02322 XERCES_CPP_NAMESPACE_END