You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xerces.apache.org by pe...@apache.org on 2003/10/07 21:38:31 UTC

cvs commit: xml-xerces/c/src/xercesc/internal XSerializeEngine.cpp XSerializeEngine.hpp

peiyongz    2003/10/07 12:38:31

  Modified:    c/src/xercesc/internal XSerializeEngine.cpp
                        XSerializeEngine.hpp
  Log:
  API for Template_Class Object Serialization/Deserialization
  
  Revision  Changes    Path
  1.6       +81 -2     xml-xerces/c/src/xercesc/internal/XSerializeEngine.cpp
  
  Index: XSerializeEngine.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/internal/XSerializeEngine.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- XSerializeEngine.cpp	25 Sep 2003 22:22:00 -0000	1.5
  +++ XSerializeEngine.cpp	7 Oct 2003 19:38:31 -0000	1.6
  @@ -57,6 +57,9 @@
   /*
    * $Id$
    * $Log$
  + * Revision 1.6  2003/10/07 19:38:31  peiyongz
  + * API for Template_Class Object Serialization/Deserialization
  + *
    * Revision 1.5  2003/09/25 22:22:00  peiyongz
    * Introduction of readString/writeString
    *
  @@ -94,8 +97,9 @@
   
   static const XSerializeEngine::XSerializedObjectId_t fgNullObjectTag  = 0;           // indicating null ptrs
   static const XSerializeEngine::XSerializedObjectId_t fgNewClassTag    = 0xFFFFFFFF;  // indicating new class
  +static const XSerializeEngine::XSerializedObjectId_t fgTemplateObjTag = 0xFFFFFFFE;  // indicating template object
   static const XSerializeEngine::XSerializedObjectId_t fgClassMask      = 0x80000000;  // indicates class tag
  -static const XSerializeEngine::XSerializedObjectId_t fgMaxObjectCount = 0x3FFFFFFE;  
  +static const XSerializeEngine::XSerializedObjectId_t fgMaxObjectCount = 0x3FFFFFFD;  
   
   static XMLCh value1[16];
   static XMLCh value2[16];
  @@ -985,6 +989,81 @@
                      , XMLExcepts::XSer_Inv_Buffer_Len
                      )
   
  +}
  +
  +// ---------------------------------------------------------------------------
  +//  Template object
  +// ---------------------------------------------------------------------------
  +/***
  + *
  + *  Search the store pool to see if the address has been seen before or not.
  + *
  + *  If yes, write the corresponding object Tag to the internal buffer
  + *  and return true.
  + *
  + *  Otherwise, add the address to the store pool and return false
  + *  to notifiy the client application code to store the template object.
  + *
  + ***/
  +bool XSerializeEngine::needToWriteTemplateObject(void* const  templateObjectToWrite)
  +{
  +    ensureStoring(); //don't ensurePointer here !!!
  +
  +    XSerializedObjectId_t   objIndex = 0;
  +
  +	if (!templateObjectToWrite)  
  +	{
  +		*this << fgNullObjectTag; // null pointer
  +        return false;
  +	}
  +    else if (objIndex = lookupStorePool(templateObjectToWrite))
  +	{
  +        *this << objIndex;         // write an object reference tag
  +        return false;
  +	}
  +	else
  +	{
  +        *this << fgTemplateObjTag;            // write fgTemplateObjTag to denote that actual
  +                                              // template object follows
  +        addStorePool(templateObjectToWrite); // put the address into StorePool
  +        return true;
  +	}
  +
  +}
  +
  +bool XSerializeEngine::needToReadTemplateObject(void**  templateObjectToRead)
  +{
  +    ensureLoading();
  +
  +	XSerializedObjectId_t obTag;
  +
  +    *this >> obTag;
  +  
  +	if (obTag == fgTemplateObjTag)
  +	{
  +        /***
  +         * what follows fgTemplateObjTag is the actual template object
  +         * We need the client application to create a template object
  +         * and register it through registerTemplateObject(), and deserialize
  +         * template object
  +         ***/
  +        return true;
  +	}
  +	else
  +	{
  +        /***
  +         * We hava a reference to an existing template object, get it.
  +         */
  +        *templateObjectToRead = lookupLoadPool(obTag);
  +        return false;
  +   }
  +
  +}
  +
  +void XSerializeEngine::registerTemplateObject(void*  const templateObjectToRegister)
  +{
  +    ensureLoading();
  +    addLoadPool(templateObjectToRegister);
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.4       +45 -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.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- XSerializeEngine.hpp	25 Sep 2003 22:22:00 -0000	1.3
  +++ XSerializeEngine.hpp	7 Oct 2003 19:38:31 -0000	1.4
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.4  2003/10/07 19:38:31  peiyongz
  + * API for Template_Class Object Serialization/Deserialization
  + *
    * Revision 1.3  2003/09/25 22:22:00  peiyongz
    * Introduction of readString/writeString
    *
  @@ -357,6 +360,47 @@
                                      , int&           bufferLen    = defaultBufferLen
                                      , int&           dataLen      = defaultDataLen
                                      , bool           toReadBufLen = false);
  +
  +
  +    /***
  +      *
  +      *  Check if the template object has been stored or not
  +      *
  +      *  Param
  +      *    objectPtr:     the template object pointer
  +      *
  +      *  Return:          true  : the object has NOT been stored yet
  +      *                   false : otherwise
  +      *
  +      ***/
  +           bool           needToWriteTemplateObject(void*       objectToWrite);
  +
  +    /***
  +      *
  +      *  Check if the template object has been loaded or not
  +      *
  +      *  Param
  +      *    objectPtr:     the address of the template object pointer
  +      *
  +      *  Return:          true  : the object has NOT been loaded yet
  +      *                   false : otherwise
  +      *
  +      ***/
  +           bool           needToReadTemplateObject(void**       objectToRead);
  +
  +    /***
  +      *
  +      *  In the case of needToReadTemplateObject() return true, the client
  +      *  application needs to instantiate an expected template object, and
  +      *  register the address to the engine.
  +      *
  +      *  Param
  +      *    objectPtr:     the template object pointer newly instantiated
  +      *
  +      *  Return:  
  +      *
  +      ***/
  +           void           registerTemplateObject(void*          const objectToRegister);
   
       static const bool toReadBufferLen;
   
  
  
  

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