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/21 16:53:29 UTC

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

dicka       2005/01/21 07:53:29

  Modified:    c/src/common BasicTypeSerializer.cpp BasicTypeSerializer.h
               c/src/soap Makefile.am SoapDeSerializer.cpp
                        SoapDeSerializer.h
  Added:       c/src/soap/xsd Short.cpp Short.hpp
  Log:
  Add Short type to Simple types OO model.
  
  Submitted by: Adrian Dick
  
  Revision  Changes    Path
  1.42      +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.41
  retrieving revision 1.42
  diff -u -r1.41 -r1.42
  --- BasicTypeSerializer.cpp	17 Jan 2005 11:59:51 -0000	1.41
  +++ BasicTypeSerializer.cpp	21 Jan 2005 15:53:29 -0000	1.42
  @@ -70,8 +70,10 @@
               m_sSZ += m_Buf;
               break;
           case XSD_SHORT:
  -            AxisSprintf (m_Buf, BTS_BUFFSIZE, "%d", *((short*)(pValue)));
  -            m_sSZ += m_Buf;
  +            {
  +                Short shortSerializer;
  +                m_sSZ += shortSerializer.serialize(pValue);
  +            }
               break;
           case XSD_UNSIGNEDSHORT:
               AxisSprintf (m_Buf, BTS_BUFFSIZE, "%u", 
  @@ -289,8 +291,10 @@
               m_sSZ += m_Buf;
               break;
           case XSD_SHORT:
  -            AxisSprintf (m_Buf, BTS_BUFFSIZE, "%d", *((short *) (pValue)));
  -            m_sSZ += m_Buf;
  +            {
  +                Short shortSerializer;
  +                m_sSZ += shortSerializer.serialize(pValue);
  +            }
               break;
           case XSD_UNSIGNEDSHORT:
               AxisSprintf (m_Buf, BTS_BUFFSIZE, "%u", 
  
  
  
  1.26      +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.25
  retrieving revision 1.26
  diff -u -r1.25 -r1.26
  --- BasicTypeSerializer.h	17 Jan 2005 11:59:51 -0000	1.25
  +++ BasicTypeSerializer.h	21 Jan 2005 15:53:29 -0000	1.26
  @@ -46,6 +46,7 @@
   #include "../soap/xsd/Integer.hpp"
   #include "../soap/xsd/Long.hpp"
   #include "../soap/xsd/Int.hpp"
  +#include "../soap/xsd/Short.hpp"
   
   using namespace std;
   
  
  
  
  1.18      +1 -0      ws-axis/c/src/soap/Makefile.am
  
  Index: Makefile.am
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/src/soap/Makefile.am,v
  retrieving revision 1.17
  retrieving revision 1.18
  diff -u -r1.17 -r1.18
  --- Makefile.am	21 Jan 2005 15:06:56 -0000	1.17
  +++ Makefile.am	21 Jan 2005 15:53:29 -0000	1.18
  @@ -39,6 +39,7 @@
           xsd/String.cpp \
           xsd/Time.cpp \
           xsd/XSD_QName.cpp \
  +        xsd/Short.cpp \
           xsd/constraints/WhiteSpace.cpp \
           xsd/constraints/Pattern.cpp \
           xsd/constraints/MinLength.cpp \
  
  
  
  1.130     +21 -10    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.129
  retrieving revision 1.130
  diff -u -r1.129 -r1.130
  --- SoapDeSerializer.cpp	21 Jan 2005 12:26:13 -0000	1.129
  +++ SoapDeSerializer.cpp	21 Jan 2005 15:53:29 -0000	1.130
  @@ -877,6 +877,7 @@
   
   /* Following macros are used just to shorten the coding */
   #define CONV_STRTOL(str) strtol(str, &m_pEndptr, 10)
  +#define CONV_STRTOSHORT(str) AxisSoapDeSerializerStringToShort(str)
   #define CONV_STRTOINT(str) AxisSoapDeSerializerStringToInt(str)
   #define CONV_STRTOLONG(str) AxisSoapDeSerializerStringToLong(str)
   #define CONV_STRTOINTEGER(str) AxisSoapDeSerializerStringToInteger(str)
  @@ -896,6 +897,12 @@
   #define CONV_STRTOQNAME(str) AxisSoapDeSerializerStringToQName(str)
   #define CONV_STRTONOTATION(str) AxisSoapDeSerializerStringToNotation(str)
   
  +short AxisSoapDeSerializerStringToShort(const char *valueAsChar)
  +{
  +    Short shortDeserializer;
  +    return *(shortDeserializer.deserializeShort(valueAsChar));
  +}
  +
   int AxisSoapDeSerializerStringToInt(const char *valueAsChar)
   {
       Int intDeserializer;
  @@ -1147,7 +1154,7 @@
   		    case XSD_UNSIGNEDINT:
   				DESERIALIZE_ENCODED_ARRAY_BLOCK (unsigned int, CONV_STRTOUL)
   		    case XSD_SHORT:
  -		    	DESERIALIZE_ENCODED_ARRAY_BLOCK (short,CONV_STRTOL)
  +		    	DESERIALIZE_ENCODED_ARRAY_BLOCK (short,CONV_STRTOSHORT)
   		    case XSD_UNSIGNEDSHORT:
   		    	DESERIALIZE_ENCODED_ARRAY_BLOCK(unsigned short, CONV_STRTOUL)
   		    case XSD_BYTE:
  @@ -1234,7 +1241,7 @@
   		case XSD_UNSIGNEDINT:
   		    DESERIALIZE_LITERAL_ARRAY_BLOCK (unsigned int, CONV_STRTOUL)
   		case XSD_SHORT:
  -			DESERIALIZE_LITERAL_ARRAY_BLOCK (short, CONV_STRTOL)
  +			DESERIALIZE_LITERAL_ARRAY_BLOCK (short, CONV_STRTOSHORT)
   		case XSD_UNSIGNEDSHORT:
   			DESERIALIZE_LITERAL_ARRAY_BLOCK (unsigned short, CONV_STRTOUL)
   		case XSD_BYTE:
  @@ -2135,9 +2142,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;
  +            Short shortDeserializer;
  +            ret = *( shortDeserializer.deserializeShort(m_pNode->m_pchNameOrValue));
  +    		m_pNode = m_pParser->next ();	/* skip end element node too */
  +    		return ret;
   	    }
   	}
   	else
  @@ -2160,9 +2168,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;
  +            Short shortDeserializer;
  +            ret = *( shortDeserializer.deserializeShort(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
   		 */
  @@ -4071,8 +4080,10 @@
   		strtoul (m_pNode->m_pchNameOrValue, &m_pEndptr, 10);
   	    break;
   	case XSD_SHORT:
  -	    *((short *) (pValue)) =
  -		(short) strtod (m_pNode->m_pchNameOrValue, &m_pEndptr);
  +        {
  +            Short shortDeserializer;
  +            pValue = shortDeserializer.deserialize(m_pNode->m_pchNameOrValue);
  +        }
   	    break;
   	case XSD_UNSIGNEDSHORT:
   	    *((unsigned short *) (pValue)) =
  
  
  
  1.29      +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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- SoapDeSerializer.h	21 Jan 2005 12:26:13 -0000	1.28
  +++ SoapDeSerializer.h	21 Jan 2005 15:53:29 -0000	1.29
  @@ -37,6 +37,7 @@
   #include "xsd/Integer.hpp"
   #include "xsd/Long.hpp"
   #include "xsd/Int.hpp"
  +#include "xsd/Short.hpp"
   #include "../platforms/PlatformAutoSense.hpp"
   
   AXIS_CPP_NAMESPACE_START
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/Short.cpp
  
  Index: Short.cpp
  ===================================================================
  #include "Short.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  Short::Short():m_Short(NULL)
  {
  }
  
  Short::~Short()
  {
      if (m_Short)
          delete m_Short;
  }
  
  AxisChar* Short::serialize(const void* value) throw (AxisSoapException)
  {
      return serialize((short*) value);
  }
  
  void* Short::deserializer(const AxisChar* valueAsChar) throw (AxisSoapException)
  {
      return (void*) deserializeShort(valueAsChar);
  }
  
  AxisChar* Short::serialize(const short* value) throw (AxisSoapException)
  {
      int valueAsInt = static_cast<int>(*value);
      return Int::serialize(&valueAsInt);
  }
  
  short* Short::deserializeShort(const AxisChar* valueAsChar) throw (AxisSoapException)
  {
      int* returnValue = Int::deserializeInt(valueAsChar);
   
      if(m_Short)
      {
          delete m_Short;
          m_Short = NULL;
      }
      m_Short = new short;
      *m_Short = static_cast<short> (*returnValue);
      return m_Short;
  }
  
  AXIS_CPP_NAMESPACE_END
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/Short.hpp
  
  Index: Short.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(_SHORT_HPP____OF_AXIS_INCLUDED_)
  #define _SHORT_HPP____OF_AXIS_INCLUDED_
  
  #include "Int.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  using namespace std;
  
  class Short : public Int {
  public:
  
      /**
       * Constructor
       */
      Short();
  
      /**
       * Destructor
       */
      ~Short();
  
      /**
       * Serialize value to it's on-the-wire string form.
       * @param value The value to be serialized.
       * @return Serialized form of value.
       */  
      AxisChar* serialize(const void* value) throw (AxisSoapException);
  
      /**
       * Deserialize value from it's on-the-wire string form.
       * @param valueAsChar Serialized form of value.
       * @return Deserialized value.
       */  
      void* deserializer(const AxisChar* valueAsChar) throw (AxisSoapException);
  
      /**
       * Serialize Short value to it's on-the-wire string form.
       * @param value The Short value to be serialized.
       * @return Serialized form of Short value.
       */  
      AxisChar* serialize(const short* value) throw (AxisSoapException);
    
      /**
       * Deserialized Short value from it's on-the-wire string form.
       * @param valueAsChar Serialized form of Short value.
       * @return Deserialized Short value.
       */
      short* deserializeShort(const AxisChar* valueAsChar) throw (AxisSoapException);
      
  private:
      short* m_Short;
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif