You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by ed...@apache.org on 2006/06/06 16:16:37 UTC
svn commit: r412127 [1/2] - in /incubator/tuscany/cpp/sdo:
projects/tuscany_sdo/sdo_axiom_test/ runtime/core/src/commonj/sdo/
Author: edslattery
Date: Tue Jun 6 07:16:35 2006
New Revision: 412127
URL: http://svn.apache.org/viewvc?rev=412127&view=rev
Log:
patch for JIRA 443
Modified:
incubator/tuscany/cpp/sdo/projects/tuscany_sdo/sdo_axiom_test/sdo_axiom_test.dsp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObject.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/TypeImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XMLDocumentImpl.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XMLHelperImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/XSDHelperImpl.cpp
Modified: incubator/tuscany/cpp/sdo/projects/tuscany_sdo/sdo_axiom_test/sdo_axiom_test.dsp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/projects/tuscany_sdo/sdo_axiom_test/sdo_axiom_test.dsp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/projects/tuscany_sdo/sdo_axiom_test/sdo_axiom_test.dsp (original)
+++ incubator/tuscany/cpp/sdo/projects/tuscany_sdo/sdo_axiom_test/sdo_axiom_test.dsp Tue Jun 6 07:16:35 2006
@@ -65,7 +65,7 @@
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
-# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\include" /I "$(AXIS2C_HOME)\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "..\..\..\include(AXIS2C_HOME)\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FD /GZ /c
# SUBTRACT CPP /YX
# ADD BASE RSC /l 0x809 /d "_DEBUG"
# ADD RSC /l 0x809 /d "_DEBUG"
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.cpp Tue Jun 6 07:16:35 2006
@@ -72,7 +72,7 @@
// abstract
addType(Type::SDOTypeNamespaceURI,"ChangeSummary");
- rootElementName = 0;
+ rootElementName.erase();
@@ -92,20 +92,18 @@
delete typeIter->second;
}
}
- if (rootElementName != 0)
- {
- delete rootElementName;
- rootElementName = 0;
- }
+
+ rootElementName.erase();
}
// ===================================================================
// get the root element name
// ===================================================================
-const char* DataFactoryImpl::getRootElementName() const
+// const char* DataFactoryImpl::getRootElementName() const
+const SDOString& DataFactoryImpl::getRootElementName() const
{
- return (const char*)rootElementName;
+ return rootElementName;
}
// ===================================================================
@@ -113,16 +111,24 @@
// ===================================================================
void DataFactoryImpl::setRootElementName(const char* ren)
{
- if (rootElementName != 0)
- {
- delete rootElementName;
- rootElementName = 0;
- }
- if (ren != 0 && (strlen(ren) != 0))
- {
- rootElementName = new char[strlen(ren) +1];
- strcpy(rootElementName, ren);
- }
+
+ // If the incoming string is meaningful then use it to reset the stored
+ // value. Otherwise, just erase what we have.
+
+ if (ren != 0 && (strlen(ren) != 0))
+ {
+ rootElementName = ren;
+ }
+ else
+ {
+ rootElementName.erase();
+ }
+
+}
+
+void DataFactoryImpl::setRootElementName(const SDOString& ren)
+{
+ rootElementName = ren;
}
// ===================================================================
@@ -131,7 +137,6 @@
DataFactoryImpl::DataFactoryImpl(const DataFactoryImpl& inmdg)
{
isResolved = false;
- rootElementName = 0;
setRootElementName(inmdg.getRootElementName());
copyTypes(inmdg);
}
@@ -143,7 +148,6 @@
{
if (this != &inmdg)
{
- rootElementName = 0;
copyTypes(inmdg);
setRootElementName(inmdg.getRootElementName());
}
@@ -432,7 +436,7 @@
}
// Check if its a ChangeSummary
- if (propTypeUri != 0 && !strcmp(propTypeUri,Type::SDOTypeNamespaceURI) &&
+ if (propTypeUri != 0 && !strcmp(propTypeUri,Type::SDOTypeNamespaceURI.c_str()) &&
!strcmp(propTypeName,"ChangeSummary") )
{
if (checkForValidChangeSummary(typeIter->second))
@@ -715,6 +719,11 @@
return c;
}
+char* DataFactoryImpl::getFullTypeName(const SDOString& uri, const SDOString& inTypeName) const
+{
+ return getFullTypeName(uri.c_str(), inTypeName.c_str());
+}
+
// ===================================================================
// getFullTypeName - return the name used as a key in the types map
// ===================================================================
@@ -738,6 +747,11 @@
return c;
}
+char* DataFactoryImpl::getAliasTypeName(const SDOString& uri, const SDOString& inTypeName) const
+{
+ return getAliasTypeName(uri.c_str(), inTypeName.c_str());
+}
+
// ===================================================================
// getType - return a pointer to the required Type
// ===================================================================
@@ -1283,6 +1297,11 @@
return *type;
}
+const TypeImpl& DataFactoryImpl::getTypeImpl(const SDOString& uri, const SDOString& inTypeName) const
+{
+ return getTypeImpl(uri.c_str(), inTypeName.c_str());
+}
+
// ===================================================================
// findType
// ===================================================================
@@ -1292,10 +1311,20 @@
return (Type*)findTypeImpl(uri,inTypeName);
}
+const Type* DataFactoryImpl::findType(const SDOString uri, const SDOString inTypeName) const
+{
+ return (Type*) findTypeImpl(uri.c_str(), inTypeName.c_str());
+}
+
// ===================================================================
// findTypeImpl
// ===================================================================
+const TypeImpl* DataFactoryImpl::findTypeImpl(const SDOString& uri, const SDOString& inTypeName) const
+{
+ return findTypeImpl(uri.c_str(), inTypeName.c_str());
+}
+
const TypeImpl* DataFactoryImpl::findTypeImpl(const char* uri, const char* inTypeName) const
{
char* fullTypeName = getFullTypeName(uri, inTypeName);
@@ -1429,7 +1458,7 @@
if (!isResolved)
{
// Allow creation of types and properties before resolve.
- if (uri != 0 && !strcmp(uri,Type::SDOTypeNamespaceURI)) {
+ if (uri != 0 && !strcmp(uri,Type::SDOTypeNamespaceURI.c_str())) {
if (!strcmp(typeName,"Type") || !strcmp(typeName,"Property"))
{
DataObject* dob = (DataObject*)(new DataObjectImpl(this, getTypeImpl(uri, typeName)));
@@ -1498,6 +1527,10 @@
openProperties.insert(make_pair(prop.getName(),prop));
}
+ void DataFactoryImpl::removeOpenProperty(const SDOString& name)
+ {
+ removeOpenProperty(name.c_str());
+ }
void DataFactoryImpl::removeOpenProperty(const char* name)
{
propertyMap::iterator i =
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataFactoryImpl.h Tue Jun 6 07:16:35 2006
@@ -653,15 +653,26 @@
virtual void resolve();
+// TODO: Remove char* form of method since it is not exposed to users
const Type* findType (const char* uri, const char* inTypeName) const;
+ const Type* findType(const SDOString uri, const SDOString inTypeName) const;
+
+// TODO: Remove char* form of method since it is not exposed to users
const TypeImpl* findTypeImpl (const char* uri, const char* inTypeName) const;
+ const TypeImpl* findTypeImpl(const SDOString& uri, const SDOString& inTypeName) const;
void addOpenProperty(const PropertyImpl& prop);
+// TODO: Remove char* form of method since it is not exposed to users
void removeOpenProperty(const char* name);
+ void removeOpenProperty(const SDOString& name);
const propertyMap& getOpenProperties();
+// TODO: Remove char* form of method since it is not exposed to users
virtual const TypeImpl& getTypeImpl(const char* uri, const char* inTypeName) const;
- virtual const char* getRootElementName() const;
+ virtual const TypeImpl& getTypeImpl(const SDOString& uri, const SDOString& inTypeName) const;
+ virtual const SDOString& getRootElementName() const;
+// TODO: Remove char* form of method since it is not exposed to users
virtual void setRootElementName(const char* ren);
+ virtual void setRootElementName(const SDOString& ren);
virtual bool checkType(const Type& t);
virtual bool isCompatible(DataFactory* df, DataObject* d);
virtual bool compareTypes(const TypeImpl* t1, const Type& t2);
@@ -676,7 +687,7 @@
std::vector<DataFactory*> compatibleFactories;
- char * rootElementName;
+ SDOString rootElementName;
propertyMap openProperties;
@@ -691,8 +702,12 @@
typedef vector<TypeImpl*> TYPES_VECTOR;
TYPES_VECTOR cstypes;
+// TODO: Remove char* form of method since it is not exposed to users
char* getFullTypeName(const char* uri, const char* inTypeName) const;
+ char* getFullTypeName(const SDOString& uri, const SDOString& inTypeName) const;
+// TODO: Remove char* form of method since it is not exposed to users
char* getAliasTypeName(const char* uri, const char* inTypeName) const;
+ char* getAliasTypeName(const SDOString& uri, const SDOString& inTypeName) const;
void copyTypes(const DataFactoryImpl& inmdg);
};
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObject.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObject.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObject.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObject.h Tue Jun 6 07:16:35 2006
@@ -114,6 +114,7 @@
*/
virtual SDO_API bool hasProperty(const char* name) = 0;
+ virtual SDO_API bool hasProperty(const SDOString& name) = 0;
/**
* These are just like getType().getProperty(), but may return
* values other than the property list for open types.
@@ -122,6 +123,7 @@
virtual const Property& getProperty(unsigned int index) = 0;
virtual const Property& getProperty(const char* prop) = 0;
+ virtual const Property& getProperty(const SDOString& prop) = 0;
/**
@@ -172,6 +174,7 @@
* reachable from it, as identified by the specified path.
*/
+ virtual SDO_API DataObjectPtr getDataObject(const SDOString& path) = 0;
virtual SDO_API DataObjectPtr getDataObject(const char* path) = 0;
virtual SDO_API DataObjectPtr getDataObject(unsigned int propertyIndex) = 0;
virtual SDO_API DataObjectPtr getDataObject(const Property& property) = 0;
@@ -185,6 +188,7 @@
virtual SDO_API void setDataObject(const char* path, DataObjectPtr value) = 0;
+ virtual SDO_API void setDataObject(const SDOString& path, DataObjectPtr value) = 0;
virtual SDO_API void setDataObject(unsigned int propertyIndex, DataObjectPtr value) = 0;
virtual SDO_API void setDataObject(const Property& property, DataObjectPtr value) = 0;
@@ -195,6 +199,7 @@
*/
virtual SDO_API bool getBoolean(const char* path) = 0;
+ virtual SDO_API bool getBoolean(const SDOString& path) = 0;
virtual SDO_API bool getBoolean(unsigned int propindex) = 0;
virtual SDO_API bool getBoolean(const Property& p) = 0;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp Tue Jun 6 07:16:35 2006
@@ -289,6 +289,53 @@
}\
}
+#define getPrimitiveFromPathUsingSDOString(primval, retval, defval)\
+ retval DataObjectImpl::get ##primval (const SDOString& path)\
+ {\
+ DataObjectImpl* d;\
+ SDOString spath;\
+ SDOString prop;\
+ try {\
+ DataObjectImpl::stripPath(path, spath);\
+ prop = findPropertyContainer(spath, &d);\
+ if (d != 0) {\
+ if (prop.empty()) {\
+ return d->get ##primval ();\
+ }\
+ else {\
+ PropertyImpl* p = d->getPropertyImpl(prop);\
+ if (p != 0) \
+ {\
+ if (p->isMany()|| p->getTypeImpl()->isFromList())\
+ {\
+ long l;\
+ DataObjectImpl* doi = d->findDataObject(prop,&l);\
+ if (doi != 0) {\
+ return doi->get ## primval();\
+ }\
+ string msg("Get value - index out of range:");\
+ msg += path;\
+ SDO_THROW_EXCEPTION("getter", SDOIndexOutOfRangeException,\
+ msg.c_str());\
+ }\
+ else\
+ {\
+ if (!d->isSet(*p)) {\
+ return p->get ##primval ##Default();\
+ }\
+ return d->get ##primval (*p);\
+ }\
+ }\
+ }\
+ }\
+ string msg("Get value - path not found");\
+ SDO_THROW_EXCEPTION("getter", SDOPathNotFoundException,\
+ msg.c_str());\
+ }\
+ catch (SDORuntimeException e) {\
+ SDO_RETHROW_EXCEPTION("getter", e);\
+ }\
+ }
/** @def getCharsFromPath
*
@@ -699,7 +746,13 @@
return getLength(getProperty(index));
}
- getPrimitiveFromPath(Boolean,bool,false);
+ bool DataObjectImpl::getBoolean(const char* path)
+ {
+ return getBoolean(SDOString(path));
+ }
+
+ // getPrimitiveFromPath(Boolean,bool,false); // Provides DataObjectImpl::getBoolean(const char*)
+ getPrimitiveFromPathUsingSDOString(Boolean,bool,false); // Provides DataObjectImpl::getBoolean(const SDOString&)
getPrimitiveFromPath(Byte,char,0);
getPrimitiveFromPath(Character,wchar_t,0);
getPrimitiveFromPath(Short,short,0);
@@ -782,6 +835,26 @@
return getPropertyImpl(propname);
}
+ const PropertyImpl* DataObjectImpl::defineProperty(const SDOString& propname,
+ const Type& t)
+ {
+ openProperties.insert(openProperties.end(),
+ PropertyImpl(getType(),
+ propname,
+ (TypeImpl&)t,
+ false,
+ false,
+ true));
+ DataFactory* df = factory;
+ ((DataFactoryImpl*)df)->addOpenProperty(PropertyImpl(getType(),
+ propname,
+ (TypeImpl&)t,
+ false,
+ false,
+ true));
+
+ return getPropertyImpl(propname);
+ }
void DataObjectImpl::undefineProperty(unsigned int index)
{
@@ -898,6 +971,11 @@
{
return defineProperty(propname,t);
}
+ const PropertyImpl* DataObjectImpl::defineDataObject(const SDOString& propname,
+ const Type& t)
+ {
+ return defineProperty(propname,t);
+ }
const PropertyImpl* DataObjectImpl::defineDataObject(const char* propname,
const char* typeURI, const char* typeName)
{
@@ -1461,6 +1539,13 @@
return true;
}
+ bool DataObjectImpl::hasProperty(const SDOString& name)
+ {
+ PropertyImpl* pi = getPropertyImpl(name);
+ if (pi == 0) return false;
+ return true;
+ }
+
PropertyImpl* DataObjectImpl::getPropertyImpl(unsigned int index)
{
@@ -1516,6 +1601,25 @@
return s;
}
+ void DataObjectImpl::stripPath(const SDOString& path, SDOString& result)
+ {
+ result.erase();
+ result.reserve(path.length());
+
+ size_t start = 0;
+ size_t position = path.find_first_not_of(templateString);
+
+ while (position != string::npos)
+ {
+ result.append(path, start, (position - start));
+ start = ++position;
+ position = path.find_first_not_of(templateString, position);
+ }
+
+ result.append(path, start, string::npos);
+
+ return;
+ }
//////////////////////////////////////////////////////////////////////
// Find a data object or return 0 if not found
@@ -1745,6 +1849,227 @@
*--eq='=';
return 0;
}
+DataObjectImpl* DataObjectImpl::findDataObject(const SDOString& token, long* index)
+{
+ // name , name[int], name[x=y] name.int
+ // char c = 0;
+ size_t beginbrace = token.find('[');
+ size_t dot = token.find('.');
+ size_t breaker = 0;
+
+// char* beginbrace = strchr(token,'[');
+// char* endbrace = strchr(token,']');
+// char* dot = strchr(token,'.');
+// char* breaker = 0;
+
+ if (dot != string::npos)
+ {
+ if (beginbrace != string::npos)
+ {
+ breaker = (beginbrace < dot) ? beginbrace : dot;
+ }
+ else
+ {
+ breaker = dot;
+ }
+ }
+ else
+ {
+ breaker = beginbrace;
+ }
+
+ if (breaker == string::npos){
+ // its this object, and a property thereof
+ *index = -1;
+ const Property& p = getProperty(token);
+ return getDataObjectImpl(p);
+ }
+
+ // We did find a breaker character.
+ const Property& p = getProperty(SDOString(token, 0, breaker));
+
+ breaker++;
+
+ size_t endbrace = token.find(']');
+ SDOString breakerStr = token.substr(breaker, (endbrace - breaker));
+ // Search for the first occurence of an = sign starting at the previously
+ // identified "breaker" character and ending at the endbrace just found. We
+ // need to make a new SDOString to contain that substring.
+
+ size_t eq = breakerStr.find('=');
+
+ if (eq == string::npos)
+ {
+ // There is no "=" sign
+ int val = atoi(breakerStr.c_str());
+ DataObjectList& list = getList(p);
+
+ // The spec says that depts[1] is the first element, as is depts.0
+ if (beginbrace != string::npos) val--;
+
+ if (val >=0 && val < list.size())
+ {
+ DataObject* dob = list[val];
+ *index = val;
+ return (DataObjectImpl*)dob;
+ }
+ *index = -1;
+ return 0;
+ }
+
+ // We did find an "=" sign.
+ // *eq = 0;
+ SDOString PropertyName = token.substr(breaker, (eq - breaker));
+ // breaker is now propname
+ eq++;
+ SDOString PropertyValue = token.substr(eq, (endbrace - eq));
+ // eq is now propval
+
+ DataObjectList& list = getList(p);
+ for (int li = 0 ; li < list.size() ; ++li)
+ {
+ // TODO comparison for double not ok
+
+ const Type & t = list[li]->getType();
+ const Property& p = list[li]->getProperty(PropertyName);
+ int ok = 0;
+
+ switch (p.getTypeEnum())
+ {
+ case Type::BooleanType:
+ {
+ // getCString will return "true" or "false"
+ if (!strcmp(PropertyValue.c_str(), list[li]->getCString(p))) ok = 1;
+ }
+ break;
+
+ case Type::ByteType:
+ {
+ char cc = PropertyValue[0];
+ // getByte return a char
+ if (cc == list[li]->getByte(p)) ok = 1;
+ }
+ break;
+
+ case Type::CharacterType:
+ {
+ wchar_t wc = *((wchar_t*) PropertyValue.c_str());
+ // wchar_t wc = (wchar_t)((wchar_t*)eq)[0];
+ // TODO - this is not a very accesible way of storing a wchar
+ if (wc == list[li]->getCharacter(p)) ok = 1;
+ }
+ break;
+
+ case Type::IntegerType:
+ {
+ long ic = atol(PropertyValue.c_str());
+ if (ic == list[li]->getInteger(p)) ok = 1;
+ }
+ break;
+
+ case Type::DateType:
+ {
+ long dc = atol(PropertyValue.c_str());
+ if (dc == (long)(list[li]->getDate(p).getTime())) ok = 1;
+ }
+ break;
+
+ case Type::DoubleType:
+ {
+ // TODO - double needs a bigger size than float
+ long double ldc = (long double)atof(PropertyValue.c_str());
+ if (ldc == list[li]->getDouble(p)) ok = 1;
+ }
+ break;
+
+ case Type::FloatType:
+ {
+ float fc = atof(PropertyValue.c_str());
+ if (fc == list[li]->getFloat(p)) ok = 1;
+ }
+ break;
+
+ case Type::LongType:
+ {
+#if defined(WIN32) || defined (_WINDOWS)
+ int64_t lic = (int64_t)_atoi64(PropertyValue.c_str());
+#else
+ int64_t lic = (int64_t)strtoll(PropertyValue.c_str(), NULL, 0);
+#endif
+
+ if (lic == list[li]->getLong(p)) ok = 1;
+ }
+ break;
+
+ case Type::ShortType:
+ {
+ short sic = atoi(PropertyValue.c_str());
+ if (sic == list[li]->getShort(p)) ok = 1;
+ }
+ break;
+
+ case Type::BytesType:
+ case Type::BigDecimalType:
+ case Type::BigIntegerType:
+ case Type::StringType:
+ case Type::UriType:
+ {
+
+ if (!strcmp(PropertyValue.c_str(), list[li]->getCString(p))) ok = 1;
+ // try with quotes too
+ size_t firstquote = PropertyValue.find('"');
+ size_t firstsingle = PropertyValue.find('\'');
+
+ char searchchar = 0;
+
+ if (firstsingle == string::npos)
+ {
+ if (firstquote != string::npos)
+ {
+ searchchar = '"';
+ }
+ }
+ else
+ {
+ if (firstquote != string::npos && firstquote < firstsingle)
+ {
+ searchchar = '"';
+ }
+ else
+ {
+ searchchar = '\'';
+ firstquote = firstsingle;
+ }
+ }
+
+ if (searchchar != 0)
+ {
+ size_t ender = PropertyValue.find(searchchar, firstquote + 1);
+ if (ender != string::npos)
+ {
+ if (!strcmp(PropertyValue.substr(firstquote + 1, ender - firstquote).c_str(), list[li]->getCString(p)))
+ ok = 1;
+ }
+ }
+ }
+ break;
+
+ case Type::DataObjectType:
+ break;
+
+ default:
+ break;
+ }
+
+ if (ok == 1)
+ {
+ DataObject* dob = list[li];
+ *index = li;
+ return (DataObjectImpl*)dob;
+ }
+ }
+ return 0;
+}
//////////////////////////////////////////////////////////////////////
@@ -1859,6 +2184,94 @@
*din = 0;
return 0;
}
+ SDOString DataObjectImpl::findPropertyContainer(const SDOString& path, DataObjectImpl** din)
+ {
+ // initially check for "#/" which indicates that we need to find the root object first
+ if (path.empty()) return 0;
+
+ if (path.length() <= 2)
+ {
+ if (path[0] == '#')
+ {
+ DataObjectImpl* root = this;
+ while (root->getContainerImpl() != 0)
+ {
+ root = root->getContainerImpl();
+ }
+ *din = root;
+ return SDOString();
+ }
+ }
+
+ if (path[0] == '#' && path[1] == '/')
+ {
+ DataObjectImpl* root = this;
+ while (root->getContainerImpl() != 0)
+ {
+ root = root->getContainerImpl();
+ }
+ return root->findPropertyContainer(SDOString(path, 2), din);
+ }
+
+ DataObjectImpl* d;
+ size_t slashPos = path.find('/'); // i is the subscript of the found character
+ SDOString remaining;
+ SDOString token;
+
+ if (slashPos != string::npos) // If we found a slash character
+ {
+ if (slashPos > 0) // If there is something before the slash
+ {
+ token.assign(path, 0, slashPos);
+ }
+ if ((path.length() - slashPos) > 1) // If there is something after the slash
+ {
+ remaining.assign(path, slashPos + 1, string::npos);
+ }
+ }
+ else
+ {
+ remaining = path;
+ }
+
+ if (token.empty())
+ {
+ if (remaining == "..")
+ {
+ /* Its the container itself */
+ *din = getContainerImpl();
+ return SDOString();
+ }
+
+ /* Its this data object - property could be empty or
+ valid or invalid - user must check */
+ *din = this;
+ return remaining;
+ }
+
+ if (token == "..") {
+ /* Its derived from the container */
+ d = getContainerImpl();
+ /* carry on trying to find a property */
+ if (d != 0) {
+ return d->findPropertyContainer(remaining, din);
+ }
+ /* Give up - no container */
+ *din = 0;
+ return 0;
+ }
+
+ /* Try to find a property ....*/
+ long l;
+ d = findDataObject(token, &l);
+ if (d != 0) {
+ return d->findPropertyContainer(remaining, din);
+ }
+
+ /* Give up its not in the tree */
+ *din = 0;
+ return 0;
+ }
@@ -2092,6 +2505,60 @@
msg.c_str());
}
+void DataObjectImpl::setDataObject(const SDOString& path, DataObjectPtr value)
+{
+ DataObjectImpl* d;
+ SDOString prop = findPropertyContainer(path, &d);
+ if (d != 0)
+ {
+ if (!prop.empty()) {
+ const PropertyImpl* p = d->getPropertyImpl(prop);
+ if (p == 0 && d->getType().isOpenType())
+ {
+ if (value != 0)
+ {
+ p = d->defineDataObject(prop, value->getType());
+ }
+ }
+ if (p != 0)
+ {
+ if (p->isMany())
+ {
+ DataObjectList& dol = d->getList((Property&)*p);
+ long index;
+ DataObjectImpl* dx = d->findDataObject(prop,&index);
+ if (index >= 0)
+ {
+ if(index < dol.size())
+ {
+ dol.setDataObject((unsigned int)index,value);
+ }
+ else
+ {
+ dol.append(value);
+ }
+ return;
+ }
+ string msg("Set of data object on many valued item");
+ msg += path;
+ SDO_THROW_EXCEPTION("setDataObject", SDOUnsupportedOperationException,
+ msg.c_str());
+ }
+ else
+ {
+ d->setDataObject((Property&)*p,value);
+ return;
+ }
+ }
+ }
+ }
+
+ string msg("Path not valid:");
+ msg += path;
+ SDO_THROW_EXCEPTION("setDataObject", SDOPathNotFoundException,
+ msg.c_str());
+}
+
void DataObjectImpl::validateIndex(unsigned int index)
{
PropertyList pl = getType().getProperties();
@@ -2620,11 +3087,17 @@
RefCountingPointer<DataObject> DataObjectImpl::getDataObject(const char* path)
{
- DataObjectImpl* ptr = getDataObjectImpl(path);;
+ DataObjectImpl* ptr = getDataObjectImpl(path);
return RefCountingPointer<DataObject> ((DataObject*)ptr);
}
- DataObjectImpl* DataObjectImpl::getDataObjectImpl(const char* path)
+ RefCountingPointer<DataObject> DataObjectImpl::getDataObject(const SDOString& path)
+ {
+ DataObjectImpl* ptr = getDataObjectImpl(path);
+ return RefCountingPointer<DataObject> ((DataObject*)ptr);
+ }
+
+ DataObjectImpl* DataObjectImpl::getDataObjectImpl(const char* path)
{
DataObjectImpl* d = 0;
@@ -2670,6 +3143,51 @@
msg.c_str());
}
+ // +++
+
+ DataObjectImpl* DataObjectImpl::getDataObjectImpl(const SDOString& path)
+ {
+
+ DataObjectImpl* d = 0;
+ SDOString prop = findPropertyContainer(path,&d);
+ // char* prop = findPropertyContainer(path,&d);
+ if (d != 0) {
+ if (!prop.empty()) {
+ if (prop.find_first_of("[.") != string::npos) {
+ /* Its a multlvalued property */
+ long l;
+ DataObjectImpl* theob = d->findDataObject(prop,&l);
+ if (theob == 0) {
+ string msg("Get DataObject - index out of range:");
+ msg += path;
+ SDO_THROW_EXCEPTION("getDataObject" ,SDOIndexOutOfRangeException,
+ msg.c_str());
+ }
+ return theob;
+ }
+ else
+ {
+ if (prop.length() == 0)
+ {
+ return d;
+ }
+ const Property& p = d->getProperty(prop);
+ return d->getDataObjectImpl(p);
+ }
+ }
+ else {
+ return d;
+ }
+ }
+
+ string msg("Invalid path:");
+ msg += path;
+ SDO_THROW_EXCEPTION("getDataObject" ,SDOPathNotFoundException,
+ msg.c_str());
+ }
+
+ // ---
+
RefCountingPointer<DataObject> DataObjectImpl::getDataObject(unsigned int propertyIndex)
{
if ((getProperty(propertyIndex).isMany()))
@@ -3003,6 +3521,19 @@
}
return (Property&)*pi;
}
+ const Property& DataObjectImpl::getProperty(const SDOString& prop)
+ {
+ PropertyImpl* pi = getPropertyImpl(prop);
+ if (pi == 0)
+ {
+ string msg("Cannot find property:");
+ msg += prop;
+ SDO_THROW_EXCEPTION("getProperty", SDOPropertyNotFoundException,
+ msg.c_str());
+
+ }
+ return (Property&)*pi;
+ }
PropertyImpl* DataObjectImpl::getPropertyImpl(const char* prop)
{
@@ -3023,6 +3554,25 @@
}
return 0;
}
+ PropertyImpl* DataObjectImpl::getPropertyImpl(const SDOString& prop)
+ {
+ PropertyImpl* pi = getTypeImpl().getPropertyImpl(prop);
+ if (pi != 0) return pi;
+
+ if (getType().isOpenType())
+ {
+ std::list<PropertyImpl>::iterator j;
+ for (j=openProperties.begin();
+ j != openProperties.end(); ++j)
+ {
+ if (!strcmp((*j).getName(), prop.c_str()))
+ {
+ return (PropertyImpl*)&(*j);
+ }
+ }
+ }
+ return 0;
+ }
DataFactory* DataObjectImpl::getDataFactory()
{
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h Tue Jun 6 07:16:35 2006
@@ -138,10 +138,12 @@
*/
virtual const Property& getProperty(unsigned int index);
-
+
virtual const Property& getProperty(const char* prop);
-
+ virtual const Property& getProperty(const SDOString& prop);
+
virtual PropertyImpl* getPropertyImpl(const char* prop);
+ virtual PropertyImpl* getPropertyImpl(const SDOString& prop);
virtual PropertyImpl* getPropertyImpl(unsigned int index);
@@ -201,6 +203,7 @@
* reachable from it, as identified by the specified path.
*/
+ virtual DataObjectPtr getDataObject(const SDOString& path);
virtual DataObjectPtr getDataObject(const char* path);
virtual DataObjectPtr getDataObject(unsigned int propertyIndex);
virtual DataObjectPtr getDataObject(const Property& property);
@@ -213,6 +216,7 @@
*/
virtual void setDataObject(const char* path, DataObjectPtr value);
+ virtual void setDataObject(const SDOString& path, DataObjectPtr value);
virtual void setDataObject(unsigned int propertyIndex, DataObjectPtr value);
virtual void setDataObject(const Property& property, DataObjectPtr value);
@@ -223,6 +227,7 @@
*/
virtual bool getBoolean(const char* path);
+ virtual bool getBoolean(const SDOString& path);
virtual bool getBoolean(unsigned int propindex);
virtual bool getBoolean(const Property& p);
@@ -394,6 +399,7 @@
*/
virtual bool hasProperty(const char* name);
+ virtual bool hasProperty(const SDOString& name);
virtual void detach();
@@ -526,6 +532,8 @@
virtual const PropertyImpl* defineProperty(const char* propname,
const Type& t);
+ virtual const PropertyImpl* defineProperty(const SDOString& propname,
+ const Type& t);
virtual const PropertyImpl* defineBoolean(const char* propname);
virtual const PropertyImpl* defineByte(const char* propname);
@@ -541,6 +549,8 @@
virtual const PropertyImpl* defineCString(const char* propname);
virtual const PropertyImpl* defineDataObject(const char* propname,
const Type&t );
+ virtual const PropertyImpl* defineDataObject(const SDOString& propname,
+ const Type&t );
virtual const PropertyImpl* defineDataObject(const char* propname,
const char* typeURI, const char* typeName );
virtual const PropertyImpl* defineList(const char* propname);
@@ -560,6 +570,7 @@
virtual bool isSet(const Property& prop, unsigned int propertyIndex);
+ virtual DataObjectImpl* getDataObjectImpl(const SDOString& path);
virtual DataObjectImpl* getDataObjectImpl(const char* path);
virtual DataObjectImpl* getDataObjectImpl(unsigned int propertyIndex);
virtual DataObjectImpl* getDataObjectImpl(const Property& property);
@@ -570,9 +581,12 @@
const char* typeName);
DataObjectImpl* findDataObject(char* token, long* index);
+ DataObjectImpl* findDataObject(const SDOString& token, long* index);
const Property* findInProperties(DataObject* ob);
char* findPropertyContainer(const char* path, DataObjectImpl** din);
+ SDOString findPropertyContainer(const SDOString& path, DataObjectImpl** din);
char* stripPath(const char* path);
+ void stripPath(const SDOString& path, SDOString& result);
// Does not keep a reference counted pointer to the container.
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp Tue Jun 6 07:16:35 2006
@@ -101,7 +101,7 @@
if (container->getType().isOpenType())
{
- if (!strcmp(intypeURI,Type::SDOTypeNamespaceURI) &&
+ if (!strcmp(intypeURI,Type::SDOTypeNamespaceURI.c_str()) &&
!strcmp(intypeName,"OpenDataObject"))
{
typeUnset = true;
@@ -375,8 +375,8 @@
msg.c_str());
}
-
-void DataObjectListImpl::setType(const char* uri, const char* name)
+//TODO Modify parameters to SDOString
+void DataObjectListImpl::setType(const char* uri, const char* name)
{
// need to check for an opentype list which has not been set up yet
if (name == 0) return;
@@ -404,6 +404,27 @@
typeUnset = false;
}
+void DataObjectListImpl::setType(const SDOString& uri, const SDOString& name)
+{
+ // need to check for an opentype list which has not been set up yet
+ // if (name == 0) return;
+
+ const TypeImpl* t = ((DataFactoryImpl*)theFactory)->findTypeImpl(uri.c_str(), name.c_str());
+ if (t == 0) return; // cannot set to a type which is not avilable
+
+ // need to modify the instance property of the container
+ container->setInstancePropertyType(pindex,t);
+
+ delete typeName;
+ typeName = new char[name.length() + 1];
+ strcpy(typeName, name.c_str());
+
+ delete typeURI;
+ typeURI = new char[uri.length() + 1];
+ strcpy(typeURI, uri.c_str());
+
+ typeUnset = false;
+}
void DataObjectListImpl::append (DataObjectPtr d)
{
@@ -478,7 +499,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Boolean");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, BooleanLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -490,7 +511,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Boolean");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, BooleanLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -502,7 +523,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Byte");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, ByteLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -514,7 +535,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Byte");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, ByteLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -526,7 +547,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Character");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, CharacterLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -538,7 +559,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Character");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, CharacterLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -550,7 +571,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "String");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, StringLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -562,7 +583,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "String");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, StringLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -573,7 +594,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, BytesLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -585,7 +606,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, BytesLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -596,7 +617,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, BytesLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -608,7 +629,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Bytes");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, BytesLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -620,7 +641,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Short");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, ShortLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -632,7 +653,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Short");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, ShortLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -646,7 +667,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Integer");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, IntegerLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -658,7 +679,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Integer");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, IntegerLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -671,7 +692,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Date");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, DateLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -683,7 +704,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Date");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, DateLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -695,7 +716,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Long");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, LongLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -707,7 +728,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Long");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, LongLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -719,7 +740,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Float");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, FloatLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -731,7 +752,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Float");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, FloatLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -743,7 +764,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Double");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, DoubleLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -755,7 +776,7 @@
{
if (theFactory == 0) return;
- if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Double");
+ if (typeUnset)setType(Type::SDOTypeNamespaceURI, DoubleLiteral);
RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName);
DataObject* dob = dol;
@@ -1064,6 +1085,18 @@
DataObject* dob = dd;
return dob->getLength();
}
+
+ const SDOString DataObjectListImpl::BooleanLiteral = "Boolean";
+ const SDOString DataObjectListImpl::ByteLiteral = "Byte";
+ const SDOString DataObjectListImpl::CharacterLiteral = "Character";
+ const SDOString DataObjectListImpl::BytesLiteral = "Bytes";
+ const SDOString DataObjectListImpl::StringLiteral = "String";
+ const SDOString DataObjectListImpl::IntegerLiteral = "Integer";
+ const SDOString DataObjectListImpl::ShortLiteral = "Short";
+ const SDOString DataObjectListImpl::DateLiteral = "Date";
+ const SDOString DataObjectListImpl::LongLiteral = "Long";
+ const SDOString DataObjectListImpl::FloatLiteral = "Float";
+ const SDOString DataObjectListImpl::DoubleLiteral = "Double";
};
};
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.h Tue Jun 6 07:16:35 2006
@@ -145,6 +145,7 @@
virtual void checkFactory(DataObjectPtr dob);
virtual void checkType(const Type& listType, const Type& objectType);
virtual void setType(const char* uri, const char* name);
+ virtual void setType(const SDOString& uri, const SDOString& name);
/* getType returns type
*
@@ -187,6 +188,19 @@
bool isReference;
void validateIndex(int index) const;
+
+ static const SDOString BooleanLiteral;
+ static const SDOString ByteLiteral;
+ static const SDOString CharacterLiteral;
+ static const SDOString BytesLiteral;
+ static const SDOString StringLiteral;
+ static const SDOString IntegerLiteral;
+ static const SDOString ShortLiteral;
+ static const SDOString DateLiteral;
+ static const SDOString LongLiteral;
+ static const SDOString FloatLiteral;
+ static const SDOString DoubleLiteral;
+
};
};
};
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Property.h Tue Jun 6 07:16:35 2006
@@ -47,7 +47,9 @@
* Returns the name of the property.
*/
+ // TODO: We would like the returned value to be an SDOString but not until the internals are ready
virtual const SDO_API char* getName() const = 0;
+ // virtual const SDO_API SDOString& getName() const = 0;
/** getAlias returns the n'th alias
*
@@ -56,7 +58,10 @@
* discover the size of the list.
*/
+ // TODO: We would lke to convert the returned value to an SDOString but that means a rename for the method.
virtual SDO_API const char* getAlias(unsigned int index = 0) const = 0;
+
+ // virtual SDO_API const SDOString& getAlias(unsigned int index = 0) const = 0;
/** getAliasCount returns the number of aliases
*
@@ -154,6 +159,7 @@
virtual SDO_API void setDefault(char c) = 0;
virtual SDO_API void setDefault(wchar_t c) = 0;
virtual SDO_API void setDefault(char* c) = 0;
+ virtual SDO_API void setDefault(const SDOString& c) = 0;
virtual SDO_API void setDefault(short s) = 0;
#if __WORDSIZE !=64
virtual SDO_API void setDefault(long l) = 0;
@@ -164,6 +170,7 @@
virtual SDO_API void setDefault(const SDODate d) = 0;
virtual SDO_API void setDefault(const wchar_t* c, unsigned int len) = 0;
virtual SDO_API void setDefault(const char* c, unsigned int len) = 0;
+ virtual SDO_API void setDefault(const SDOString& c, unsigned int len) = 0;
/** getDefault gets the right sort of default.
*
@@ -173,6 +180,7 @@
virtual SDO_API unsigned int getStringDefault(wchar_t* val, unsigned int max) const = 0;
virtual SDO_API unsigned int getBytesDefault(char* val, unsigned int max) const = 0;
+ virtual SDO_API unsigned int getBytesDefault(SDOString& val, unsigned int max) const = 0;
virtual SDO_API bool getBooleanDefault() const = 0;
virtual SDO_API char getByteDefault() const = 0;
virtual SDO_API wchar_t getCharacterDefault() const = 0;
@@ -183,6 +191,8 @@
virtual SDO_API long double getDoubleDefault() const = 0;
virtual SDO_API const SDODate getDateDefault() const = 0;
virtual SDO_API const char* getCStringDefault() const = 0;
+ // TODO: Can't overload return types.
+ // virtual SDO_API const SDOString& getSDOStringDefault() const = 0;
virtual SDO_API unsigned int getDefaultLength() const = 0;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.cpp Tue Jun 6 07:16:35 2006
@@ -38,67 +38,54 @@
#include "commonj/sdo/SDORuntimeException.h"
namespace commonj{
-namespace sdo{
-
+ namespace sdo{
- Substitution::Substitution()
- {
- name = 0;
- type = 0;
- }
- Substitution::Substitution(DataFactoryPtr mdg, const char* inname,
- const Type& intype)
- {
- DataFactory* f = (DataFactory*)mdg;
-
-
- if (inname != 0)
+ Substitution::Substitution() : name(), type(0)
{
- name = new char[strlen(inname) + 1];
- strcpy(name,inname);
}
- else
+
+ // Standard Constructor
+ Substitution::Substitution(DataFactoryPtr mdg,
+ const SDOString& inname,
+ const Type& intype) : name(inname)
{
- name = 0;
- }
+ DataFactory* f = (DataFactory*)mdg;
- type = ((DataFactoryImpl*)f)->findType(intype.getURI(),intype.getName());
- }
+ type = ((DataFactoryImpl*)f)->findType(intype.getURI(),intype.getName());
+ }
- Substitution::Substitution(const Substitution& s)
- {
- type = s.type;
- if (s.name != 0)
+ // Copy constructor
+ Substitution::Substitution(const Substitution& s) : name(s.name), type(s.type)
{
- name = new char[strlen(s.name)+1];
- strcpy(name,s.name);
}
- else
+
+ Substitution::~Substitution()
{
- name = 0;
}
- }
-
- Substitution::~Substitution()
- {
- if (name != 0) delete (char*)name;
- }
///////////////////////////////////////////////////////////////////////////
// construction by DAS
///////////////////////////////////////////////////////////////////////////
- PropertyImpl::PropertyImpl( const Type& cont,
+ PropertyImpl::PropertyImpl(const Type& cont,
const char* inname,
const TypeImpl& intype,
bool many ,
bool ro ,
bool contain) : containertype(cont), type (intype)
{
- name = new char[strlen(inname)+1];
- strcpy(name,inname);
+ // name = new char[strlen(inname)+1];
+ // strcpy(name,inname);
+ if (inname != 0)
+ {
+ name = inname;
+ }
+ else
+ {
+ name.erase();
+ }
defvalue = 0;
defvaluelength = 0;
opposite = 0;
@@ -117,24 +104,25 @@
}
}
-
- PropertyImpl::PropertyImpl(const PropertyImpl& p) :
- type((*(p.getTypeImpl()))),
- containertype (p.getContainingType())
-
-
+ PropertyImpl::PropertyImpl(const Type& cont,
+ const SDOString& inname,
+ const TypeImpl& intype,
+ bool many,
+ bool ro,
+ bool contain) :
+ containertype(cont),
+ name(inname),
+ type(intype),
+ bisMany(many),
+ bisReadOnly(ro),
+ bisContainer(contain),
+ bDefaulted(false),
+ opposite(0),
+ stringdef(0),
+ defvalue(0),
+ defvaluelength(0)
{
- name = new char[strlen(p.getName())+1];
- strcpy(name,p.getName());
- defvalue = 0;
- defvaluelength = 0;
- stringdef = 0;
- opposite = 0;
- bisMany = p.bisMany;
- bisReadOnly = p.bisReadOnly;
- bisContainer = p.bisContainer;
- bDefaulted=false;
- if (bisContainer == false && type.isDataObjectType())
+ if (contain == false && intype.isDataObjectType())
{
bisReference = true;
}
@@ -144,17 +132,33 @@
}
}
-
+ PropertyImpl::PropertyImpl(const PropertyImpl& p) :
+ type((*(p.getTypeImpl()))),
+ containertype(p.getContainingType()),
+ name(p.name),
+ bisMany(p.bisMany),
+ bisReadOnly(p.bisReadOnly),
+ bisContainer(p.bisContainer),
+ bDefaulted(false),
+ opposite(0),
+ defvalue(0),
+ defvaluelength(0),
+ stringdef(0)
+ {
+ if (bisContainer == false && type.isDataObjectType())
+ {
+ bisReference = true;
+ }
+ else
+ {
+ bisReference = false;
+ }
+ }
+
PropertyImpl::~PropertyImpl()
{
- if (name != 0) delete (char*)name;
if (defvalue != 0) delete (char*)defvalue;
if (stringdef != 0) delete stringdef;
- for (int i = 0; i < aliases.size();i++)
- {
- delete ((char*)aliases[i]);
- }
-
}
///////////////////////////////////////////////////////////////////////////
@@ -211,6 +215,10 @@
{
setDefaultCString(c);
}
+ void PropertyImpl::setDefault(const SDOString& c)
+ {
+ setDefaultCString(c);
+ }
void PropertyImpl::setDefault(short s )
{
setDefaultShort(s);
@@ -241,6 +249,10 @@
{
setDefaultBytes(c, len);
}
+ void PropertyImpl::setDefault(const SDOString& c , unsigned int len)
+ {
+ setDefaultBytes(c, len);
+ }
void PropertyImpl::setDefault(const wchar_t* c, unsigned int len )
{
@@ -254,7 +266,7 @@
{
for (int i=0;i<substitutions.size();i++)
{
- if (!strcmp(inname, substitutions[i].name))
+ if (!strcmp(inname, substitutions[i].name.c_str()))
{
return substitutions[i].type;
}
@@ -266,7 +278,7 @@
{
if (index < getSubstitutionCount())
{
- return (substitutions[index].name);
+ return (substitutions[index].name.c_str());
}
SDO_THROW_EXCEPTION("getSubstitutionName", SDOIndexOutOfRangeException,
"index out of range");
@@ -298,9 +310,14 @@
///////////////////////////////////////////////////////////////////////////
const char* PropertyImpl::getName() const
{
- return name;
+ return name.c_str();
}
+// const SDOString& PropertyImpl::getName() const
+// {
+// return name;
+// }
+
void PropertyImpl::setAlias(const char* alias)
{
char* tmp = new char[strlen(alias)+1];
@@ -308,13 +325,18 @@
aliases.push_back(tmp);
}
+ void PropertyImpl::setAlias(const SDOString& alias)
+ {
+ aliases.push_back(alias);
+ }
+
const char* PropertyImpl::getAlias(unsigned int index) const
{
if (index < aliases.size())
{
- return aliases[index];
+ return aliases[index].c_str();
}
- return name;
+ return name.c_str();
}
unsigned int PropertyImpl::getAliasCount() const
@@ -453,6 +475,12 @@
return getTypeImpl()->convertToBytes(defvalue, val, defvaluelength, max);
}
+ unsigned int PropertyImpl::getBytesDefault(SDOString& val, unsigned int max) const
+ {
+ if (max == 0) return defvaluelength;
+ return getTypeImpl()->convertToBytes(defvalue, val, defvaluelength, max);
+ }
+
unsigned int PropertyImpl::getDefaultLength() const
{
return defvaluelength;
@@ -467,12 +495,22 @@
bDefaulted=true;
defvaluelength = getTypeImpl()->convert(&defvalue,s);
}
+ void PropertyImpl::setDefaultCString(const SDOString& s)
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue, s);
+ }
void PropertyImpl::setDefaultString( const wchar_t* c , unsigned int len )
{
bDefaulted=true;
defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
}
void PropertyImpl::setDefaultBytes( const char* c , unsigned int len )
+ {
+ bDefaulted=true;
+ defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
+ }
+ void PropertyImpl::setDefaultBytes(const SDOString& c , unsigned int len)
{
bDefaulted=true;
defvaluelength = getTypeImpl()->convert(&defvalue,c, len);
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/PropertyImpl.h Tue Jun 6 07:16:35 2006
@@ -22,9 +22,6 @@
#include "commonj/sdo/disable_warn.h"
-#include <string>
-using namespace std;
-
#include "commonj/sdo/DASProperty.h"
#include "commonj/sdo/SDODate.h"
#include "commonj/sdo/DataFactory.h"
@@ -43,19 +40,20 @@
* data object in place of a property of another type.
*/
-
class Substitution
{
public:
Substitution();
- Substitution(DataFactoryPtr mdg, const char* inname,
+ Substitution(DataFactoryPtr mdg, const SDOString& inname,
const Type& intype);
Substitution(const Substitution& s);
virtual ~Substitution();
const Type* type;
- char* name;
+ SDOString name;
};
+
+
/** PropertyImpl implements the abstract class Property.
*
* A representation of a property in the type of a data object.
@@ -78,9 +76,16 @@
bool ro = false,
bool contain = false);
+ SDO_API PropertyImpl(const Type& cont,
+ const SDOString& name,
+ const TypeImpl& type,
+ bool many = false,
+ bool ro = false,
+ bool contain = false);
+
- virtual SDO_API ~PropertyImpl();
+ virtual SDO_API ~PropertyImpl();
/**
* A Data access service may set the features of this property instead of
@@ -116,6 +121,7 @@
virtual SDO_API void setDefault(char c);
virtual SDO_API void setDefault(wchar_t c);
virtual SDO_API void setDefault(char* c);
+ virtual SDO_API void setDefault(const SDOString& c);
virtual SDO_API void setDefault(short s);
#if __WORDSIZE !=64
virtual SDO_API void setDefault(long l);
@@ -126,6 +132,7 @@
virtual SDO_API void setDefault(const SDODate d);
virtual SDO_API void setDefault(const wchar_t* c, unsigned int len);
virtual SDO_API void setDefault(const char* c, unsigned int len);
+ virtual SDO_API void setDefault(const SDOString& c, unsigned int len);
@@ -147,6 +154,7 @@
virtual const char* getAlias(unsigned int index = 0) const ;
virtual unsigned int getAliasCount() const ;
virtual void setAlias(const char* alias) ;
+ virtual void setAlias(const SDOString& alias) ;
/**
*
@@ -206,8 +214,10 @@
*/
SDO_API void setDefaultCString( const char* s);
+ SDO_API void setDefaultCString(const SDOString& s);
SDO_API void setDefaultString( const wchar_t* c , unsigned int len );
SDO_API void setDefaultBytes( const char* c , unsigned int len );
+ SDO_API void setDefaultBytes(const SDOString& c , unsigned int len);
SDO_API void setDefaultBoolean( const bool b );
SDO_API void setDefaultByte( const char c );
SDO_API void setDefaultCharacter( const wchar_t c);
@@ -221,6 +231,7 @@
SDO_API const char* getCStringDefault() const;
SDO_API unsigned int getStringDefault(wchar_t* val, unsigned int max) const;
SDO_API unsigned int getBytesDefault(char* val, unsigned int max) const;
+ SDO_API unsigned int getBytesDefault(SDOString& val, unsigned int max) const;
SDO_API bool getBooleanDefault() const;
SDO_API char getByteDefault() const;
SDO_API wchar_t getCharacterDefault() const;
@@ -256,7 +267,7 @@
const TypeImpl& type;
const Type& containertype;
const Property* opposite;
- char* name;
+ SDOString name;
char* stringdef;
void* defvalue;
@@ -264,7 +275,8 @@
unsigned int defvaluelength;
// alias support
- std::vector<char*> aliases;
+ // std::vector<char*> aliases;
+ std::vector<SDOString> aliases;
std::vector<Substitution> substitutions;
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSAX2Parser.cpp Tue Jun 6 07:16:35 2006
@@ -625,7 +625,7 @@
}
- if (URI.equalsIgnoreCase(Type::SDOTypeNamespaceURI))
+ if (URI.equalsIgnoreCase(Type::SDOTypeNamespaceURI.c_str()))
{
///////////////////////////////////////////////////////////////////////
// Handle datagraph
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOSchemaSAX2Parser.cpp Tue Jun 6 07:16:35 2006
@@ -942,7 +942,7 @@
currentType.isRestriction=false;
// ?? Does this only apply within a <simpleContent> tag??
- if (typeUri.equalsIgnoreCase(Type::SDOTypeNamespaceURI))
+ if (typeUri.equalsIgnoreCase(Type::SDOTypeNamespaceURI.c_str()))
{
// here the type needs to be flagged so that
// we know to serialize this property as an element with
@@ -1060,7 +1060,7 @@
if (currentProperty.typeName.isNull())
{
// Set the type of this property to default (sdo:String)
- currentProperty.typeUri = Type::SDOTypeNamespaceURI;
+ currentProperty.typeUri = Type::SDOTypeNamespaceURI.c_str();
currentProperty.typeName = "String";
}
@@ -1313,7 +1313,7 @@
///////////////////////////////////////////////////////////////////////
if (qname.getURI().equalsIgnoreCase("http://www.w3.org/2001/XMLSchema"))
{
- uri = Type::SDOTypeNamespaceURI;
+ uri = Type::SDOTypeNamespaceURI.c_str();
if (qname.getLocalName().equalsIgnoreCase("ID"))
{
name = "String";
@@ -1418,7 +1418,7 @@
}
// Temporary hack: ChangeSummaryType is ChangeSummary in core
- else if (qname.getURI().equalsIgnoreCase(Type::SDOTypeNamespaceURI))
+ else if (qname.getURI().equalsIgnoreCase(Type::SDOTypeNamespaceURI.c_str()))
{
if (qname.getLocalName().equalsIgnoreCase("ChangeSummaryType"))
{
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.cpp Tue Jun 6 07:16:35 2006
@@ -21,155 +21,65 @@
#include "commonj/sdo/SDOString.h"
#include <iostream>
-#include "libxml/globals.h"
+// #include "libxml/globals.h"
#include <ctype.h>
#include <string>
+// C6 duff compilation - see http://www.codecomments.com/message294418.html
+using std::string;
+#define std_string string
+
namespace commonj
{
namespace sdo
{
-
- SDOString::SDOString()
- : characters()
- {
- }
-
- SDOString::SDOString(const char* localString)
- {
- characters = localString;
- }
-
- SDOString::SDOString(const std::string& str)
- : characters(str)
- {
- }
-
- SDOString::SDOString(const SDOString& str)
- {
- characters = str.characters;
- }
-
- SDOString& SDOString::operator=(const SDOString& str)
+ inline SDOString::SDOString(const std::string& str)
+ : std_string(str)
{
- if (this != &str)
- {
- characters = str.characters;
- }
- return *this;
}
- SDOString SDOString::operator+(const SDOString& str) const
+ inline SDOString::~SDOString()
{
- std::string temp1 = characters;
- temp1 += str.characters;
- SDOString returnString = temp1.c_str();
-
- return returnString;
- }
- SDOString& SDOString::operator+=(const SDOString& str)
- {
- characters += str.characters;
- return *this;
- }
-
- SDOString::~SDOString()
- {
}
- bool SDOString::operator< (const SDOString& str) const
+ inline SDOString SDOString::substr(size_t i, size_t n) const
{
- if (characters.compare(str.characters) < 0)
- return true;
- else
- return false;
+ return SDOString(substr(i, n));
}
- bool SDOString::operator==(const SDOString& str) const
- {
- if (characters.compare(str.characters) == 0)
- return true;
- else
- return false;
- }
+// inline SDOString::SDOString(const std::string& str, size_t pos)
+// : std_string(str, pos)
+// {
+// }
- bool SDOString::equals(const SDOString& str) const
+ inline SDOString::SDOString(const std::string& str, size_t pos, size_t n)
+ : std_string(str, pos, n)
{
- // return (characters.equals(str.characters));
- return (characters == str.characters);
}
-
- bool SDOString::equals(const char* localString) const
- {
- return equals(SDOString(localString));
- }
-
-// bool SDOString::equalsIgnoreCase(const SDOString& str) const
-// {
-// return equalsIgnoreCase(str.xmlForm);
-// }
-// bool SDOString::equalsIgnoreCase(const char* localString) const
-// {
-// return equalsIgnoreCase(SDOString(localString));
-// }
-
- std::ostream& operator<<(std::ostream& output, const SDOString& str)
+ inline SDOString::SDOString(const char* str)
+ : std_string(str)
{
- if (!str.characters.empty())
- output << str.characters;
- return output;
}
- bool SDOString::isNull() const
+ inline SDOString::SDOString()
+ : std_string()
{
- return (characters.empty());
}
SDOString SDOString::toLower(unsigned int start, unsigned int length)
{
std::string result_string;
- result_string.reserve(characters.length());
-
- for (unsigned int i = start; (i < characters.length() && i < length); i++)
- {
- result_string[i] = tolower(characters[i]);
- }
-
- return SDOString(result_string);
- }
-
- int SDOString::firstIndexOf(const char ch) const
- {
- return int(characters.find_first_of(ch));
- }
+ result_string.reserve(size());
- int SDOString::lastIndexOf(const char ch) const
- {
- return int(characters.find_last_of(ch));
- }
-
- SDOString SDOString::substring(int start, int length) const
- {
- if (characters.length() > 0)
+ for (unsigned int i = start; (i < size() && i < length); i++)
{
- return SDOString(characters.substr(start, length));
+ result_string[i] = tolower((*this)[i]);
}
- else
- return SDOString();
- }
- SDOString SDOString::substring(int start) const
- {
- return substring(start, (characters.length() - start));
+ return SDOString(result_string);
}
-
- SDO_SPI const char* SDOString::c_str() const
- {
- return characters.c_str();
- }
-
} // End - namespace sdo
} // End - namespace commonj
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOString.h Tue Jun 6 07:16:35 2006
@@ -36,49 +36,39 @@
* replace it with a more NLS friendly version later.
*/
- class SDOString
- {
- public:
- SDO_SPI SDOString();
- SDO_SPI SDOString(const char* localString);
- SDO_SPI SDOString(const std::string& str);
- SDO_SPI SDOString(const SDOString& str);
- SDO_SPI virtual ~SDOString();
-
- SDO_SPI SDOString& operator=(const SDOString& str);
- SDO_SPI SDOString operator+(const SDOString& str) const;
- SDO_SPI SDOString& operator+=(const SDOString& str);
-
-
- SDO_SPI bool operator== (const SDOString& str) const;
- SDO_SPI bool equals(const char* localString) const;
- SDO_SPI bool equals(const SDOString& str) const;
- SDO_SPI bool equalsIgnoreCase(const char* localString) const;
- SDO_SPI bool equalsIgnoreCase(const SDOString& str) const;
-
- SDO_SPI bool operator< (const SDOString& str) const;
-
- // SDO_SPI operator const char*() const {return (const char*) xmlForm;}
-
- SDO_SPI friend std::ostream& operator<<(std::ostream& output, const SDOString& str);
-
- SDO_SPI bool isNull() const;
-
- SDO_SPI SDOString toLower(
- unsigned int start = 0,
- unsigned int length = 0);
-
-
- SDO_SPI int firstIndexOf(const char ch) const;
- SDO_SPI int lastIndexOf(const char ch) const;
- SDO_SPI SDOString substring(int start, int length) const;
- SDO_SPI SDOString substring(int start) const;
-
- SDO_SPI const char* c_str() const;
- private :
- std::string characters;
- void release();
- };
+ class SDOString : public std::string
+ {
+ public:
+ SDO_API SDOString substr(size_t i = 0, size_t n = std::string::npos) const;
+
+ SDO_API SDOString toLower(unsigned int start = 0,
+ unsigned int length = 0);
+ SDO_API SDOString(const std::string& str);
+ // SDO_SPI SDOString(const std::string& str, size_t pos);
+ SDO_API SDOString(const std::string& str, size_t pos, size_t n = std::string::npos);
+ SDO_API SDOString(const char* str);
+ SDO_API SDOString();
+ SDO_API ~SDOString();
+
+
+ // User defined conversion so that the compiler will automatically convert SDOString to const char *
+
+ // This is currently omitted because it can lead to confusion over
+ // which method should be called. For example, suppose we have two
+ // (overloaded) methods
+ // 1. void fn(const char* first, const char* second)
+ // 2. void fn(const SDOString& first, const SDOString& second)
+ // and we make a call passing a C style string as the first parameter and an SDOString
+ // as the second parameter. Currently, the first parameter is
+ // converted to an SDOString and the second method is called. If the
+ // conversion below is uncommented, then the compiler also has the
+ // option to convert the second parameter to a C style string and then
+ // call the first method - and it is ambiguous which of these to choose,
+ // leading to a compile time error.
+
+ // operator const char*() const { return c_str(); }
+
+ };
} // End - namespace sdo
} // End - namespace commonj
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXMLWriter.cpp Tue Jun 6 07:16:35 2006
@@ -19,6 +19,7 @@
#include "commonj/sdo/SDOXMLWriter.h"
#include "commonj/sdo/SDOXMLString.h"
+#include "commonj/sdo/SDOString.h"
#include "iostream"
using namespace::std;
#include "commonj/sdo/DASProperty.h"
@@ -120,15 +121,15 @@
{
elementURI = root->getType().getURI();
}
- SDOXMLString elementName = doc->getRootElementName();
- if (elementName.isNull() || elementName.equals(""))
+ SDOString elementName = doc->getRootElementName();
+ if (elementName.empty())
{
elementName = root->getType().getName();
elementName = elementName.toLower(0,1);
writeXSIType = true;
}
- writeDO(root, elementURI, elementName, true, true);
+ writeDO(root, elementURI, elementName.c_str(), true, true);
}
rc = xmlTextWriterEndDocument(writer);
if (rc < 0) {
@@ -466,7 +467,7 @@
ChangedDataObjectList& changedDOs = cs->getChangedDataObjects();
rc = xmlTextWriterStartElementNS(writer,
- SDOXMLString("sdo"), SDOXMLString("changeSummary"), SDOXMLString(Type::SDOTypeNamespaceURI));
+ SDOXMLString("sdo"), SDOXMLString("changeSummary"), SDOXMLString(Type::SDOTypeNamespaceURI.c_str()));
if (rc != 0) return;
if (cs->isLogging())
{
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOXSDWriter.cpp Tue Jun 6 07:16:35 2006
@@ -192,7 +192,7 @@
// --------------------------------------------------------------
SDOXMLString tns;
SDOXMLString xsd("xsd");
- SDOXMLString sdoURI(Type::SDOTypeNamespaceURI);
+ SDOXMLString sdoURI(Type::SDOTypeNamespaceURI.c_str());
SDOXMLString schemaURI = "http://www.w3.org/2001/XMLSchema";
rc = xmlTextWriterStartElementNS(writer, xsd, SDOXMLString("schema"), schemaURI);
@@ -219,7 +219,7 @@
for (i = 0; i<types.size(); i++)
{
SDOXMLString uri = types[i].getURI();
- if (uri.equals(Type::SDOTypeNamespaceURI)) continue;
+ if (uri.equals(Type::SDOTypeNamespaceURI.c_str())) continue;
std::map<SDOXMLString,SDOXMLString>::iterator it = namespaceMap.find(uri);
if (it == namespaceMap.end())
{
@@ -267,7 +267,7 @@
// Do not define SDO DataTypes
SDOXMLString uri = type.getURI();
- if (uri.equals(Type::SDOTypeNamespaceURI))
+ if (uri.equals(Type::SDOTypeNamespaceURI.c_str()))
continue;
// Do not define the RootType
@@ -701,7 +701,7 @@
SDOXMLString SDOXSDWriter::resolveName(const SDOXMLString& uri, const SDOXMLString& name, const SDOXMLString& targetNamespaceURI)
{
SDOXMLString resolvedName = name;
- if (uri.equals(Type::SDOTypeNamespaceURI))
+ if (uri.equals(Type::SDOTypeNamespaceURI.c_str()))
{
resolvedName = "xsd:";
if (name.equalsIgnoreCase("Boolean"))
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp Tue Jun 6 07:16:35 2006
@@ -37,7 +37,7 @@
SDO_THROW_EXCEPTION("Sequence API", SDOIndexOutOfRangeException,\
msg.c_str());\
}\
- int j = 0;\
+ unsigned int j = 0;\
for (i = the_list.begin(); (j < index) && (i != the_list.end()); ++i)\
{\
j++;\
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.cpp?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.cpp Tue Jun 6 07:16:35 2006
@@ -27,7 +27,7 @@
{
}
- const char* Type::SDOTypeNamespaceURI = "commonj.sdo";
+ const SDOString Type::SDOTypeNamespaceURI = "commonj.sdo";
};
};
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h?rev=412127&r1=412126&r2=412127&view=diff
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Type.h Tue Jun 6 07:16:35 2006
@@ -24,6 +24,8 @@
#include "commonj/sdo/export.h"
#include "commonj/sdo/PropertyList.h"
+#include "commonj/sdo/SDOString.h"
+
namespace commonj{
namespace sdo{
@@ -138,6 +140,7 @@
*/
virtual SDO_API const Property& getProperty(const char* propertyName) const = 0;
+ virtual SDO_API const Property& getProperty(const SDOString& propertyName) const = 0;
virtual SDO_API const Property& getProperty(unsigned int index) const = 0;
/** getPropertyIndex returns an index
@@ -146,6 +149,7 @@
*/
virtual SDO_API unsigned int getPropertyIndex(const char* propertyName) const = 0;
+ virtual SDO_API unsigned int getPropertyIndex(const SDOString& propertyName) const = 0;
/** isDataObjectType true if not a DataType
*
@@ -217,7 +221,7 @@
virtual SDO_API bool equals(const Type& tother) const = 0;
- static SDO_API const char* SDOTypeNamespaceURI;
+ static SDO_API const SDOString SDOTypeNamespaceURI;
};
};
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org