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 [2/2] - in /incubator/tuscany/cpp/sdo/runtime/core:
src/commonj/sdo/ test/
Modified: incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.h?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/src/commonj/sdo/SequenceImpl.h Tue Feb 13 01:34:23 2007
@@ -94,6 +94,7 @@
virtual long double getDoubleValue(unsigned int index);
virtual const SDODate getDateValue(unsigned int index);
virtual DataObjectPtr getDataObjectValue(unsigned int index);
+ virtual const SDOValue& getSDOValue(unsigned int index);
virtual unsigned int getLength(unsigned int index);
@@ -137,6 +138,7 @@
virtual bool addDouble( const char* propertyName,long double d );
virtual bool addDate( const char* propertyName,const SDODate t );
virtual bool addDataObject(const char* propertyName,DataObjectPtr d );
+ virtual bool addSDOValue(const char* propertyName, const SDOValue& sval);
///////////////////////////////////////////////////////////////////////////
@@ -158,6 +160,7 @@
virtual bool addDouble( unsigned int propertyIndex,long double d );
virtual bool addDate( unsigned int propertyIndex,const SDODate t );
virtual bool addDataObject(unsigned int propertyIndex,DataObjectPtr d );
+ virtual bool addSDOValue(unsigned int propertyIndex, const SDOValue& sval);
///////////////////////////////////////////////////////////////////////////
@@ -180,6 +183,7 @@
virtual bool addDouble( const Property& property,long double d );
virtual bool addDate( const Property& property,const SDODate t );
virtual bool addDataObject(const Property& property,DataObjectPtr d );
+ virtual bool addSDOValue(const Property& property, const SDOValue& sval);
///////////////////////////////////////////////////////////////////////////
@@ -202,7 +206,7 @@
virtual bool addDouble( unsigned int index,const char* propertyName,long double d );
virtual bool addDate( unsigned int index,const char* propertyName,const SDODate t );
virtual bool addDataObject(unsigned int index,const char* propertyName,DataObjectPtr d );
-
+ virtual bool addSDOValue(unsigned int index, const char* propertyName, const SDOValue& sval);
///////////////////////////////////////////////////////////////////////////
// adds a new entry with the specified property index and value
@@ -224,7 +228,7 @@
virtual bool addDouble( unsigned int index,unsigned int propertyIndex,long double d );
virtual bool addDate( unsigned int index,unsigned int propertyIndex,const SDODate t );
virtual bool addDataObject(unsigned int index,unsigned int propertyIndex,DataObjectPtr d );
-
+ virtual bool addSDOValue(unsigned int index, unsigned int propertyIndex, const SDOValue& sval);
///////////////////////////////////////////////////////////////////////////
// adds a new entry with the specified property and value
@@ -246,7 +250,7 @@
virtual bool addDouble( unsigned int index,const Property& property,long double d );
virtual bool addDate( unsigned int index,const Property& property,const SDODate t );
virtual bool addDataObject(unsigned int index,const Property& property,DataObjectPtr d );
-
+ virtual bool addSDOValue(unsigned int index, const Property& property, const SDOValue& sval);
///////////////////////////////////////////////////////////////////////////
// removes the entry at the given entry index.
@@ -306,56 +310,75 @@
class seq_item {
public:
- seq_item(const Property* p, unsigned int i):
- the_prop(p)
- {
- index = i;
- text = 0;
- }
- seq_item(const char* t)
- {
- text = new char[strlen(t) + 1];
- strcpy(text,t);
- the_prop = 0;
- }
+ // Constructors
+ seq_item(const Property* p, unsigned int i):
+ the_prop(p), index(i), freeText(0)
+ {
+ }
+ seq_item(const char* t) :
+ the_prop(0)
+ {
+ freeText = new SDOValue(t);
+ }
+ // Copy constructor
+ seq_item(const seq_item& sin) :
+ index(sin.index), freeText(0), the_prop(sin.the_prop)
+ {
+ if (sin.freeText != 0)
+ {
+ freeText = new SDOValue(*sin.freeText);
+ }
+ }
+
+ // Copy assignment
+ seq_item& operator=(const seq_item& sin)
+ {
+ if (freeText)
+ {
+ delete freeText;
+ }
+ if (sin.freeText != 0)
+ {
+ freeText = new SDOValue(*sin.freeText);
+ }
+ }
+
+ // Destructor
+ ~seq_item()
+ {
+ if (freeText)
+ {
+ delete freeText;
+ }
+ }
- ~seq_item()
- {
- if (text) {
- delete text;
- }
- }
-
- seq_item(const seq_item& sin)
- {
- the_prop = sin.the_prop;
- index = sin.index;
- if (sin.text) {
- text = new char[strlen(sin.text) +1];
- strcpy(text, sin.text);
- }
- else
- {
- text =0;
- }
- }
const Property* getProp() {return the_prop;}
unsigned int getIndex() { return index;}
- char* getText() { return text;}
+
+ const char* getText()
+ {
+ return freeText->getCString();
+ }
+
+ const SDOValue* getFreeText()
+ {
+ return freeText;
+ }
+
void setProp(Property* p) { the_prop = p;}
- void setText(const char* intext)
- {
- if (intext != 0)
- {
- if (text != 0)
- {
- delete text;
- }
- text = new char[strlen(intext) +1];
- strcpy(text,intext);
- }
- }
+
+ void setText(const char* intext)
+ {
+ if (intext != 0)
+ {
+ if (freeText != 0)
+ {
+ delete freeText;
+ }
+ freeText = new SDOValue(intext);
+ }
+ }
void setIndex(unsigned int i)
{
index = i;
@@ -363,10 +386,11 @@
private:
const Property* the_prop;
unsigned int index;
- char* text;
+ SDOValue* freeText;
};
typedef std::list<seq_item> SEQUENCE_ITEM_LIST;
+ virtual void checkRange(unsigned int index, SEQUENCE_ITEM_LIST::iterator& i);
SEQUENCE_ITEM_LIST the_list;
Added: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_animaltypes.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/jira980_animaltypes.xsd?view=auto&rev=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira980_animaltypes.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira980_animaltypes.xsd Tue Feb 13 01:34:23 2007
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema">
+ <complexType name="snakeType">
+ <sequence>
+ <element name= "name" type="string"/>
+ <element name= "length" type="positiveInteger" />
+ </sequence>
+ </complexType>
+ <complexType name="bearType">
+ <sequence>
+ <element name= "name" type="string"/>
+ <element name= "weight" type="positiveInteger" />
+ </sequence>
+ </complexType>
+ <complexType name="pantherType">
+ <sequence>
+ <element name= "name" type="string"/>
+ <element name= "colour" type="string" />
+ </sequence>
+ </complexType>
+</schema>
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_animaltypes.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_animaltypes.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle.xsd?view=auto&rev=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle.xsd Tue Feb 13 01:34:23 2007
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="jungle">
+ <complexType>
+ <sequence>
+ <any minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+</schema>
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle_out.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle_out.txt?view=auto&rev=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle_out.txt (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle_out.txt Tue Feb 13 01:34:23 2007
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<jungle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><bear xsi:type="bearType"><name>Mummy bear</name><weight>700</weight></bear><panther xsi:type="pantherType"><name>Bagheera</name><colour>inky black</colour></panther><snake xsi:type="snakeType"><name>Kaa</name><length>25</length></snake></jungle>
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_jungle_out.txt
------------------------------------------------------------------------------
svn:eol-style = native
Added: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle.xsd
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle.xsd?view=auto&rev=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle.xsd (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle.xsd Tue Feb 13 01:34:23 2007
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<schema xmlns="http://www.w3.org/2001/XMLSchema">
+ <element name="mixedJungle">
+ <complexType mixed="true">
+ <sequence>
+ <any minOccurs="0" maxOccurs="unbounded"/>
+ </sequence>
+ </complexType>
+ </element>
+</schema>
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle.xsd
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle.xsd
------------------------------------------------------------------------------
svn:keywords = Rev Date
Added: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle_out.txt
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle_out.txt?view=auto&rev=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle_out.txt (added)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle_out.txt Tue Feb 13 01:34:23 2007
@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<mixedJungle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><bear xsi:type="bearType"><name>Mummy bear</name><weight>700</weight></bear><panther xsi:type="pantherType"><name>Bagheera</name><colour>inky black</colour></panther><snake xsi:type="snakeType"><name>Kaa</name><length>25</length></snake></mixedJungle>
Propchange: incubator/tuscany/cpp/sdo/runtime/core/test/jira980_mixedJungle_out.txt
------------------------------------------------------------------------------
svn:eol-style = native
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/main.cpp Tue Feb 13 01:34:23 2007
@@ -51,6 +51,7 @@
/* TEST ( sdotest::xhtml1() ); */
TEST ( sdotest::scopetest() );
TEST ( sdotest::xsdtosdo() );
+ TEST ( sdotest::jira980() );
/* groups now supported*/
TEST ( sdotest::testany("list1.xsd",0,"list1.xml", 0) );
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest.h Tue Feb 13 01:34:23 2007
@@ -177,6 +177,8 @@
static int jira705();
static int jira546();
static int jira945();
+ static int jira980();
+
static int b48602();
static int b48736();
Modified: incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp
URL: http://svn.apache.org/viewvc/incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp?view=diff&rev=506932&r1=506931&r2=506932
==============================================================================
--- incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp (original)
+++ incubator/tuscany/cpp/sdo/runtime/core/test/sdotest2.cpp Tue Feb 13 01:34:23 2007
@@ -1571,3 +1571,104 @@
return 0;
}
}
+
+int sdotest::jira980()
+{
+
+ try
+ {
+ // Data factory to load both schema files.
+ DataFactoryPtr df_both = DataFactory::getDataFactory();
+ XSDHelperPtr xsh_both = HelperProvider::getXSDHelper(df_both);
+
+ // Load a root element definition, then the three animal types.
+ xsh_both->defineFile("jira980_jungle.xsd");
+ xsh_both->defineFile("jira980_animaltypes.xsd");
+
+ // Print the metadata that we now have.
+ TypeList types_both = df_both->getTypes();
+
+ // Create three animals based on the preceding types.
+ DataObjectPtr baloo = df_both->create("", "bearType");
+ baloo->setCString("name", "Mummy bear");
+ baloo->setInteger("weight", 700);
+
+ DataObjectPtr bagheera = df_both->create("", "pantherType");
+ bagheera->setCString("name", "Bagheera");
+ bagheera->setCString("colour", "inky black");
+
+ DataObjectPtr kaa = df_both->create("", "snakeType");
+ kaa->setCString("name", "Kaa");
+ kaa->setInteger("length", 25);
+
+ // Create an output document
+ XMLHelperPtr xmh_both = HelperProvider::getXMLHelper(df_both);
+ XMLDocumentPtr document_both = xmh_both->createDocument();
+
+ DataObjectPtr jungle = document_both->getRootDataObject();
+
+ // Add the three animals as children of the document root. In this test
+ // that root will be a "jungle" element.
+ jungle->setDataObject("bear", baloo);
+ jungle->setDataObject("panther", bagheera);
+ jungle->setDataObject("snake", kaa);
+
+ xmh_both->save(document_both, "jira980_jungle_out.xml");
+ if (!comparefiles("jira980_jungle_out.txt" ,"jira980_jungle_out.xml"))
+ {
+ return 0;
+ }
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in jira980" << e << endl;
+ return 0;
+ }
+
+ try
+ {
+ // Data factory to load both schema files.
+ DataFactoryPtr df_both = DataFactory::getDataFactory();
+
+ XSDHelperPtr xsh_both = HelperProvider::getXSDHelper(df_both);
+
+ // Load a root element definition, then the three animal types.
+ xsh_both->defineFile("jira980_mixedJungle.xsd");
+ xsh_both->defineFile("jira980_animaltypes.xsd");
+
+ // Create three animals based on the preceding types.
+ DataObjectPtr baloo = df_both->create("", "bearType");
+ baloo->setCString("name", "Mummy bear");
+ baloo->setInteger("weight", 700);
+
+ DataObjectPtr bagheera = df_both->create("", "pantherType");
+ bagheera->setCString("name", "Bagheera");
+ bagheera->setCString("colour", "inky black");
+
+ DataObjectPtr kaa = df_both->create("", "snakeType");
+ kaa->setCString("name", "Kaa");
+ kaa->setInteger("length", 25);
+
+ // Create an output document
+ XMLHelperPtr xmh_both = HelperProvider::getXMLHelper(df_both);
+ XMLDocumentPtr document_both = xmh_both->createDocument();
+
+ DataObjectPtr mixedJungle = document_both->getRootDataObject();
+
+ // Add the three animals as children of the document root. In this test
+ // that root will be a "mixedJungle" element.
+ mixedJungle->setDataObject("bear", baloo);
+ mixedJungle->setDataObject("panther", bagheera);
+ mixedJungle->setDataObject("snake", kaa);
+
+ xmh_both->save(document_both, "jira980_mixedJungle_out.xml");
+ return comparefiles("jira980_mixedJungle_out.txt" ,"jira980_mixedJungle_out.xml");
+
+ }
+ catch (SDORuntimeException e)
+ {
+ cout << "Exception in jira980" << e << endl;
+ return 0;
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org