You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by gw...@apache.org on 2007/02/02 14:12:46 UTC
svn commit: r502599 [4/4] - in /incubator/tuscany/cpp/sdo:
VSExpress/tuscany_sdo/sdo_runtime/ runtime/core/src/commonj/sdo/
runtime/core/test/
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp?view=diff&rev=502599&r1=502598&r2=502599
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp Fri Feb 2 05:12:45 2007
@@ -484,7 +484,7 @@
}
const Property& TypeImpl::getProperty(const SDOString& propertyName) const
{
- PropertyImpl* pi = getPropertyImpl(propertyName); // ??? GMW
+ PropertyImpl* pi = getPropertyImpl(propertyName);
if (pi == 0)
{
string msg("Property not found:");
@@ -2128,6 +2128,43 @@
return 0;
}
+unsigned int TypeImpl::convertToString(const SDOValue& sdoValue,
+ wchar_t* outval,
+ unsigned int max) const
+{
+ switch (typeEnum)
+ {
+ case BigDecimalType:
+ case BigIntegerType:
+ case UriType:
+ case StringType:
+ case BytesType:
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case ShortType:
+ case IntegerType:
+ case LongType:
+ case DateType:
+ case DoubleType:
+ case FloatType:
+ return sdoValue.getString(outval, max);
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get String from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getString" ,
+ SDOInvalidConversionException,
+ msg.c_str());
+ break;
+ }
+ }
+ return 0;
+}
+
unsigned int TypeImpl::convertToBytes(void* value, char* outval, unsigned int len,
unsigned int max) const
{
@@ -2261,6 +2298,40 @@
return 0;
}
+ unsigned int TypeImpl::convertToBytes(const SDOValue& sdoValue, char* outptr, unsigned int max) const
+ {
+ unsigned int i;
+ switch (typeEnum)
+ {
+ case BytesType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case UriType:
+ case StringType:
+ case BooleanType:
+ case CharacterType:
+ case ByteType:
+ case ShortType:
+ case IntegerType:
+ case LongType:
+ case DateType:
+ case DoubleType:
+ case FloatType:
+ return sdoValue.getBytes(outptr, max);
+
+ case DataObjectType:
+ case OtherTypes:
+ default:
+ string msg("Cannot get Bytes from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getBytes" ,
+ SDOInvalidConversionException,
+ msg.c_str());
+ }
+ return 0;
+ }
+
+
// +++
// value is a pointer to the byte stream that is the value to convert
@@ -2594,6 +2665,42 @@
return 0;
}
+ const char* TypeImpl::convertToCString(const SDOValue& sdoValue) const
+ {
+
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getCString();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get CString from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getCString" ,
+ SDOInvalidConversionException,
+ msg.c_str());
+ }
+ return 0;
+ }
+ }
+
+
const bool TypeImpl::convertToBoolean(void* value, unsigned int len) const
{
switch (typeEnum)
@@ -2689,6 +2796,41 @@
}
+ const bool TypeImpl::convertToBoolean(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getBoolean();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get Boolean from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getBoolean" ,
+ SDOInvalidConversionException,
+ msg.c_str());
+ break;
+ }
+ }
+ }
+
+
const char TypeImpl::convertToByte(void* value , unsigned int len) const
{
switch (typeEnum)
@@ -2784,6 +2926,41 @@
}
}
+ const char TypeImpl::convertToByte(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getByte();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get Byte from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getByte",
+ SDOInvalidConversionException,
+ msg.c_str());
+ break;
+ }
+ }
+ }
+
+
const wchar_t TypeImpl::convertToCharacter(void* value, unsigned int len) const
{
switch (typeEnum)
@@ -2859,6 +3036,43 @@
}
}
}
+
+
+ const wchar_t TypeImpl::convertToCharacter(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getCharacter();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get Character from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getCharacter" ,
+ SDOInvalidConversionException, msg.c_str());
+ break;
+ }
+ }
+ }
+
+
+
const short TypeImpl::convertToShort(void* value, unsigned int len) const
{
#if ! defined(WIN32) && !defined (_WINDOWS)
@@ -2949,6 +3163,40 @@
}
}
+ const short TypeImpl::convertToShort(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getShort();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get Short from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getShort" ,
+ SDOInvalidConversionException,
+ msg.c_str());
+ break;
+ }
+ }
+ }
+
/* const int TypeImpl::convertToInt(void* value, unsigned int len) const
{
@@ -3143,6 +3391,42 @@
}
}
}
+
+ const long TypeImpl::convertToInteger(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getInteger();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get Long from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getLong" ,
+ SDOInvalidConversionException,
+ msg.c_str());
+ break;
+ }
+ }
+ }
+
+
const int64_t TypeImpl::convertToLong(void* value, unsigned int len) const
{
#if ! defined(WIN32) && ! defined (_WINDOWS)
@@ -3245,6 +3529,41 @@
}
}
}
+
+ const int64_t TypeImpl::convertToLong(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case CharacterType:
+ case ByteType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getLong();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get Long Long from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getLongLong" ,
+ SDOInvalidConversionException, msg.c_str());
+ break;
+ }
+ }
+ }
+
+
const float TypeImpl::convertToFloat(void* value, unsigned int len) const
{
switch (typeEnum)
@@ -3524,6 +3843,74 @@
}
}
}
+
+ const long double TypeImpl::convertToDouble(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getDouble();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get double from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getDouble" ,
+ SDOInvalidConversionException, msg.c_str());
+ break;
+ }
+ }
+ }
+
+ const float TypeImpl::convertToFloat(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case BooleanType:
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BigDecimalType:
+ case BigIntegerType:
+ case StringType:
+ case UriType:
+ case BytesType:
+ return sdoValue.getFloat();
+
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get float from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getFloat" ,
+ SDOInvalidConversionException, msg.c_str());
+ break;
+ }
+ }
+ }
+
+
const SDODate TypeImpl::convertToDate(void* value, unsigned int len) const
{
switch (typeEnum)
@@ -3589,6 +3976,42 @@
}
}
}
+
+ const SDODate TypeImpl::convertToDate(const SDOValue& sdoValue) const
+ {
+ switch (typeEnum)
+ {
+ case ByteType:
+ case CharacterType:
+ case IntegerType:
+ case ShortType:
+ case DoubleType:
+ case FloatType:
+ case LongType:
+ case DateType:
+ case BooleanType:
+ case BytesType:
+ case StringType:
+ return sdoValue.getDate();
+
+ case BigDecimalType:
+ case BigIntegerType:
+ case UriType:
+ case OtherTypes:
+ case DataObjectType:
+ default:
+ {
+ string msg("Cannot get Date from object of type:");
+ msg += getName();
+ SDO_THROW_EXCEPTION("getDate" ,
+ SDOInvalidConversionException,
+ msg.c_str());
+ break;
+ }
+ }
+ }
+
+
DataObject* TypeImpl::convertToDataObject(void* value, unsigned int len) const
{
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h?view=diff&rev=502599&r1=502598&r2=502599
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h Fri Feb 2 05:12:45 2007
@@ -30,6 +30,7 @@
#include "commonj/sdo/DASType.h"
#include "commonj/sdo/PropertyImpl.h"
#include "commonj/sdo/SDODate.h"
+#include "commonj/sdo/SDOValue.h"
#define MAX_LONG_SIZE 20
@@ -97,22 +98,36 @@
unsigned int convert( void ** value,DataObject* dob) const;
const char* convertToCString( void* value , char** inbuf, unsigned int len) const;
+ const char* convertToCString(const SDOValue& sdoValue) const;
const bool convertToBoolean( void* value, unsigned int len) const;
+ const bool convertToBoolean(const SDOValue& sdoValue) const;
const char convertToByte( void* value,unsigned int len ) const;
+ const char convertToByte(const SDOValue& sdoValue) const;
unsigned int convertToString( void* value , wchar_t* val, unsigned int len,
unsigned int max) const;
+ unsigned int convertToString(const SDOValue& sdoValue,
+ wchar_t* val,
+ unsigned int max) const;
unsigned int convertToBytes( void* value , char* val, unsigned int len,
unsigned int max) const;
+ unsigned int convertToBytes(const SDOValue& sdoValue , char* val, unsigned int max) const;
unsigned int convertToBytes( const void* value , SDOString& val, unsigned int len,
unsigned int max) const;
const wchar_t convertToCharacter( void* value ,unsigned int len) const;
+ const wchar_t convertToCharacter(const SDOValue& sdoValue) const;
const short convertToShort( void* value ,unsigned int len) const;
+ const short convertToShort(const SDOValue& sdoValue) const;
const long convertToInteger( void* value ,unsigned int len) const;
+ const long convertToInteger(const SDOValue& sdoValue) const;
const int64_t convertToLong( void* value ,unsigned int len) const;
+ const int64_t convertToLong(const SDOValue& sdoValue) const;
const float convertToFloat( void* value ,unsigned int len) const;
+ const float convertToFloat(const SDOValue& sdoValue) const;
const long double convertToDouble(void* value ,unsigned int len) const;
+ const long double convertToDouble(const SDOValue& sdoValue) const;
DataObject* convertToDataObject(void* value ,unsigned int len) const;
const SDODate convertToDate (void* value ,unsigned int len) const;
+ const SDODate convertToDate (const SDOValue& sdoValue) const;
/** equals - compares
*
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt?view=diff&rev=502599&r1=502598&r2=502599
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/maintest.txt Fri Feb 2 05:12:45 2007
@@ -183,6 +183,6 @@
Department: Architecture
Department: Pyrotechnics
Department: Accounts
-Normal expected exception
+String in list type:department label
Normal Invalid path exception
Normal SDOPropertyNotFound exception
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp?view=diff&rev=502599&r1=502598&r2=502599
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.cpp Fri Feb 2 05:12:45 2007
@@ -908,389 +908,422 @@
int sdotest::testGetter(DataObjectPtr dor, char* str)
{
-
- try {
- bool b = dor->getBoolean(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
- if (!strcmp(str,"dataobject")) return 1;
+ try
+ {
+ bool b = dor->getBoolean(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent)
+ {
+ cout << "WRONG unset and undefaulted" << endl;
+ }
return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
+ if (!strcmp(str,"dataobject"))
+ {
+ return 1;
+ }
+ return 0;
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
-
- try {
- char by = dor->getByte(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ char by = dor->getByte(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- wchar_t cy = dor->getCharacter(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ wchar_t cy = dor->getCharacter(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- short s = dor->getShort(str);
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ short s = dor->getShort(str);
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
if (!strcmp(str,"bytes")) return 1;
return 0;
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- int i = dor->getInteger(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ int i = dor->getInteger(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- long l = dor->getLong(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ long l = dor->getLong(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- int64_t ll = dor->getLong(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ int64_t ll = dor->getLong(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- float f = dor->getFloat(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ float f = dor->getFloat(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- long double d = dor->getDouble(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ long double d = dor->getDouble(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
-
- unsigned int len;
-
- try {
- len = dor->getLength(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
- if (!strcmp(str,"dataobject")) return 1;
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
return 0;
+ }
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ unsigned int len;
- if (len > 0) {
- try {
- wchar_t * buf = new wchar_t[len];
- unsigned int gotlen = dor->getString(str,buf,len);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
- if (!strcmp(str,"dataobject")) return 1;
- return 0;
+ try {
+ len = dor->getLength(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent)
+ {
+ cout << "WRONG unset and undefaulted" << endl;
+ }
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
+ if (!strcmp(str,"dataobject"))
+ {
+ return 1;
+ }
+ return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
- try {
- char * cbuf = new char[len];
- unsigned int gotlen = dor->getBytes(str,cbuf,len);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
- if (!strcmp(str,"dataobject")) return 1;
- return 0;
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
- }
+ if (len > 0) {
+ try {
+ wchar_t * buf = new wchar_t[len];
+ unsigned int gotlen = dor->getString(str,buf,len);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
+ if (!strcmp(str,"dataobject")) return 1;
+ return 0;
+
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
+ try {
+ char * cbuf = new char[len];
+ unsigned int gotlen = dor->getBytes(str,cbuf,len);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
+ if (!strcmp(str,"dataobject")) return 1;
+ return 0;
+
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
+ }
+
+ try {
+ SDODate t = dor->getDate(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << " WRONG unset and undefaulted" << endl;
+ return 0;
+ }
- try {
- SDODate t = dor->getDate(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << " WRONG unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
- if (!strcmp(str,"boolean")) return 1;
- if (!strcmp(str,"boolean")) return 1;
- if (!strcmp(str,"string")) return 1;
- if (!strcmp(str,"dataobject")) return 1;
+ // The following catch block returns to the caller, regardless of whether
+ // the getDate call succeeded or failed. This has the effect of aborting
+ // further tests in this method. Similar remarks apply to many of the catch
+ // blocks here. They should be cleaned up so that as many tests as possible
+ // are run, certainly when predecessors succeed and preferably even if they fail.
+ catch (SDOInvalidConversionException ec)
+ {
+ if (!strcmp(str,"bytes")) return 1;
+ if (!strcmp(str,"boolean")) return 1;
+ if (!strcmp(str,"string")) return 1;
+ if (!strcmp(str,"dataobject")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- try {
- const char * string = dor->getCString(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG - unset and undefaulted" << endl;
- return 0;
- }
- catch (SDOInvalidConversionException ec)
- {
+ try {
+ const char * string = dor->getCString(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG - unset and undefaulted" << endl;
+ return 0;
+ }
+ catch (SDOInvalidConversionException ec)
+ {
if (!strcmp(str,"dataobject")) return 1;
if (!strcmp(str,"date")) return 1;
return 0;
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
-
- try {
- DataObjectPtr dob = dor->getDataObject(str);
- }
- catch (SDOPropertyNotSetException pe)
- {
- if (!silent) cout << "WRONG unset and undefaulted" << endl;
- return 0;
- }
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
- catch (SDOInvalidConversionException ec)
- {
- if (!strcmp(str,"dataobject")) return 0;
- return 1;
+ try {
+ DataObjectPtr dob = dor->getDataObject(str);
+ }
+ catch (SDOPropertyNotSetException pe)
+ {
+ if (!silent) cout << "WRONG unset and undefaulted" << endl;
+ return 0;
+ }
- }
- catch (SDORuntimeException e)
- {
- if (!silent) cout << e.getEClassName() << endl;
- return 0;
- }
- return 1;
+ catch (SDOInvalidConversionException ec)
+ {
+ if (!strcmp(str,"dataobject")) return 0;
+ return 1;
+
+ }
+ catch (SDORuntimeException e)
+ {
+ if (!silent) cout << e.getEClassName() << endl;
+ return 0;
+ }
+ return 1;
}
int sdotest::conversiontest()
{
- //cout << "Conversion tests" << endl;
- DataFactoryPtr mdg = DataFactory::getDataFactory();
- mdg->addType("myspace","Container");
- mdg->addType("myspace","Contained");
- mdg->addPropertyToType("myspace","Container","boolean","commonj.sdo","Boolean");
- mdg->addPropertyToType("myspace","Container","byte","commonj.sdo","Byte");
- mdg->addPropertyToType("myspace","Container","character","commonj.sdo","Character");
- mdg->addPropertyToType("myspace","Container","short","commonj.sdo","Short");
- mdg->addPropertyToType("myspace","Container","integer","commonj.sdo","Integer");
- mdg->addPropertyToType("myspace","Container","long","commonj.sdo","Long");
- mdg->addPropertyToType("myspace","Container","float","commonj.sdo","Float");
- mdg->addPropertyToType("myspace","Container","double","commonj.sdo","Double");
- mdg->addPropertyToType("myspace","Container","string","commonj.sdo","String");
- mdg->addPropertyToType("myspace","Container","bytes","commonj.sdo","Bytes");
- mdg->addPropertyToType("myspace","Container","dataobject","myspace","Contained");
- mdg->addPropertyToType("myspace","Container","date","commonj.sdo","Date");
- mdg->addPropertyToType("myspace","Container","bigint","commonj.sdo","BigInteger");
- mdg->addPropertyToType("myspace","Container","bigdec","commonj.sdo","BigDecimal");
-
-
- const Type& tcc = mdg->getType("myspace","Container");
- DataObjectPtr dor = mdg->create((Type&)tcc);
-
- // phase 1 - all unset.......
-
- // cout << "+++++++++++++++PROPERTY VALUES UNSET ++++++++++++++++++" << endl;
-
- if (!testGetters(dor)) return 0;
-
- // cout << "+++++++++++++++PROPERTY VALUES SET ++++++++++++++++++++" << endl;
-
- // RHEL 4 has problems processing 64 bit integer constants, so we'll do it the hard way
- // This is overkill but gives the option to vary the value a bit.
-
- int64_t largeInt = 0xFFFF;
- for (int j = 0; j < 2; j++)
- {
- largeInt <<= 16;
- largeInt += 0xFFFF;
- }
-
- DataObjectPtr sub = dor->createDataObject("dataobject");
- dor->setBoolean("boolean", true);
- dor->setByte("byte",20);
- dor->setCharacter("character", 1000);
- dor->setShort("short", (short)12345678);
- dor->setInteger("integer", 87654321);
- dor->setLong("long", largeInt);
- dor->setFloat("float", (float)12345.678);
- dor->setDouble("double", 1234567.891);
- dor->setDate("date", 37575);
- wchar_t* chars = new wchar_t[50];
- for (int i=0;i<50;i++) {chars[i] = 0x7F20 + i ;}
- dor->setString("string",chars, 50);
-
- char* tchars = new char[50];
- for (int ii=0;ii<50;ii++) {tchars[ii] = ii + 32;}
- dor->setBytes("bytes",tchars, 50);
-
-
- if (!testGetters(dor)) return 0;
+ if (!silent)
+ {
+ cout << "Conversion tests" << endl;
+ }
+
+ DataFactoryPtr mdg = DataFactory::getDataFactory();
+ mdg->addType("myspace","Container");
+ mdg->addType("myspace","Contained");
+ mdg->addPropertyToType("myspace","Container","boolean","commonj.sdo","Boolean");
+ mdg->addPropertyToType("myspace","Container","byte","commonj.sdo","Byte");
+ mdg->addPropertyToType("myspace","Container","character","commonj.sdo","Character");
+ mdg->addPropertyToType("myspace","Container","short","commonj.sdo","Short");
+ mdg->addPropertyToType("myspace","Container","integer","commonj.sdo","Integer");
+ mdg->addPropertyToType("myspace","Container","long","commonj.sdo","Long");
+ mdg->addPropertyToType("myspace","Container","float","commonj.sdo","Float");
+ mdg->addPropertyToType("myspace","Container","double","commonj.sdo","Double");
+ mdg->addPropertyToType("myspace","Container","string","commonj.sdo","String");
+ mdg->addPropertyToType("myspace","Container","bytes","commonj.sdo","Bytes");
+ mdg->addPropertyToType("myspace","Container","dataobject","myspace","Contained");
+ mdg->addPropertyToType("myspace","Container","date","commonj.sdo","Date");
+ mdg->addPropertyToType("myspace","Container","bigint","commonj.sdo","BigInteger");
+ mdg->addPropertyToType("myspace","Container","bigdec","commonj.sdo","BigDecimal");
+
+ const Type& tcc = mdg->getType("myspace","Container");
+ DataObjectPtr dor = mdg->create((Type&)tcc);
+
+ if (!silent)
+ {
+ cout << "+++++++++++++++PROPERTY VALUES UNSET ++++++++++++++++++" << endl;
+ }
+
+ if (!testGetters(dor))
+ {
+ return 0;
+ }
+
+ if (!silent)
+ {
+ cout << "+++++++++++++++PROPERTY VALUES SET ++++++++++++++++++++" << endl;
+ }
+
+ // RHEL 4 has problems processing 64 bit integer constants, so we'll do it
+ // the hard way. This is overkill but gives the option to vary the value a
+ // bit.
+
+ int64_t largeInt = 0xFFFF;
+ for (int j = 0; j < 2; j++)
+ {
+ largeInt <<= 16;
+ largeInt += 0xFFFF;
+ }
+
+ DataObjectPtr sub = dor->createDataObject("dataobject");
+ dor->setBoolean("boolean", true);
+ dor->setByte("byte",20);
+ dor->setCharacter("character", 1000);
+ dor->setShort("short", (short)12345678);
+ dor->setInteger("integer", 87654321);
+ dor->setLong("long", largeInt);
+ dor->setFloat("float", (float)12345.678);
+ dor->setDouble("double", 1234567.891);
+ dor->setDate("date", 37575);
+ wchar_t* chars = new wchar_t[50];
+ for (int i=0;i<50;i++) {chars[i] = 0x7F20 + i ;}
+ dor->setString("string",chars, 50);
+
+ char* tchars = new char[50];
+ for (int ii=0;ii<50;ii++) {tchars[ii] = ii + 32;}
+ dor->setBytes("bytes",tchars, 50);
- // cout << "+++++++++++++++END OF TEST ++++++++++++++++++++++++++++" << endl;
+ if (!testGetters(dor))
+ {
+ return 0;
+ }
- return 1;
+ if (!silent)
+ {
+ cout << "+++++++++++++++END OF TEST ++++++++++++++++++++++++++++" << endl;
+ }
+
+ return 1;
}
@@ -2989,7 +3022,9 @@
dor->setCString("departments","department label");
const char* slabel = dor->getCString("departments");
fprintf(f, "String in list type:%s\n", slabel);
- return 0;
+ // SDOValue change. Setting values usually works now, so no
+ //exception expected (the error is thrown on the get)
+ //return 0;
}
catch (SDORuntimeException e)
{
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org