You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by di...@apache.org on 2005/01/17 12:59:52 UTC

cvs commit: ws-axis/c/src/soap/xsd Int.cpp Int.hpp

dicka       2005/01/17 03:59:51

  Modified:    c/src/common BasicTypeSerializer.cpp BasicTypeSerializer.h
               c/src/soap SoapDeSerializer.cpp SoapDeSerializer.h
  Added:       c/src/soap/xsd Int.cpp Int.hpp
  Log:
  Add Int type to Simple types OO model.
  
  Submitted by: Adrian Dick
  
  Revision  Changes    Path
  1.41      +8 -4      ws-axis/c/src/common/BasicTypeSerializer.cpp
  
  Index: BasicTypeSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/common/BasicTypeSerializer.cpp,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- BasicTypeSerializer.cpp	14 Jan 2005 16:37:13 -0000	1.40
  +++ BasicTypeSerializer.cpp	17 Jan 2005 11:59:51 -0000	1.41
  @@ -54,8 +54,10 @@
       switch (type)
       {
           case XSD_INT:
  -            AxisSprintf (m_Buf, BTS_BUFFSIZE, "%d", *((int*)(pValue)));
  -            m_sSZ += m_Buf;
  +            {
  +                Int intSerializer;
  +                m_sSZ += intSerializer.serialize(pValue);
  +            }
               break;
           case XSD_BOOLEAN:
           	{
  @@ -271,8 +273,10 @@
       switch (type)
       {
           case XSD_INT:
  -            AxisSprintf (m_Buf, BTS_BUFFSIZE, "%d", *((int*)(pValue)));
  -            m_sSZ += m_Buf;
  +            {
  +                Int intSerializer;
  +                m_sSZ += intSerializer.serialize(pValue);
  +            }
               break;
           case XSD_BOOLEAN:
           	{
  
  
  
  1.25      +1 -0      ws-axis/c/src/common/BasicTypeSerializer.h
  
  Index: BasicTypeSerializer.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/common/BasicTypeSerializer.h,v
  retrieving revision 1.24
  retrieving revision 1.25
  diff -u -r1.24 -r1.25
  --- BasicTypeSerializer.h	14 Jan 2005 16:37:13 -0000	1.24
  +++ BasicTypeSerializer.h	17 Jan 2005 11:59:51 -0000	1.25
  @@ -45,6 +45,7 @@
   #include "../soap/xsd/Decimal.hpp"
   #include "../soap/xsd/Integer.hpp"
   #include "../soap/xsd/Long.hpp"
  +#include "../soap/xsd/Int.hpp"
   
   using namespace std;
   
  
  
  
  1.126     +21 -139   ws-axis/c/src/soap/SoapDeSerializer.cpp
  
  Index: SoapDeSerializer.cpp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapDeSerializer.cpp,v
  retrieving revision 1.125
  retrieving revision 1.126
  diff -u -r1.125 -r1.126
  --- SoapDeSerializer.cpp	14 Jan 2005 16:37:14 -0000	1.125
  +++ SoapDeSerializer.cpp	17 Jan 2005 11:59:51 -0000	1.126
  @@ -874,6 +874,7 @@
   
   /* Following macros are used just to shorten the coding */
   #define CONV_STRTOL(str) strtol(str, &m_pEndptr, 10)
  +#define CONV_STRTOINT(str) AxisSoapDeSerializerStringToInt(str)
   #define CONV_STRTOLONG(str) AxisSoapDeSerializerStringToLong(str)
   #define CONV_STRTOINTEGER(str) AxisSoapDeSerializerStringToInteger(str)
   #define CONV_STRTOUL(str) strtoul(str, &m_pEndptr, 10)
  @@ -892,6 +893,12 @@
   #define CONV_STRTOQNAME(str) AxisSoapDeSerializerStringToQName(str)
   #define CONV_STRTONOTATION(str) AxisSoapDeSerializerStringToNotation(str)
   
  +int AxisSoapDeSerializerStringToInt(const char *valueAsChar)
  +{
  +    Int intDeserializer;
  +    return *(intDeserializer.deserializeInt(valueAsChar));
  +}
  +
   LONGLONG AxisSoapDeSerializerStringToLong(const char *valueAsChar)
   {
       Long longDeserializer;
  @@ -1133,44 +1140,7 @@
   		    switch (nType)
   		    {
   		    case XSD_INT:
  -			Array.m_Array = new int[Array.m_Size];
  -	
  -			if (!Array.m_Array)
  -			{
  -			    Array.m_Size = 0;
  -			    m_nStatus = AXIS_FAIL;
  -	
  -			    return Array;
  -			}
  -	
  -			for (; nIndex < Array.m_Size; nIndex++)
  -			{
  -			    m_pNode = m_pParser->next ();
  -			    /* wrapper node without type info  Ex: <item> */
  -			    m_pNode = m_pParser->next (true);	/* charactor node */
  -	
  -			    if (m_pNode && (CHARACTER_ELEMENT == m_pNode->m_type))
  -			    {
  -				((int *) Array.m_Array)[nIndex] =
  -				    strtol (m_pNode->m_pchNameOrValue, &m_pEndptr,
  -					    10);
  -				m_pNode = m_pParser->next ();
  -				/* skip end element node too */
  -				continue;
  -			    }
  -	
  -			    /* error : unexpected element type or end of stream */
  -			    m_nStatus = AXIS_FAIL;
  -			    delete[](int *) Array.m_Array;
  -			    Array.m_Array = 0;
  -			    Array.m_Size = 0;
  -	
  -			    return Array;
  -			}
  -	
  -			m_pNode = m_pParser->next ();	/* skip end element node too */
  -			return Array;
  -	
  +                DESERIALIZE_ENCODED_ARRAY_BLOCK (int, CONV_STRTOINT)
   		    case XSD_UNSIGNEDINT:
   				DESERIALIZE_ENCODED_ARRAY_BLOCK (unsigned int, CONV_STRTOUL)
   		    case XSD_SHORT:
  @@ -1257,99 +1227,7 @@
   		switch (nType)
   		{
   		case XSD_INT:
  -		    Array.m_Array = new int[INITIAL_ARRAY_SIZE];
  -	
  -		    if (!Array.m_Array)
  -		    {
  -			return Array;
  -		    }
  -	
  -		    Array.m_Size = INITIAL_ARRAY_SIZE;
  -	
  -		    while (true)
  -		    {
  -			for (; nIndex < Array.m_Size; nIndex++)
  -			{
  -			    if (!m_pNode)
  -			    {
  -				/* if there is an unprocessed node that may be one 
  -				 * left from last array deserialization
  -				 */
  -				m_pNode = m_pParser->next ();
  -			    }
  -	
  -			    /* wrapper node without type info  Ex: <phonenumbers> */
  -			    if (!m_pNode)
  -			    {
  -				m_nStatus = AXIS_FAIL;
  -				delete[](int *) Array.m_Array;
  -				Array.m_Array = 0;
  -				Array.m_Size = 0;
  -	
  -				return Array;
  -			    }
  -	
  -			    if (0 == strcmp (pName, m_pNode->m_pchNameOrValue))
  -			    {
  -				m_pNode = m_pParser->next (true);	/* charactor node */
  -	
  -				if (m_pNode && (CHARACTER_ELEMENT == m_pNode->m_type))
  -				{
  -				    ((int *) Array.m_Array)[nIndex] =
  -					strtol (m_pNode->m_pchNameOrValue, &m_pEndptr,
  -						10);
  -				    m_pNode = m_pParser->next ();
  -				    /* skip end element node too */
  -				    m_pNode = NULL;	/* this is important in doc/lit 
  -							 * style when deserializing arrays
  -							 */
  -				    continue;
  -				}
  -				/* error : unexpected element type or end of the stream */
  -			    }
  -			    else
  -			    {
  -				if (nIndex > 0)
  -				{
  -				    Array.m_Size = nIndex;
  -				    /* put the actual deserialized item size
  -				     * note we do not make m_pNode = NULL because this
  -				     * node doesnot belong to this array
  -				     */
  -				    return Array;
  -				}
  -				/* error : no elements deserialized */
  -			    }
  -	
  -			    /* if we come here it is an error situation */
  -			    m_nStatus = AXIS_FAIL;
  -			    m_pNode = NULL;
  -			    delete[](int *) Array.m_Array;
  -			    Array.m_Array = 0;
  -			    Array.m_Size = 0;
  -			    return Array;
  -			}
  -			/* if we come here that means the array allocated is not enough
  -			 * So double it
  -			 */
  -			void *tmp = Array.m_Array;
  -			Array.m_Array = new int[Array.m_Size * 2];
  -	
  -			if (!Array.m_Array)
  -			{
  -			    Array.m_Size = 0;
  -			    return Array;
  -			}
  -	
  -			memcpy (Array.m_Array, tmp, Array.m_Size * sizeof (int));
  -			delete[](int *) tmp;
  -			Array.m_Size *= 2;
  -			/* Array.m_RealSize = Array.m_Size; */
  -		    }
  -	
  -		    return Array;
  -		    break;
  -	
  +            DESERIALIZE_LITERAL_ARRAY_BLOCK (int, CONV_STRTOINT)	
   		case XSD_UNSIGNEDINT:
   		    DESERIALIZE_LITERAL_ARRAY_BLOCK (unsigned int, CONV_STRTOUL)
   		case XSD_SHORT:
  @@ -2104,9 +1982,10 @@
   	    m_pNode = m_pParser->next (true);	/* charactor node */
   	    if (m_pNode && (CHARACTER_ELEMENT == m_pNode->m_type))
   	    {
  -		ret = strtol (m_pNode->m_pchNameOrValue, &m_pEndptr, 10);
  -		m_pNode = m_pParser->next ();	/* skip end element node too */
  -		return ret;
  +            Int intDeserializer;
  +            ret = *(intDeserializer.deserializeInt(m_pNode->m_pchNameOrValue));
  +    		m_pNode = m_pParser->next ();	/* skip end element node too */
  +    		return ret;
   	    }
   	}
   	else
  @@ -2131,9 +2010,10 @@
   	    m_pNode = m_pParser->next (true);	/* charactor node */
   	    if (m_pNode && (CHARACTER_ELEMENT == m_pNode->m_type))
   	    {
  -		ret = strtol (m_pNode->m_pchNameOrValue, &m_pEndptr, 10);
  -		m_pNode = m_pParser->next ();	/* skip end element node too */
  -		m_pNode = NULL;
  +            Int intDeserializer;
  +            ret = *(intDeserializer.deserializeInt(m_pNode->m_pchNameOrValue));
  +    		m_pNode = m_pParser->next ();	/* skip end element node too */
  +    		m_pNode = NULL;
   		/*
   		 * this is important in doc/lit style when deserializing 
   		 * arrays
  @@ -4144,8 +4024,10 @@
   	switch (type)
   	{
   	case XSD_INT:
  -	    *((int *) (pValue)) =
  -		(int) strtod (m_pNode->m_pchNameOrValue, &m_pEndptr);
  +        {
  +            Int intDeserializer;
  +            pValue = intDeserializer.deserialize(m_pNode->m_pchNameOrValue);
  +        }
   	    break;
   	case XSD_BOOLEAN:
   		{
  
  
  
  1.27      +1 -0      ws-axis/c/src/soap/SoapDeSerializer.h
  
  Index: SoapDeSerializer.h
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/SoapDeSerializer.h,v
  retrieving revision 1.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- SoapDeSerializer.h	14 Jan 2005 16:37:14 -0000	1.26
  +++ SoapDeSerializer.h	17 Jan 2005 11:59:51 -0000	1.27
  @@ -36,6 +36,7 @@
   #include "xsd/Decimal.hpp"
   #include "xsd/Integer.hpp"
   #include "xsd/Long.hpp"
  +#include "xsd/Int.hpp"
   #include "../platforms/PlatformAutoSense.hpp"
   
   AXIS_CPP_NAMESPACE_START
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/Int.cpp
  
  Index: Int.cpp
  ===================================================================
  #include "Int.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  int* Int::deserializeInt(const AxisChar* valueAsChar) throw (AxisSoapException)
  {
      return (int*) deserialize(valueAsChar);
  }
  
  AXIS_CPP_NAMESPACE_END
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/Int.hpp
  
  Index: Int.hpp
  ===================================================================
  /* -*- C++ -*- */
  /*
   *   Copyright 2003-2004 The Apache Software Foundation.
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *   limitations under the License.
   *
   *
   * @author Adrian Dick (adrian.dick@uk.ibm.com)
   *
   */
  
  #if !defined(_INT_HPP____OF_AXIS_INCLUDED_)
  #define _INT_HPP____OF_AXIS_INCLUDED_
  
  #include "Long.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  using namespace std;
  
  class Int : public Long {
  public:
    
    /**
     * Deserialized Int value from it's on-the-wire string form.
     * @param valueAsChar Serialized form of Int value.
     * @return Deserialized Int value.
     */
      int* deserializeInt(const AxisChar* valueAsChar) throw (AxisSoapException);
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif