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/25 17:18:17 UTC

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

dicka       2005/01/25 08:18:15

  Modified:    c/src/soap Makefile.am
               c/vc     AxisClientDLL.dsp AxisServerDLL.dsp
  Added:       c/src/soap/xsd NonPositiveInteger.cpp NonPositiveInteger.hpp
  Log:
  Add NonPositiveInteger type to Simple types OO model.
  
  Submitted by: Adrian Dick
  
  Revision  Changes    Path
  1.29      +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.28
  retrieving revision 1.29
  diff -u -r1.28 -r1.29
  --- Makefile.am	25 Jan 2005 14:56:27 -0000	1.28
  +++ Makefile.am	25 Jan 2005 16:18:15 -0000	1.29
  @@ -47,6 +47,7 @@
           xsd/UnsignedShort.cpp \
           xsd/UnsignedByte.cpp \
           xsd/PositiveInteger.cpp \
  +        xsd/NonPositiveInteger.cpp \
           xsd/constraints/IConstrainingFacet.cpp \
           xsd/constraints/WhiteSpace.cpp \
           xsd/constraints/Pattern.cpp \
  
  
  
  1.39      +4 -0      ws-axis/c/vc/AxisClientDLL.dsp
  
  Index: AxisClientDLL.dsp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/vc/AxisClientDLL.dsp,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- AxisClientDLL.dsp	25 Jan 2005 14:56:27 -0000	1.38
  +++ AxisClientDLL.dsp	25 Jan 2005 16:18:15 -0000	1.39
  @@ -334,6 +334,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\src\soap\xsd\NonPositiveInteger.cpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\src\soap\xsd\NOTATION.cpp
   # End Source File
   # Begin Source File
  
  
  
  1.38      +4 -0      ws-axis/c/vc/AxisServerDLL.dsp
  
  Index: AxisServerDLL.dsp
  ===================================================================
  RCS file: /home/cvs/ws-axis/c/vc/AxisServerDLL.dsp,v
  retrieving revision 1.37
  retrieving revision 1.38
  diff -u -r1.37 -r1.38
  --- AxisServerDLL.dsp	25 Jan 2005 14:56:27 -0000	1.37
  +++ AxisServerDLL.dsp	25 Jan 2005 16:18:15 -0000	1.38
  @@ -330,6 +330,10 @@
   # End Source File
   # Begin Source File
   
  +SOURCE=..\src\soap\xsd\NonPositiveInteger.cpp
  +# End Source File
  +# Begin Source File
  +
   SOURCE=..\src\soap\xsd\NOTATION.cpp
   # End Source File
   # Begin Source File
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/NonPositiveInteger.cpp
  
  Index: NonPositiveInteger.cpp
  ===================================================================
  #include "NonPositiveInteger.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  NonPositiveInteger::NonPositiveInteger():m_NonPositiveInteger(NULL)
  {
  }
  
  NonPositiveInteger::~NonPositiveInteger()
  {
      if (m_NonPositiveInteger)
          delete m_NonPositiveInteger;
  }
  
  AxisChar* NonPositiveInteger::serialize(const void* value) throw (AxisSoapException)
  {
      return serialize((unsigned LONGLONG*) value);  
  }
  
  void* NonPositiveInteger::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
  {
     return (void*) deserializeNonPositiveInteger(valueAsChar);
  }
  
  
  AxisChar* NonPositiveInteger::serialize(const unsigned LONGLONG* value) throw (AxisSoapException)
  {
      MinInclusive* minInclusive = getMinInclusive();
      if (minInclusive->isSet())
      {
          if ( *value > minInclusive->getMinInclusiveAsUnsignedLONGLONG() )
          {
              AxisString exceptionMessage =
              "Value to be serialized is less than MinInclusive specified for this type.  MinInclusive = -";
              AxisChar* length = new AxisChar[25];
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, minInclusive->getMinInclusiveAsUnsignedLONGLONG());
              exceptionMessage += length;
              exceptionMessage += ", Value = -";
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, *value);
              exceptionMessage += length;
              exceptionMessage += ".";
              delete [] length;
              
              throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
                  const_cast<AxisChar*>(exceptionMessage.c_str()));
          }
      }
      delete minInclusive;
  
      MinExclusive* minExclusive = getMinExclusive();
      if (minExclusive->isSet())
      {
          if ( *value >= minExclusive->getMinExclusiveAsUnsignedLONGLONG() )
          {
              AxisString exceptionMessage =
              "Value to be serialized is less than or equal to MinExclusive specified for this type.  MinExclusive = -";
              AxisChar* length = new AxisChar[25];
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, minExclusive->getMinExclusiveAsUnsignedLONGLONG());
              exceptionMessage += length;
              exceptionMessage += ", Value = -";
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, *value);
              exceptionMessage += length;
              exceptionMessage += ".";
              delete [] length;
              
              throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
                  const_cast<AxisChar*>(exceptionMessage.c_str()));
          }
      }
      delete minExclusive;
  
      MaxInclusive* maxInclusive = getMaxInclusive();
      if (maxInclusive->isSet())
      {
          if ( *value < maxInclusive->getMaxInclusiveAsUnsignedLONGLONG() )
          {
              AxisString exceptionMessage =
              "Value to be serialized is less than MaxInclusive specified for this type.  MaxInclusive = -";
              AxisChar* length = new AxisChar[25];
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, maxInclusive->getMaxInclusiveAsUnsignedLONGLONG());
              exceptionMessage += length;
              exceptionMessage += ", Value = -";
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, *value);
              exceptionMessage += length;
              exceptionMessage += ".";
              delete [] length;
              
              throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
                  const_cast<AxisChar*>(exceptionMessage.c_str()));
          }
      }
      delete maxInclusive;
  
      MaxExclusive* maxExclusive = getMaxExclusive();
      if (maxExclusive->isSet())
      {
          if ( *value <= maxExclusive->getMaxExclusiveAsUnsignedLONGLONG() )
          {
              AxisString exceptionMessage =
              "Value to be serialized is less than or equal to MaxExclusive specified for this type.  MaxExclusive = -";
              AxisChar* length = new AxisChar[25];
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, maxExclusive->getMaxExclusiveAsUnsignedLONGLONG());
              exceptionMessage += length;
              exceptionMessage += ", Value = -";
              sprintf(length, PRINTF_LONGLONG_FORMAT_SPECIFIER, *value);
              exceptionMessage += length;
              exceptionMessage += ".";
              delete [] length;
              
              throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR,
                  const_cast<AxisChar*>(exceptionMessage.c_str()));
          }
      }
      delete maxExclusive;
      
  
      AxisChar* serializedValue = new char[80];
      AxisSprintf (serializedValue, 80, PRINTF_LONGLONG_FORMAT_SPECIFIER, *value);
  
      if(*value != 0)
      {
          AxisString serializingString = "-";
          serializingString += serializedValue;
          
          serializedValue = const_cast<AxisChar*>(serializingString.c_str());
      }
    
      IAnySimpleType::serialize(serializedValue);
      delete [] serializedValue;        
      return m_Buf;
  }
  
  unsigned LONGLONG* NonPositiveInteger::deserializeNonPositiveInteger(const AxisChar* valueAsChar) throw (AxisSoapException)
  {
      AxisChar* end;
      
      if(m_NonPositiveInteger)
      {
          delete m_NonPositiveInteger;
          m_NonPositiveInteger = NULL;
      }
      
      m_NonPositiveInteger = new unsigned LONGLONG;
      if (*valueAsChar == '-')
      {
          const AxisChar* tempVar = valueAsChar + 1;
          *m_NonPositiveInteger = strtol (tempVar, &end, 10);
      }
      else
      {
          
          *m_NonPositiveInteger = strtol (valueAsChar, &end, 10);
      }
    
      return m_NonPositiveInteger;
  }
  
  MaxInclusive* NonPositiveInteger::getMaxInclusive()
  {   
      return new MaxInclusive((unsigned LONGLONG) 0);
  }
  
  AXIS_CPP_NAMESPACE_END
  
  
  
  1.1                  ws-axis/c/src/soap/xsd/NonPositiveInteger.hpp
  
  Index: NonPositiveInteger.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(_NONPOSITIVEINTEGER_HPP____OF_AXIS_INCLUDED_)
  #define _NONPOSITIVEINTEGER_HPP____OF_AXIS_INCLUDED_
  
  #include "Integer.hpp"
  
  AXIS_CPP_NAMESPACE_START
  
  using namespace std;
  
  class NonPositiveInteger : public Integer {
  public:
  
      /**
       * Constructor
       */
      NonPositiveInteger();
      
      /**
       * Destructor
       */
      ~NonPositiveInteger();
  
      /**
       * 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* deserialize(const AxisChar* valueAsChar) throw (AxisSoapException);
      
      /**
       * Serialize NonPositiveInteger value to it's on-the-wire string form.
       * @param value The NonPositiveInteger value to be serialized.
       * @return Serialized form of NonPositiveInteger value.
       */
      AxisChar* serialize(const unsigned LONGLONG* value) throw (AxisSoapException);
    
    /**
     * Deserialized NonPositiveInteger value from it's on-the-wire string form.
     * @param valueAsChar Serialized form of NonPositiveInteger value.
     * @return Deserialized NonPositiveInteger value.
     */
      unsigned LONGLONG* deserializeNonPositiveInteger(const AxisChar* valueAsChar) throw (AxisSoapException);
  
  protected:
  
      /**
       * Creates a MaxInclusive object.  For the NonPositiveInteger type this is
       * defined as 0.
       * @return MaxInclusive object
       */
      virtual MaxInclusive* getMaxInclusive();
  
  private:
     unsigned LONGLONG* m_NonPositiveInteger;
  
  };
  
  AXIS_CPP_NAMESPACE_END
  
  #endif