susantha    2003/07/16 07:16:15

  Modified:    c/src/common Param.h Param.cpp ISoapSerializer.h
                        AccessBean.h AccessBean.cpp
  Log:
  changes done for,
  1. minimizing duplicate code linking with webservices
  2. processing multidimensional arrays support for soap 1.1
  
  Revision  Changes    Path
  1.5       +3 -4      xml-axis/c/src/common/Param.h
  
  Index: Param.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/common/Param.h,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- Param.h   11 Jul 2003 07:25:18 -0000      1.4
  +++ Param.h   16 Jul 2003 14:15:54 -0000      1.5
  @@ -75,12 +75,12 @@
   
   #include <string>
   #include "../soap/TypeMapping.h"
  +#include "ISoapSerializer.h"
   
   using namespace std;
   
   class AccessBean;
   class ArrayBean;
  -class SoapSerializer;
   
   class Param  
   {
  @@ -109,7 +109,7 @@
        string m_sName; //Name of the parameter
        XSDTYPE m_Type; //Type of the parameter
   
  -     static string m_sSZ; //Used for serialization
  +//   static string m_sSZ; //Used for serialization
        static char m_Buf[64]; //Used for conversions using sprintf
   
   private:
  @@ -119,8 +119,7 @@
   public: //Conversion functions
        int SetValue(string& sValue);
        XSDTYPE GetType() const;        
  -     int serialize(string& sSerialized, SoapSerializer& pSZ);
  -     int serialize(string& sSerialized);
  +     int serialize(ISoapSerializer& pSZ);
   
        //Following functions are used by wrapper class methods making sure of the 
valid type.
        int GetInt();
  
  
  
  1.6       +44 -46    xml-axis/c/src/common/Param.cpp
  
  Index: Param.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/common/Param.cpp,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- Param.cpp 15 Jul 2003 06:49:41 -0000      1.5
  +++ Param.cpp 16 Jul 2003 14:15:54 -0000      1.6
  @@ -67,14 +67,13 @@
   
   #include "Param.h"
   #include "AccessBean.h"
  -#include "../common/AxisException.h"
   #include "BasicTypeSerializer.h"
   #include <stdlib.h>
   
   //////////////////////////////////////////////////////////////////////
   // Construction/Destruction
   //////////////////////////////////////////////////////////////////////
  -string Param::m_sSZ = "";
  +//string Param::m_sSZ = "";
   //string ArrayBean::m_sSZ = "";
   char Param::m_Buf[64];
   
  @@ -94,8 +93,8 @@
                m_Value.a = new ArrayBean();
                m_Value.a->m_TypeName = param.m_Value.a->m_TypeName;
                m_Value.a->m_URI = param.m_Value.a->m_URI;
  -             m_Value.a->t = param.m_Value.a->t;
  -             m_Value.a->s = param.m_Value.a->s;
  +             m_Value.a->m_type = param.m_Value.a->m_type;
  +             m_Value.a->m_size = param.m_Value.a->m_size;
                m_Value.a->m_ItemName = param.m_Value.a->m_ItemName;
                //copy constructor is not intended to use to copy the array in
                //union v
  @@ -161,7 +160,7 @@
        }
        else 
        {
  -             throw new AxisException(SF_PARATYPEMISMATCH); 
  +             //exception
        }
        return m_sValue;
   }
  @@ -175,7 +174,7 @@
        }
        else 
        {
  -             throw new AxisException(SF_PARATYPEMISMATCH); 
  +             //exception
        }
        return m_sValue;
   }
  @@ -189,7 +188,7 @@
        }
        else 
        {
  -             throw new AxisException(SF_PARATYPEMISMATCH); 
  +             //exception
        }
        return m_sValue;
   }
  @@ -208,7 +207,7 @@
        }
        else 
        {
  -    throw new AxisException(SF_PARATYPEMISMATCH); 
  +             //exception
        }
        return m_Value.n;
   }
  @@ -223,7 +222,7 @@
        }
        else
        {
  -             throw new AxisException(SF_PARATYPEMISMATCH); 
  +             //exception
        }
        return m_Value.f;
   }
  @@ -233,83 +232,83 @@
        return m_Type;
   }
   
  -int Param::serialize(string& sSerialized, SoapSerializer& pSZ)
  -{
  -     return SUCCESS;
  -}
  -
  -int Param::serialize(string& sSerialized)
  +int Param::serialize(ISoapSerializer& pSZ)
   {
  +     string ATprefix;
        switch (m_Type){
        case XSD_INT:
  -             m_sSZ = BasicTypeSerializer::serialize(m_sName, m_Value.n);
  +             pSZ << BasicTypeSerializer::serialize(m_sName, m_Value.n).c_str();
                break;
        case XSD_FLOAT:
  -             m_sSZ = BasicTypeSerializer::serialize(m_sName, m_Value.f);
  +             pSZ << BasicTypeSerializer::serialize(m_sName, m_Value.f).c_str();
                break;
        case XSD_STRING:
  -             m_sSZ = BasicTypeSerializer::serialize(m_sName, m_sValue);
  +             pSZ << BasicTypeSerializer::serialize(m_sName, m_sValue).c_str();
                break;
        case XSD_HEXBINARY:
  -             m_sSZ = BasicTypeSerializer::serialize(m_sName, m_sValue, 
XSD_HEXBINARY);
  +             pSZ << BasicTypeSerializer::serialize(m_sName, m_sValue, 
XSD_HEXBINARY).c_str();
                break;
        case XSD_BASE64BINARY:
  -             m_sSZ = BasicTypeSerializer::serialize(m_sName, m_sValue, 
XSD_BASE64BINARY);
  +             pSZ << BasicTypeSerializer::serialize(m_sName, m_sValue, 
XSD_BASE64BINARY).c_str();
                break;
        case XSD_ARRAY:
  -             //m_sSZ = "<abc:ArrayOfPhoneNumbers 
xmlns:abc="http://example.org/2001/06/numbers";
  +             //pSZ << "<abc:ArrayOfPhoneNumbers 
xmlns:abc="http://example.org/2001/06/numbers";
                //                              
xmlns:enc="http://www.w3.org/2001/06/soap-encoding"; 
           //              enc:arrayType="abc:phoneNumberType[2]" >";
                if (!m_Value.a) return FAIL; //error condition
  -             m_sSZ = "<";
  +             pSZ << "<";
                if (!m_strPrefix.empty())
                {
  -                     m_sSZ += m_strPrefix + ":" + m_sName + " xmlns:" + m_strPrefix 
+ "=\"" + m_strUri + "\"";
  +                     pSZ << m_strPrefix.c_str() << ":" << m_sName.c_str() << " 
xmlns:" << m_strPrefix.c_str() << "=\"" << m_strUri.c_str() << "\"";
                }
                else
                {
  -                     m_sSZ += m_sName ;
  +                     pSZ << m_sName.c_str();
                }
  +             //get a prefix from Serializer
  +             ATprefix = pSZ.getNewNamespacePrefix();
   
  -             m_sSZ += " xmlns:enc"; 
  -             m_sSZ += "=\"http://www.w3.org/2001/06/soap-encoding\"";;
  -             if (m_Value.a->t == USER_TYPE)
  +             pSZ << " xmlns:enc"; 
  +             pSZ << "=\"http://www.w3.org/2001/06/soap-encoding\"";;
  +             if (m_Value.a->m_type == USER_TYPE)
                {
  -                     m_sSZ += " xmlns:def=" + m_Value.a->m_URI; //this prefix 
should be dynamically taken from serializer.
  +                     pSZ << " xmlns:" << ATprefix.c_str() << "=" << 
m_Value.a->m_URI.c_str(); //this prefix should be dynamically taken from serializer.
                }
  -             m_sSZ += "enc:arrayType=";
  -             if (m_Value.a->t == USER_TYPE)
  +             pSZ << "enc:arrayType=";
  +             if (m_Value.a->m_type == USER_TYPE)
                {
  -                     m_sSZ += "def:" + m_Value.a->m_TypeName; //this prefix should 
be dynamically taken from serializer.
  +                     pSZ << ATprefix.c_str() << ":" << 
m_Value.a->m_TypeName.c_str(); //this prefix should be dynamically taken from 
serializer.
                }
                else //basic type array
                {
  -                     m_sSZ += "xsd:";
  -                     m_sSZ += BasicTypeSerializer::BasicTypeStr(m_Value.a->t);
  +                     pSZ << "xsd:";
  +                     pSZ << BasicTypeSerializer::BasicTypeStr(m_Value.a->m_type);
                }
  -
  -             sprintf(m_Buf,"[%d]", m_Value.a->s);
  -
  -             m_sSZ += m_Buf;
  -             m_sSZ += ">";
  -             m_sSZ += m_Value.a->Serialize(); //Only serializes the inner items
  -             m_sSZ += "</";
  +             {
  +                     for (list<int>::iterator it=m_Value.a->m_size.begin(); 
it!=m_Value.a->m_size.end(); it++)
  +                     {
  +                             sprintf(m_Buf,"[%d]", *it);
  +                             pSZ << m_Buf;
  +                     }
  +             }
  +             pSZ << ">";
  +             m_Value.a->Serialize(pSZ); //Only serializes the inner items
  +             pSZ << "</";
                if (!m_strPrefix.empty())
                {
  -                     m_sSZ += m_strPrefix + ":" + m_sName; 
  +                     pSZ << m_strPrefix.c_str() << ":" << m_sName.c_str(); 
                }
                else
                {
  -                     m_sSZ += m_sName;
  +                     pSZ << m_sName.c_str();
                }
  -             m_sSZ += ">";
  +             pSZ << ">";
                break;
        case USER_TYPE:
  -             m_sSZ = m_Value.o->Serialize();
  +             m_Value.o->Serialize(pSZ);
                break;
        default:;
        }
  -     sSerialized += m_sSZ;
        return SUCCESS;
   }
   
  @@ -335,7 +334,6 @@
        //Continue this for all basic types
        case XSD_ARRAY:
        case USER_TYPE:
  -    throw new AxisException(SF_PARATYPEMISMATCH);
                //this is an error situation - probably something wrong with the soap
                break;
        default:
  
  
  
  1.2       +4 -2      xml-axis/c/src/common/ISoapSerializer.h
  
  Index: ISoapSerializer.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/common/ISoapSerializer.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ISoapSerializer.h 15 Jul 2003 06:37:03 -0000      1.1
  +++ ISoapSerializer.h 16 Jul 2003 14:15:54 -0000      1.2
  @@ -68,13 +68,15 @@
   #define AFX_ISOAPSERIALIZER_H__4F8E4E72_56C8_4F1C_A488_350FDEFF9028__INCLUDED_
   
   #include "ISoapMethod.h"
  -#include "Param.h"
  +class Param;
   
   class ISoapSerializer
   {
   public:      
  -     virtual int setResponseParam(Param& param)=0;
  +     virtual int setResponseParam(Param* pParam)=0;
        virtual ISoapMethod* createSoapMethod()=0;
  +     virtual ISoapSerializer& operator<<(const char *cSerialized)=0;
  +     virtual const char* getNewNamespacePrefix()=0;
   };
   
   #endif // 
!defined(AFX_ISOAPSERIALIZER_H__4F8E4E72_56C8_4F1C_A488_350FDEFF9028__INCLUDED_)
  
  
  
  1.3       +22 -16    xml-axis/c/src/common/AccessBean.h
  
  Index: AccessBean.h
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/common/AccessBean.h,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AccessBean.h      15 Jul 2003 05:18:56 -0000      1.2
  +++ AccessBean.h      16 Jul 2003 14:15:55 -0000      1.3
  @@ -63,6 +63,7 @@
   // AccessBean.h: interface for the AccessBean class.
   //
   //////////////////////////////////////////////////////////////////////
  +#pragma warning (disable : 4786)
   
   #if !defined(AFX_ACCESSBEAN_H__DAFED24B_0423_4501_BD9C_8EE072651FFF__INCLUDED_)
   #define AFX_ACCESSBEAN_H__DAFED24B_0423_4501_BD9C_8EE072651FFF__INCLUDED_
  @@ -72,19 +73,18 @@
   #endif // _MSC_VER > 1000
   
   //this is a trick :-)
  -
  -#include <string>
  -using namespace std;
  +#define ACCESSBEAN_SERIALIZABLE int DeSerialize(ISoapDeSerializer *pDZ);int 
Serialize(ISoapSerializer& pSZ); int GetSize();
   
   #include "../common/GDefine.h"
   #include "../soap/TypeMapping.h"
   #include "ISoapSerializer.h"
   #include "ISoapDeSerializer.h"
  -//#include "../soap/SoapSerializer.h"
  -//#include "../soap/SoapDeSerializer.h"
   
  +#include <list>
  +#include <string>
  +using namespace std;
   
  -#define ACCESSBEAN_SERIALIZABLE int DeSerialize(ISoapDeSerializer *pDZ);string& 
Serialize();
  +class SoapDeSerializer;
   
   class AccessBean  
   {
  @@ -92,11 +92,10 @@
        AccessBean();
        virtual ~AccessBean(){};
        virtual int DeSerialize(ISoapDeSerializer *pDZ);
  -     virtual string& Serialize();
  -public:
  -     string m_TypeName;//array type name in case of complex type arrays 
  +     virtual int Serialize(ISoapSerializer& pSZ);
  +     virtual int GetSize();
  +     string m_TypeName;
        string m_URI;
  -     string m_sSZ; //Used for serialization
   };
   
   //This class is used inside Param class and wrapper classes only.
  @@ -106,16 +105,23 @@
        ArrayBean();
        virtual ~ArrayBean();
        virtual int DeSerialize(ISoapDeSerializer *pDZ);
  -     virtual string& Serialize();
  +     virtual int Serialize(ISoapSerializer& pSZ);
  +     int GetArraySize();
  +private:
  +     int GetArrayBlockSize(list<int>::iterator it);
  +//   void DeleteArray(list<int>::iterator it, int nItemOffset, int nItemSize, int 
nDim);
  +//   int SerializeArray(list<int>::iterator it, int nItemOffset, int nItemSize, int 
nDim, string& sSerialized);
  +//   int DeSerializeArray(list<int>::iterator it, int nItemOffset, int nItemSize, 
int nDim, SoapDeSerializer *pDZ);
  +
   public:
  -     XSDTYPE t; //array element type
  -     int s; //array size only one dimensional arrays
  +     XSDTYPE m_type; //array element type
  +     list<int> m_size; //array size only one dimensional arrays
        string m_ItemName;//name of an item like <item>34</item>
        union uAValue //this is useful only when Param is used as a return parameter
        {
  -             void* so; //for simple types
  -             AccessBean** co; //for complex types
  -     }v;     
  +             void* sta; //simple type array
  +             AccessBean* cta; //complex type array
  +     }m_value;       
   };
   
   #endif // 
!defined(AFX_ACCESSBEAN_H__DAFED24B_0423_4501_BD9C_8EE072651FFF__INCLUDED_)
  
  
  
  1.3       +182 -72   xml-axis/c/src/common/AccessBean.cpp
  
  Index: AccessBean.cpp
  ===================================================================
  RCS file: /home/cvs/xml-axis/c/src/common/AccessBean.cpp,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- AccessBean.cpp    15 Jul 2003 05:30:13 -0000      1.2
  +++ AccessBean.cpp    16 Jul 2003 14:16:04 -0000      1.3
  @@ -1,10 +1,9 @@
   #include "AccessBean.h"
  -#include "Param.h"
  +#include "../soap/SoapDeSerializer.h"
   #include "BasicTypeSerializer.h"
   
   AccessBean::AccessBean()
   {
  -     m_TypeName = "";
   }
   
   //this is never called. just default method
  @@ -14,67 +13,117 @@
   }
   
   //this is never called. just default method
  -string& AccessBean::Serialize()
  +int AccessBean::Serialize(ISoapSerializer& pSZ)
   {
  -     return m_TypeName; 
  +     return SUCCESS;
   }
   
  +int AccessBean::GetSize()
  +{
  +     return sizeof(AccessBean);
  +}
   ArrayBean::ArrayBean()
   {
  -     t = XSD_UNKNOWN;
  -     s = 0;
  +     m_type = XSD_UNKNOWN;
        m_ItemName = "";
  -     v.so = NULL;
  +     m_value.sta = NULL;
   }
   
   ArrayBean::~ArrayBean()
   {
  -     switch (t)
  +     switch (m_type)
        {
        case XSD_INT:
                {
  -                     int* a = (int*)v.so;
  +                     int* a = (int*)m_value.sta;
                        delete [] a;
                }
                break;
        case XSD_FLOAT:
                {
  -                     float* a = (float*)v.so;
  +                     float* a = (float*)m_value.sta;
                        delete [] a;
                }
                break;
        case XSD_STRING:
                {
  -                     string* a = (string*)v.so;
  +                     string* a = (string*)m_value.sta;
                        delete [] a;
                }
                break;
                //continue this for all basic types
        case USER_TYPE: //array of user types
                {
  -                     AccessBean** a = v.co;
  -                     for (int ix=0;ix<s; ix++)
  +                     AccessBean* pItem;
  +                     int itemsize = m_value.cta->GetSize();
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     unsigned long ptrval = reinterpret_cast<unsigned 
long>(m_value.cta);
  +                     for (int x=0; x<blocksize; x++)
                        {
  -                             delete (*a);
  -                             a++;
  +                             pItem = 
reinterpret_cast<AccessBean*>(ptrval+x*itemsize);
  +                             delete pItem;
                        }
  -                     delete [] a;
                }
                break;
        default:;
        }       
   }
   
  +int ArrayBean::GetArraySize()
  +{
  +     list<int>::iterator it = m_size.begin();        
  +     return GetArrayBlockSize(it);
  +}
  +
  +int ArrayBean::GetArrayBlockSize(list<int>::iterator it)
  +{
  +     int size = *it;
  +     it++;
  +     if (it != m_size.end())
  +     {
  +             return size*GetArrayBlockSize(it);      
  +     }
  +     else
  +     {
  +             return size;
  +     }
  +}
  +/*
  +void ArrayBean::DeleteArray(list<int>::iterator it, int nItemOffset, int nItemSize, 
int nDim)
  +{
  +     AccessBean* p;
  +     nDim--;
  +     if (nDim > 0)
  +     {       
  +             int curdim = *it;
  +             it++;
  +             for (int d=0; d<curdim; d++) //do for each dimension
  +             {
  +                     DeleteArray(it,nItemOffset + 
GetArrayBlockSize(it)*d,nItemSize,nDim);
  +             }
  +             return;
  +     }
  +     unsigned long ptrval = reinterpret_cast<unsigned long>(m_value.cta) + 
nItemOffset*nItemSize;
  +     for (int x=0; x<*it; x++)
  +     {
  +             p = reinterpret_cast<AccessBean*>(ptrval+x*nItemSize);
  +             delete p;
  +     }
  +}
  +*/
   int ArrayBean::DeSerialize(ISoapDeSerializer *pDZ)
   {
        Param* p;
  -     if ((XSD_UNKNOWN == t) ||(s<=0)||(!v.so)) return FAIL;
  -     switch (t)
  +     if ((XSD_UNKNOWN == m_type) ||(0==m_size.size())||(!m_value.sta)) return FAIL;
  +     switch (m_type)
        {
        case XSD_INT:
                {
  -                     int* a = (int*)v.so;
  -                     for (int ix=0;ix<s;ix++)
  +                     int* a = (int*)m_value.sta;
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     for (int ix=0;ix<blocksize;ix++)
                        {
                                p = pDZ->GetParam();
                                if (!p) return FAIL;
  @@ -84,8 +133,10 @@
                break;
        case XSD_FLOAT:
                {
  -                     float* a = (float*)v.so;
  -                     for (int ix=0;ix<s;ix++)
  +                     float* a = (float*)m_value.sta;
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     for (int ix=0;ix<blocksize;ix++)
                        {
                                p = pDZ->GetParam();
                                if (!p) return FAIL;
  @@ -95,8 +146,10 @@
                break;
        case XSD_STRING:
                {
  -                     string* a = (string*)v.so;
  -                     for (int ix=0;ix<s;ix++)
  +                     string* a = (string*)m_value.sta;
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     for (int ix=0;ix<blocksize;ix++)
                        {
                                p = pDZ->GetParam();
                                if (!p) return FAIL;
  @@ -107,68 +160,125 @@
                //continue this for all basic types
        case USER_TYPE: //array of user types
                {
  -                     AccessBean** a = v.co;
  -                     for (int ix=0;ix<s;ix++)
  +                     AccessBean* pItem;
  +                     int itemsize = m_value.cta->GetSize();
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     unsigned long ptrval = reinterpret_cast<unsigned 
long>(m_value.cta);
  +                     for (int x=0; x<blocksize; x++)
                        {
  -                             p = pDZ->GetParam();
  -                     //      a->m_TypeName = p->m_sName;
  -                             (*a)->DeSerialize(pDZ);
  -                             a++;
  +                             pItem = 
reinterpret_cast<AccessBean*>(ptrval+x*itemsize);
  +                             pItem->DeSerialize(pDZ);
                        }
                }
                break;
        default:;
        }
  +     return SUCCESS;
   }
  -
  -string& ArrayBean::Serialize()
  -{    
  -     m_sSZ = "";
  -     if (t == USER_TYPE)
  -     {
  -             AccessBean** pType = v.co;
  -             for (int ix=0; ix<s; ix++)
  +/*
  +int ArrayBean::DeSerializeArray(list<int>::iterator it, int nItemOffset, int 
nItemSize, int nDim, SoapDeSerializer *pDZ)
  +{
  +     AccessBean* p;
  +     nDim--;
  +     if (nDim > 0)
  +     {       
  +             int curdim = *it;
  +             it++;
  +             for (int d=0; d<curdim; d++) //do for each dimension
                {
  -                     m_sSZ += (*pType)->Serialize();
  -                     pType++;
  +                     DeSerializeArray(it,nItemOffset + 
GetArrayBlockSize(it)*d,nItemSize,nDim,pDZ);
                }
  +             return SUCCESS;
        }
  -     else
  +     unsigned long ptrval = reinterpret_cast<unsigned long>(m_value.cta) + 
nItemOffset*nItemSize;
  +     for (int x=0; x<*it; x++)
  +     {
  +             p = reinterpret_cast<AccessBean*>(ptrval+x*nItemSize);
  +             p->DeSerialize(pDZ);
  +     }
  +     return SUCCESS;
  +}
  +*/
  +int ArrayBean::Serialize(ISoapSerializer& pSZ)
  +{    
  +     switch (m_type)
        {
  -             switch (t)
  +     case XSD_INT:
  +             {
  +                     int* pInt = (int*)m_value.sta;
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     for (int ix=0;ix<blocksize;ix++)
  +                     {
  +                             pSZ << BasicTypeSerializer::serialize(m_ItemName, 
*pInt).c_str();
  +                             pInt++;
  +                     }
  +             }
  +             break;
  +     case XSD_FLOAT:
  +             {
  +                     float* pFloat = (float*)m_value.sta;
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     for (int ix=0;ix<blocksize;ix++)
  +                     {
  +                             pSZ << BasicTypeSerializer::serialize(m_ItemName, 
*pFloat).c_str();
  +                             pFloat++;
  +                     }
  +             }
  +             break;
  +     case XSD_STRING:
                {
  -             case XSD_INT:
  +                     string* pStr = (string*)m_value.sta;
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     for (int ix=0;ix<blocksize;ix++)
                        {
  -                             int* pInt = (int*)v.so;
  -                             for (int ix=0; ix<s; ix++)
  -                             {
  -                                     m_sSZ += 
BasicTypeSerializer::serialize(m_ItemName, *pInt);
  -                                     pInt++;
  -                             }
  -                     }
  -                     break;
  -             case XSD_FLOAT:
  -                     {
  -                             float* pFloat = (float*)v.so;
  -                             for (int ix=0; ix<s; ix++)
  -                             {
  -                                     m_sSZ += 
BasicTypeSerializer::serialize(m_ItemName, *pFloat);
  -                                     pFloat++;
  -                             }
  -                     }
  -                     break;
  -             case XSD_STRING:
  -                     {
  -                             string* pStr = (string*)v.so;
  -                             for (int ix=0; ix<s; ix++)
  -                             {
  -                                     m_sSZ += 
BasicTypeSerializer::serialize(m_ItemName, *pStr);
  -                                     pStr++;
  -                             }
  +                             pSZ << BasicTypeSerializer::serialize(m_ItemName, 
*pStr).c_str();
  +                             pStr++;
                        }
  -                     break;
  -             default:;
                }
  +             break;
  +     case USER_TYPE:
  +             {
  +                     AccessBean* pItem;
  +                     int itemsize = m_value.cta->GetSize();
  +                     list<int>::iterator it = m_size.begin();
  +                     int blocksize = GetArrayBlockSize(it);
  +                     unsigned long ptrval = reinterpret_cast<unsigned 
long>(m_value.cta);
  +                     for (int x=0; x<blocksize; x++)
  +                     {
  +                             pItem = 
reinterpret_cast<AccessBean*>(ptrval+x*itemsize);
  +                             pItem->Serialize(pSZ);
  +                     }
  +             }
  +             break;
  +     default:;
        }
  -     return m_sSZ;
  +     return SUCCESS;
  +}
  +/*
  +int ArrayBean::SerializeArray(list<int>::iterator it, int nItemOffset, int 
nItemSize, int nDim, string& sSerialized)
  +{
  +     AccessBean* p;
  +     nDim--;
  +     if (nDim > 0)
  +     {       
  +             int curdim = *it;
  +             it++;
  +             for (int d=0; d<curdim; d++) //do for each dimension
  +             {
  +                     SerializeArray(it,nItemOffset + 
GetArrayBlockSize(it)*d,nItemSize,nDim,sSerialized);
  +             }
  +             return SUCCESS;
  +     }
  +     unsigned long ptrval = reinterpret_cast<unsigned long>(m_value.cta) + 
nItemOffset*nItemSize;
  +     for (int x=0; x<*it; x++)
  +     {
  +             p = reinterpret_cast<AccessBean*>(ptrval+x*nItemSize);
  +             p->Serialize(sSerialized);
  +     }
  +     return SUCCESS;
   }
  +*/
  \ No newline at end of file
  
  
  

Reply via email to