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/14 17:24:23 UTC

cvs commit: xml-xerces/c/src/xercesc/validators/schema/identity IC_Field.cpp IC_Field.hpp IC_Key.cpp IC_Key.hpp IC_KeyRef.cpp IC_KeyRef.hpp IC_Selector.cpp IC_Selector.hpp IC_Unique.cpp IC_Unique.hpp IdentityConstraint.cpp IdentityConstraint.hpp XercesXPath.cpp XercesXPath.hpp

peiyongz    2003/10/14 08:24:23

  Modified:    c/src/xercesc/validators/schema/identity IC_Field.cpp
                        IC_Field.hpp IC_Key.cpp IC_Key.hpp IC_KeyRef.cpp
                        IC_KeyRef.hpp IC_Selector.cpp IC_Selector.hpp
                        IC_Unique.cpp IC_Unique.hpp IdentityConstraint.cpp
                        IdentityConstraint.hpp XercesXPath.cpp
                        XercesXPath.hpp
  Log:
  Implementation of Serialization/Deserialization
  
  Revision  Changes    Path
  1.5       +37 -0     xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.cpp
  
  Index: IC_Field.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.cpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IC_Field.cpp	15 May 2003 18:59:34 -0000	1.4
  +++ IC_Field.cpp	14 Oct 2003 15:24:23 -0000	1.5
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.5  2003/10/14 15:24:23  peiyongz
  + * Implementation of Serialization/Deserialization
  + *
    * Revision 1.4  2003/05/15 18:59:34  knoaman
    * Partial implementation of the configurable memory manager.
    *
  @@ -83,6 +86,8 @@
   #include <xercesc/validators/schema/identity/ValueStore.hpp>
   #include <xercesc/validators/schema/identity/XercesXPath.hpp>
   
  +#include <xercesc/validators/schema/identity/IdentityConstraint.hpp>
  +
   XERCES_CPP_NAMESPACE_BEGIN
   
   // ---------------------------------------------------------------------------
  @@ -153,6 +158,38 @@
                                         MemoryManager* const manager) {
   
       return new (manager) FieldMatcher(fXPath, this, valueStore, manager);
  +}
  +
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(IC_Field)
  +
  +void IC_Field::serialize(XSerializeEngine& serEng)
  +{
  +
  +    if (serEng.isStoring())
  +    {
  +        serEng<<fMayMatch;
  +        serEng<<fXPath;
  +        
  +        IdentityConstraint::storeIC(serEng, fIdentityConstraint);
  +    }
  +    else
  +    {
  +        serEng>>fMayMatch;
  +        serEng>>fXPath;
  +
  +        fIdentityConstraint = IdentityConstraint::loadIC(serEng);
  +    }
  +
  +}
  +
  +IC_Field::IC_Field(MemoryManager* const )
  +:fXPath(0)
  +,fIdentityConstraint(0)
  +{
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.5       +11 -2     xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.hpp
  
  Index: IC_Field.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Field.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IC_Field.hpp	22 May 2003 02:10:52 -0000	1.4
  +++ IC_Field.hpp	14 Oct 2003 15:24:23 -0000	1.5
  @@ -67,6 +67,8 @@
   // ---------------------------------------------------------------------------
   #include <xercesc/validators/schema/identity/XPathMatcher.hpp>
   
  +#include <xercesc/internal/XSerializable.hpp>
  +
   XERCES_CPP_NAMESPACE_BEGIN
   
   // ---------------------------------------------------------------------------
  @@ -75,7 +77,7 @@
   class ValueStore;
   
   
  -class VALIDATORS_EXPORT IC_Field : public XMemory
  +class VALIDATORS_EXPORT IC_Field : public XSerializable, public XMemory
   {
   public:
       // -----------------------------------------------------------------------
  @@ -108,6 +110,13 @@
       // -----------------------------------------------------------------------
       XPathMatcher* createMatcher(ValueStore* const valueStore,
                                   MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(IC_Field)
  +
  +    IC_Field(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
   
   private:
       // -----------------------------------------------------------------------
  
  
  
  1.4       +22 -1     xml-xerces/c/src/xercesc/validators/schema/identity/IC_Key.cpp
  
  Index: IC_Key.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Key.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IC_Key.cpp	15 May 2003 18:59:34 -0000	1.3
  +++ IC_Key.cpp	14 Oct 2003 15:24:23 -0000	1.4
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.4  2003/10/14 15:24:23  peiyongz
  + * Implementation of Serialization/Deserialization
  + *
    * Revision 1.3  2003/05/15 18:59:34  knoaman
    * Partial implementation of the configurable memory manager.
    *
  @@ -83,12 +86,30 @@
   IC_Key::IC_Key(const XMLCh* const identityConstraintName,
                  const XMLCh* const elemName,
   			   MemoryManager* const manager)
  -    : IdentityConstraint(identityConstraintName, elemName, manager)
  +:IdentityConstraint(identityConstraintName, elemName, manager)
   {
   }
   
   
   IC_Key::~IC_Key()
  +{
  +}
  +
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(IC_Key)
  +
  +void IC_Key::serialize(XSerializeEngine& serEng)
  +{
  +    IdentityConstraint::serialize(serEng);
  +
  +    //no data
  +}
  +
  +IC_Key::IC_Key(MemoryManager* const manager)
  +:IdentityConstraint(0, 0, manager)
   {
   }
   
  
  
  
  1.5       +8 -1      xml-xerces/c/src/xercesc/validators/schema/identity/IC_Key.hpp
  
  Index: IC_Key.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Key.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IC_Key.hpp	16 May 2003 21:43:22 -0000	1.4
  +++ IC_Key.hpp	14 Oct 2003 15:24:23 -0000	1.5
  @@ -85,6 +85,13 @@
       // -----------------------------------------------------------------------
       short getType() const;
   
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(IC_Key)
  +
  +    IC_Key(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
   private:
       // -----------------------------------------------------------------------
       //  Unimplemented contstructors and operators
  
  
  
  1.4       +30 -0     xml-xerces/c/src/xercesc/validators/schema/identity/IC_KeyRef.cpp
  
  Index: IC_KeyRef.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_KeyRef.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IC_KeyRef.cpp	15 May 2003 18:59:34 -0000	1.3
  +++ IC_KeyRef.cpp	14 Oct 2003 15:24:23 -0000	1.4
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.4  2003/10/14 15:24:23  peiyongz
  + * Implementation of Serialization/Deserialization
  + *
    * Revision 1.3  2003/05/15 18:59:34  knoaman
    * Partial implementation of the configurable memory manager.
    *
  @@ -91,6 +94,33 @@
   
   
   IC_KeyRef::~IC_KeyRef()
  +{
  +}
  +
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(IC_KeyRef)
  +
  +void IC_KeyRef::serialize(XSerializeEngine& serEng)
  +{
  +    IdentityConstraint::serialize(serEng);
  +
  +    if (serEng.isStoring())
  +    {
  +        IdentityConstraint::storeIC(serEng, fKey);
  +    }
  +    else
  +    {
  +        fKey = IdentityConstraint::loadIC(serEng);
  +    }
  +
  +}
  +
  +IC_KeyRef::IC_KeyRef(MemoryManager* const manager)
  +:IdentityConstraint(0, 0, manager)
  +,fKey(0)
   {
   }
   
  
  
  
  1.5       +8 -1      xml-xerces/c/src/xercesc/validators/schema/identity/IC_KeyRef.hpp
  
  Index: IC_KeyRef.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_KeyRef.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IC_KeyRef.hpp	16 May 2003 21:43:22 -0000	1.4
  +++ IC_KeyRef.hpp	14 Oct 2003 15:24:23 -0000	1.5
  @@ -87,6 +87,13 @@
       short getType() const;
       IdentityConstraint* getKey() const;
   
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(IC_KeyRef)
  +
  +    IC_KeyRef(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
   private:
       // -----------------------------------------------------------------------
       //  Unimplemented contstructors and operators
  
  
  
  1.6       +32 -0     xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.cpp
  
  Index: IC_Selector.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IC_Selector.cpp	15 May 2003 18:59:34 -0000	1.5
  +++ IC_Selector.cpp	14 Oct 2003 15:24:23 -0000	1.6
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.6  2003/10/14 15:24:23  peiyongz
  + * Implementation of Serialization/Deserialization
  + *
    * Revision 1.5  2003/05/15 18:59:34  knoaman
    * Partial implementation of the configurable memory manager.
    *
  @@ -197,6 +200,35 @@
                                            MemoryManager* const manager) {
   
       return new (manager) SelectorMatcher(fXPath, this, fieldActivator, initialDepth, manager);
  +}
  +
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(IC_Selector)
  +
  +void IC_Selector::serialize(XSerializeEngine& serEng)
  +{
  +    if (serEng.isStoring())
  +    {
  +        serEng<<fXPath;
  +        
  +        IdentityConstraint::storeIC(serEng, fIdentityConstraint);
  +    }
  +    else
  +    {
  +        serEng>>fXPath;
  +
  +        fIdentityConstraint = IdentityConstraint::loadIC(serEng);
  +    }
  +
  +}
  +
  +IC_Selector::IC_Selector(MemoryManager* const )
  +:fXPath(0)
  +,fIdentityConstraint(0)
  +{
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.8       +11 -2     xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.hpp
  
  Index: IC_Selector.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Selector.hpp,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- IC_Selector.hpp	3 Jun 2003 18:12:29 -0000	1.7
  +++ IC_Selector.hpp	14 Oct 2003 15:24:23 -0000	1.8
  @@ -67,6 +67,8 @@
   // ---------------------------------------------------------------------------
   #include <xercesc/validators/schema/identity/XPathMatcher.hpp>
   
  +#include <xercesc/internal/XSerializable.hpp>
  +
   XERCES_CPP_NAMESPACE_BEGIN
   
   // ---------------------------------------------------------------------------
  @@ -75,7 +77,7 @@
   class FieldActivator;
   
   
  -class VALIDATORS_EXPORT IC_Selector : public XMemory
  +class VALIDATORS_EXPORT IC_Selector : public XSerializable, public XMemory
   {
   public:
       // -----------------------------------------------------------------------
  @@ -103,6 +105,13 @@
       XPathMatcher* createMatcher(FieldActivator* const fieldActivator,
                                   const int initialDepth,
                                   MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(IC_Selector)
  +
  +    IC_Selector(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
   
   private:
       // -----------------------------------------------------------------------
  
  
  
  1.4       +21 -0     xml-xerces/c/src/xercesc/validators/schema/identity/IC_Unique.cpp
  
  Index: IC_Unique.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Unique.cpp,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- IC_Unique.cpp	15 May 2003 18:59:34 -0000	1.3
  +++ IC_Unique.cpp	14 Oct 2003 15:24:23 -0000	1.4
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.4  2003/10/14 15:24:23  peiyongz
  + * Implementation of Serialization/Deserialization
  + *
    * Revision 1.3  2003/05/15 18:59:34  knoaman
    * Partial implementation of the configurable memory manager.
    *
  @@ -89,6 +92,24 @@
   
   
   IC_Unique::~IC_Unique()
  +{
  +}
  +
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(IC_Unique)
  +
  +void IC_Unique::serialize(XSerializeEngine& serEng)
  +{
  +    IdentityConstraint::serialize(serEng);
  +
  +    //no data
  +}
  +
  +IC_Unique::IC_Unique(MemoryManager* const manager)
  +:IdentityConstraint(0, 0, manager)
   {
   }
   
  
  
  
  1.5       +8 -1      xml-xerces/c/src/xercesc/validators/schema/identity/IC_Unique.hpp
  
  Index: IC_Unique.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IC_Unique.hpp,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- IC_Unique.hpp	16 May 2003 21:43:22 -0000	1.4
  +++ IC_Unique.hpp	14 Oct 2003 15:24:23 -0000	1.5
  @@ -89,6 +89,13 @@
       // -----------------------------------------------------------------------
       short getType() const;
   
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(IC_Unique)
  +
  +    IC_Unique(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
   private:
       // -----------------------------------------------------------------------
       //  Unimplemented contstructors and operators
  
  
  
  1.6       +127 -0    xml-xerces/c/src/xercesc/validators/schema/identity/IdentityConstraint.cpp
  
  Index: IdentityConstraint.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IdentityConstraint.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IdentityConstraint.cpp	1 Oct 2003 16:32:42 -0000	1.5
  +++ IdentityConstraint.cpp	14 Oct 2003 15:24:23 -0000	1.6
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.6  2003/10/14 15:24:23  peiyongz
  + * Implementation of Serialization/Deserialization
  + *
    * Revision 1.5  2003/10/01 16:32:42  neilg
    * improve handling of out of memory conditions, bug #23415.  Thanks to David Cargill.
    *
  @@ -88,6 +91,13 @@
   #include <xercesc/util/XMLString.hpp>
   #include <xercesc/util/OutOfMemoryException.hpp>
   
  +//since we need to dynamically created each and every derivatives 
  +//during deserialization by XSerializeEngine>>Derivative, we got
  +//to include all hpp
  +#include <xercesc/validators/schema/identity/IC_Unique.hpp>
  +#include <xercesc/validators/schema/identity/IC_Key.hpp>
  +#include <xercesc/validators/schema/identity/IC_KeyRef.hpp>
  +
   XERCES_CPP_NAMESPACE_BEGIN
   
   // ---------------------------------------------------------------------------
  @@ -177,6 +187,123 @@
       fMemoryManager->deallocate(fElemName);//delete [] fElemName;
       delete fFields;
       delete fSelector;
  +}
  +
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_NOCREATE(IdentityConstraint)
  +
  +void IdentityConstraint::serialize(XSerializeEngine& serEng)
  +{
  +
  +    if (serEng.isStoring())
  +    {
  +        serEng.writeString(fIdentityConstraintName);
  +        serEng.writeString(fElemName);
  +
  +        serEng<<fSelector;
  +
  +        /***
  +         *
  +         * Serialize RefVectorOf<IC_Field>* fFields;
  +         *
  +         ***/
  +        if (serEng.needToWriteTemplateObject(fFields))
  +        {
  +            int vectorLength = fFields->size();
  +            serEng<<vectorLength;
  +
  +            for ( int i = 0 ; i < vectorLength; i++)
  +            {
  +                serEng<<fFields->elementAt(i);
  +            }
  +        }
  +    
  +    }
  +    else
  +    {
  +
  +        serEng.readString(fIdentityConstraintName);
  +        serEng.readString(fElemName);
  +
  +        serEng>>fSelector;
  +
  +        /***
  +         *
  +         * Deserialize RefVectorOf<IC_Field>* fFields;
  +         *
  +         ***/
  +        if (serEng.needToReadTemplateObject((void**)&fFields))
  +        {
  +            if (!fFields)
  +            {
  +                fFields = new (fMemoryManager) RefVectorOf<IC_Field>(8, true, fMemoryManager);
  +            }
  +
  +            serEng.registerTemplateObject(fFields);
  +
  +            int vectorLength = 0;
  +            serEng>>vectorLength;
  +            for ( int i = 0 ; i < vectorLength; i++)
  +            {     
  +                IC_Field* data;
  +                serEng>>data;
  +                fFields->addElement(data);
  +            }
  +        }
  +
  +    }
  +
  +}  
  +
  +void IdentityConstraint::storeIC(XSerializeEngine&         serEng
  +                               , IdentityConstraint* const ic)
  +{
  +    if (ic)
  +    {
  +        serEng<<(int) ic->getType();
  +        serEng<<ic;
  +    }
  +    else
  +    {
  +        serEng<<(int) UNKNOWN;
  +    }
  +
  +}
  +
  +IdentityConstraint* IdentityConstraint::loadIC(XSerializeEngine& serEng)
  +{
  +
  +    int type;
  +    serEng>>type;
  +
  +    switch((ICType)type)
  +    {
  +    case UNIQUE: 
  +        IC_Unique* ic_unique;
  +        serEng>>ic_unique;
  +        return ic_unique;
  +        break;
  +    case KEY:
  +        IC_Key* ic_key;
  +        serEng>>ic_key;
  +        return ic_key;
  +        break;
  +    case KEYREF: 
  +        IC_KeyRef* ic_keyref;
  +        serEng>>ic_keyref;
  +        return ic_keyref;
  +        break;
  +    case UNKNOWN:
  +        return 0;
  +        break;
  +    default: //we treat this same as UnKnown
  +        return 0;
  +        break;
  +    }
  +
   }
   
   XERCES_CPP_NAMESPACE_END
  
  
  
  1.6       +17 -4     xml-xerces/c/src/xercesc/validators/schema/identity/IdentityConstraint.hpp
  
  Index: IdentityConstraint.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/IdentityConstraint.hpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- IdentityConstraint.hpp	18 May 2003 14:02:09 -0000	1.5
  +++ IdentityConstraint.hpp	14 Oct 2003 15:24:23 -0000	1.6
  @@ -72,6 +72,8 @@
   #include <xercesc/util/RefVectorOf.hpp>
   #include <xercesc/validators/schema/identity/IC_Field.hpp>
   
  +#include <xercesc/internal/XSerializable.hpp>
  +
   XERCES_CPP_NAMESPACE_BEGIN
   
   // ---------------------------------------------------------------------------
  @@ -79,16 +81,17 @@
   // ---------------------------------------------------------------------------
   class IC_Selector;
   
  -class VALIDATORS_EXPORT IdentityConstraint : public XMemory
  +class VALIDATORS_EXPORT IdentityConstraint : public XSerializable, public XMemory
   {
   public:
       // -----------------------------------------------------------------------
       //  Constants
       // -----------------------------------------------------------------------
  -    enum {
  +    enum ICType {
           UNIQUE = 0,
           KEY = 1,
  -        KEYREF = 2
  +        KEYREF = 2,
  +        UNKNOWN
       };
   
       // -----------------------------------------------------------------------
  @@ -122,6 +125,16 @@
       void addField(IC_Field* const field);
       const IC_Field* getFieldAt(const unsigned int index) const;
       IC_Field* getFieldAt(const unsigned int index);
  +
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(IdentityConstraint)
  +
  +	static void                storeIC(XSerializeEngine&         serEng
  +                                     , IdentityConstraint* const ic);
  +
  +	static IdentityConstraint* loadIC(XSerializeEngine& serEng);
   
   protected:
       // -----------------------------------------------------------------------
  
  
  
  1.10      +187 -0    xml-xerces/c/src/xercesc/validators/schema/identity/XercesXPath.cpp
  
  Index: XercesXPath.cpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/XercesXPath.cpp,v
  retrieving revision 1.9
  retrieving revision 1.10
  diff -u -r1.9 -r1.10
  --- XercesXPath.cpp	1 Oct 2003 16:32:42 -0000	1.9
  +++ XercesXPath.cpp	14 Oct 2003 15:24:23 -0000	1.10
  @@ -56,6 +56,9 @@
   
   /*
    * $Log$
  + * Revision 1.10  2003/10/14 15:24:23  peiyongz
  + * Implementation of Serialization/Deserialization
  + *
    * Revision 1.9  2003/10/01 16:32:42  neilg
    * improve handling of out of memory conditions, bug #23415.  Thanks to David Cargill.
    *
  @@ -159,6 +162,33 @@
   {
   }
   
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(XercesNodeTest)
  +
  +void XercesNodeTest::serialize(XSerializeEngine& serEng)
  +{
  +
  +    if (serEng.isStoring())
  +    {
  +        serEng<<fType;
  +        serEng<<fName;
  +    }
  +    else
  +    {
  +        serEng>>fType;
  +        serEng>>fName;
  +    }
  +}
  +
  +XercesNodeTest::XercesNodeTest(MemoryManager* const manager)
  +:fType(UNKNOWN)
  +,fName(0)
  +{
  +}
  +
   // ---------------------------------------------------------------------------
   //  XercesNodeTest: Operators
   // ---------------------------------------------------------------------------
  @@ -240,6 +270,32 @@
       return !operator==(other);
   }
   
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(XercesStep)
  +
  +void XercesStep::serialize(XSerializeEngine& serEng)
  +{
  +    if (serEng.isStoring())
  +    {
  +        serEng<<fAxisType;
  +        serEng<<fNodeTest;
  +    }
  +    else
  +    {
  +        serEng>>fAxisType;
  +        serEng>>fNodeTest;
  +    }
  +}
  +
  +XercesStep::XercesStep(MemoryManager* const manager)
  +:fAxisType(UNKNOWN)
  +,fNodeTest(0)
  +{
  +}
  +
   // ---------------------------------------------------------------------------
   //  XercesLocationPath: Constructors and Destructor
   // ---------------------------------------------------------------------------
  @@ -271,6 +327,66 @@
       return !operator==(other);
   }
   
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(XercesLocationPath)
  +
  +void XercesLocationPath::serialize(XSerializeEngine& serEng)
  +{
  +    if (serEng.isStoring())
  +    {
  +        /***
  +         *
  +         * Serialize RefVectorOf<XercesStep>* fSteps;
  +         *
  +         ***/
  +        if (serEng.needToWriteTemplateObject(fSteps))
  +        {
  +            int vectorLength = fSteps->size();
  +            serEng<<vectorLength;
  +
  +            for ( int i = 0 ; i < vectorLength; i++)
  +            {
  +                serEng<<fSteps->elementAt(i);
  +            }
  +        }
  +
  +    }
  +    else
  +    {
  +        /***
  +         *
  +         * Deserialize RefVectorOf<XercesStep>* fSteps;
  +         *
  +         ***/
  +        if (serEng.needToReadTemplateObject((void**)&fSteps))
  +        {
  +            if (!fSteps)
  +            {
  +                fSteps = new (serEng.getMemoryManager()) RefVectorOf<XercesStep>(8, true, serEng.getMemoryManager());
  +            }
  +
  +            serEng.registerTemplateObject(fSteps);
  +
  +            int vectorLength = 0;
  +            serEng>>vectorLength;
  +            for ( int i = 0 ; i < vectorLength; i++)
  +            {            
  +                XercesStep* data;
  +                serEng>>data;
  +                fSteps->addElement(data);
  +            }
  +        }
  +    }
  +}
  +
  +XercesLocationPath::XercesLocationPath(MemoryManager* const manager)
  +:fSteps(0)
  +{
  +}
  +
   // ---------------------------------------------------------------------------
   //  XercesPath: Constructors and Destructor
   // ---------------------------------------------------------------------------
  @@ -624,6 +740,77 @@
   
       fLocationPaths->addElement(new (fMemoryManager) XercesLocationPath(stepsVector));
       janSteps.orphan();
  +}
  +
  +/***
  + * Support for Serialization/De-serialization
  + ***/
  +
  +IMPL_XSERIALIZABLE_TOCREATE(XercesXPath)
  +
  +void XercesXPath::serialize(XSerializeEngine& serEng)
  +{
  +
  +    if (serEng.isStoring())
  +    {
  +        serEng<<fEmptyNamespaceId;
  +        serEng.writeString(fExpression);
  +
  +        /***
  +         *
  +         * Serialize RefVectorOf<XercesLocationPath>* fLocationPaths;
  +         *
  +         ***/
  +        if (serEng.needToWriteTemplateObject(fLocationPaths))
  +        {
  +            int vectorLength = fLocationPaths->size();
  +            serEng<<vectorLength;
  +
  +            for ( int i = 0 ; i < vectorLength; i++)
  +            {
  +                serEng<<fLocationPaths->elementAt(i);
  +            }
  +        }
  +
  +    }
  +    else
  +    {
  +        serEng>>fEmptyNamespaceId;
  +        serEng.readString(fExpression);
  +
  +        /***
  +         *
  +         * Deserialize RefVectorOf<XercesLocationPath>* fLocationPaths;
  +         *
  +         ***/
  +        if (serEng.needToReadTemplateObject((void**)&fLocationPaths))
  +        {
  +            if (!fLocationPaths)
  +            {
  +                fLocationPaths = new (fMemoryManager) RefVectorOf<XercesLocationPath>(8, true, fMemoryManager);
  +            }
  +
  +            serEng.registerTemplateObject(fLocationPaths);
  +
  +            int vectorLength = 0;
  +            serEng>>vectorLength;
  +            for ( int i = 0 ; i < vectorLength; i++)
  +            {            
  +                XercesLocationPath* data;
  +                serEng>>data;
  +                fLocationPaths->addElement(data);
  +            }
  +        }
  +
  +    }
  +}
  +
  +XercesXPath::XercesXPath(MemoryManager* const manager)
  +:fEmptyNamespaceId(0)
  +,fExpression(0)
  +,fLocationPaths(0)
  +,fMemoryManager(manager)
  +{
   }
   
   // ---------------------------------------------------------------------------
  
  
  
  1.7       +39 -7     xml-xerces/c/src/xercesc/validators/schema/identity/XercesXPath.hpp
  
  Index: XercesXPath.hpp
  ===================================================================
  RCS file: /home/cvs/xml-xerces/c/src/xercesc/validators/schema/identity/XercesXPath.hpp,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- XercesXPath.hpp	22 May 2003 02:10:52 -0000	1.6
  +++ XercesXPath.hpp	14 Oct 2003 15:24:23 -0000	1.7
  @@ -69,6 +69,8 @@
   #include <xercesc/util/RefVectorOf.hpp>
   #include <xercesc/util/ValueVectorOf.hpp>
   
  +#include <xercesc/internal/XSerializable.hpp>
  +
   XERCES_CPP_NAMESPACE_BEGIN
   
   // ---------------------------------------------------------------------------
  @@ -78,7 +80,7 @@
   class NamespaceScope;
   
   
  -class VALIDATORS_EXPORT XercesNodeTest : public XMemory
  +class VALIDATORS_EXPORT XercesNodeTest : public XSerializable, public XMemory
   {
   public:
       // -----------------------------------------------------------------------
  @@ -88,7 +90,8 @@
           QNAME = 1,
           WILDCARD = 2,
           NODE = 3,
  -        NAMESPACE= 4
  +        NAMESPACE= 4,
  +        UNKNOWN
       };
   
       // -----------------------------------------------------------------------
  @@ -115,6 +118,13 @@
       short getType() const { return fType; }
       QName* getName() const { return fName; }
   
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(XercesNodeTest)
  +
  +    XercesNodeTest(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
   private:
       // -----------------------------------------------------------------------
       //  Data members
  @@ -127,7 +137,7 @@
   /**
     * A location path step comprised of an axis and node test.
     */
  -class VALIDATORS_EXPORT XercesStep : public XMemory
  +class VALIDATORS_EXPORT XercesStep : public XSerializable, public XMemory
   {
   public:
       // -----------------------------------------------------------------------
  @@ -137,7 +147,8 @@
           CHILD = 1,
           ATTRIBUTE = 2,
           SELF = 3,
  -        DESCENDANT = 4
  +        DESCENDANT = 4,
  +        UNKNOWN
       };
   
       // -----------------------------------------------------------------------
  @@ -160,6 +171,13 @@
       unsigned short getAxisType() const { return fAxisType; }
       XercesNodeTest* getNodeTest() const { return fNodeTest; }
   
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(XercesStep)
  +
  +    XercesStep(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
   private:
       // -----------------------------------------------------------------------
       //  Data members
  @@ -172,7 +190,7 @@
   /**
     * A location path representation for an XPath expression.
     */
  -class VALIDATORS_EXPORT XercesLocationPath : public XMemory
  +class VALIDATORS_EXPORT XercesLocationPath : public XSerializable, public XMemory
   {
   public:
       // -----------------------------------------------------------------------
  @@ -194,6 +212,13 @@
       void addStep(XercesStep* const aStep);
       XercesStep* getStep(const unsigned int index) const;
   
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(XercesLocationPath)
  +
  +    XercesLocationPath(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
  +
   private:
       // -----------------------------------------------------------------------
       //  Unimplemented contstructors and operators
  @@ -208,7 +233,7 @@
   };
   
   
  -class VALIDATORS_EXPORT XercesXPath : public XMemory
  +class VALIDATORS_EXPORT XercesXPath : public XSerializable, public XMemory
   {
   public:
       // -----------------------------------------------------------------------
  @@ -292,6 +317,13 @@
       //  Constructors/Destructor
       // -----------------------------------------------------------------------
       RefVectorOf<XercesLocationPath>* getLocationPaths() const;
  +
  +    /***
  +     * Support for Serialization/De-serialization
  +     ***/
  +    DECL_XSERIALIZABLE(XercesXPath)
  +
  +    XercesXPath(MemoryManager* const manager = XMLPlatformUtils::fgMemoryManager);
   
   private:
       // -----------------------------------------------------------------------
  
  
  

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