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/10 18:18:35 UTC
cvs commit: ws-axis/c/src/soap/xsd AnyURI.cpp AnyURI.hpp Base64Binary.cpp Base64Binary.hpp Boolean.cpp Boolean.hpp Date.cpp Date.hpp DateTime.cpp DateTime.hpp Decimal.cpp Decimal.hpp Double.cpp Double.hpp Duration.cpp Duration.hpp Float.cpp Float.hpp HexBinary.cpp HexBinary.hpp IAnySimpleType.cpp IAnySimpleType.hpp NOTATION.cpp NOTATION.hpp String.cpp String.hpp Time.cpp Time.hpp XSD_QName.cpp XSD_QName.hpp
dicka 2005/01/10 09:18:34
Added: c/src/soap/xsd AnyURI.cpp AnyURI.hpp Base64Binary.cpp
Base64Binary.hpp Boolean.cpp Boolean.hpp Date.cpp
Date.hpp DateTime.cpp DateTime.hpp Decimal.cpp
Decimal.hpp Double.cpp Double.hpp Duration.cpp
Duration.hpp Float.cpp Float.hpp HexBinary.cpp
HexBinary.hpp IAnySimpleType.cpp IAnySimpleType.hpp
NOTATION.cpp NOTATION.hpp String.cpp String.hpp
Time.cpp Time.hpp XSD_QName.cpp XSD_QName.hpp
Log:
Creation of OO Model for XSD simple types.
XSD primitive simple types, using existing deserialization/serialization algorithms.
Submitted by: Adrian Dick
Revision Changes Path
1.1 ws-axis/c/src/soap/xsd/AnyURI.cpp
Index: AnyURI.cpp
===================================================================
#include "AnyURI.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* AnyURI::serialize(const void* value) throw (AxisSoapException)
{
return serialize((AxisChar*) value);
}
void* AnyURI::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeAnyURI(valueAsChar);
}
AxisChar* AnyURI::serialize(const AxisChar* value) throw (AxisSoapException)
{
AxisString valueAsString = value;
AxisChar* returnValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
m_Buf = new char[strlen (returnValue) + 1];
strcpy (m_Buf, returnValue);
return m_Buf;
}
AxisChar* AnyURI::deserializeAnyURI(const AxisChar* valueAsChar) throw (AxisSoapException)
{
m_Buf = new char[strlen (valueAsChar) + 1];
strcpy (m_Buf, valueAsChar);
return m_Buf;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/AnyURI.hpp
Index: AnyURI.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(_ANYURI_HPP____OF_AXIS_INCLUDED_)
#define _ANYURI_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class AnyURI : public IAnySimpleType {
public:
/**
* 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 AnyURI value to it's on-the-wire string form.
* @param value The AnyURI value to be serialized.
* @return Serialized form of AnyURI value.
*/
AxisChar* serialize(const AxisChar* value) throw (AxisSoapException);
/**
* Deserialized AnyURI value from it's on-the-wire string form.
* @param valueAsChar Serialized form of AnyURI value.
* @return Deserialized AnyURI value.
*/
AxisChar* deserializeAnyURI(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Base64Binary.cpp
Index: Base64Binary.cpp
===================================================================
#include "Base64Binary.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* Base64Binary::serialize(const void* value) throw (AxisSoapException)
{
return serialize((xsd__base64Binary*) value);
}
void* Base64Binary::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeBase64Binary(valueAsChar);
}
AxisChar* Base64Binary::serialize(const xsd__base64Binary* value) throw (AxisSoapException)
{
int len = apr_base64_encode_len (value->__size);
AxisChar* serializedValue = new AxisChar[len + 1];
len = apr_base64_encode_binary (serializedValue, value->__ptr, value->__size);
serializedValue[len] = 0;
m_Buf = new char[strlen (serializedValue) + 1];
strcpy (m_Buf, serializedValue);
return m_Buf;
}
xsd__base64Binary* Base64Binary::deserializeBase64Binary(const AxisChar* valueAsChar) throw (AxisSoapException)
{
m_base64Binary = new xsd__base64Binary();
m_base64Binary->__size = apr_base64_decode_len (valueAsChar);
m_base64Binary->__ptr = new unsigned char[m_base64Binary->__size + 1];
m_base64Binary->__size = apr_base64_decode_binary (m_base64Binary->__ptr, valueAsChar);
/* put null at the end because it enables the decoded string to be used
* as a string
*/
m_base64Binary->__ptr[m_base64Binary->__size] = 0;
return m_base64Binary;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Base64Binary.hpp
Index: Base64Binary.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(_BASE64BINARY_HPP____OF_AXIS_INCLUDED_)
#define _BASE64BINARY_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
#include "../apr_base64.h"
#include <axis/AxisUserAPI.hpp>
AXIS_CPP_NAMESPACE_START
using namespace std;
class Base64Binary : public IAnySimpleType {
public:
/**
* 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 Base64Binary value to it's on-the-wire string form.
* @param value The Base64Binary value to be serialized.
* @return Serialized form of Base64Binary value.
*/
AxisChar* serialize(const xsd__base64Binary* value) throw (AxisSoapException);
/**
* Deserialized Base64Binary value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Base64Binary value.
* @return Deserialized Base64Binary value.
*/
xsd__base64Binary* deserializeBase64Binary(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
xsd__base64Binary* m_base64Binary;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Boolean.cpp
Index: Boolean.cpp
===================================================================
#include "Boolean.hpp"
AXIS_CPP_NAMESPACE_START
/**
* Serialize value to it's on-the-wire string form.
* @param value The value to be serialized.
* @return Serialized form of value.
*/
AxisChar* Boolean::serialize(const void* value) throw (AxisSoapException)
{
return serialize((bool*) value);
}
/**
* Deserialize value from it's on-the-wire string form.
* @param valueAsChar Serialized form of value.
* @return Deserialized value.
*/
void* Boolean::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeBoolean(valueAsChar);
}
/**
* Serialize boolean value to it's on-the-wire string form.
* @param value The boolean value to be serialized.
* @return Serialized form of boolean value.
*/
AxisChar* Boolean::serialize(const bool* value) throw (AxisSoapException)
{
AxisSprintf (m_Buf, 6, "%s",
(*((int *) (value)) == false_) ? "false" : "true");
return m_Buf;
}
/**
* Deserialize boolean value from it's on-the-wire string form.
* @param valueAsChar Serialized form of boolean value.
* @return Deserialized boolean value.
*/
xsd__boolean Boolean::deserializeBoolean(const AxisChar* valueAsChar) throw (AxisSoapException)
{
if ( 0 == strcmp (valueAsChar, "true") || 0 == strcmp (valueAsChar, "1"))
{
return true_;
}
else
{
return false_;
}
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Boolean.hpp
Index: Boolean.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(_BOOLEAN_HPP____OF_AXIS_INCLUDED_)
#define _BOOLEAN_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
#include <axis/AxisUserAPI.hpp>
AXIS_CPP_NAMESPACE_START
using namespace std;
class Boolean : public IAnySimpleType {
public:
/**
* 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 boolean value to it's on-the-wire string form.
* @param value The boolean value to be serialized.
* @return Serialized form of boolean value.
*/
AxisChar* serialize(const bool* value) throw (AxisSoapException);
/**
* Deserialized boolean value from it's on-the-wire string form.
* @param valueAsChar Serialized form of boolean value.
* @return Deserialized boolean value.
*/
xsd__boolean deserializeBoolean(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar m_Buf[6];
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Date.cpp
Index: Date.cpp
===================================================================
#include "Date.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* Date::serialize(const void* value) throw (AxisSoapException)
{
return serialize((struct tm*) value);
}
void* Date::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeDate(valueAsChar);
}
AxisChar* Date::serialize(const struct tm* value) throw (AxisSoapException)
{
AxisChar* serializedValue = new AxisChar[80];
strftime (serializedValue, 80, "%Y-%m-%dZ", value);
m_Buf = new char[strlen (serializedValue) + 1];
strcpy (m_Buf, serializedValue);
return m_Buf;
}
struct tm* Date::deserializeDate(const AxisChar* valueAsChar) throw (AxisSoapException)
{
struct tm value;
struct tm *pTm;
AxisChar *cUtc;
AxisChar *cTemp;
AxisChar *cTemp2;
time_t now;
time (&now);
pTm = gmtime (&now);
struct tm result1;
memcpy (&result1, pTm, sizeof (tm));
pTm = localtime (&now);
struct tm result2;
memcpy (&result2, pTm, sizeof (tm));
time_t d = mktime (&result1) - mktime (&result2);
if (d == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
/* dismantle m_sValue to get tm value;
* XSD_DATETIME format is
* CCYY(-)MM(-)DDZ OR
* CCYY(-)MM(-)DD+/-<UTC TIME DIFFERENCE>
*/
if (sscanf (valueAsChar, "%d-%d-%d", &value.tm_year,
&value.tm_mon, &value.tm_mday) != 3)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
value.tm_year -= 1900;
value.tm_mon--;
value.tm_hour = 0;
value.tm_min = 0;
value.tm_sec = 0;
value.tm_isdst = -1;
#if !defined(WIN32) && !defined(AIX) && !defined( __OS400__ ) && !defined(__sun)
value.tm_zone = NULL;
value.tm_gmtoff = -1;
#endif
cTemp2 = const_cast<char*>(strpbrk (valueAsChar, ":"));
/* if the timezone is represented adding 'Z' at the end */
if ((cTemp = const_cast<char*>(strpbrk (valueAsChar, "Z"))) != NULL)
{
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&timeInSecs);
}
else if (cTemp2 != NULL)
{
cUtc = const_cast<char*>(strrchr (valueAsChar, '+'));
if (cUtc == NULL)
{
cUtc = const_cast<char*>(strrchr (valueAsChar, '-'));
}
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int hours = 0;
int mins = 0;
if (sscanf (cUtc + 1, "%d:%d", &hours, &mins) != 2)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int secs = hours * 60 * 60 + mins * 60;
if ((cTemp = strpbrk ((cUtc), "+")) != NULL)
{
timeInSecs += secs;
}
else
{
timeInSecs -= secs;
}
pTm = localtime (&timeInSecs);
memcpy (&value, pTm, sizeof (tm));
time_t t = mktime (&value);
if (t == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
pTm = gmtime (&t);
}
/*if the zone is not represented in the date */
else
{
/*else it is assumed that the sent time is localtime */
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = gmtime (&timeInSecs);
}
m_Date = new struct tm;
memcpy (m_Date, pTm, sizeof (tm));
return m_Date;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Date.hpp
Index: Date.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(_DATE_HPP____OF_AXIS_INCLUDED_)
#define _DATE_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
#include <ctime>
AXIS_CPP_NAMESPACE_START
using namespace std;
class Date : public IAnySimpleType {
public:
/**
* 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 Date value to it's on-the-wire string form.
* @param value The Date value to be serialized.
* @return Serialized form of Date value.
*/
AxisChar* serialize(const struct tm* value) throw (AxisSoapException);
/**
* Deserialized Date value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Date value.
* @return Deserialized Date value.
*/
struct tm* deserializeDate(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
struct tm* m_Date;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/DateTime.cpp
Index: DateTime.cpp
===================================================================
#include "DateTime.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* DateTime::serialize(const void* value) throw (AxisSoapException)
{
return serialize((struct tm*) value);
}
void* DateTime::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeDateTime(valueAsChar);
}
AxisChar* DateTime::serialize(const struct tm* value) throw (AxisSoapException)
{
AxisChar* serializedValue = new AxisChar[80];
strftime (serializedValue, 80, "%Y-%m-%dT%H:%M:%SZ", value);
m_Buf = new char[strlen (serializedValue) + 1];
strcpy (m_Buf, serializedValue);
return m_Buf;
}
struct tm* DateTime::deserializeDateTime(const AxisChar* valueAsChar) throw (AxisSoapException)
{
struct tm value;
struct tm* pTm;
AxisChar *cUtc;
AxisChar *cTemp;
AxisChar *cTemp2;
AxisChar *cTemp3;
time_t now;
pTm = gmtime (&now);
struct tm result1;
memcpy (&result1, pTm, sizeof (tm));
pTm = localtime (&now);
struct tm result2;
memcpy (&result2, pTm, sizeof (tm));
time_t d = mktime (&result1) - mktime (&result2);
if (d == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
/* dismantle m_sValue to get tm value;
* XSD_DATETIME format is
* CCYY(-)MM(-)DDThh:mm:ss.ss...Z OR
* CCYY(-)MM(-)DDThh:mm:ss.ss...+/-<UTC TIME DIFFERENCE>
*/
if (sscanf (valueAsChar, "%d-%d-%dT%d:%d:%d", &value.tm_year,
&value.tm_mon, &value.tm_mday, &value.tm_hour, &value.tm_min,
&value.tm_sec) != 6)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
value.tm_year -= 1900;
value.tm_mon--;
value.tm_isdst = -1;
#if !defined(WIN32) && !defined(AIX) && !defined( __OS400__ ) && !defined(__sun)
value.tm_zone = NULL;
value.tm_gmtoff = -1;
#endif
cTemp2 = const_cast<char*>(strpbrk (valueAsChar, "T"));
cTemp3 = strrchr (cTemp2, ':');
cTemp3[0] = '\0';
unsigned int len = strlen (cTemp2);
cTemp3[0] = ':';
/*if the timezone is represented adding 'Z' at the end */
if ((cTemp = const_cast<char*>(strpbrk (valueAsChar, "Z"))) != NULL)
{
time_t temp = mktime (&value);
if (temp == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&temp);
}
/*if the timezone is represented using +/-hh:mm format */
else if (len > (sizeof (char) * 6))
{
cUtc = strpbrk (cTemp2, "+");
if (cUtc == NULL)
{
cUtc = strpbrk (cTemp2, "-");
}
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int hours = 0;
int minutes = 0;
if (sscanf (cUtc + 1, "%d:%d", &hours, &minutes) != 2)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int secs = hours * 60 * 60 + minutes * 60;
if ((cTemp = strpbrk ((cUtc), "+")) != NULL)
{
timeInSecs += secs;
}
else
{
timeInSecs -= secs;
}
pTm = localtime (&timeInSecs);
memcpy (&value, pTm, sizeof (tm));
time_t t = mktime (&value);
if (t == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
t = labs (t - d);
pTm = gmtime (&t);
}
/*if the zone is not represented in the date */
else
{
/*else it is assumed that the sent time is localtime */
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = gmtime (&timeInSecs);
}
m_DateTime = new struct tm;
memcpy (m_DateTime, pTm, sizeof (tm));
return m_DateTime;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/DateTime.hpp
Index: DateTime.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(_DATETIME_HPP____OF_AXIS_INCLUDED_)
#define _DATETIME_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
#include <ctime>
AXIS_CPP_NAMESPACE_START
using namespace std;
class DateTime : public IAnySimpleType {
public:
/**
* 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 DateTime value to it's on-the-wire string form.
* @param value The DateTime value to be serialized.
* @return Serialized form of DateTime value.
*/
AxisChar* serialize(const struct tm* value) throw (AxisSoapException);
/**
* Deserialized DateTime value from it's on-the-wire string form.
* @param valueAsChar Serialized form of DateTime value.
* @return Deserialized Date value.
*/
struct tm* deserializeDateTime(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
struct tm* m_DateTime;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Decimal.cpp
Index: Decimal.cpp
===================================================================
#include "Decimal.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* Decimal::serialize(const void* value) throw (AxisSoapException)
{
return serialize((double*) value);
}
void* Decimal::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeDecimal(valueAsChar);
}
AxisChar* Decimal::serialize(const double* value) throw (AxisSoapException)
{
AxisSprintf (m_Buf, 80, "%f", *value);
return m_Buf;
}
double* Decimal::deserializeDecimal(const AxisChar* valueAsChar) throw (AxisSoapException)
{
AxisChar* end;
m_Decimal = new double;
*m_Decimal = strtod (valueAsChar, &end);
return m_Decimal;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Decimal.hpp
Index: Decimal.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(_DECIMAL_HPP____OF_AXIS_INCLUDED_)
#define _DECIMAL_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class Decimal : public IAnySimpleType {
public:
/**
* 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 Decimal value to it's on-the-wire string form.
* @param value The Decimal value to be serialized.
* @return Serialized form of Decimal value.
*/
AxisChar* serialize(const double* value) throw (AxisSoapException);
/**
* Deserialized Decimal value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Decimal value.
* @return Deserialized Decimal value.
*/
double* deserializeDecimal(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar m_Buf[80];
double* m_Decimal;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Double.cpp
Index: Double.cpp
===================================================================
#include "Double.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* Double::serialize(const void* value) throw (AxisSoapException)
{
return serialize((double*) value);
}
void* Double::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeDouble(valueAsChar);
}
AxisChar* Double::serialize(const double* value) throw (AxisSoapException)
{
AxisSprintf (m_Buf, 80, "%f", *value);
return m_Buf;
}
double* Double::deserializeDouble(const AxisChar* valueAsChar) throw (AxisSoapException)
{
AxisChar* end;
m_Double = new double;
*m_Double = strtod (valueAsChar, &end);
return m_Double;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Double.hpp
Index: Double.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(_DOUBLE_HPP____OF_AXIS_INCLUDED_)
#define _DOUBLE_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class Double : public IAnySimpleType {
public:
/**
* 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 Double value to it's on-the-wire string form.
* @param value The Double value to be serialized.
* @return Serialized form of Double value.
*/
AxisChar* serialize(const double* value) throw (AxisSoapException);
/**
* Deserialized Double value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Double value.
* @return Deserialized Double value.
*/
double* deserializeDouble(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar m_Buf[80];
double* m_Double;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Duration.cpp
Index: Duration.cpp
===================================================================
#include "Duration.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* Duration::serialize(const void* value) throw (AxisSoapException)
{
return serialize((long*) value);
}
void* Duration::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeDuration(valueAsChar);
}
AxisChar* Duration::serialize(const long* value) throw (AxisSoapException)
{
long valueToSerialize = *value;
AxisChar buff[4];
AxisString serializedValue;
/*
* Duration takes the form:
* PnYnMnDTnHnMnS
*/
serializedValue = "P";
// Calculate years
int x = 365 * 24 * 3600;
int intYears = valueToSerialize / x;
long tempYears = intYears * x;
AxisSprintf (buff, 4, "%d", intYears);
serializedValue.append (buff);
serializedValue.append ("Y");
// Calculate Months
valueToSerialize = valueToSerialize - (tempYears);
x = 30 * 24 * 3600;
int intMonths = valueToSerialize / x;
AxisSprintf (buff, 4, "%d", intMonths);
serializedValue.append (buff);
serializedValue.append ("M");
// Calculate Days
valueToSerialize = valueToSerialize - (intMonths * x);
x = 24 * 3600;
int intDays = valueToSerialize / x;
AxisSprintf (buff, 4, "%d", intDays);
serializedValue.append (buff);
serializedValue.append ("DT");
// Calculate Hours
valueToSerialize = valueToSerialize - (intDays * x);
x = 3600;
int intHours = valueToSerialize / x;
AxisSprintf (buff, 4, "%d", intHours);
serializedValue.append (buff);
serializedValue.append ("H");
// Calculate Minutes
valueToSerialize = valueToSerialize - (intHours * x);
x = 60;
int intMins = valueToSerialize / x;
AxisSprintf (buff, 4, "%d", intMins);
serializedValue.append (buff);
serializedValue.append ("M");
// Calculate Seconds
int intSecs = valueToSerialize - (intMins * x);
AxisSprintf (buff, 4, "%d", intSecs);
serializedValue.append (buff);
serializedValue.append ("S");
// Convert from String to Char[]
AxisChar* returnValue = (AxisChar*) serializedValue.c_str ();
m_Buf = new char[strlen (returnValue) + 1];
strcpy (m_Buf, returnValue);
return m_Buf;
}
long* Duration::deserializeDuration(const AxisChar* valueAsChar) throw (AxisSoapException)
{
AxisString valueAsString = valueAsChar;
AxisString buff;
unsigned int intPos1, intPos2, intPos3, intPos4, intPos5, intPos6;
/*XSD_DURATION is of the format PnYnMnDTnHnMnS */
// Deserialize Years
*m_Duration = 0;
intPos1 = valueAsString.find_first_of ("Y");
buff = valueAsString.substr (1, intPos1 - 1);
int years = atoi (buff.c_str ());
*m_Duration += years * 365 * 24 * 3600;
// Deserialize Months
intPos2 = valueAsString.find_first_of ("M");
buff = valueAsString.substr (intPos1 + 1, intPos2 - intPos1 - 1);
int months = atoi (buff.c_str ());
*m_Duration = months * 30 * 24 * 3600;
// Deserialize Days
intPos3 = valueAsString.find_first_of ("D");
buff = valueAsString.substr (intPos2 + 1, intPos3 - intPos2 - 1);
int days = atoi (buff.c_str ());
*m_Duration = days * 24 * 3600;
// Deserialize Hours
intPos4 = valueAsString.find_first_of ("H");
buff = valueAsString.substr (intPos3 + 2, intPos4 - intPos3 - 2);
int hours = atoi (buff.c_str ());
*m_Duration = hours * 3600;
// Deserialize Minutes
intPos5 = valueAsString.find_first_of ("M");
buff = valueAsString.substr (intPos4 + 1, intPos5 - intPos4 - 1);
int mins = atoi (buff.c_str ());
*m_Duration += mins * 60;
// Deserialize Seconds
intPos6 = valueAsString.find_first_of ("S");
buff = valueAsString.substr (intPos5 + 1, intPos6 - intPos5 - 1);
int secs = atoi (buff.c_str ());
*m_Duration += secs;
return m_Duration;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Duration.hpp
Index: Duration.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(_DURATION_HPP____OF_AXIS_INCLUDED_)
#define _DURATION_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
#include <string>
AXIS_CPP_NAMESPACE_START
using namespace std;
class Duration : public IAnySimpleType {
public:
/**
* 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 Duration value to it's on-the-wire string form.
* @param value The Duration value to be serialized.
* @return Serialized form of Duration value.
*/
AxisChar* serialize(const long* value) throw (AxisSoapException);
/**
* Deserialized Duration value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Duration value.
* @return Deserialized Duration value.
*/
long* deserializeDuration(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
long* m_Duration;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Float.cpp
Index: Float.cpp
===================================================================
#include "Float.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* Float::serialize(const void* value) throw (AxisSoapException)
{
return serialize((float*) value);
}
void* Float::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeFloat(valueAsChar);
}
AxisChar* Float::serialize(const float* value) throw (AxisSoapException)
{
AxisSprintf (m_Buf, 80, "%f", *value);
return m_Buf;
}
float* Float::deserializeFloat(const AxisChar* valueAsChar) throw (AxisSoapException)
{
AxisChar* end;
m_Float = new float;
*m_Float = (float) strtod (valueAsChar, &end);
return m_Float;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Float.hpp
Index: Float.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(_FLOAT_HPP____OF_AXIS_INCLUDED_)
#define _FLOAT_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class Float : public IAnySimpleType {
public:
/**
* 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 Float value to it's on-the-wire string form.
* @param value The Float value to be serialized.
* @return Serialized form of Float value.
*/
AxisChar* serialize(const float* value) throw (AxisSoapException);
/**
* Deserialized Float value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Float value.
* @return Deserialized Float value.
*/
float* deserializeFloat(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar m_Buf[80];
float* m_Float;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/HexBinary.cpp
Index: HexBinary.cpp
===================================================================
#include "HexBinary.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* HexBinary::serialize(const void* value) throw (AxisSoapException)
{
return serialize((xsd__hexBinary*) value);
}
void* HexBinary::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeHexBinary(valueAsChar);
}
AxisChar* HexBinary::serialize(const xsd__hexBinary* value) throw (AxisSoapException)
{
char* serializedValue = new char[value->__size * 2 + 1];
Hex_Encode (serializedValue, value->__ptr, value->__size);
serializedValue[value->__size * 2] = 0;
m_Buf = new char[strlen (serializedValue) + 1];
strcpy (m_Buf, serializedValue);
return m_Buf;
}
xsd__hexBinary* HexBinary::deserializeHexBinary(const AxisChar* valueAsChar) throw (AxisSoapException)
{
m_hexBinary = new xsd__hexBinary();
m_hexBinary->__size = strlen (valueAsChar) / 2;
m_hexBinary->__ptr = new unsigned char[m_hexBinary->__size + 1];
Hex_Decode (m_hexBinary->__ptr, valueAsChar);
/* put null at the end because it enables the decoded string to be used
* as a string
*/
m_hexBinary->__ptr[m_hexBinary->__size] = 0;
return m_hexBinary;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/HexBinary.hpp
Index: HexBinary.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(_HEXBINARY_HPP____OF_AXIS_INCLUDED_)
#define _HEXBINARY_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
#include <axis/AxisUserAPI.hpp>
#include "../HexCoder.h"
AXIS_CPP_NAMESPACE_START
using namespace std;
class HexBinary : public IAnySimpleType {
public:
/**
* 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 HexBinary value to it's on-the-wire string form.
* @param value The HexBinary value to be serialized.
* @return Serialized form of HexBinary value.
*/
AxisChar* serialize(const xsd__hexBinary* value) throw (AxisSoapException);
/**
* Deserialized HexBinary value from it's on-the-wire string form.
* @param valueAsChar Serialized form of HexBinary value.
* @return Deserialized HexBinary value.
*/
xsd__hexBinary* deserializeHexBinary(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
xsd__hexBinary* m_hexBinary;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/IAnySimpleType.cpp
Index: IAnySimpleType.cpp
===================================================================
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
const AxisString& IAnySimpleType::replaceReservedCharacters(AxisString &value)
{
m_strReturnVal = "";
if (value.empty ())
{
return value;
}
/* Find entity reference characters and returns the first any of chars find
* position
*/
unsigned int nPos = value.find_first_of (XML_ENTITY_REFERENCE_CHARS);
/* Check for position validity */
if (AxisString::npos == nPos)
{
return value;
}
int nOldIdx = 0; // Counter value
while (AxisString::npos != nPos)
{ // Get pointered character
switch (value.at (nPos))
{
case LESSER_THAN_CHAR: // Process < character
m_strReturnVal.append (value.substr (nOldIdx, nPos - nOldIdx));
m_strReturnVal.append (ENCODED_LESSER_STR);
break;
case GREATER_THAN_CHAR: // Process > character
m_strReturnVal.append (value.substr (nOldIdx, nPos - nOldIdx));
m_strReturnVal.append (ENCODED_GREATER_STR);
break;
case AMPERSAND_CHAR: // Process & character
m_strReturnVal.append (value.substr (nOldIdx, nPos - nOldIdx));
m_strReturnVal.append (ENCODED_AMPERSAND_STR);
break;
case DOUBLE_QUOTE_CHAR: // Process " character
m_strReturnVal.append (value.substr (nOldIdx, nPos - nOldIdx));
m_strReturnVal.append (ENCODED_DBL_QUOTE_STR);
break;
case SINGLE_QUOTE_CHAR: // Process ' character
m_strReturnVal.append (value.substr (nOldIdx, nPos - nOldIdx));
m_strReturnVal.append (ENCODED_SGL_QUOTE_STR);
break;
}
nOldIdx = ++nPos; // Get old position
/* Find the next entity reference characters from previous found
* position,
*/
nPos = value.find_first_of (XML_ENTITY_REFERENCE_CHARS, nPos);
}
int nDataLen = value.length (); // Get the length of the field value
int nLen = nDataLen - nOldIdx; // Get remaining number of characters
if (nLen > 0)
{
m_strReturnVal += value.substr (nOldIdx, nLen); /* Apend the remaining
* data
*/
}
return m_strReturnVal;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/IAnySimpleType.hpp
Index: IAnySimpleType.hpp
===================================================================
/*
* 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.
*/
/*
* @file IAnySimpleType.hpp
*/
#if !defined(_IANYSIMPLETYPE_HPP____OF_AXIS_INCLUDED_)
#define _IANYSIMPLETYPE_HPP____OF_AXIS_INCLUDED_
#include <axis/GDefine.hpp>
#include <string>
#include "../AxisSoapException.h"
AXIS_CPP_NAMESPACE_START
const AxisChar XML_ENTITY_REFERENCE_CHARS[] = "<>&\"\'";
/* Entity reference characters */
const AxisChar ENCODED_LESSER_STR[] = "<";
/* Encoded string for less than character */
const AxisChar ENCODED_GREATER_STR[] = ">";
/* Encoded string for greator than character */
const AxisChar ENCODED_AMPERSAND_STR[] = "&";
/* Encoded string for ampersand character */
const AxisChar ENCODED_DBL_QUOTE_STR[] = """;
/* Encoded string for single quote character */
const AxisChar ENCODED_SGL_QUOTE_STR[] = "'";
/* Encoded string for double quote character */
/**
* @class IAnySimpleType
* @brief Interface for all XSD built-in simple type.
*
* @author Adrian Dick (adrian.dick@uk.ibm.com)
*
*/
class IAnySimpleType {
public:
virtual ~IAnySimpleType() {};
/**
* Serialize value to it's on-the-wire string form.
* @param value The value to be serialized.
* @return Serialized form of value.
*/
virtual AxisChar* serialize(const void* value) throw (AxisSoapException) = 0;
/**
* Deserialize value from it's on-the-wire string form.
* @param valueAsChar Serialized form of value.
* @return Deserialized value.
*/
virtual void* deserialize(const AxisChar* valueAsChar) throw (AxisSoapException) = 0;
protected:
const AxisString& replaceReservedCharacters(AxisString& value);
enum
{
GREATER_THAN_CHAR = L'>', /* Greater than character */
LESSER_THAN_CHAR = L'<', /* Less than character */
SINGLE_QUOTE_CHAR = L'\'', /* Single quotation character */
DOUBLE_QUOTE_CHAR = L'\"', /* Double quotation character */
AMPERSAND_CHAR = L'&' /* Ampersand character */
};
private:
AxisString m_strReturnVal;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/NOTATION.cpp
Index: NOTATION.cpp
===================================================================
#include "NOTATION.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* NOTATION::serialize(const void* value) throw (AxisSoapException)
{
return serialize((AxisChar*) value);
}
void* NOTATION::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeNOTATION(valueAsChar);
}
AxisChar* NOTATION::serialize(const AxisChar* value) throw (AxisSoapException)
{
AxisString valueAsString = value;
AxisChar* returnValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
m_Buf = new char[strlen (returnValue) + 1];
strcpy (m_Buf, returnValue);
return m_Buf;
}
AxisChar* NOTATION::deserializeNOTATION(const AxisChar* valueAsChar) throw (AxisSoapException)
{
m_Buf = new char[strlen (valueAsChar) + 1];
strcpy (m_Buf, valueAsChar);
return m_Buf;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/NOTATION.hpp
Index: NOTATION.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(_NOTATION_HPP____OF_AXIS_INCLUDED_)
#define _NOTATION_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class NOTATION : public IAnySimpleType {
public:
AxisChar* serialize(const void* value) throw (AxisSoapException);
void* deserialize(const AxisChar* valueAsChar) throw (AxisSoapException);
AxisChar* serialize(const AxisChar* value) throw (AxisSoapException);
AxisChar* deserializeNOTATION(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/String.cpp
Index: String.cpp
===================================================================
#include "String.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* String::serialize(const void* value) throw (AxisSoapException)
{
return serialize((AxisChar*) value);
}
void* String::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeString(valueAsChar);
}
AxisChar* String::serialize(const AxisChar* value) throw (AxisSoapException)
{
AxisString valueAsString = value;
AxisChar* returnValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
m_Buf = new char[strlen (returnValue) + 1];
strcpy (m_Buf, returnValue);
return m_Buf;
}
AxisChar* String::deserializeString(const AxisChar* valueAsChar) throw (AxisSoapException)
{
m_Buf = new char[strlen (valueAsChar) + 1];
strcpy (m_Buf, valueAsChar);
return m_Buf;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/String.hpp
Index: String.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(_STRING_HPP____OF_AXIS_INCLUDED_)
#define _STRING_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class String : public IAnySimpleType {
public:
AxisChar* serialize(const void* value) throw (AxisSoapException);
void* deserialize(const AxisChar* valueAsChar) throw (AxisSoapException);
AxisChar* serialize(const AxisChar* value) throw (AxisSoapException);
AxisChar* deserializeString(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/Time.cpp
Index: Time.cpp
===================================================================
#include "Time.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* Time::serialize(const void* value) throw (AxisSoapException)
{
return serialize((struct tm*) value);
}
void* Time::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeTime(valueAsChar);
}
AxisChar* Time::serialize(const struct tm* value) throw (AxisSoapException)
{
AxisChar* serializedValue = new AxisChar[80];
strftime (serializedValue, 80, "%H:%M:%SZ", value);
m_Buf = new char[strlen (serializedValue) + 1];
strcpy (m_Buf, serializedValue);
return m_Buf;
}
struct tm* Time::deserializeTime(const AxisChar* valueAsChar) throw (AxisSoapException)
{
struct tm value;
struct tm *pTm;
AxisChar *cUtc;
AxisChar *cTemp;
AxisChar *cTemp2;
AxisChar *cTemp3;
time_t now;
time (&now);
pTm = gmtime (&now);
struct tm result1;
memcpy (&result1, pTm, sizeof (tm));
pTm = localtime (&now);
struct tm result2;
memcpy (&result2, pTm, sizeof (tm));
time_t d = mktime (&result1) - mktime (&result2);
if (d == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
/* dismantle m_sValue to get tm value;
* XSD_TIME format is
* hh:mm:ss.ss...Z OR
* hh:mm:ss.ss...+/-<UTC TIME DIFFERENCE>
*/
if (sscanf (valueAsChar, "%d:%d:%d", &value.tm_hour,
&value.tm_min, &value.tm_sec) != 3)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
value.tm_year = 70;
value.tm_mon = 0;
value.tm_mday = 1; /* Day of month (1 - 31) */
value.tm_isdst = -1;
#if !defined(WIN32) && !defined(AIX) && !defined( __OS400__ ) && !defined(__sun)
value.tm_zone = NULL;
value.tm_gmtoff = -1;
#endif
cTemp2 = (char*) valueAsChar;
cTemp3 = strrchr (cTemp2, ':');
cTemp3[0] = '\0';
unsigned int len = strlen (cTemp2);
cTemp3[0] = ':';
/* if the timezone is represented adding 'Z' at the end */
if ((cTemp = const_cast<char*>(strpbrk (valueAsChar, "Z"))) != NULL)
{
time_t temp = mktime (&value);
if (temp == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = localtime (&temp);
}
/* if the timezone is represented using +/-hh:mm format */
else if (len > (sizeof (char) * 6))
{
cUtc = strpbrk (cTemp2, "+");
if (cUtc == NULL)
{
cUtc = strpbrk (cTemp2, "-");
}
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int hours = 0;
int mins = 0;
if (sscanf (cUtc + 1, "%d:%d", &hours, &mins) != 2)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
int secs = hours * 60 * 60 + mins * 60;
if ((cTemp = strpbrk ((cUtc), "+")) != NULL)
{
timeInSecs += secs;
}
else
{
timeInSecs -= secs;
}
pTm = localtime (&timeInSecs);
memcpy (&value, pTm, sizeof (tm));
time_t t = mktime (&value);
if (t == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
//t = fabs (t - d);
t = labs (t - d); // Samisa - use correct typed methods - we need long int; not double
pTm = gmtime (&t);
}
/* if the zone is not represented in the date */
else
{
/* else it is assumed that the sent time is localtime */
// memcpy(&m_TMUTC, &m_TM, sizeof(tm));
time_t timeInSecs = mktime (&value);
if (timeInSecs == -1)
{
throw new AxisSoapException(CLIENT_SOAP_SOAP_CONTENT_ERROR);
}
pTm = gmtime (&timeInSecs);
}
m_Time = new struct tm;
memcpy (m_Time, pTm, sizeof (tm));
return m_Time;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/Time.hpp
Index: Time.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(_TIME_HPP____OF_AXIS_INCLUDED_)
#define _TIME_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
#include <ctime>
AXIS_CPP_NAMESPACE_START
using namespace std;
class Time : public IAnySimpleType {
public:
/**
* 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 Time value to it's on-the-wire string form.
* @param value The Time value to be serialized.
* @return Serialized form of Time value.
*/
AxisChar* serialize(const struct tm* value) throw (AxisSoapException);
/**
* Deserialized Time value from it's on-the-wire string form.
* @param valueAsChar Serialized form of Time value.
* @return Deserialized Time value.
*/
struct tm* deserializeTime(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
struct tm* m_Time;
};
AXIS_CPP_NAMESPACE_END
#endif
1.1 ws-axis/c/src/soap/xsd/XSD_QName.cpp
Index: XSD_QName.cpp
===================================================================
#include "XSD_QName.hpp"
AXIS_CPP_NAMESPACE_START
AxisChar* XSD_QName::serialize(const void* value) throw (AxisSoapException)
{
return serialize((AxisChar*) value);
}
void* XSD_QName::deserialize(const AxisChar* valueAsChar) throw (AxisSoapException)
{
return (void*) deserializeQName(valueAsChar);
}
AxisChar* XSD_QName::serialize(const AxisChar* value) throw (AxisSoapException)
{
AxisString valueAsString = value;
AxisChar* returnValue = (AxisChar*) replaceReservedCharacters(valueAsString).c_str();
m_Buf = new char[strlen (returnValue) + 1];
strcpy (m_Buf, returnValue);
return m_Buf;
}
AxisChar* XSD_QName::deserializeQName(const AxisChar* valueAsChar) throw (AxisSoapException)
{
m_Buf = new char[strlen (valueAsChar) + 1];
strcpy (m_Buf, valueAsChar);
return m_Buf;
}
AXIS_CPP_NAMESPACE_END
1.1 ws-axis/c/src/soap/xsd/XSD_QName.hpp
Index: XSD_QName.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(_QNAME_HPP____OF_AXIS_INCLUDED_)
#define _QNAME_HPP____OF_AXIS_INCLUDED_
#include "IAnySimpleType.hpp"
AXIS_CPP_NAMESPACE_START
using namespace std;
class XSD_QName : public IAnySimpleType {
public:
/**
* 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 QName to it's on-the-wire string form.
* @param value The QName to be serialized.
* @return Serialized form of QName.
*/
AxisChar* serialize(const AxisChar* value) throw (AxisSoapException);
/**
* Deserialize QName from it's on-the-wire string form.
* @param valueAsChar Serialized form of QName.
* @return Deserialized QName.
*/
AxisChar* deserializeQName(const AxisChar* valueAsChar) throw (AxisSoapException);
private:
AxisChar* m_Buf;
};
AXIS_CPP_NAMESPACE_END
#endif