knoaman     2003/11/11 14:48:13

  Modified:    c/src/xercesc/framework/psvi XSAnnotation.cpp
                        XSAnnotation.hpp
               c/src/xercesc/internal XSerializeEngine.hpp
                        XTemplateSerializer.cpp XTemplateSerializer.hpp
               c/src/xercesc/validators/schema SchemaGrammar.cpp
  Log:
  Serialization of XSAnnotation.
  
  Revision  Changes    Path
  1.3       +38 -0     xml-xerces/c/src/xercesc/framework/psvi/XSAnnotation.cpp
  
  Index: XSAnnotation.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAnnotation.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSAnnotation.cpp  6 Nov 2003 19:28:11 -0000       1.2
  +++ XSAnnotation.cpp  11 Nov 2003 22:48:13 -0000      1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.3  2003/11/11 22:48:13  knoaman
  + * Serialization of XSAnnotation.
  + *
    * Revision 1.2  2003/11/06 19:28:11  knoaman
    * PSVI support for annotations.
    *
  @@ -77,6 +80,13 @@
   {
   }
   
  +XSAnnotation::XSAnnotation(MemoryManager * const manager):
  +    XSObject(XSConstants::ANNOTATION, manager)
  +    , fContents(0)
  +    , fNext(0)
  +{
  +}
  +
   XSAnnotation::~XSAnnotation()
   {
       fMemoryManager->deallocate(fContents);
  @@ -117,7 +127,35 @@
           fNext = nextAnnotation;
   }
   
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(XSAnnotation)
   
  +void XSAnnotation::serialize(XSerializeEngine& serEng)
  +{
  +    /***
  +     * Since we are pretty sure that fIdMap and fHashTable is 
  +     * not shared by any other object, therefore there is no owned/referenced
  +     * issue. Thus we can serialize the raw data only, rather than serializing 
  +     * both fIdMap and fHashTable.
  +     *
  +     * And we can rebuild the fIdMap and fHashTable out of the raw data during
  +     * deserialization.
  +     *
  +    ***/
  +    if (serEng.isStoring())
  +    {
  +        serEng.writeString(fContents);
  +        serEng<<fNext;
  +    }
  +    else
  +    {
  +        serEng.readString(fContents);
  +        serEng>>fNext;
  +    }
  +}
   
   XERCES_CPP_NAMESPACE_END
   
  
  
  
  1.3       +12 -1     xml-xerces/c/src/xercesc/framework/psvi/XSAnnotation.hpp
  
  Index: XSAnnotation.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/framework/psvi/XSAnnotation.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XSAnnotation.hpp  6 Nov 2003 19:28:11 -0000       1.2
  +++ XSAnnotation.hpp  11 Nov 2003 22:48:13 -0000      1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.3  2003/11/11 22:48:13  knoaman
  + * Serialization of XSAnnotation.
  + *
    * Revision 1.2  2003/11/06 19:28:11  knoaman
    * PSVI support for annotations.
    *
  @@ -68,6 +71,7 @@
   #define XSANNOTATION_HPP
   
   #include <xercesc/framework/psvi/XSObject.hpp>
  +#include <xercesc/internal/XSerializable.hpp>
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -79,7 +83,7 @@
    */
   
   
  -class XMLPARSER_EXPORT XSAnnotation : public XSObject
  +class XMLPARSER_EXPORT XSAnnotation : public XSerializable, public XSObject
   {
   public:
   
  @@ -159,6 +163,13 @@
       void setNext(XSAnnotation* const nextAnnotation);
   
       //@}
  +
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(XSAnnotation)
  +    XSAnnotation(MemoryManager* const manager);
  +
   private:
   
       // -----------------------------------------------------------------------
  
  
  
  1.8       +9 -1      xml-xerces/c/src/xercesc/internal/XSerializeEngine.hpp
  
  Index: XSerializeEngine.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XSerializeEngine.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XSerializeEngine.hpp      17 Oct 2003 21:09:03 -0000      1.7
  +++ XSerializeEngine.hpp      11 Nov 2003 22:48:13 -0000      1.8
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.8  2003/11/11 22:48:13  knoaman
  + * Serialization of XSAnnotation.
  + *
    * Revision 1.7  2003/10/17 21:09:03  peiyongz
    * renaming methods
    *
  @@ -533,6 +536,11 @@
   
       inline void            Assert(bool  toEval
                                   , const XMLExcepts::Codes toThrow)  const;
  +
  +    // Make XTemplateSerializer friend of XSerializeEngine so that
  +    // we can call lookupStorePool and lookupLoadPool in the case of
  +    // annotations.
  +    friend class XTemplateSerializer;
   
       // 
-------------------------------------------------------------------------------
       //  data
  
  
  
  1.5       +82 -1     xml-xerces/c/src/xercesc/internal/XTemplateSerializer.cpp
  
  Index: XTemplateSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XTemplateSerializer.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- XTemplateSerializer.cpp   3 Nov 2003 22:01:27 -0000       1.4
  +++ XTemplateSerializer.cpp   11 Nov 2003 22:48:13 -0000      1.5
  @@ -57,6 +57,9 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.5  2003/11/11 22:48:13  knoaman
  + * Serialization of XSAnnotation.
  + *
    * Revision 1.4  2003/11/03 22:01:27  peiyongz
    * Store/Load keys separately from SchemaElementDecl
    *
  @@ -79,6 +82,7 @@
   #include <xercesc/internal/XSerializeEngine.hpp>
   #include <xercesc/internal/XTemplateSerializer.hpp>
   #include <xercesc/validators/common/Grammar.hpp>
  +#include <xercesc/util/HashPtr.hpp>
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -764,6 +768,7 @@
    *   XMLRefInfo
    *   DatatypeValidator
    *   Grammar
  + *   XSAnnotation
    *
    ***********************************************************/
   void XTemplateSerializer::storeObject(RefHashTableOf<KVStringPair>* const objToStore
  @@ -1381,6 +1386,82 @@
               data = Grammar::loadGrammar(serEng);
   
               (*objToLoad)->put((void*)key, data);
  +        }
  +    }
  +}
  +
  +
  +void XTemplateSerializer::storeObject(RefHashTableOf<XSAnnotation>* const objToStore
  +                                    , XSerializeEngine&              serEng)
  +{
  +
  +    if (serEng.needToStoreObject(objToStore))
  +    {
  +        RefHashTableOfEnumerator<XSAnnotation> e(objToStore);
  +        ValueVectorOf<XSerializeEngine::XSerializedObjectId_t> ids(16, 
serEng.getMemoryManager());
  +        ValueVectorOf<void*> keys(16, serEng.getMemoryManager());
  +
  +        while (e.hasMoreElements())
  +        {
  +            void* key = e.nextElementKey();
  +            XSerializeEngine::XSerializedObjectId_t keyId = 
serEng.lookupStorePool(key);
  +
  +            if (keyId)
  +            {
  +                ids.addElement(keyId);
  +                keys.addElement(key);
  +            }
  +        }
  +
  +        int itemNumber = ids.size();
  +        serEng<<itemNumber;
  +
  +        for (int i=0; i<itemNumber; i++)
  +        {
  +            XSerializeEngine::XSerializedObjectId_t keyId = ids.elementAt(i);
  +            XSAnnotation* data = objToStore->get(keys.elementAt(i));
  +            serEng<<keyId;
  +            serEng<<data;
  +        }
  +    }
  +}
  +
  +void XTemplateSerializer::loadObject(RefHashTableOf<XSAnnotation>** objToLoad
  +                                   , int                            initSize
  +                                   , bool                           toAdopt
  +                                   , XSerializeEngine&              serEng)
  +{
  +    if (serEng.needToLoadObject((void**)objToLoad))
  +    {
  +        if (!*objToLoad)
  +        {
  +            if (initSize < 0)
  +                initSize = 29;
  +
  +            *objToLoad = new (serEng.getMemoryManager())
  +                RefHashTableOf<XSAnnotation>(
  +                    initSize
  +                    , toAdopt
  +                    , new (serEng.getMemoryManager()) HashPtr()
  +                    , serEng.getMemoryManager()
  +                );
  +        }
  +
  +        serEng.registerObject(*objToLoad);
  +
  +        int itemNumber = 0;
  +        serEng>>itemNumber;
  +
  +        for (int itemIndex = 0; itemIndex < itemNumber; itemIndex++)
  +        {
  +            XSerializeEngine::XSerializedObjectId_t keyId = 0;
  +            serEng>>keyId;
  +
  +            void* key = serEng.lookupLoadPool(keyId);
  +            XSAnnotation*  data;
  +            serEng>>data;
  +
  +            (*objToLoad)->put(key, data);
           }
       }
   }
  
  
  
  1.3       +14 -1     xml-xerces/c/src/xercesc/internal/XTemplateSerializer.hpp
  
  Index: XTemplateSerializer.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XTemplateSerializer.hpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- XTemplateSerializer.hpp   29 Oct 2003 16:16:08 -0000      1.2
  +++ XTemplateSerializer.hpp   11 Nov 2003 22:48:13 -0000      1.3
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.3  2003/11/11 22:48:13  knoaman
  + * Serialization of XSAnnotation.
  + *
    * Revision 1.2  2003/10/29 16:16:08  peiyongz
    * GrammarPool' serialization/deserialization support
    *
  @@ -92,6 +95,7 @@
   #include <xercesc/validators/schema/identity/IC_Field.hpp>
   #include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
   #include <xercesc/validators/schema/identity/XercesXPath.hpp>
  +#include <xercesc/framework/psvi/XSAnnotation.hpp>
   
   XERCES_CPP_NAMESPACE_BEGIN
   
  @@ -239,6 +243,7 @@
        *   XMLRefInfo
        *   DatatypeValidator
        *   Grammar
  +     *   XSAnnotation
        *
        ***********************************************************/
       static void           storeObject(RefHashTableOf<KVStringPair>* const 
tempObjToWrite
  @@ -309,6 +314,14 @@
                                       , XSerializeEngine&              serEng);
   
       static void           loadObject(RefHashTableOf<Grammar>**       tempObjToRead
  +                                   , int                             initSize
  +                                   , bool                            toAdopt
  +                                   , XSerializeEngine&               serEng);
  +
  +    static void           storeObject(RefHashTableOf<XSAnnotation>* const 
tempObjToWrite
  +                                    , XSerializeEngine&                   serEng);
  +
  +    static void           loadObject(RefHashTableOf<XSAnnotation>**  tempObjToRead
                                      , int                             initSize
                                      , bool                            toAdopt
                                      , XSerializeEngine&               serEng);
  
  
  
  1.16      +14 -1     xml-xerces/c/src/xercesc/validators/schema/SchemaGrammar.cpp
  
  Index: SchemaGrammar.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/SchemaGrammar.cpp,v
  retrieving revision 1.15
  retrieving revision 1.16
  diff -u -r1.15 -r1.16
  --- SchemaGrammar.cpp 6 Nov 2003 21:52:17 -0000       1.15
  +++ SchemaGrammar.cpp 11 Nov 2003 22:48:13 -0000      1.16
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.16  2003/11/11 22:48:13  knoaman
  + * Serialization of XSAnnotation.
  + *
    * Revision 1.15  2003/11/06 21:52:17  neilg
    * fix typo
    *
  @@ -419,6 +422,11 @@
            ***/
           XTemplateSerializer::storeObject(fValidSubstitutionGroups, serEng);
   
  +        /***
  +         * Serialize RefHashTableOf<XSAnnotation>*       fAnnotations;
  +         ***/
  +        XTemplateSerializer::storeObject(fAnnotations, serEng);
  +
           serEng.writeString(fTargetNamespace);
           serEng<<fValidated;
           serEng<<fGramDesc;
  @@ -466,6 +474,11 @@
            * Deserialize RefHash2KeysTableOf<ElemVector>*       
fValidSubstitutionGroups;
            ***/
           XTemplateSerializer::loadObject(&fValidSubstitutionGroups, 29, true, 
serEng);
  +
  +        /***
  +         * Deserialize RefHashTableOf<XSAnnotation>*       fAnnotations;
  +         ***/
  +        XTemplateSerializer::loadObject(&fAnnotations, 29, true, serEng);
   
           serEng.readString(fTargetNamespace);
           serEng>>fValidated;
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to