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 18:07:56 UTC

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

dicka       2005/01/21 09:07:56

  Modified:    c/src/common BasicTypeSerializer.cpp BasicTypeSerializer.h
               c/src/soap Makefile.am SoapDeSerializer.cpp
                        SoapDeSerializer.h
               c/vc     AxisClientDLL.dsp AxisServerDLL.dsp
  Added:       c/src/soap/xsd Byte.cpp Byte.hpp
  Log:
  Add Byte type to Simple types OO model.
  
  Submitted by: Adrian Dick
  
  Revision  Changes    Path
  1.43      +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.42
  retrieving revision 1.43
  diff -u -r1.42 -r1.43
  --- BasicTypeSerializer.cpp	21 Jan 2005 15:53:29 -0000	1.42
  +++ BasicTypeSerializer.cpp	21 Jan 2005 17:07:56 -0000	1.43
  @@ -81,8 +81,10 @@
               m_sSZ += m_Buf;
               break;
           case XSD_BYTE:
  -            AxisSprintf (m_Buf, BTS_BUFFSIZE, "%d", *((char*)(pValue)));
  -            m_sSZ += m_Buf;
  +            {
  +                Byte byteSerializer;
  +                m_sSZ += byteSerializer.serialize(pValue);
  +            }
               break;
           case XSD_UNSIGNEDBYTE:
               AxisSprintf (m_Buf, BTS_BUFFSIZE, "%u", 
  @@ -302,8 +304,10 @@
               m_sSZ += m_Buf;
               break;
           case XSD_BYTE:
  -            AxisSprintf (m_Buf, BTS_BUFFSIZE, "%c", *((char*)(pValue)));
  -            m_sSZ += m_Buf;
  +            {
  +                Byte byteSerializer;
  +                m_sSZ += byteSerializer.serialize(pValue);
  +            }
               break;
           case XSD_UNSIGNEDBYTE:
               AxisSprintf (m_Buf, BTS_BUFFSIZE, "%c", 
  
  
  
  1.27      +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.26
  retrieving revision 1.27
  diff -u -r1.26 -r1.27
  --- BasicTypeSerializer.h	21 Jan 2005 15:53:29 -0000	1.26
  +++ BasicTypeSerializer.h	21 Jan 2005 17:07:56 -0000	1.27
  @@ -47,6 +47,7 @@
   #include "../soap/xsd/Long.hpp"
   #include "../soap/xsd/Int.hpp"
   #include "../soap/xsd/Short.hpp"
  +#include "../soap/xsd/Byte.hpp"
   
   using namespace std;
   
  
  
  
  1.19      +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.18
  retrieving revision 1.19
  diff -u -r1.18 -r1.19
  --- Makefile.am	21 Jan 2005 15:53:29 -0000	1.18
  +++ Makefile.am	21 Jan 2005 17:07:56 -0000	1.19
  @@ -40,6 +40,7 @@
           xsd/Time.cpp \
           xsd/XSD_QName.cpp \
           xsd/Short.cpp \
  +        xsd/Byte.cpp \
           xsd/constraints/WhiteSpace.cpp \
           xsd/constraints/Pattern.cpp \
           xsd/constraints/MinLength.cpp \
  
  
  
  1.131     +25 -14    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.130
  retrieving revision 1.131
  diff -u -r1.130 -r1.131
  --- SoapDeSerializer.cpp	21 Jan 2005 15:53:29 -0000	1.130
  +++ SoapDeSerializer.cpp	21 Jan 2005 17:07:56 -0000	1.131
  @@ -877,6 +877,7 @@
   
   /* Following macros are used just to shorten the coding */
   #define CONV_STRTOL(str) strtol(str, &m_pEndptr, 10)
  +#define CONV_STRTOBYTE(str) AxisSoapDeSerializerStringToByte(str)
   #define CONV_STRTOSHORT(str) AxisSoapDeSerializerStringToShort(str)
   #define CONV_STRTOINT(str) AxisSoapDeSerializerStringToInt(str)
   #define CONV_STRTOLONG(str) AxisSoapDeSerializerStringToLong(str)
  @@ -897,6 +898,12 @@
   #define CONV_STRTOQNAME(str) AxisSoapDeSerializerStringToQName(str)
   #define CONV_STRTONOTATION(str) AxisSoapDeSerializerStringToNotation(str)
   
  +char AxisSoapDeSerializerStringToByte(const char *valueAsChar)
  +{
  +    Byte byteDeserializer;
  +    return *(byteDeserializer.deserializeByte(valueAsChar));
  +}
  +
   short AxisSoapDeSerializerStringToShort(const char *valueAsChar)
   {
       Short shortDeserializer;
  @@ -1158,7 +1165,7 @@
   		    case XSD_UNSIGNEDSHORT:
   		    	DESERIALIZE_ENCODED_ARRAY_BLOCK(unsigned short, CONV_STRTOUL)
   		    case XSD_BYTE:
  -		    	DESERIALIZE_ENCODED_ARRAY_BLOCK (char, CONV_STRTOL)
  +		    	DESERIALIZE_ENCODED_ARRAY_BLOCK (char, CONV_STRTOBYTE)
   		    case XSD_UNSIGNEDBYTE:
   		    	DESERIALIZE_ENCODED_ARRAY_BLOCK (unsigned char, CONV_STRTOUL)
   		    case XSD_LONG:
  @@ -1245,7 +1252,7 @@
   		case XSD_UNSIGNEDSHORT:
   			DESERIALIZE_LITERAL_ARRAY_BLOCK (unsigned short, CONV_STRTOUL)
   		case XSD_BYTE:
  -			DESERIALIZE_LITERAL_ARRAY_BLOCK (char, CONV_STRTOL)
  +			DESERIALIZE_LITERAL_ARRAY_BLOCK (char, CONV_STRTOBYTE)
   		case XSD_UNSIGNEDBYTE:
   			DESERIALIZE_LITERAL_ARRAY_BLOCK (unsigned char, CONV_STRTOUL)
   		case XSD_LONG:
  @@ -2291,9 +2298,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;
  +            Byte byteDeserializer;
  +            ret = *( byteDeserializer.deserializeByte(m_pNode->m_pchNameOrValue));
  +    		m_pNode = m_pParser->next ();	/* skip end element node too */
  +    		return ret;
   	    }
   	}
   	else
  @@ -2316,13 +2324,14 @@
   	    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;
  -		/* this is important in doc/lit style when deserializing
  -		 * arrays
  -		 */
  -		return ret;
  +            Byte byteDeserializer;
  +            ret = *( byteDeserializer.deserializeByte(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
  +    		 */
  +    		return ret;
   	    }
   	    else
   	    {
  @@ -4090,8 +4099,10 @@
   		strtoul (m_pNode->m_pchNameOrValue, &m_pEndptr, 10);
   	    break;
   	case XSD_BYTE:
  -	    *((char *) (pValue)) =
  -		(char) strtod (m_pNode->m_pchNameOrValue, &m_pEndptr);
  +        {
  +            Byte byteDeserializer;
  +            pValue = byteDeserializer.deserialize(m_pNode->m_pchNameOrValue);
  +        }
   	    break;
   	case XSD_UNSIGNEDBYTE:
   	    *((unsigned char *) (pValue)) =
  
  
  
  1.30      +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.29
  retrieving revision 1.30
  diff -u -r1.29 -r1.30
  --- SoapDeSerializer.h	21 Jan 2005 15:53:29 -0000	1.29
  +++ SoapDeSerializer.h	21 Jan 2005 17:07:56 -0000	1.30
  @@ -38,6 +38,7 @@
   #include "xsd/Long.hpp"
   #include "xsd/Int.hpp"
   #include "xsd/Short.hpp"
  +#include "xsd/Byte.hpp"
   #include "../platforms/PlatformAutoSense.hpp"
   
   AXIS_CPP_NAMESPACE_START
  
  
  
  1.29      +8 -0      ws-axis/c/vc/AxisClientDLL.dsp
  
  Index: AxisClientDLL.dsp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/vc/AxisClientDLL.dsp,v
  retrieving revision 1.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- AxisClientDLL.dsp	21 Jan 2005 15:06:56 -0000	1.28
  +++ AxisClientDLL.dsp	21 Jan 2005 17:07:56 -0000	1.29
  @@ -190,6 +190,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\src\soap\xsd\Byte.cpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\src\engine\client\Call.cpp
   # End Source File
   # Begin Source File
  @@ -331,6 +335,10 @@
   # Begin Source File
   
   SOURCE=..\src\engine\SharedObject.cpp
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\src\soap\xsd\Short.cpp
   # End Source File
   # Begin Source File
   
  
  
  
  1.28      +8 -0      ws-axis/c/vc/AxisServerDLL.dsp
  
  Index: AxisServerDLL.dsp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/vc/AxisServerDLL.dsp,v
  retrieving revision 1.27
  retrieving revision 1.28
  diff -u -r1.27 -r1.28
  --- AxisServerDLL.dsp	21 Jan 2005 15:06:56 -0000	1.27
  +++ AxisServerDLL.dsp	21 Jan 2005 17:07:56 -0000	1.28
  @@ -194,6 +194,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\src\soap\xsd\Byte.cpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\src\soap\CharacterElement.cpp
   # End Source File
   # Begin Source File
  @@ -331,6 +335,10 @@
   # Begin Source File
   
   SOURCE=..\src\engine\SharedObject.cpp
  +# End Source File
  +# Begin Source File
  +
  +SOURCE=..\src\soap\xsd\Short.cpp
   # End Source File
   # Begin Source File
   
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/Byte.cpp
  
  Index: Byte.cpp
  ===================================================================
  #include "Byte.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  Byte::Byte():m_Byte(NULL)
  {
  }
  
  Byte::~Byte()
  {
      if (m_Byte)
          delete m_Byte;
  }
  
  AxisChar* Byte::serialize(const void* value) throw (AxisSoapException)
  {
      return serialize((char*) value);
  }
  
  void* Byte::deserializer(const AxisChar* valueAsChar) throw (AxisSoapException)
  {
      return (void*) deserializeByte(valueAsChar);
  }
  
  AxisChar* Byte::serialize(const char* value) throw (AxisSoapException)
  {
      short valueAsShort = static_cast<short>(*value);
      return Short::serialize(&valueAsShort);
  }
  
  char* Byte::deserializeByte(const AxisChar* valueAsChar) throw (AxisSoapException)
  {
      short* returnValue = Short::deserializeShort(valueAsChar);
   
      if(m_Byte)
      {
          delete m_Byte;
          m_Byte = NULL;
      }
      m_Byte = new char;
      *m_Byte = static_cast<char> (*returnValue);
      return m_Byte;
  }
  
  AXIS_CPP_NAMESPACE_END
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/Byte.hpp
  
  Index: Byte.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(_BYTE_HPP____OF_AXIS_INCLUDED_)
  #define _BYTE_HPP____OF_AXIS_INCLUDED_
  
  #include "Short.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  using namespace std;
  
  class Byte : public Short {
  public:
  
      /**
       * Constructor
       */
      Byte();
  
      /**
       * Destructor
       */
      ~Byte();
  
      /**
       * 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 Byte value to it's on-the-wire string form.
       * @param value The Byte value to be serialized.
       * @return Serialized form of Byte value.
       */  
      AxisChar* serialize(const char* value) throw (AxisSoapException);
    
      /**
       * Deserialized Byte value from it's on-the-wire string form.
       * @param valueAsChar Serialized form of Byte value.
       * @return Deserialized Byte value.
       */
      char* deserializeByte(const AxisChar* valueAsChar) throw (AxisSoapException);
      
  private:
      char* m_Byte;
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif