You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2005/01/14 17:37:14 UTC
cvs commit: ws-axis/c/src/soap/xsd Long.cpp Long.hpp
dicka 2005/01/14 08:37:14
Modified: c/src/common BasicTypeSerializer.cpp BasicTypeSerializer.h
c/src/platforms/aix PlatformSpecificAIX.hpp
c/src/platforms/os400 PlatformSpecificOS400.hpp
c/src/soap SoapDeSerializer.cpp SoapDeSerializer.h
Added: c/src/soap/xsd Long.cpp Long.hpp
Log:
Add Long type to Simple types OO model. Also further associated changes for 64bit integers being added to platform files.
Submitted by: Adrian Dick
Revision Changes Path
1.40 +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.39
retrieving revision 1.40
diff -u -r1.39 -r1.40
--- BasicTypeSerializer.cpp 14 Jan 2005 13:42:18 -0000 1.39
+++ BasicTypeSerializer.cpp 14 Jan 2005 16:37:13 -0000 1.40
@@ -86,8 +86,10 @@
m_sSZ += m_Buf;
break;
case XSD_LONG:
- AxisSprintf (m_Buf, BTS_BUFFSIZE, PRINTF_LONGLONG_FORMAT_SPECIFIER, *((LONGLONG*)(pValue)));
- m_sSZ += m_Buf;
+ {
+ Long longSerializer;
+ m_sSZ += longSerializer.serialize(pValue);
+ }
break;
case XSD_INTEGER:
{
@@ -301,8 +303,10 @@
m_sSZ += m_Buf;
break;
case XSD_LONG:
- AxisSprintf (m_Buf, BTS_BUFFSIZE, PRINTF_LONGLONG_FORMAT_SPECIFIER, *((LONGLONG*)(pValue)));
- m_sSZ += m_Buf;
+ {
+ Long longSerializer;
+ m_sSZ += longSerializer.serialize(pValue);
+ }
break;
case XSD_INTEGER:
{
1.24 +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.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- BasicTypeSerializer.h 14 Jan 2005 13:42:18 -0000 1.23
+++ BasicTypeSerializer.h 14 Jan 2005 16:37:13 -0000 1.24
@@ -44,6 +44,7 @@
#include "../soap/xsd/Double.hpp"
#include "../soap/xsd/Decimal.hpp"
#include "../soap/xsd/Integer.hpp"
+#include "../soap/xsd/Long.hpp"
using namespace std;
1.9 +8 -0 ws-axis/c/src/platforms/aix/PlatformSpecificAIX.hpp
Index: PlatformSpecificAIX.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/platforms/aix/PlatformSpecificAIX.hpp,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- PlatformSpecificAIX.hpp 13 Jan 2005 17:03:06 -0000 1.8
+++ PlatformSpecificAIX.hpp 14 Jan 2005 16:37:14 -0000 1.9
@@ -94,7 +94,15 @@
#include <string>
#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string(strerror(errorNumber));
+/**
+ * type to be used for 64bit integers
+ */
+#define LONGLONG long long
+/**
+ * Format string to be used in printf for 64bit integers
+ */
+#define PRINTF_LONGLONG_FORMAT_SPECIFIER "%lld"
#endif
1.11 +10 -0 ws-axis/c/src/platforms/os400/PlatformSpecificOS400.hpp
Index: PlatformSpecificOS400.hpp
===================================================================
RCS file: /home/cvs/ws-axis/c/src/platforms/os400/PlatformSpecificOS400.hpp,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- PlatformSpecificOS400.hpp 13 Jan 2005 17:03:06 -0000 1.10
+++ PlatformSpecificOS400.hpp 14 Jan 2005 16:37:14 -0000 1.11
@@ -85,6 +85,16 @@
#include <string>
#define PLATFORM_GET_ERROR_MESSAGE(errorNumber) new string();
+/**
+ * type to be used for 64bit integers
+ */
+#define LONGLONG long long
+
+/**
+ * Format string to be used in printf for 64bit integers
+ */
+#define PRINTF_LONGLONG_FORMAT_SPECIFIER "%lld"
+
#endif
1.125 +25 -214 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.124
retrieving revision 1.125
diff -u -r1.124 -r1.125
--- SoapDeSerializer.cpp 14 Jan 2005 13:42:19 -0000 1.124
+++ SoapDeSerializer.cpp 14 Jan 2005 16:37:14 -0000 1.125
@@ -874,6 +874,7 @@
/* Following macros are used just to shorten the coding */
#define CONV_STRTOL(str) strtol(str, &m_pEndptr, 10)
+#define CONV_STRTOLONG(str) AxisSoapDeSerializerStringToLong(str)
#define CONV_STRTOINTEGER(str) AxisSoapDeSerializerStringToInteger(str)
#define CONV_STRTOUL(str) strtoul(str, &m_pEndptr, 10)
#define CONV_STRTODECIMAL(str) AxisSoapDeSerializerStringToDecimal(str)
@@ -891,6 +892,12 @@
#define CONV_STRTOQNAME(str) AxisSoapDeSerializerStringToQName(str)
#define CONV_STRTONOTATION(str) AxisSoapDeSerializerStringToNotation(str)
+LONGLONG AxisSoapDeSerializerStringToLong(const char *valueAsChar)
+{
+ Long longDeserializer;
+ return *(longDeserializer.deserializeLong(valueAsChar));
+}
+
LONGLONG AxisSoapDeSerializerStringToInteger(const char *valueAsChar)
{
Integer integerDeserializer;
@@ -1175,7 +1182,7 @@
case XSD_UNSIGNEDBYTE:
DESERIALIZE_ENCODED_ARRAY_BLOCK (unsigned char, CONV_STRTOUL)
case XSD_LONG:
- DESERIALIZE_ENCODED_ARRAY_BLOCK (LONGLONG, CONV_STRTOUL)
+ DESERIALIZE_ENCODED_ARRAY_BLOCK (LONGLONG, CONV_STRTOLONG)
case XSD_INTEGER:
DESERIALIZE_ENCODED_ARRAY_BLOCK (LONGLONG, CONV_STRTOINTEGER)
case XSD_UNSIGNEDLONG:
@@ -1354,106 +1361,7 @@
case XSD_UNSIGNEDBYTE:
DESERIALIZE_LITERAL_ARRAY_BLOCK (unsigned char, CONV_STRTOUL)
case XSD_LONG:
- // DESERIALIZE_ENCODED_ARRAY_BLOCK (LONGLONG, CONV_STRTOUL)
- // > FJP
- Array.m_Array = new LONGLONG[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[](LONGLONG *) 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))
- {
- ((LONGLONG *) Array.m_Array)[nIndex] =
- SoapDeSerializer::strtoll (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
- 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[](LONGLONG *) 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 LONGLONG[Array.m_Size * 2];
-
- if (!Array.m_Array)
- {
- Array.m_Size = 0;
-
- return Array;
- }
-
- memcpy (Array.m_Array, tmp, Array.m_Size * sizeof (LONGLONG));
-
- delete[](LONGLONG *) tmp;
-
- Array.m_Size *= 2;
- }
-
- return Array;
- break;
-
- // < FJP
+ DESERIALIZE_ENCODED_ARRAY_BLOCK (LONGLONG, CONV_STRTOLONG)
case XSD_INTEGER:
DESERIALIZE_LITERAL_ARRAY_BLOCK (LONGLONG, CONV_STRTOINTEGER)
case XSD_UNSIGNEDLONG:
@@ -1476,106 +1384,6 @@
DESERIALIZE_LITERAL_ARRAY_BLOCK (xsd__hexBinary, CONV_STRTOHEXBINARY)
case XSD_BASE64BINARY:
DESERIALIZE_LITERAL_ARRAY_BLOCK (xsd__base64Binary, CONV_STRTOBASE64BINARY)
-
- /*
- // > FJP
- Array.m_Array = new char *[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[](LONGLONG *) 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))
- {
- ((char*) Array.m_Array)[nIndex] = SoapDeSerializer::strtoll( 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
- 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 [] (LONGLONG *) 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( LONGLONG));
-
- delete[](LONGLONG *) tmp;
-
- Array.m_Size *= 2;
- }
-
- return Array;
- break;
-
- // < FJP
- */
case XSD_DATETIME:
DESERIALIZE_LITERAL_ARRAY_BLOCK (struct tm, CONV_STRTODATETIME)
case XSD_DATE:
@@ -2735,9 +2543,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;
+ Long longDeserializer;
+ ret = *(longDeserializer.deserializeLong(m_pNode->m_pchNameOrValue));
+ m_pNode = m_pParser->next (); /* skip end element node too */
+ return ret;
}
}
else
@@ -2760,14 +2569,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);
- ret = strtoll (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;
+ Long longSerializer;
+ ret = *(longSerializer.deserializeLong(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
{
@@ -4365,8 +4174,10 @@
strtoul (m_pNode->m_pchNameOrValue, &m_pEndptr, 10);
break;
case XSD_LONG:
- *((LONGLONG *) (pValue)) =
- strtol (m_pNode->m_pchNameOrValue, &m_pEndptr, 10);
+ {
+ Long longDeserializer;
+ pValue = longDeserializer.deserialize(m_pNode->m_pchNameOrValue);
+ }
break;
case XSD_INTEGER:
{
1.26 +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.25
retrieving revision 1.26
diff -u -r1.25 -r1.26
--- SoapDeSerializer.h 14 Jan 2005 13:42:19 -0000 1.25
+++ SoapDeSerializer.h 14 Jan 2005 16:37:14 -0000 1.26
@@ -35,6 +35,7 @@
#include "xsd/Double.hpp"
#include "xsd/Decimal.hpp"
#include "xsd/Integer.hpp"
+#include "xsd/Long.hpp"
#include "../platforms/PlatformAutoSense.hpp"
AXIS_CPP_NAMESPACE_START
1.1 ws-axis/c/src/soap/xsd/Long.cpp
Index: Long.cpp
===================================================================
#include "Long.hpp"
AXIS_CPP_NAMESPACE_START
LONGLONG* Long::deserializeLong(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (LONGLONG*) deserialize(valueAsChar);
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Long.hpp
Index: Long.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(_LONG_HPP____OF_AXIS_INCLUDED_)
#define _LONG_HPP____OF_AXIS_INCLUDED_
#include "Integer.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class Long : public Integer {
public:
/**
* Deserialized Long value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Long value.
* @return Deserialized Long value.
*/
LONGLONG* deserializeLong(const AxisChar* valueAsChar) throw (AxisSoapException);
};
AXIS_CPP_NAMESPACE_END
#endif