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/13 10:34:25 UTC
svn commit: r506932 [1/2] - in /incubator/tuscany/cpp/sdo/runtime/core:
src/commonj/sdo/ test/
Author: gwinn
Date: Tue Feb 13 01:34:23 2007
New Revision: 506932
URL: http://svn.apache.org/viewvc?view=rev&rev=506932
Log:
TUSCANY-980
Fix problem where sequenced types lose content on output.
Added:
incubator/tuscany/cpp/sdo/runtime/core/test/jira980_animaltypes.xsd (with props)
incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle.xsd (with props)
incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle_out.txt (with props)
incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle.xsd (with props)
incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle_out.txt (with props)
Modified:
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/SDODataConverter.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Sequence.h
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp
incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.h
incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
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?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObject.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObject.h Tue Feb 13 01:34:23 2007
@@ -190,8 +190,11 @@
virtual SDO_API void setDataObject(const char* path, DataObjectPtr value) = 0;
+ virtual SDO_API void setDataObject(const char* path, DataObjectPtr value, bool updateSequence) = 0;
virtual SDO_API void setDataObject(const SDOString& path, DataObjectPtr value) = 0;
+ virtual SDO_API void setDataObject(const SDOString& path, DataObjectPtr value, bool updateSequence) = 0;
virtual SDO_API void setDataObject(unsigned int propertyIndex, DataObjectPtr value) = 0;
+ virtual SDO_API void setDataObject(unsigned int propertyIndex, DataObjectPtr value, bool updateSequence) = 0;
virtual SDO_API void setDataObject(const Property& property, DataObjectPtr value) = 0;
/** getBoolean returns a boolean by path, index or property
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?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.cpp Tue Feb 13 01:34:23 2007
@@ -580,42 +580,42 @@
}
}
- void DataObjectImpl::setNull(const unsigned int propertyIndex)
- {
- validateIndex(propertyIndex);
- const Property& property = getProperty(propertyIndex);
- if ((property.isMany()))
- {
- string msg("Setting a list to null is not supported:");
- msg += property.getName();
- SDO_THROW_EXCEPTION("setNull", SDOUnsupportedOperationException,
- msg.c_str());
- }
-
- ASSERT_WRITABLE(property, setNull)
+ void DataObjectImpl::setNull(const unsigned int propertyIndex)
+ {
+ validateIndex(propertyIndex);
+ const Property& property = getProperty(propertyIndex);
+ if (property.isMany())
+ {
+ string msg("Setting a list to null is not supported:");
+ msg += property.getName();
+ SDO_THROW_EXCEPTION("setNull",
+ SDOUnsupportedOperationException,
+ msg.c_str());
+ }
- PropertyValueMap::iterator i;
- for (i = PropertyValues.begin(); i != PropertyValues.end();++i)
- {
- if ((*i).first == propertyIndex)
- {
- logChange(propertyIndex);
- (*i).second->setNull();
- return;
- }
- }
- // The property was not set yet...
- logChange(propertyIndex);
- DataFactory* df = getDataFactory();
- DataObjectImpl* b = new DataObjectImpl(df,
- getProperty(propertyIndex).getType());
- b->setContainer(this);
- b->setApplicableChangeSummary();
- PropertyValues.insert(PropertyValues.end(),rdo(propertyIndex,b));
- b->setNull();
+ ASSERT_WRITABLE(property, setNull);
+ PropertyValueMap::iterator i;
+ for (i = PropertyValues.begin(); i != PropertyValues.end(); ++i)
+ {
+ if ((*i).first == propertyIndex)
+ {
+ logChange(propertyIndex);
+ (*i).second->setNull();
+ return;
+ }
+ }
+ // The property was not set yet...
+ logChange(propertyIndex);
+ DataFactory* df = getDataFactory();
+ DataObjectImpl* b =
+ new DataObjectImpl(df, getProperty(propertyIndex).getType());
+ b->setContainer(this);
+ b->setApplicableChangeSummary();
+ PropertyValues.insert(PropertyValues.end(),rdo(propertyIndex,b));
+ b->setNull();
+ }
- }
void DataObjectImpl::setNull(const Property& property)
{
setNull(getPropertyIndexInternal(property));
@@ -1495,12 +1495,24 @@
void DataObjectImpl::setDataObject(const char* path, DataObjectPtr value)
{
- setDataObject(SDOString(path), value);
+ setDataObject(SDOString(path), value, true);
}
+ void DataObjectImpl::setDataObject(const char* path, DataObjectPtr value, bool updateSequence)
+ {
+ setDataObject(SDOString(path), value, updateSequence);
+ }
+
void DataObjectImpl::setDataObject(const SDOString& path,
DataObjectPtr value)
{
+ setDataObject(path, value, false);
+ }
+
+ void DataObjectImpl::setDataObject(const SDOString& path,
+ DataObjectPtr value,
+ bool updateSequence)
+ {
DataObjectImpl* d;
SDOString prop = findPropertyContainer(path, &d);
@@ -1546,7 +1558,7 @@
}
else
{
- d->setDataObject((Property&)*p,value);
+ d->setDataObject((Property&) *p, value, updateSequence);
return;
}
}
@@ -1658,130 +1670,173 @@
void DataObjectImpl::setDataObject(unsigned int propertyIndex, DataObjectPtr value)
{
- setDataObject(getProperty(propertyIndex), value);
+ setDataObject(getProperty(propertyIndex), value, true);
}
- void DataObjectImpl::setDataObject(const Property& prop, DataObjectPtr value)
+ void DataObjectImpl::setDataObject(unsigned int propertyIndex, DataObjectPtr value, bool updateSequence)
{
- unsigned int propertyIndex = getPropertyIndexInternal(prop);
+ setDataObject(getProperty(propertyIndex), value, updateSequence);
+ }
- if (value != 0)
- {
- checkFactory(value, propertyIndex);
- checkType(prop, value->getType());
- }
+ void DataObjectImpl::setDataObject(const Property& prop, DataObjectPtr value)
+ {
+ setDataObject(prop, value, false);
+ }
- validateIndex(propertyIndex);
+void DataObjectImpl::setDataObject(const Property& prop,
+ DataObjectPtr value,
+ bool updateSequence)
+{
+ unsigned int propertyIndex = getPropertyIndexInternal(prop);
- if (prop.isReference() && (value != 0))
- {
- // just need to make sure that the object is already part of our tree.
- DataObjectImpl* r1 = this;
- while (r1->getContainerImpl() != 0)
- {
- r1 = r1->getContainerImpl();
- }
- DataObjectImpl* r2 = (DataObjectImpl*) (DataObject*) value;
- while (r2->getContainerImpl() != 0)
- {
- r2 = r2->getContainerImpl();
- }
- if (r1 != r2)
- {
- string msg("Set of a reference to an object outside the graph");
- SDO_THROW_EXCEPTION("setDataObject",
- SDOUnsupportedOperationException,
- msg.c_str());
- }
- }
+ if (value != 0)
+ {
+ checkFactory(value, propertyIndex);
+ checkType(prop, value->getType());
+ }
- if ((prop.isMany()))
- {
- string msg("Set operation on a many valued property:");
- msg += prop.getName();
- SDO_THROW_EXCEPTION("setDataObject",
- SDOUnsupportedOperationException,
- msg.c_str());
- }
+ validateIndex(propertyIndex);
- ASSERT_WRITABLE(prop, setDataObject);
+ if (prop.isReference() && (value != 0))
+ {
+ // just need to make sure that the object is already part of our tree.
+ DataObjectImpl* r1 = this;
+ while (r1->getContainerImpl() != 0)
+ {
+ r1 = r1->getContainerImpl();
+ }
+ DataObjectImpl* r2 = (DataObjectImpl*) (DataObject*) value;
+ while (r2->getContainerImpl() != 0)
+ {
+ r2 = r2->getContainerImpl();
+ }
+ if (r1 != r2)
+ {
+ string msg("Set of a reference to an object outside the graph");
+ SDO_THROW_EXCEPTION("setDataObject",
+ SDOUnsupportedOperationException,
+ msg.c_str());
+ }
+ }
- if (value == 0)
- {
- PropertyValueMap::iterator j;
- for (j = PropertyValues.begin(); j != PropertyValues.end(); ++j)
- {
- if ((*j).first == propertyIndex)
- {
- if (prop.isReference())
- {
- ((*j).second)->unsetReference(this, prop);
- }
- else
- {
- // log both deletion and change - change is not
- // automatically recorded by deletion.
- ((*j).second)->logDeletion();
- }
- logChange(prop);
- (*j).second = RefCountingPointer<DataObjectImpl>(0);
- return;
- }
- }
- logChange(prop);
- PropertyValues.insert(PropertyValues.end(), rdo(propertyIndex, (DataObjectImpl*) 0));
- return;
- }
+ if ((prop.isMany()))
+ {
+ string msg("Set operation on a many valued property:");
+ msg += prop.getName();
+ SDO_THROW_EXCEPTION("setDataObject",
+ SDOUnsupportedOperationException,
+ msg.c_str());
+ }
- DataObject* dob = value;
- PropertyValueMap::iterator i;
- for (i = PropertyValues.begin(); i != PropertyValues.end(); ++i)
- {
- if ((*i).first == propertyIndex)
- {
- if (prop.isReference())
- {
- ((*i).second)->unsetReference(this, prop);
- }
- else
- {
- // log both deletion and change - change is not
- // automatically recorded by deletion.
- ((*i).second)->logDeletion();
- }
- logChange(prop);
+ ASSERT_WRITABLE(prop, setDataObject);
- (*i).second = RefCountingPointer<DataObjectImpl>((DataObjectImpl*) dob);
+ if (value == 0)
+ {
+ // The new data object value is actually a null pointer.
+ PropertyValueMap::iterator j;
+ // Scan the property value map looking for this property.
+ for (j = PropertyValues.begin(); j != PropertyValues.end(); ++j)
+ {
+ if ((*j).first == propertyIndex)
+ {
+ if (prop.isReference())
+ {
+ ((*j).second)->unsetReference(this, prop);
+ }
+ else
+ {
+ // log both deletion and change - change is not
+ // automatically recorded by deletion.
+ ((*j).second)->logDeletion();
+ }
+ logChange(prop);
+ (*j).second = RefCountingPointer<DataObjectImpl>(0);
+ // We have just changed the value of this property, therefore
+ // if this is a sequenced data object, then we must update the
+ // sequence so that the new setting appears at the end (and
+ // the existing entry is removed).
+ if ((getType().isSequencedType()) && updateSequence)
+ {
+ SequenceImpl* mySequence = getSequenceImpl();
+ mySequence->removeAll(prop);
+ mySequence->push(prop, 0);
+ }
- if (prop.isReference())
- {
- ((DataObjectImpl*) dob)->setReference(this, prop);
- }
- else
- {
- logCreation((*i).second, this, prop);
- }
- return;
- }
- }
- if (prop.isReference())
- {
- ((DataObjectImpl*)dob)->setReference(this, prop);
- }
- else
- {
- ((DataObjectImpl*)dob)->setContainer(this);
- ((DataObjectImpl*)dob)->setApplicableChangeSummary();
- // log creation before putting into property values.
- // also log change - not done by logCreation
- logCreation((DataObjectImpl*)dob, this, prop);
- }
+ return;
+ }
+ }
+ // The property does not currently have a value.
+ logChange(prop);
+ PropertyValues.insert(PropertyValues.end(), rdo(propertyIndex, (DataObjectImpl*) 0));
+ // If this is a sequenced data object then update the
+ // sequence. We already know that a) the property was not previously
+ // set so it can't be in the sequence currently and b) it is not a
+ // multi-valued property.
+ if ((getType().isSequencedType()) && updateSequence)
+ {
+ getSequenceImpl()->push(prop, 0);
+ }
+ return;
+ }
- logChange(prop);
+ DataObject* dob = value;
+ PropertyValueMap::iterator i;
+ for (i = PropertyValues.begin(); i != PropertyValues.end(); ++i)
+ {
+ if ((*i).first == propertyIndex)
+ {
+ if (prop.isReference())
+ {
+ ((*i).second)->unsetReference(this, prop);
+ }
+ else
+ {
+ // log both deletion and change - change is not
+ // automatically recorded by deletion.
+ ((*i).second)->logDeletion();
+ }
+ logChange(prop);
- PropertyValues.insert(PropertyValues.end(), rdo(propertyIndex, (DataObjectImpl*) dob));
- return;
- }
+ (*i).second = RefCountingPointer<DataObjectImpl>((DataObjectImpl*) dob);
+
+ if (prop.isReference())
+ {
+ ((DataObjectImpl*) dob)->setReference(this, prop);
+ }
+ else
+ {
+ logCreation((*i).second, this, prop);
+ }
+ return;
+ }
+ }
+ if (prop.isReference())
+ {
+ ((DataObjectImpl*)dob)->setReference(this, prop);
+ }
+ else
+ {
+ ((DataObjectImpl*)dob)->setContainer(this);
+ ((DataObjectImpl*)dob)->setApplicableChangeSummary();
+ // log creation before putting into property values.
+ // also log change - not done by logCreation
+ logCreation((DataObjectImpl*)dob, this, prop);
+ }
+
+ logChange(prop);
+
+ PropertyValues.insert(PropertyValues.end(), rdo(propertyIndex, (DataObjectImpl*) dob));
+ // If this is a sequenced data object then update the
+ // sequence. We already know that a) the property is not
+ // in the sequence currently and b) it is not a
+ // multi-valued property.
+ if ((getType().isSequencedType()) && updateSequence)
+ {
+ getSequenceImpl()->push(prop, 0);
+ }
+
+ return;
+}
bool DataObjectImpl::isValid(const char* path)
{
@@ -1908,54 +1963,55 @@
}
}
- void DataObjectImpl::unset(const SDOString& path)
- {
- DataObjectImpl* d;
- SDOString prop = findPropertyContainer(path, &d);
- if (d != 0)
- {
- if (!prop.empty())
- {
- const Property& p = d->getProperty(prop);
- ASSERT_WRITABLE(p, unset)
- if (p.isMany())
- {
- SDOString subscript;
- size_t beginbrace = prop.find('[');
- if (beginbrace != string::npos)
- {
- size_t endbrace = prop.find(']', ++beginbrace);
- if (endbrace != string::npos) {
- subscript =
- prop.substr(beginbrace, (endbrace - beginbrace));
- }
- unsigned int i = atoi(subscript.c_str());
- if (i > 0) {
- i--;
- DataObjectList& li = d->getList(p);
- li.remove(i);
- }
- return;
- }
- size_t firstdot = prop.find('.');
- if (firstdot != string::npos) {
- subscript = prop.substr(++firstdot);
- unsigned int i = atoi(subscript.c_str());
- DataObjectList& li = d->getList(p);
- li.remove(i);
- return;
- }
- }
- d->unset(p);
- return;
+ void DataObjectImpl::unset(const SDOString& path)
+ {
+ DataObjectImpl* d;
+ SDOString prop = findPropertyContainer(path, &d);
+ if (d != 0)
+ {
+ if (!prop.empty())
+ {
+ const Property& p = d->getProperty(prop);
+ ASSERT_WRITABLE(p, unset);
+ if (p.isMany())
+ {
+ SDOString subscript;
+ size_t beginbrace = prop.find('[');
+ if (beginbrace != string::npos)
+ {
+ size_t endbrace = prop.find(']', ++beginbrace);
+ if (endbrace != string::npos) {
+ subscript =
+ prop.substr(beginbrace, (endbrace - beginbrace));
+ }
+ unsigned int i = atoi(subscript.c_str());
+ if (i > 0) {
+ i--;
+ DataObjectList& li = d->getList(p);
+ li.remove(i);
+ }
+ return;
+ }
+ size_t firstdot = prop.find('.');
+ if (firstdot != string::npos) {
+ subscript = prop.substr(++firstdot);
+ unsigned int i = atoi(subscript.c_str());
+ DataObjectList& li = d->getList(p);
+ li.remove(i);
+ return;
+ }
}
- }
-
- string msg("Invalid path:");
- msg += path;
- SDO_THROW_EXCEPTION("unset", SDOPathNotFoundException,
- msg.c_str());
- }
+ d->unset(p);
+ return;
+ }
+ }
+
+ string msg("Invalid path:");
+ msg += path;
+ SDO_THROW_EXCEPTION("unset",
+ SDOPathNotFoundException,
+ msg.c_str());
+ }
void DataObjectImpl::unset(unsigned int propertyIndex)
{
@@ -3684,6 +3740,14 @@
const SDOValue& sval,
const SDOString& dataType)
{
+ setSDOValue(propertyIndex, sval, dataType, false);
+ }
+
+ void DataObjectImpl::setSDOValue(unsigned int propertyIndex,
+ const SDOValue& sval,
+ const SDOString& dataType,
+ bool updateSequence)
+ {
validateIndex(propertyIndex);
PropertyImpl *const p = getPropertyImpl(propertyIndex);
@@ -3715,11 +3779,21 @@
logChange(propertyIndex);
(*i).second->unsetNull();
(*i).second->setSDOValue(sval);
+
+ // If this is a sequenced data object then update the sequence. We
+ // already know that a) the property is already set and b) it
+ // is not a multi-valued property.
+ if ((getType().isSequencedType()) && updateSequence)
+ {
+ SequenceImpl* mySequence = getSequenceImpl();
+ mySequence->removeAll(getProperty(propertyIndex));
+ mySequence->push(getProperty(propertyIndex), 0);
+ }
return;
}
}
- // No existing property has the given index.
+ // No existing property has the given index.
DataFactory* df = getDataFactory();
// It is tempting to use the raw data type from the SDOValue object to
// set the type of the created DataObjectImpl but we can't because the
@@ -3731,6 +3805,17 @@
logChange(propertyIndex);
PropertyValues.insert(PropertyValues.end(), rdo(propertyIndex, b));
b->setSDOValue(sval);
+
+ // If this is a sequenced data object then update the sequence. We
+ // already know that a) the property is not already set and b) it
+ // is not a multi-valued property.
+ if ((getType().isSequencedType()) && updateSequence)
+ {
+ SequenceImpl* mySequence = getSequenceImpl();
+ mySequence->removeAll(getProperty(propertyIndex));
+ mySequence->push(getProperty(propertyIndex), 0);
+ }
+
return;
}
@@ -3739,6 +3824,14 @@
const SDOString& dataType)
{
setSDOValue(getPropertyIndexInternal(property), sval, dataType);
+ }
+
+ void DataObjectImpl::setSDOValue(const Property& property,
+ const SDOValue& sval,
+ const SDOString& dataType,
+ bool updateSequence)
+ {
+ setSDOValue(getPropertyIndexInternal(property), sval, dataType, updateSequence);
}
void DataObjectImpl::setSDOValue(const SDOValue& invalue)
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?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectImpl.h Tue Feb 13 01:34:23 2007
@@ -215,9 +215,13 @@
*/
virtual void setDataObject(const char* path, DataObjectPtr value);
+ virtual void setDataObject(const char* path, DataObjectPtr value, bool updateSequence);
virtual void setDataObject(const SDOString& path, DataObjectPtr value);
+ virtual void setDataObject(const SDOString& path, DataObjectPtr value, bool updateSequence);
virtual void setDataObject(unsigned int propertyIndex, DataObjectPtr value);
+ virtual void setDataObject(unsigned int propertyIndex, DataObjectPtr value, bool updateSequence);
virtual void setDataObject(const Property& property, DataObjectPtr value);
+ virtual void setDataObject(const Property& property, DataObjectPtr value, bool updateSequence);
/** getBoolean returns a boolean by path, index or property
*
@@ -596,6 +600,21 @@
virtual std::ostream& printSelf(std::ostream &os);
+ virtual const SDOValue& getSDOValue(PropertyImpl** propertyForDefault);
+ virtual const SDOValue& getSDOValue(const unsigned int propertyIndex,
+ PropertyImpl** propertyForDefault);
+ virtual const SDOValue& getSDOValue(const Property& property,
+ PropertyImpl** propertyForDefault);
+ virtual const SDOValue& getSDOValue(const SDOString& path,
+ PropertyImpl** propertyForDefault);
+ virtual void setSDOValue(const SDOString& path, const SDOValue& sval, const SDOString& dataType);
+ virtual void setSDOValue(unsigned int propindex, const SDOValue& sval, const SDOString& dataType);
+ virtual void setSDOValue(unsigned int propindex, const SDOValue& sval, const SDOString& dataType, bool updateSequence);
+ virtual void setSDOValue(const Property& p, const SDOValue& sval, const SDOString& dataType);
+ virtual void setSDOValue(const Property& p, const SDOValue& sval, const SDOString& dataType, bool updateSequence);
+
+
+
private:
/**
* This method is used internally to find the index of a
@@ -634,18 +653,6 @@
// Does not keep a reference counted pointer to the container.
DataObjectImpl* container;
-
- virtual void setSDOValue(const SDOString& path, const SDOValue& sval, const SDOString& dataType);
- virtual void setSDOValue(unsigned int propindex, const SDOValue& sval, const SDOString& dataType);
- virtual void setSDOValue(const Property& p, const SDOValue& sval, const SDOString& dataType);
-
- virtual const SDOValue& getSDOValue(PropertyImpl** propertyForDefault);
- virtual const SDOValue& getSDOValue(const unsigned int propertyIndex,
- PropertyImpl** propertyForDefault);
- virtual const SDOValue& getSDOValue(const Property& property,
- PropertyImpl** propertyForDefault);
- virtual const SDOValue& getSDOValue(const SDOString& path,
- PropertyImpl** propertyForDefault);
PropertyValueMap PropertyValues;
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?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/DataObjectListImpl.cpp Tue Feb 13 01:34:23 2007
@@ -402,73 +402,80 @@
void DataObjectListImpl::append (DataObjectPtr d)
{
- if (typeUnset)setType(d->getType().getURI(),d->getType().getName());
-
- if (container != 0)
- {
- container->logChange(pindex);
- }
-
- for (unsigned int i=0;i < plist.size(); i++)
- {
- if (plist[i] == d)
- {
- std::string msg("Append of object which already exists in the list:");
- msg += typeURI;
- msg += " ";
- msg += typeName;
- SDO_THROW_EXCEPTION("List append", SDOUnsupportedOperationException,
- msg.c_str());
- }
- }
-
- checkFactory(d);
-
- checkType(theFactory->getType(typeURI,typeName),
- d->getType());
-
- const Property& property = container->getProperty(pindex);
- ASSERT_WRITABLE(property,append)
-
- DataObject* dob = d; // unwrap the data object ready for a downcasting hack.
- DataObjectImpl* con = ((DataObjectImpl*)dob)->getContainerImpl();
-
- if (!isReference)
- {
- if (con != 0)
- {
- if (con != container)
- {
- /* this data object is already contained somewhere else */
- std::string msg("Append of object to list, object is already contained:");
- msg += d->getType().getURI();
- msg += " ";
- msg += d->getType().getName();
- SDO_THROW_EXCEPTION("List append", SDOInvalidConversionException,
- msg.c_str());
- }
- }
- else
- {
- ((DataObjectImpl*)dob)->setContainer(container);
- ((DataObjectImpl*)dob)->setApplicableChangeSummary();
- if (!container->getProperty(pindex).getType().isDataType())
- {
- ((DataObjectImpl*)dob)->logCreation((DataObjectImpl*)dob,
- container,property);
- }
-
- }
- }
- plist.insert(plist.end(),RefCountingPointer<DataObjectImpl>((DataObjectImpl*)dob));
-
- if (container != 0) {
- if (container->getType().isSequencedType())
- {
- SequenceImpl* sq = container->getSequenceImpl();
- if (sq)sq->push(property,plist.size()-1);
- }
- }
+ if (typeUnset)
+ {
+ setType(d->getType().getURI(), d->getType().getName());
+ }
+ if (container != 0)
+ {
+ container->logChange(pindex);
+ }
+
+ for (unsigned int i = 0; i < plist.size(); i++)
+ {
+ if (plist[i] == d)
+ {
+ std::string msg("Append of object which already exists in the list:");
+ msg += typeURI;
+ msg += " ";
+ msg += typeName;
+ SDO_THROW_EXCEPTION("List append",
+ SDOUnsupportedOperationException,
+ msg.c_str());
+ }
+ }
+
+ checkFactory(d);
+
+ checkType(theFactory->getType(typeURI, typeName),
+ d->getType());
+
+ const Property& property = container->getProperty(pindex);
+ ASSERT_WRITABLE(property, append);
+
+ DataObject* dob = d; // unwrap the data object ready for a downcasting hack.
+ DataObjectImpl* con = ((DataObjectImpl*) dob)->getContainerImpl();
+
+ if (!isReference)
+ {
+ if (con != 0)
+ {
+ if (con != container)
+ {
+ /* this data object is already contained somewhere else */
+ std::string msg("Append of object to list, object is already contained:");
+ msg += d->getType().getURI();
+ msg += " ";
+ msg += d->getType().getName();
+ SDO_THROW_EXCEPTION("List append",
+ SDOInvalidConversionException,
+ msg.c_str());
+ }
+ }
+ else
+ {
+ ((DataObjectImpl*) dob)->setContainer(container);
+ ((DataObjectImpl*) dob)->setApplicableChangeSummary();
+ if (!container->getProperty(pindex).getType().isDataType())
+ {
+ ((DataObjectImpl*) dob)->logCreation((DataObjectImpl*)dob,
+ container,
+ property);
+ }
+ }
+ }
+ plist.insert(plist.end(), RefCountingPointer<DataObjectImpl>((DataObjectImpl*) dob));
+
+ if (container != 0) {
+ if (container->getType().isSequencedType())
+ {
+ SequenceImpl* sq = container->getSequenceImpl();
+ if (sq)
+ {
+ sq->push(property, (plist.size() - 1));
+ }
+ }
+ }
}
void DataObjectListImpl::insert (unsigned int index, bool d)
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDODataConverter.cpp Tue Feb 13 01:34:23 2007
@@ -640,12 +640,12 @@
case DataTypeInfo::TDTfloat:
{
- sprintf(buffer , "%ld", sourceValue.Float);
+ sprintf(buffer , "%.3e", sourceValue.Float);
break;
}
case DataTypeInfo::TDTdouble:
{
- sprintf(buffer , "%ld", sourceValue.Double);
+ sprintf(buffer , "%.3Le", sourceValue.Double);
break;
}
case DataTypeInfo::TDTSDODate:
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.cpp?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.cpp Tue Feb 13 01:34:23 2007
@@ -93,6 +93,7 @@
case DataTypeInfo::SDOCString:
case DataTypeInfo::SDOByteArray:
value.TextString = new SDOString(*(inValue.value.TextString));
+ break;
case DataTypeInfo::SDOWideString:
value.WideString.data = new wchar_t[inValue.value.WideString.length + 1];
// The loop copies the null terminator that was added to the end
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.h?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SDOValue.h Tue Feb 13 01:34:23 2007
@@ -111,6 +111,12 @@
value.TextString = new SDOString(inValue);
}
+ SDO_API SDOValue(const char* inValue) :
+ typeOfValue(DataTypeInfo::SDOCString), transient_buffer(0)
+ {
+ value.TextString = new SDOString(inValue);
+ }
+
SDO_API SDOValue(const char* inValue, unsigned int len);
SDO_API SDOValue(const wchar_t* inValue, unsigned int len);
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Sequence.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Sequence.h?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Sequence.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/Sequence.h Tue Feb 13 01:34:23 2007
@@ -28,6 +28,7 @@
#include "commonj/sdo/RefCountingPointer.h"
#include "commonj/sdo/SDODate.h"
#include "commonj/sdo/Type.h"
+#include "commonj/sdo/SDOValue.h"
namespace commonj{
@@ -123,6 +124,7 @@
SDO_API virtual long double getDoubleValue(unsigned int index) = 0;
SDO_API virtual const SDODate getDateValue(unsigned int index) = 0;
SDO_API virtual DataObjectPtr getDataObjectValue(unsigned int index) = 0;
+ SDO_API virtual const SDOValue& getSDOValue(unsigned int index) = 0;
/**
*
@@ -178,6 +180,7 @@
SDO_API virtual bool addDouble(const char* propertyName,long double d ) = 0;
SDO_API virtual bool addDate(const char* propertyName,const SDODate t ) = 0;
SDO_API virtual bool addDataObject(const char* propertyName,DataObjectPtr d ) = 0;
+ SDO_API virtual bool addSDOValue(const char* propertyName, const SDOValue& sval) = 0;
SDO_API virtual bool addCString( unsigned int propertyIndex,const char* s ) = 0;
@@ -193,6 +196,7 @@
SDO_API virtual bool addDouble(unsigned int propertyIndex,long double d ) = 0;
SDO_API virtual bool addDate(unsigned int propertyIndex,const SDODate t ) = 0;
SDO_API virtual bool addDataObject(unsigned int propertyIndex,DataObjectPtr d ) = 0;
+ SDO_API virtual bool addSDOValue(unsigned int propertyIndex, const SDOValue& sval) = 0;
@@ -209,6 +213,7 @@
SDO_API virtual bool addDouble(const Property& property,long double d ) = 0;
SDO_API virtual bool addDate(const Property& property,const SDODate t ) = 0;
SDO_API virtual bool addDataObject(const Property& property,DataObjectPtr d ) = 0;
+ SDO_API virtual bool addSDOValue(const Property& property, const SDOValue& sval) = 0;
/**
@@ -235,6 +240,7 @@
SDO_API virtual bool addDouble(unsigned int index,const char* propertyName,long double d ) = 0;
SDO_API virtual bool addDate(unsigned int index,const char* propertyName,const SDODate t ) = 0;
SDO_API virtual bool addDataObject(unsigned int index,const char* propertyName,DataObjectPtr d ) = 0;
+ SDO_API virtual bool addSDOValue(unsigned int index, const char* propertyName, const SDOValue& sval) = 0;
SDO_API virtual bool addCString( unsigned int index,unsigned int propertyIndex,const char* s ) = 0;
@@ -250,6 +256,7 @@
SDO_API virtual bool addDouble(unsigned int index,unsigned int propertyIndex,long double d ) = 0;
SDO_API virtual bool addDate(unsigned int index,unsigned int propertyIndex,const SDODate t ) = 0;
SDO_API virtual bool addDataObject(unsigned int index,unsigned int propertyIndex,DataObjectPtr d ) = 0;
+ SDO_API virtual bool addSDOValue(unsigned int index, unsigned int propertyIndex, const SDOValue& sval) = 0;
SDO_API virtual bool addCString( unsigned int index,const Property& property,const char* s ) = 0;
@@ -265,6 +272,7 @@
SDO_API virtual bool addDouble(unsigned int index,const Property& property,long double d ) = 0;
SDO_API virtual bool addDate(unsigned int index,const Property& property,const SDODate t ) = 0;
SDO_API virtual bool addDataObject(unsigned int index,const Property& property,DataObjectPtr d ) = 0;
+ SDO_API virtual bool addSDOValue(unsigned int index, const Property& property, const SDOValue& sval) = 0;
/** remove() removes an item.
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?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.cpp Tue Feb 13 01:34:23 2007
@@ -46,242 +46,213 @@
}
-namespace commonj{
-namespace sdo{
-
- SequenceImpl::SequenceImpl()
- {
- SDO_THROW_EXCEPTION("Sequence constructor", SDORuntimeException,\
- "SequenceImpl::construction without a data object");\
- }
+namespace commonj
+{
+ namespace sdo
+ {
- SequenceImpl::SequenceImpl(DataObject* indo)
- {
- the_do = (DataObjectImpl*)indo;
- }
+ SequenceImpl::SequenceImpl()
+ {
+ SDO_THROW_EXCEPTION("Sequence constructor",
+ SDORuntimeException,
+ "SequenceImpl::construction without a data object");
+ }
- SequenceImpl::SequenceImpl(SequenceImpl* inseq)
- {
- // take a copy of the_list
- the_list = inseq->the_list;
- }
+ SequenceImpl::SequenceImpl(DataObject* indo)
+ {
+ the_do = (DataObjectImpl*) indo;
+ }
- unsigned int SequenceImpl::size()
- {
- return the_list.size();
- }
+ SequenceImpl::SequenceImpl(SequenceImpl* inseq)
+ {
+ // take a copy of the_list
+ the_list = inseq->the_list;
+ }
-
- /**
- * Return the data object associated with this sequence
- */
+ unsigned int SequenceImpl::size()
+ {
+ return the_list.size();
+ }
- const DataObjectPtr SequenceImpl::getDataObject()
- {
- return the_do;
- }
+ // Convert an index into the sequence into an iterator (pointer) to the
+ // list element identified by the index. If the index is invalid then
+ // throw an exception.
+ void SequenceImpl::checkRange(unsigned int index, SEQUENCE_ITEM_LIST::iterator& i)
+ {
+ if (index >= the_list.size())
+ {
+ std::string msg("Index out of range:");
+ msg += index;
+ SDO_THROW_EXCEPTION("Sequence API",
+ SDOIndexOutOfRangeException,
+ msg.c_str());
+ }
+ unsigned int j = 0;
+ for (i = the_list.begin(); (j < index) && (i != the_list.end()); ++i)
+ {
+ j++;
+ }
+ return;
+ }
+
+ // Return the data object associated with this sequence
+ const DataObjectPtr SequenceImpl::getDataObject()
+ {
+ return the_do;
+ }
- const Property& SequenceImpl::getProperty(unsigned int index)
- {
- SEQUENCE_ITEM_LIST::iterator i;
+ const Property& SequenceImpl::getProperty(unsigned int index)
+ {
+ SEQUENCE_ITEM_LIST::iterator i;
- if (isText(index))
- {
+ if (isText(index))
+ {
std::string msg("Cannot get property of a text item");
msg += index;
- SDO_THROW_EXCEPTION("getProperty", SDOUnsupportedOperationException,
- msg.c_str());
- }
+ SDO_THROW_EXCEPTION("getProperty",
+ SDOUnsupportedOperationException,
+ msg.c_str());
+ }
- unsigned int j = 0;
- for (i = the_list.begin() ; (j < index) && (i != the_list.end()); ++i){j++;}
-
- if (i != the_list.end()) {
+ checkRange(index, i);
+
+ if (i != the_list.end())
+ {
return *((*i).getProp());
- }
- std::string msg("Index out of range:");
- msg += index;
- SDO_THROW_EXCEPTION("getProperty", SDOIndexOutOfRangeException,
- msg.c_str());
- }
+ }
+ std::string msg("Index out of range:");
+ msg += index;
+ SDO_THROW_EXCEPTION("getProperty",
+ SDOIndexOutOfRangeException,
+ msg.c_str());
+ }
- Type::Types SequenceImpl::getTypeEnum(unsigned int index)
- {
- SEQUENCE_ITEM_LIST::iterator i;
+ Type::Types SequenceImpl::getTypeEnum(unsigned int index)
+ {
+ SEQUENCE_ITEM_LIST::iterator i;
- unsigned int j = 0;
- for (i = the_list.begin() ; (j < index) && (i != the_list.end()); ++i){j++;}
+ checkRange(index, i);
- if (i != the_list.end()) {
- if ((*i).getProp() == 0) {
- // text type
- return Type::TextType;
+ if (i != the_list.end())
+ {
+ if ((*i).getProp() == 0)
+ {
+ // text type
+ return Type::TextType;
}
- return (*i).getProp()->getTypeEnum();
- }
- std::string msg("Index out of range:");
- msg += index;
- SDO_THROW_EXCEPTION("getTypeEnum", SDOIndexOutOfRangeException,
- msg.c_str());
- }
+ return (*i).getProp()->getTypeEnum();
+ }
+ std::string msg("Index out of range:");
+ msg += index;
+ SDO_THROW_EXCEPTION("getTypeEnum",
+ SDOIndexOutOfRangeException,
+ msg.c_str());
+ }
- unsigned int SequenceImpl::getListIndex(unsigned int index)
- {
- SEQUENCE_ITEM_LIST::iterator i;
- unsigned int j = 0;
- for (i = the_list.begin() ; (j < index) && (i != the_list.end()); ++i){j++;}
+ unsigned int SequenceImpl::getListIndex(unsigned int index)
+ {
+ SEQUENCE_ITEM_LIST::iterator i;
- if (i != the_list.end()) {
+ checkRange(index, i);
+
+ if (i != the_list.end()) {
if ((*i).getProp() == 0)
{
- std::string msg("Get list index on text property");
- SDO_THROW_EXCEPTION("getListIndex", SDOUnsupportedOperationException,
- msg.c_str());
+ std::string msg("Get list index on text property");
+ SDO_THROW_EXCEPTION("getListIndex",
+ SDOUnsupportedOperationException,
+ msg.c_str());
}
- if ( (*i).getProp()->isMany())
+ if ((*i).getProp()->isMany())
{
- return (*i).getIndex();
+ return (*i).getIndex();
}
- else
+ else
{
- std::string msg("Get list index on text single valued property");
- SDO_THROW_EXCEPTION("getListIndex", SDOUnsupportedOperationException,
- msg.c_str());
+ std::string msg("Get list index on text single valued property");
+ SDO_THROW_EXCEPTION("getListIndex",
+ SDOUnsupportedOperationException,
+ msg.c_str());
}
- }
- std::string msg("Index out of range:");
- msg += index;
- SDO_THROW_EXCEPTION("getListIndex", SDOIndexOutOfRangeException,
- msg.c_str());
- }
+ }
+ std::string msg("Index out of range:");
+ msg += index;
+ SDO_THROW_EXCEPTION("getListIndex",
+ SDOIndexOutOfRangeException,
+ msg.c_str());
+ }
- unsigned int SequenceImpl::getIndex(const char* propName, unsigned int pindex)
- {
- SEQUENCE_ITEM_LIST::iterator i;
- unsigned int j = 0;
- for (i=the_list.begin(), j=0;i != the_list.end();++i,++j) {
+ unsigned int SequenceImpl::getIndex(const char* propName, unsigned int pindex)
+ {
+ SEQUENCE_ITEM_LIST::iterator i;
+ unsigned int j = 0;
+ for (i = the_list.begin(), j = 0; i != the_list.end(); ++i, ++j)
+ {
const Property* p = (*i).getProp();
- if (p == 0 ) continue; // avoid text
- if (!strcmp(p->getName(), propName)) {
- if (p->isMany())
- {
- if( pindex == (*i).getIndex())return j;
- }
- else {
- return j;
- }
+ if (p == 0)
+ {
+ continue; // avoid text
}
- }
- SDO_THROW_EXCEPTION("getIndex", SDOIndexOutOfRangeException,
- "SequenceImpl::getIndex - property Setting not in sequence");
- }
-
- unsigned int SequenceImpl::getIndex(const Property& p, unsigned int pindex)
- {
- return getIndex(p.getName(), pindex);
- }
-
- ///////////////////////////////////////////////////////////////////////////
- // specific getters for prims and data objects
- ///////////////////////////////////////////////////////////////////////////
-
-
-
-#define getter(returntype,primtype,defval)\
- returntype SequenceImpl::get##primtype##Value(unsigned int index)\
- {\
- SEQUENCE_ITEM_LIST::iterator i;\
- CHECK_RANGE;\
- const Property* p = (*i).getProp();\
- if (p == 0) {\
- return defval;\
- }\
- if (p->isMany())\
- {\
- DataObjectList& dol = the_do->getList(*p);\
- DataObject* list_do = dol[(*i).getIndex()];\
- if (list_do != 0)\
- {\
- return ((DataObjectImpl*)list_do)->get##primtype();\
- }\
- return defval;\
- }\
- return the_do->get##primtype(*((*i).getProp()));\
- }
+ if (!strcmp(p->getName(), propName))
+ {
+ if (p->isMany())
+ {
+ if (pindex == (*i).getIndex())
+ {
+ return j;
+ }
+ }
+ else
+ {
+ return j;
+ }
+ }
+ }
+ SDO_THROW_EXCEPTION("getIndex",
+ SDOIndexOutOfRangeException,
+ "SequenceImpl::getIndex - property Setting not in sequence");
+ }
-#define CharGetter(returntype,primtype,defval)\
- unsigned int SequenceImpl::get##primtype##Value(unsigned int index, returntype ptr, unsigned int max)\
- {\
- SEQUENCE_ITEM_LIST::iterator i;\
- CHECK_RANGE;\
- const Property* p = (*i).getProp();\
- if (p == 0) {\
- return defval;\
- }\
- if (p->isMany())\
- {\
- DataObjectList& dol = the_do->getList(*p);\
- DataObject* list_do = dol[(*i).getIndex()];\
- if (list_do != 0)\
- {\
- return ((DataObjectImpl*)list_do)->get##primtype(ptr, max);\
- }\
- return defval;\
- }\
- return the_do->get##primtype(*((*i).getProp()), ptr, max);\
- }
+ unsigned int SequenceImpl::getIndex(const Property& p, unsigned int pindex)
+ {
+ return getIndex(p.getName(), pindex);
+ }
+ // specific getters for prims and data objects
- const char* SequenceImpl::getCStringValue(unsigned int index)
- {
- SEQUENCE_ITEM_LIST::iterator i;
- CHECK_RANGE;
- const Property* p = (*i).getProp();
- if (p == 0) {
- return (*i).getText();
- }
- if (p->isMany())
+ // It isn't obvious from the code here, however, this method also
+ // retrieves free text elements (see the spec) ie text items that can be
+ // added to the sequence even though they are not associated with a property.
+ const char* SequenceImpl::getCStringValue(unsigned int index)
{
- DataObjectList& dol = the_do->getList(*p);
- DataObject* list_do = dol[(*i).getIndex()];
- if (list_do != 0)
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
{
- return ((DataObjectImpl*)list_do)->getCString();
+ return result.getCString();
+ }
+ else
+ {
+ return 0;
}
- return 0;
}
- return the_do->getCString(*((*i).getProp()));
- }
-CharGetter( wchar_t* , String, 0);
-CharGetter( char*, Bytes, 0);
-
-unsigned int SequenceImpl::getLength(unsigned int index)
-{
- SEQUENCE_ITEM_LIST::iterator i;
- CHECK_RANGE;
- const Property* p = (*i).getProp();
- switch (p->getTypeEnum())
- {
- case Type::StringType:
- return getStringValue(index,0,0);
- case Type::BytesType:
- return getBytesValue(index,0,0);
- default:
- return 0;
- }
-}
-
-getter(bool, Boolean, false);
-getter(char, Byte, (char)0);
-getter(wchar_t, Character, 0);
-getter(short, Short, 0);
-getter(long, Integer, 0L);
-getter(int64_t, Long, 0);
-getter(float, Float, (float)0);
-getter(long double, Double, 0);
-getter(const SDODate, Date, 0);
+ unsigned int SequenceImpl::getLength(unsigned int index)
+ {
+ SEQUENCE_ITEM_LIST::iterator i;
+ CHECK_RANGE;
+ const Property* p = (*i).getProp();
+ switch (p->getTypeEnum())
+ {
+ case Type::StringType:
+ return getStringValue(index,0,0);
+ case Type::BytesType:
+ return getBytesValue(index,0,0);
+ default:
+ return 0;
+ }
+ }
RefCountingPointer<DataObject> SequenceImpl::getDataObjectValue(unsigned int index)
{
@@ -439,69 +410,6 @@
}
-#define adder(primtype,primval, platval)\
- bool SequenceImpl::add##primtype(const char* propertyName, primval v)\
- {\
- const PropertyImpl* p = the_do->getPropertyImpl(propertyName);\
- if (p == 0)\
- {\
- if (the_do->getType().isOpenType())\
- {\
- p = the_do->define ##primtype (propertyName);\
- }\
- if (p == 0)\
- {\
- std::string msg("Cannot find property:");\
- msg += propertyName;\
- SDO_THROW_EXCEPTION("getProperty", SDOPropertyNotFoundException,\
- msg.c_str());\
- }\
- }\
- return add##primtype((const Property&)*p,v);\
- }\
- bool SequenceImpl::add##primtype(unsigned int propertyIndex, primval v)\
- {\
- return add##primtype(the_do->getProperty(propertyIndex), v);\
- }\
- bool SequenceImpl::add##primtype(const Property& p, primval v)\
- {\
- if (p.isMany())\
- {\
- DataObjectList& dol = the_do->getList(p);\
- dol.append((platval)v);\
- /* the_list.push_back(seq_item(&p,dol.size()-1));*/\
- return true;\
- }\
- SEQUENCE_ITEM_LIST::iterator i;\
- for (i=the_list.begin();i != the_list.end();++i) {\
- const Property* pp = (*i).getProp();\
- if (pp == 0) continue;\
- if (!strcmp(pp->getName(),p.getName()))\
- {\
- SDO_THROW_EXCEPTION("add", SDOUnsupportedOperationException,\
- "Sequence::add of property which already exists in sequence");\
- }\
- }\
- the_do->set##primtype(p,v);\
- the_list.push_back(seq_item(&p,0));\
- return true;\
- }
-
-adder( CString , const char* , const char* );
-adder( Boolean, bool, bool);
-adder( Byte, char , char );
-adder(Character, wchar_t, wchar_t);
-adder(Short, short, short);
-#if __WORDSIZE ==64
-adder(Integer, long, int64_t);
-#else
-adder(Integer, long, long);
-#endif
-adder(Long, int64_t, int64_t);
-adder(Float, float, float);
-adder(Double, long double, long double);
-adder(Date, const SDODate, const SDODate);
-
bool SequenceImpl::addDataObject(const char* propertyName, RefCountingPointer<DataObject> v)
{
const PropertyImpl* p = the_do->getPropertyImpl(propertyName);
@@ -527,160 +435,41 @@
}
bool SequenceImpl::addDataObject(const Property& p, RefCountingPointer<DataObject> v)
{
+ // If this is a many valued property.
if (p.isMany())
{
+ // Append the incoming data object value to the end of the list of
+ // values. The sequence is updated as part of the append operation.
DataObjectList& dol = the_do->getList(p);
- dol.append((RefCountingPointer<DataObject>)v);
+ dol.append((RefCountingPointer<DataObject>) v);
/* the_list.push_back(seq_item(&p,dol.size()-1));*/
return true;
}
+
SEQUENCE_ITEM_LIST::iterator i;
- for (i=the_list.begin();i != the_list.end();++i) {
+
+ // Scan the sequence to check that this property has not been set already.
+ for (i= the_list.begin(); i != the_list.end(); ++i)
+ {
const Property* pp = (*i).getProp();
- if (pp == 0) continue;
- if (!strcmp(pp->getName(),p.getName()))
+ if (pp == 0)
+ {
+ continue; // This item is a free text entry.
+ }
+ if (!strcmp(pp->getName(), p.getName()))
{
- SDO_THROW_EXCEPTION("add", SDOUnsupportedOperationException,
+ SDO_THROW_EXCEPTION("add",
+ SDOUnsupportedOperationException,
"Sequence::add of property which already exists in sequence");
}
}
- the_do->setDataObject(p,v);
- the_list.push_back(seq_item(&p,0));
+
+ the_do->setDataObject(p, v, true);
+ // the_list.push_back(seq_item(&p, 0));
return true;
}
-#define charAdder(primtype,primval)\
- bool SequenceImpl::add##primtype(const char* propertyName, primval v, unsigned int len)\
- {\
- const PropertyImpl* p = the_do->getPropertyImpl(propertyName);\
- if (p == 0)\
- {\
- if (the_do->getType().isOpenType())\
- {\
- p = the_do->define ##primtype (propertyName);\
- }\
- if (p == 0)\
- {\
- std::string msg("Cannot find property:");\
- msg += propertyName;\
- SDO_THROW_EXCEPTION("getProperty", SDOPropertyNotFoundException,\
- msg.c_str());\
- }\
- }\
- return add##primtype((const Property&)*p,v, len);\
- }\
- bool SequenceImpl::add##primtype(unsigned int propertyIndex, primval v, unsigned int len)\
- {\
- return add##primtype(the_do->getProperty(propertyIndex), v, len);\
- }\
- bool SequenceImpl::add##primtype(const Property& p, primval v, unsigned int len)\
- {\
- if (p.isMany())\
- {\
- DataObjectList& dol = the_do->getList(p);\
- dol.append((primval)v, len);\
- /*the_list.push_back(seq_item(&p,dol.size()-1));*/\
- return true;\
- }\
- SEQUENCE_ITEM_LIST::iterator i;\
- for (i=the_list.begin();i != the_list.end();++i) {\
- const Property* pp = (*i).getProp();\
- if (pp == 0) continue;\
- if (!strcmp(pp->getName(),p.getName()))\
- {\
- SDO_THROW_EXCEPTION("add", SDOUnsupportedOperationException,\
- "Sequence::add of property which already exists in sequence");\
- }\
- }\
- the_do->set##primtype(p,v, len);\
- the_list.push_back(seq_item(&p,0));\
- return true;\
- }
-
-
-charAdder ( String, const wchar_t* );
-charAdder ( Bytes , const char* );
-
-
-#define inserter(primtype,primval, platval)\
- bool SequenceImpl::add##primtype(unsigned int index, const char* propertyName, primval v)\
- {\
- const PropertyImpl* p = the_do->getPropertyImpl(propertyName);\
- if (p == 0)\
- {\
- if (the_do->getType().isOpenType())\
- {\
- p = the_do->define ##primtype (propertyName);\
- }\
- if (p == 0)\
- {\
- std::string msg("Cannot find property:");\
- msg += propertyName;\
- SDO_THROW_EXCEPTION("getProperty", SDOPropertyNotFoundException,\
- msg.c_str());\
- }\
- }\
- return add##primtype(index,(const Property&)*p,v);\
- }\
- bool SequenceImpl::add##primtype(unsigned int index, unsigned int propertyIndex, primval v)\
- {\
- return add##primtype(index,the_do->getProperty(propertyIndex), v);\
- }\
- bool SequenceImpl::add##primtype(unsigned int index, const Property& p, primval v)\
- {\
- SEQUENCE_ITEM_LIST::iterator i;\
- SEQUENCE_ITEM_LIST::iterator i2 = the_list.end();\
- unsigned int j;\
- if (index >= the_list.size()) {\
- return add##primtype(p,v);\
- }\
- if (p.isMany())\
- {\
- DataObjectList& dol = the_do->getList(p);\
- dol.append((platval)v);\
- j = 0;\
- for (i=the_list.begin();(j < index) && (i != the_list.end());++i) {\
- j++;\
- }\
- /*the_list.insert(i,seq_item(&p,dol.size()-1));*/\
- return true;\
- }\
- j = 0;\
- for (i=the_list.begin();i != the_list.end();++i) {\
- const Property* pp = (*i).getProp();\
- if (pp == 0) continue;\
- if (!strcmp(pp->getName(),p.getName()))\
- {\
- SDO_THROW_EXCEPTION("Insert", SDOUnsupportedOperationException,\
- "Sequence::insert of property which already exists in sequence");\
- }\
- if (j == index) {\
- i2 = i;\
- }\
- j++;\
- }\
- the_do->set##primtype(p,v);\
- the_list.insert(i2,seq_item(&p,0));\
- return true;\
- }
-
-
-inserter( CString , const char* , const char* );
-inserter( Boolean, bool, bool);
-inserter( Byte, char , char );
-inserter(Character, wchar_t, wchar_t );
-inserter(Short, short, short );
-#if __WORDSIZE ==64
-inserter(Integer, long, int64_t );
-#else
-inserter(Integer, long, long );
-#endif
-inserter(Long, int64_t, int64_t);
-inserter(Float, float, float );
-inserter(Double, long double, long double);
-inserter(Date, const SDODate, const SDODate);
-
bool SequenceImpl::addDataObject(unsigned int index, const char* propertyName, RefCountingPointer<DataObject> v)
{
const PropertyImpl* p = the_do->getPropertyImpl(propertyName);
@@ -708,112 +497,49 @@
{
SEQUENCE_ITEM_LIST::iterator i;
SEQUENCE_ITEM_LIST::iterator i2 = the_list.end();
- unsigned int j;
- if (index >= the_list.size()) {
- return addDataObject(p,v);
+ unsigned int j = 0;
+
+ if (index >= the_list.size())
+ {
+ return addDataObject(p, v);
}
if (p.isMany())
{
DataObjectList& dol = the_do->getList(p);
dol.append((RefCountingPointer<DataObject>)v);
- j = 0;
- for (i=the_list.begin();(j < index) && (i != the_list.end());++i) {
- j++;
- }
+
+ checkRange(index, i);
+
/*the_list.insert(i,seq_item(&p,dol.size()-1));*/
return true;
}
- j = 0;
- for (i=the_list.begin();i != the_list.end();++i) {
+
+ for (i = the_list.begin(); i != the_list.end(); ++i)
+ {
const Property* pp = (*i).getProp();
- if (pp == 0) continue;
- if (!strcmp(pp->getName(),p.getName()))
+ if (pp == 0)
+ {
+ continue; // This item is a free text entry.
+ }
+ if (!strcmp(pp->getName(), p.getName()))
{
- SDO_THROW_EXCEPTION("Insert", SDOUnsupportedOperationException,
+ SDO_THROW_EXCEPTION("Insert",
+ SDOUnsupportedOperationException,
"Sequence::insert of property which already exists in sequence");
}
- if (j == index) {
+ if (j == index)
+ {
i2 = i;
}
j++;
}
- the_do->setDataObject(p,v);
- the_list.insert(i2,seq_item(&p,0));
+ // setDataObject can update the sequence but does not do so by an append
+ // so tell it to mind its own business and we will update the sequence here.
+ the_do->setDataObject(p, v, false);
+ the_list.insert(i2, seq_item(&p, 0));
return true;
}
-
-
-#define charInserter(primtype,primval)\
- bool SequenceImpl::add##primtype(unsigned int index, const char* propertyName, primval v, unsigned int len)\
- {\
- const PropertyImpl* p = the_do->getPropertyImpl(propertyName);\
- if (p == 0)\
- {\
- if (the_do->getType().isOpenType())\
- {\
- p = the_do->define ##primtype (propertyName);\
- }\
- if (p == 0)\
- {\
- std::string msg("Cannot find property:");\
- msg += propertyName;\
- SDO_THROW_EXCEPTION("getProperty", SDOPropertyNotFoundException,\
- msg.c_str());\
- }\
- }\
- return add##primtype(index,(const Property&)*p,v, len);\
- }\
- bool SequenceImpl::add##primtype(unsigned int index, unsigned int propertyIndex, primval v, unsigned int len)\
- {\
- return add##primtype(index,the_do->getProperty(propertyIndex), v, len);\
- }\
- bool SequenceImpl::add##primtype(unsigned int index, const Property& p, primval v, unsigned int len)\
- {\
- SEQUENCE_ITEM_LIST::iterator i;\
- SEQUENCE_ITEM_LIST::iterator i2 = the_list.end();\
- unsigned int j;\
- if (index >= the_list.size()) {\
- return add##primtype(p,v, len);\
- }\
- if (p.isMany())\
- {\
- DataObjectList& dol = the_do->getList(p);\
- dol.append((primval)v, len);\
- j = 0;\
- for (i=the_list.begin();(j < index) && (i != the_list.end());++i) {\
- j++;\
- }\
- /*the_list.insert(i,seq_item(&p,dol.size()-1));*/\
- return true;\
- }\
- j = 0;\
- for (i=the_list.begin();i != the_list.end();++i) {\
- const Property* pp = (*i).getProp();\
- if (pp == 0) continue;\
- if (!strcmp(pp->getName(),p.getName()))\
- {\
- SDO_THROW_EXCEPTION("Insert", SDOUnsupportedOperationException,\
- "Sequence::insert of property which already exists in sequence");\
- }\
- if (j == index) {\
- i2 = i;\
- }\
- j++;\
- }\
- the_do->set##primtype(p,v, len);\
- the_list.insert(i2,seq_item(&p,0));\
- return true;\
- }
-
-
-charInserter( String , const wchar_t* );
-charInserter (Bytes , const char* );
-
-
-
-
-
void SequenceImpl::push(const Property& p, unsigned int index)
{
the_list.push_back(seq_item(&p,index));
@@ -828,11 +554,9 @@
msg.c_str());
}
SEQUENCE_ITEM_LIST::iterator i;
- unsigned int j = 0;
- for (i=the_list.begin();(j < index) && (i != the_list.end()) ; ++i)
- {
- j++;
- }
+
+ checkRange(index, i);
+
the_list.erase(i);
return;
}
@@ -923,11 +647,9 @@
return false;
}
SEQUENCE_ITEM_LIST::iterator i;
- unsigned int j = 0;
- for (i= the_list.begin(); (j < index) && (i != the_list.end()); ++i)
- {
- j++;
- }
+
+ checkRange(index, i);
+
if ((*i).getProp() == 0)
{
return true;
@@ -943,11 +665,9 @@
}
SEQUENCE_ITEM_LIST::iterator i;
- unsigned int j = 0;
- for (i= the_list.begin(); (j < index) && (i != the_list.end()); ++i)
- {
- j++;
- }
+
+ checkRange(index, i);
+
the_list.insert(i,seq_item(text));
return true;
}
@@ -964,15 +684,645 @@
}
SEQUENCE_ITEM_LIST::iterator i;
+
+ checkRange(index, i);
+
+ (*i).setText(text);
+ return true;
+ }
+
+const SDOValue& SequenceImpl::getSDOValue(unsigned int index)
+{
+ SEQUENCE_ITEM_LIST::iterator i;
+
+ checkRange(index, i);
+
+ const Property* p = (*i).getProp();
+ if (p == 0)
+ {
+ // There is no property. Either this is a free text element or we have a
+ // problem.
+ const SDOValue* freeText = (*i).getFreeText();
+ if (freeText != 0)
+ {
+ return *freeText;
+ }
+ else
+ {
+ return SDOValue::unsetSDOValue;
+ }
+ }
+ PropertyImpl* pProp = 0; // Not used. Just a place for getSDOValue to
+ // write the return value that we don't need.
+ if (p->isMany())
+ {
+ DataObjectList& dol = the_do->getList(*p);
+ DataObject* list_do = dol[(*i).getIndex()];
+ if (list_do != 0)
+ {
+ return ((DataObjectImpl*) list_do)->getSDOValue(&pProp);
+ }
+ return SDOValue::unsetSDOValue;
+ }
+ return the_do->getSDOValue(*((*i).getProp()), &pProp);
+}
+
+bool SequenceImpl::getBooleanValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getBoolean();
+ }
+ else
+ {
+ return (bool) 0;
+ }
+}
+
+char SequenceImpl::getByteValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getByte();
+ }
+ else
+ {
+ return (char) 0;
+ }
+}
+
+wchar_t SequenceImpl::getCharacterValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getCharacter();
+ }
+ else
+ {
+ return (wchar_t) 0;
+ }
+}
+
+short SequenceImpl::getShortValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getShort();
+ }
+ else
+ {
+ return (short) 0;
+ }
+}
+
+long SequenceImpl::getIntegerValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getInteger();
+ }
+ else
+ {
+ return (long) 0;
+ }
+}
+
+int64_t SequenceImpl::getLongValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getLong();
+ }
+ else
+ {
+ return (int64_t) 0;
+ }
+}
+
+float SequenceImpl::getFloatValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getFloat();
+ }
+ else
+ {
+ return (float) 0;
+ }
+}
+
+long double SequenceImpl::getDoubleValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getDouble();
+ }
+ else
+ {
+ return (long double) 0;
+ }
+}
+
+const SDODate SequenceImpl::getDateValue(unsigned int index)
+{
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getDate();
+ }
+ else
+ {
+ return (SDODate) 0;
+ }
+}
+
+bool SequenceImpl::addCString(const char* propertyName, const char* v)
+{
+ return addSDOValue(propertyName, SDOValue(SDOString(v)));
+}
+bool SequenceImpl::addCString(const Property& p, const char* v)
+{
+ return addSDOValue(p, SDOValue(SDOString(v)));
+}
+bool SequenceImpl::addCString(unsigned int propertyIndex, const char* v)
+{
+ return addCString(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addByte(const char* propertyName, char v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addByte(const Property& p, char v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addByte(unsigned int propertyIndex, char v)
+{
+ return addByte(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addCharacter(const char* propertyName, wchar_t v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addCharacter(const Property& p, wchar_t v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addCharacter(unsigned int propertyIndex, wchar_t v)
+{
+ return addCharacter(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addShort(const char* propertyName, short v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addShort(const Property& p, short v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addShort(unsigned int propertyIndex, short v)
+{
+ return addShort(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addFloat(const char* propertyName, float v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addFloat(const Property& p, float v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addFloat(unsigned int propertyIndex, float v)
+{
+ return addFloat(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addDouble(const char* propertyName, long double v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addDouble(const Property& p, long double v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addDouble(unsigned int propertyIndex, long double v)
+{
+ return addDouble(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addDate(const char* propertyName, const SDODate v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addDate(const Property& p, const SDODate v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addDate(unsigned int propertyIndex, const SDODate v)
+{
+ return addDate(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addLong(const char* propertyName, int64_t v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addLong(const Property& p, int64_t v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addLong(unsigned int propertyIndex, int64_t v)
+{
+ return addLong(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addInteger(const char* propertyName, long v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addInteger(const Property& p, long v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+bool SequenceImpl::addInteger(unsigned int propertyIndex, long v)
+{
+ return addInteger(the_do->getProperty(propertyIndex), v);
+}
+
+bool SequenceImpl::addBoolean(const char* propertyName, bool v)
+{
+ return addSDOValue(propertyName, SDOValue(v));
+}
+bool SequenceImpl::addBoolean(const Property& p, bool v)
+{
+ return addSDOValue(p, SDOValue(v));
+}
+
+bool SequenceImpl::addBoolean(unsigned int propertyIndex, bool v)
+{
+ return addBoolean(the_do->getProperty(propertyIndex), v);
+}
+
+// The return value is not spec compliant (which calls for void) it is a
+// yes/no as to whether the call succeeded.
+bool SequenceImpl::addSDOValue(const char* propertyName, const SDOValue& sval)
+{
+ const PropertyImpl* p = the_do->getPropertyImpl(propertyName);
+ if (p == 0)
+ {
+ if (the_do->getType().isOpenType())
+ {
+ p = the_do->defineSDOValue(propertyName, sval);
+ }
+ if (p == 0)
+ {
+ std::string msg("Cannot find property:");
+ msg += propertyName;
+ SDO_THROW_EXCEPTION("SequenceImpl::addSDOValue",
+ SDOPropertyNotFoundException,
+ msg.c_str());
+ }
+ }
+ return addSDOValue((const Property&) *p, sval);
+}
+bool SequenceImpl::addSDOValue(const Property& p, const SDOValue& sval)
+{
+ if (p.isMany())
+ {
+ DataObjectList& dol = the_do->getList(p);
+ dol.append(sval);
+ /* the_list.push_back(seq_item(&p,dol.size()-1));*/
+ return true;
+ }
+// std::cout << "Incoming property: " << p.getName() << std::endl << std::endl;
+ SEQUENCE_ITEM_LIST::iterator i;
+ for (i = the_list.begin(); i != the_list.end(); ++i)
+ {
+ const Property* pp = (*i).getProp();
+ if (pp == 0) continue;
+// std::cout << pp->getName() << std::endl;
+ if (!strcmp(pp->getName(), p.getName()))
+ {
+ SDO_THROW_EXCEPTION("add",
+ SDOUnsupportedOperationException,
+ "Sequence::add of property which already exists in sequence");
+ }
+ }
+// std::cout << std::endl;
+ the_do->setSDOValue(p, sval, sval.convertTypeEnumToString(), true);
+ // the_list.push_back(seq_item(&p, 0));
+ return true;
+}
+bool SequenceImpl::addSDOValue(unsigned int propertyIndex, const SDOValue& sval)
+{
+ return addSDOValue(the_do->getProperty(propertyIndex), sval);
+}
+
+bool SequenceImpl::addString(const char* propertyName, const wchar_t* v, unsigned int len)
+{
+ return addSDOValue(propertyName, SDOValue(v, len));
+}
+bool SequenceImpl::addString(unsigned int propertyIndex, const wchar_t* v, unsigned int len)
+{
+ return addString(the_do->getProperty(propertyIndex), v, len);
+}
+bool SequenceImpl::addString(const Property& p, const wchar_t* v, unsigned int len)
+{
+ return addSDOValue(p, SDOValue(v, len));
+}
+
+bool SequenceImpl::addBytes(const char* propertyName, const char* v, unsigned int len)
+{
+ return addSDOValue(propertyName, SDOValue(v, len));
+}
+bool SequenceImpl::addBytes(unsigned int propertyIndex, const char* v, unsigned int len)
+{
+ return addBytes(the_do->getProperty(propertyIndex), v, len);
+}
+bool SequenceImpl::addBytes(const Property& p, const char* v, unsigned int len)
+{
+ return addSDOValue(p, SDOValue(v, len));
+}
+
+ bool SequenceImpl::addByte(unsigned int index, const char* propertyName, char v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addByte(unsigned int index, unsigned int propertyIndex, char v)
+ {
+ return addByte(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addByte(unsigned int index, const Property& p, char v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addCharacter(unsigned int index, const char* propertyName, wchar_t v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addCharacter(unsigned int index, unsigned int propertyIndex, wchar_t v)
+ {
+ return addCharacter(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addCharacter(unsigned int index, const Property& p, wchar_t v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addShort(unsigned int index, const char* propertyName, short v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addShort(unsigned int index, unsigned int propertyIndex, short v)
+ {
+ return addShort(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addShort(unsigned int index, const Property& p, short v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addLong(unsigned int index, const char* propertyName, int64_t v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addLong(unsigned int index, unsigned int propertyIndex, int64_t v)
+ {
+ return addLong(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addLong(unsigned int index, const Property& p, int64_t v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addFloat(unsigned int index, const char* propertyName, float v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addFloat(unsigned int index, unsigned int propertyIndex, float v)
+ {
+ return addFloat(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addFloat(unsigned int index, const Property& p, float v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addDouble(unsigned int index, const char* propertyName, long double v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addDouble(unsigned int index, unsigned int propertyIndex, long double v)
+ {
+ return addDouble(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addDouble(unsigned int index, const Property& p, long double v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addDate(unsigned int index, const char* propertyName, const SDODate v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addDate(unsigned int index, unsigned int propertyIndex, const SDODate v)
+ {
+ return addDate(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addDate(unsigned int index, const Property& p, const SDODate v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addInteger(unsigned int index, const char* propertyName, long v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addInteger(unsigned int index, unsigned int propertyIndex, long v)
+ {
+ return addInteger(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addInteger(unsigned int index, const Property& p, long v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addCString(unsigned int index, const char* propertyName, const char* v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(SDOString(v)));
+ }
+ bool SequenceImpl::addCString(unsigned int index, unsigned int propertyIndex, const char* v)
+ {
+ return addCString(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addCString(unsigned int index, const Property& p, const char* v)
+ {
+ return addSDOValue(index, p, SDOValue(SDOString(v)));
+ }
+
+ bool SequenceImpl::addBoolean(unsigned int index, const char* propertyName, bool v)
+ {
+ return addSDOValue(index, propertyName, SDOValue(v));
+ }
+ bool SequenceImpl::addBoolean(unsigned int index, unsigned int propertyIndex, bool v)
+ {
+ return addBoolean(index, the_do->getProperty(propertyIndex), v);
+ }
+ bool SequenceImpl::addBoolean(unsigned int index, const Property& p, bool v)
+ {
+ return addSDOValue(index, p, SDOValue(v));
+ }
+
+ bool SequenceImpl::addSDOValue(unsigned int index, const char* propertyName, const SDOValue& sval)
+ {
+ const PropertyImpl* p = the_do->getPropertyImpl(propertyName);
+ if (p == 0)
+ {
+ if (the_do->getType().isOpenType())
+ {
+ p = the_do->defineSDOValue(propertyName, sval);
+ }
+ if (p == 0)
+ {
+ std::string msg("Cannot find property:");
+ msg += propertyName;
+ SDO_THROW_EXCEPTION("getProperty",
+ SDOPropertyNotFoundException,
+ msg.c_str());
+ }
+ }
+ return addSDOValue(index, (const Property&) *p, sval);
+ }
+ bool SequenceImpl::addSDOValue(unsigned int index, unsigned int propertyIndex, const SDOValue& sval)
+ {
+ return addSDOValue(index,the_do->getProperty(propertyIndex), sval);
+ }
+ bool SequenceImpl::addSDOValue(unsigned int index, const Property& p, const SDOValue& sval)
+ {
+ SEQUENCE_ITEM_LIST::iterator i;
+ SEQUENCE_ITEM_LIST::iterator i2 = the_list.end();
unsigned int j = 0;
- for (i= the_list.begin(); (j < index) && (i != the_list.end()); ++i)
+ if (index >= the_list.size()) {
+ return addSDOValue(p, sval);
+ }
+ if (p.isMany())
{
+ DataObjectList& dol = the_do->getList(p);
+ dol.append(sval);
+
+ checkRange(index, i);
+
+ /*the_list.insert(i,seq_item(&p,dol.size()-1));*/
+ return true;
+ }
+
+ for (i = the_list.begin(); i != the_list.end(); ++i)
+ {
+ const Property* pp = (*i).getProp();
+ if (pp == 0) continue;
+ if (!strcmp(pp->getName(), p.getName()))
+ {
+ SDO_THROW_EXCEPTION("Insert",
+ SDOUnsupportedOperationException,
+ "Sequence::insert of property which already exists in sequence");
+ }
+ if (j == index) {
+ i2 = i;
+ }
j++;
}
- (*i).setText(text);
+
+ // setSDOValue can update the sequence but does not do so by an append so
+ // tell it to mind its own business and we will update the sequence here.
+ the_do->setSDOValue(p, sval, sval.convertTypeEnumToString(), false);
+ the_list.insert(i2, seq_item(&p, 0));
return true;
}
+bool SequenceImpl::addString(unsigned int index,
+ const char* propertyName,
+ const wchar_t* v,
+ unsigned int len)
+{
+ return addSDOValue(index, propertyName, SDOValue(v, len));
+}
+
+bool SequenceImpl::addString(unsigned int index, unsigned int propertyIndex, const wchar_t* v, unsigned int len)
+{
+ return addString(index,the_do->getProperty(propertyIndex), v, len);
+}
+bool SequenceImpl::addString(unsigned int index, const Property& p, const wchar_t* v, unsigned int len)
+{
+ return addSDOValue(index, p, SDOValue(v, len));
+}
+
+bool SequenceImpl::addBytes(unsigned int index,
+ const char* propertyName,
+ const char* v,
+ unsigned int len)
+{
+ return addSDOValue(index, propertyName, SDOValue(v, len));
+}
+
+bool SequenceImpl::addBytes(unsigned int index, unsigned int propertyIndex, const char* v, unsigned int len)
+{
+ return addBytes(index,the_do->getProperty(propertyIndex), v, len);
+}
+bool SequenceImpl::addBytes(unsigned int index, const Property& p, const char* v, unsigned int len)
+{
+ return addSDOValue(index, p, SDOValue(v, len));
+}
+
+unsigned int SequenceImpl::getBytesValue(unsigned int index, char* ptr, unsigned int max)
+{
+
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getBytes(ptr, max);
+ }
+ else
+ {
+ return 0;
+ }
+}
+unsigned int SequenceImpl::getStringValue(unsigned int index, wchar_t* ptr, unsigned int max)
+{
+
+ const SDOValue& result = getSDOValue(index);
+
+ if (result.isSet())
+ {
+ return result.getString(ptr, max);
+ }
+ else
+ {
+ return 0;
+ }
+}
+
};
};
-
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org