cvs: pecl /sdo SDO_CPPException.cpp SDO_DAS_DataFactory.cpp SDO_Exception.cpp php_sdo_das_xml.h php_sdo_int.h /sdo/DAS/Relational/Tests
TestRelational.php /sdo/commonj/sdo DataFactory.h DataFactoryImpl.cpp DataFactoryImpl.h DataObjectImpl.cpp DataObjectImpl.h DataObjectListImpl.cpp
SDOXMLWriter.cpp /sdo/tests SDOAPITest.php /sdo/tests/XMLDAS/PHPUnitTests/restrictedComplexType load.php

From: Date: Fri, 17 Mar 2006 16:43:47 +0000
Subject: cvs: pecl /sdo SDO_CPPException.cpp SDO_DAS_DataFactory.cpp SDO_Exception.cpp php_sdo_das_xml.h php_sdo_int.h /sdo/DAS/Relational/Tests
TestRelational.php /sdo/commonj/sdo DataFactory.h DataFactoryImpl.cpp DataFactoryImpl.h DataObjectImpl.cpp DataObjectImpl.h DataObjectListImpl.cpp
SDOXMLWriter.cpp /sdo/tests SDOAPITest.php /sdo/tests/XMLDAS/PHPUnitTests/restrictedComplexType load.php
Groups: php.pecl.cvs 
Request: Send a blank email to pecl-cvs+get-5486@lists.php.net to get a copy of this message
cem Fri Mar 17 16:43:47 2006 UTC Removed files: /pecl/sdo/tests/XMLDAS/PHPUnitTests/restrictedComplexType load.php Modified files: /pecl/sdo/DAS/Relational/Tests TestRelational.php /pecl/sdo SDO_CPPException.cpp SDO_DAS_DataFactory.cpp SDO_Exception.cpp php_sdo_das_xml.h php_sdo_int.h /pecl/sdo/commonj/sdo DataFactory.h DataFactoryImpl.cpp DataFactoryImpl.h DataObjectImpl.cpp DataObjectImpl.h DataObjectListImpl.cpp SDOXMLWriter.cpp /pecl/sdo/tests SDOAPITest.php Log: changes for version 1_0_1

http://cvs.php.net/viewcvs.cgi/pecl/sdo/DAS/Relational/Tests/TestRelational.php?r1=1.2&r2=1.3&diff_format=u Index: pecl/sdo/DAS/Relational/Tests/TestRelational.php diff -u pecl/sdo/DAS/Relational/Tests/TestRelational.php:1.2 pecl/sdo/DAS/Relational/Tests/TestRelational.php:1.3 --- pecl/sdo/DAS/Relational/Tests/TestRelational.php:1.2 Wed Oct 19 11:35:43 2005 +++ pecl/sdo/DAS/Relational/Tests/TestRelational.php Fri Mar 17 16:43:46 2006 @@ -1,7 +1,7 @@ <?php /* +----------------------------------------------------------------------+ -| (c) Copyright IBM Corporation 2005. | +| (c) Copyright IBM Corporation 2005, 2006. | | All Rights Reserved. | +----------------------------------------------------------------------+ | | @@ -38,6 +38,7 @@ public function testConstructor_ThrowsExceptionIfNoDatabaseMetadata() { $database_metadata = null; $exception_thrown = false; + $msg = null; try { $das = new SDO_DAS_Relational ($database_metadata); } catch (SDO_DAS_Relational_Exception $e) { @@ -57,6 +58,7 @@ $database_metadata = array($company_table_metadata); $exception_thrown = false; + $msg = null; try { $das = new SDO_DAS_Relational($database_metadata); } catch (SDO_DAS_Relational_Exception $e) { @@ -105,6 +107,7 @@ $database_metadata = array($company_table_metadata, $department_table_metadata); $exception_thrown = false; + $msg = null; try { $das = new SDO_DAS_Relational($database_metadata,'company',null); } catch (SDO_DAS_Relational_Exception $e) { http://cvs.php.net/viewcvs.cgi/pecl/sdo/SDO_CPPException.cpp?r1=1.1&r2=1.2&diff_format=u Index: pecl/sdo/SDO_CPPException.cpp diff -u pecl/sdo/SDO_CPPException.cpp:1.1 pecl/sdo/SDO_CPPException.cpp:1.2 --- pecl/sdo/SDO_CPPException.cpp:1.1 Mon Feb 20 18:50:25 2006 +++ pecl/sdo/SDO_CPPException.cpp Fri Mar 17 16:43:46 2006 @@ -1,25 +1,25 @@ -/* +/* +----------------------------------------------------------------------+ -| (c) Copyright IBM Corporation 2005. | +| (c) Copyright IBM Corporation 2005, 2006. | | All Rights Reserved. | -+----------------------------------------------------------------------+ -| | -| Licensed under the Apache License, Version 2.0 (the "License"); you | -| may not use this file except in compliance with the License. You may | -| obtain a copy of the License at | ++----------------------------------------------------------------------+ +| | +| Licensed under the Apache License, Version 2.0 (the "License"); you | +| may not use this file except in compliance with the License. You may | +| obtain a copy of the License at | | http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | -| implied. See the License for the specific language governing | -| permissions and limitations under the License. | -+----------------------------------------------------------------------+ -| Author: Caroline Maynard | -+----------------------------------------------------------------------+ +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | +| implied. See the License for the specific language governing | +| permissions and limitations under the License. | ++----------------------------------------------------------------------+ +| Author: Caroline Maynard | ++----------------------------------------------------------------------+ */ -static char rcs_id[] = "$Id: SDO_CPPException.cpp,v 1.1 2006/02/20 18:50:25 mfp Exp $"; +static char rcs_id[] = "$Id: SDO_CPPException.cpp,v 1.2 2006/03/17 16:43:46 cem Exp $"; #ifdef PHP_WIN32 #include <iostream> @@ -48,28 +48,27 @@ zend_class_entry *exception_class; const char *message = e->getMessageText(); const char *exception_type = e->getEClassName(); - + MAKE_STD_ZVAL(z_cause); sdo_cppexception_new (z_cause, e TSRMLS_CC); - - if (strcmp(exception_type, "SDOUnsupportedOperationException") == 0) + + if (strcmp(exception_type, "SDOUnsupportedOperationException") == 0) exception_class = sdo_unsupportedoperationexception_class_entry; - else if (strcmp(exception_type, "SDOPropertyNotFoundException") == 0 || - strcmp(exception_type, "SDOPathNotFoundException") == 0) + else if (strcmp(exception_type, "SDOPropertyNotFoundException") == 0 || + strcmp(exception_type, "SDOPathNotFoundException") == 0) exception_class = sdo_propertynotfoundexception_class_entry; - else if (strcmp(exception_type, "SDOTypeNotFoundException") == 0) + else if (strcmp(exception_type, "SDOTypeNotFoundException") == 0) exception_class = sdo_typenotfoundexception_class_entry; - else if (strcmp(exception_type, "SDOIndexOutOfRangeException") == 0) + else if (strcmp(exception_type, "SDOIndexOutOfRangeException") == 0) exception_class = sdo_indexoutofboundsexception_class_entry; - else if (strcmp(exception_type, "SDOInvalidConversionException") == 0) + else if (strcmp(exception_type, "SDOInvalidConversionException") == 0) exception_class = sdo_invalidconversionexception_class_entry; - else if (strcmp(exception_type, "SDOPropertyNotSetException") == 0) + else if (strcmp(exception_type, "SDOPropertyNotSetException") == 0) exception_class = sdo_propertynotsetexception_class_entry; else exception_class = sdo_exception_class_entry; - - z_sdo_exception = sdo_throw_exception (exception_class, message, 0, 0 TSRMLS_CC); - z_sdo_exception = sdo_throw_exception (exception_class, message, 0, z_cause TSRMLS_CC); + + z_sdo_exception = sdo_throw_exception (exception_class, message, 0, z_cause TSRMLS_CC); zval_ptr_dtor(&z_cause); return z_sdo_exception; } @@ -97,7 +96,7 @@ /* {{{ sdo_cppexception_get_property */ -static void sdo_cppexception_get_property(zval *me, char *name, long name_len, zval *return_value TSRMLS_DC) +static void sdo_cppexception_get_property(zval *me, char *name, long name_len, zval *return_value TSRMLS_DC) { zval *value; @@ -111,19 +110,19 @@ /* }}} */ /* {{{ sdo_cppexception_cast_object -*/ -static int sdo_cppexception_cast_object(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) +*/ +static int sdo_cppexception_cast_object(zval *readobj, zval *writeobj, int type, int should_free TSRMLS_DC) { ostringstream print_buf; zval free_obj; int rc = SUCCESS; - + if (should_free) { free_obj = *writeobj; } - + sdo_cppexception_get_property(readobj, "string", sizeof("string") - 1, writeobj TSRMLS_CC); - + switch(type) { case IS_STRING: convert_to_string(writeobj); @@ -140,11 +139,11 @@ default: rc = FAILURE; } - + if (should_free) { zval_dtor(&free_obj); } - + return rc; } /* }}} */ @@ -155,18 +154,18 @@ * PHP Exception, but there's no debug trace. */ void sdo_cppexception_minit(zend_class_entry *ce TSRMLS_DC) -{ - sdo_cppexception_class_entry = - zend_register_internal_class(ce TSRMLS_CC); +{ + sdo_cppexception_class_entry = + zend_register_internal_class(ce TSRMLS_CC); sdo_cppexception_class_entry->create_object = sdo_cppexception_create_object; memcpy(&sdo_cppexception_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); /*TODO There's a signature change for cast_object in PHP6. */ -#if (PHP_MAJOR_VERSION < 6) +#if (PHP_MAJOR_VERSION < 6) sdo_cppexception_object_handlers.cast_object = sdo_cppexception_cast_object; #endif - - zend_declare_property_string(sdo_cppexception_class_entry, + + zend_declare_property_string(sdo_cppexception_class_entry, "class", sizeof("class") - 1, "", ZEND_ACC_PUBLIC TSRMLS_CC); zend_declare_property_string(sdo_cppexception_class_entry, "file", sizeof("file") - 1, "", ZEND_ACC_PUBLIC TSRMLS_CC); @@ -188,19 +187,19 @@ * Instantiate an SDO_CPPException from an SDORuntimeException */ void sdo_cppexception_new(zval *me, SDORuntimeException *cpp_exception TSRMLS_DC) -{ +{ const char *eclass = cpp_exception->getEClassName(); const char *function = cpp_exception->getFunctionName(); const char *message = cpp_exception->getMessageText(); const char *file = cpp_exception->getFileName(); long line = cpp_exception->getLineNumber(); char *class_name, *space; - + long severity; - + ostringstream print_buf; string print_string; - + switch(cpp_exception->getSeverity()) { case SDORuntimeException::Normal: severity = E_NOTICE; @@ -214,44 +213,44 @@ severity = E_ERROR; break; } - + if (object_init_ex(me, sdo_cppexception_class_entry) == FAILURE) { class_name = get_active_class_name(&space TSRMLS_CC); - php_error(E_ERROR, "%s%s%s(): internal error (%i) - failed to instantiate %s object", + php_error(E_ERROR, "%s%s%s(): internal error (%i) - failed to instantiate %s object", class_name, space, get_active_function_name(TSRMLS_C), __LINE__, CLASS_NAME); return; } - + if (eclass) { zend_update_property_string(sdo_cppexception_class_entry, me, "class", sizeof("class")-1, (char *)eclass TSRMLS_CC); } - + if (file) { zend_update_property_string(sdo_cppexception_class_entry, me, "file", sizeof("file")-1, (char *)file TSRMLS_CC); } - - zend_update_property_long(sdo_cppexception_class_entry, me, + + zend_update_property_long(sdo_cppexception_class_entry, me, "line", sizeof("line")-1, line TSRMLS_CC); - + if (function) { zend_update_property_string(sdo_cppexception_class_entry, me, "function", sizeof("function")-1, (char *)function TSRMLS_CC); } - + if (message) { zend_update_property_string(sdo_cppexception_class_entry, me, "message", sizeof("message")-1, (char *)message TSRMLS_CC); } - - zend_update_property_long(sdo_cppexception_class_entry, me, + + zend_update_property_long(sdo_cppexception_class_entry, me, "severity", sizeof("severity")-1, severity TSRMLS_CC); - + print_buf << *cpp_exception; print_string = print_buf.str(); zend_update_property_stringl (sdo_cppexception_class_entry, me, - "string", sizeof("string") - 1, + "string", sizeof("string") - 1, (char *)print_string.c_str(), print_string.length() TSRMLS_CC); } /* }}} */ @@ -259,11 +258,11 @@ /* {{{ SDO_CPPException::getClass */ PHP_METHOD(SDO_CPPException, getClass) -{ +{ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + sdo_cppexception_get_property( getThis(), "class", sizeof("class") - 1, return_value TSRMLS_CC); } @@ -272,11 +271,11 @@ /* {{{ SDO_CPPException::getFile */ PHP_METHOD(SDO_CPPException, getFile) -{ +{ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + sdo_cppexception_get_property( getThis(), "file", sizeof("file") - 1, return_value TSRMLS_CC); } @@ -285,11 +284,11 @@ /* {{{ SDO_CPPException::getLine */ PHP_METHOD(SDO_CPPException, getLine) -{ +{ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + sdo_cppexception_get_property( getThis(), "line", sizeof("line") - 1, return_value TSRMLS_CC); } @@ -298,11 +297,11 @@ /* {{{ SDO_CPPException::getFunction */ PHP_METHOD(SDO_CPPException, getFunction) -{ +{ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + sdo_cppexception_get_property( getThis(), "function", sizeof("function") - 1, return_value TSRMLS_CC); } @@ -311,11 +310,11 @@ /* {{{ SDO_CPPException::getMessage */ PHP_METHOD(SDO_CPPException, getMessage) -{ +{ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + sdo_cppexception_get_property( getThis(), "message", sizeof("message") - 1, return_value TSRMLS_CC); } @@ -324,11 +323,11 @@ /* {{{ SDO_CPPException::getSeverity */ PHP_METHOD(SDO_CPPException, getSeverity) -{ +{ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + sdo_cppexception_get_property( getThis(), "severity", sizeof("severity") - 1, return_value TSRMLS_CC); } http://cvs.php.net/viewcvs.cgi/pecl/sdo/SDO_DAS_DataFactory.cpp?r1=1.9&r2=1.10&diff_format=u Index: pecl/sdo/SDO_DAS_DataFactory.cpp diff -u pecl/sdo/SDO_DAS_DataFactory.cpp:1.9 pecl/sdo/SDO_DAS_DataFactory.cpp:1.10 --- pecl/sdo/SDO_DAS_DataFactory.cpp:1.9 Wed Mar 1 13:46:05 2006 +++ pecl/sdo/SDO_DAS_DataFactory.cpp Fri Mar 17 16:43:46 2006 @@ -1,25 +1,25 @@ -/* +/* +----------------------------------------------------------------------+ -| (c) Copyright IBM Corporation 2005. | +| (c) Copyright IBM Corporation 2005, 2006. | | All Rights Reserved. | -+----------------------------------------------------------------------+ -| | -| Licensed under the Apache License, Version 2.0 (the "License"); you | -| may not use this file except in compliance with the License. You may | -| obtain a copy of the License at | ++----------------------------------------------------------------------+ +| | +| Licensed under the Apache License, Version 2.0 (the "License"); you | +| may not use this file except in compliance with the License. You may | +| obtain a copy of the License at | | http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | -| implied. See the License for the specific language governing | -| permissions and limitations under the License. | -+----------------------------------------------------------------------+ -| Author: Caroline Maynard | -+----------------------------------------------------------------------+ +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | +| implied. See the License for the specific language governing | +| permissions and limitations under the License. | ++----------------------------------------------------------------------+ +| Author: Caroline Maynard | ++----------------------------------------------------------------------+ */ -static char rcs_id[] = "$Id: SDO_DAS_DataFactory.cpp,v 1.9 2006/03/01 13:46:05 cem Exp $"; +static char rcs_id[] = "$Id: SDO_DAS_DataFactory.cpp,v 1.10 2006/03/17 16:43:46 cem Exp $"; #ifdef PHP_WIN32 #include <iostream> @@ -47,7 +47,7 @@ /* {{{ sdo_das_df_get_instance */ -static sdo_das_df_object *sdo_das_df_get_instance(zval *me TSRMLS_DC) +static sdo_das_df_object *sdo_das_df_get_instance(zval *me TSRMLS_DC) { return (sdo_das_df_object *)zend_object_store_get_object(me TSRMLS_CC); } @@ -94,7 +94,7 @@ * utility function for DAS implementations */ DataFactoryPtr sdo_das_df_get(zval *me TSRMLS_DC) -{ +{ sdo_das_df_object *my_object; my_object = (sdo_das_df_object *)zend_object_store_get_object(me TSRMLS_CC); @@ -105,14 +105,14 @@ /* {{{ sdo_das_df_new */ void sdo_das_df_new(zval *me, DataFactoryPtr dfp TSRMLS_DC) -{ +{ sdo_das_df_object *my_object; char *class_name, *space; - Z_TYPE_P(me) = IS_OBJECT; + Z_TYPE_P(me) = IS_OBJECT; if (object_init_ex(me, sdo_das_datafactoryimpl_class_entry) == FAILURE) { class_name = get_active_class_name(&space TSRMLS_CC); - php_error(E_ERROR, "%s%s%s(): internal error (%i) - failed to instantiate %s object", + php_error(E_ERROR, "%s%s%s(): internal error (%i) - failed to instantiate %s object", class_name, space, get_active_function_name(TSRMLS_C), __LINE__, CLASS_NAME); return; } @@ -124,7 +124,7 @@ /* {{{ sdo_das_df_minit */ -void sdo_das_df_minit(zend_class_entry *tmp_ce TSRMLS_DC) +void sdo_das_df_minit(zend_class_entry *tmp_ce TSRMLS_DC) { tmp_ce->create_object = sdo_das_df_object_create; sdo_das_datafactoryimpl_class_entry = zend_register_internal_class(tmp_ce TSRMLS_CC); @@ -140,41 +140,42 @@ PHP_METHOD(SDO_DAS_DataFactory, getDataFactory) { DataFactoryPtr dfp; - + if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + try { dfp = DataFactory::getDataFactory(); sdo_das_df_new (return_value, dfp TSRMLS_CC); } catch (SDORuntimeException e) { sdo_throw_runtimeexception(&e TSRMLS_CC); } - + } /* }}} */ /* {{{ SDO_DAS_DataFactoryImpl::create */ -PHP_METHOD(SDO_DAS_DataFactoryImpl, create) +PHP_METHOD(SDO_DAS_DataFactoryImpl, create) { sdo_das_df_object *my_object; char *type_uri; int *type_uri_len; char *type_name; int *type_name_len; - + DataObjectPtr dop; - - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", - &type_uri, &type_uri_len, &type_name, &type_name_len) == FAILURE) + + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss", + &type_uri, &type_uri_len, &type_name, &type_name_len) == FAILURE) return; - + my_object = sdo_das_df_get_instance(getThis() TSRMLS_CC); try { dop = my_object->dfp->create(type_uri, type_name); - sdo_do_new(return_value, dop TSRMLS_CC); + /* We have a good data object, so set up its PHP incarnation */ + sdo_do_new(return_value, dop TSRMLS_CC); } catch (SDORuntimeException e) { sdo_throw_runtimeexception(&e TSRMLS_CC); } @@ -183,7 +184,7 @@ /* {{{ */ static zend_bool sdo_get_boolean_value (zval *z_value) { - + zend_bool bool_value; if (Z_TYPE_P(z_value) == IS_BOOL) { @@ -202,20 +203,20 @@ /* {{{ SDO_DAS_DataFactoryImpl::addType * This is a static factory method */ -PHP_METHOD(SDO_DAS_DataFactoryImpl, addType) +PHP_METHOD(SDO_DAS_DataFactoryImpl, addType) { sdo_das_df_object *my_object; char *type_uri; int type_uri_len; char *type_name; int type_name_len; - + /* optional parameters with default values */ zend_bool is_sequenced = false; zend_bool is_open = false; zend_bool is_abstract = false; zend_bool is_derived = false; - + /* optional array of optional argumants */ zval *args = NULL; HashTable *args_hash; @@ -224,51 +225,51 @@ char *key_string; uint key_string_len; ulong key_index; - + /* and a further array for the basetype values */ HashTable *basetype_hash; zval **z_basetype_uri; zval **z_basetype_name; char *basetype_uri; char *basetype_name; - + char *class_name, *space; if (ZEND_NUM_ARGS() < 2) WRONG_PARAM_COUNT; - + if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|a", &type_uri, &type_uri_len, &type_name, &type_name_len, &args) == FAILURE) { - return; - } - + return; + } + if (args != NULL) { args_hash = Z_ARRVAL_P(args); - + for (zend_hash_internal_pointer_reset_ex(args_hash, &args_pointer); zend_hash_get_current_data_ex(args_hash, (void **)&value, &args_pointer) == SUCCESS; zend_hash_move_forward_ex(args_hash, &args_pointer)) { if (zend_hash_get_current_key_ex( args_hash, &key_string, &key_string_len, &key_index, 0, &args_pointer) == HASH_KEY_IS_STRING) { - + if (strcmp(key_string, "sequenced") == SUCCESS) { is_sequenced = sdo_get_boolean_value (*value); continue; - } - + } + if (strcmp(key_string, "open") == SUCCESS) { - is_open = sdo_get_boolean_value (*value); + is_open = sdo_get_boolean_value (*value); continue; - } - + } + if (strcmp(key_string, "abstract") == SUCCESS) { - is_abstract = sdo_get_boolean_value (*value); + is_abstract = sdo_get_boolean_value (*value); continue; } - + if (strcmp(key_string, "basetype") == SUCCESS) { - /* If the basetype option is present, its value + /* If the basetype option is present, its value * is an array of type uri and type name. */ is_derived = true; @@ -278,8 +279,8 @@ "%s%s%s(): %s argument should be an array", class_name, space, get_active_function_name(TSRMLS_C), key_string); return; - } - + } + basetype_hash = Z_ARRVAL_PP(value); if (zend_hash_num_elements(basetype_hash) != 2) { class_name = get_active_class_name(&space TSRMLS_CC); @@ -287,24 +288,24 @@ "%s%s%s(): %s array should have exactly two elements", class_name, space, get_active_function_name(TSRMLS_C), key_string); return; - } - + } + if (zend_hash_index_find(basetype_hash, 0, (void **)&z_basetype_uri) == SUCCESS && Z_TYPE_PP(z_basetype_uri) == IS_STRING) { basetype_uri = Z_STRVAL_PP(z_basetype_uri); } else { - class_name = get_active_class_name(&space TSRMLS_CC); + class_name = get_active_class_name(&space TSRMLS_CC); sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, "%s%s%s(): invalid value for %s type namespace URI", class_name, space, get_active_function_name(TSRMLS_C), key_string); return; } - + if (zend_hash_index_find(basetype_hash, 1, (void **)&z_basetype_name) == SUCCESS&& Z_TYPE_PP(z_basetype_name) == IS_STRING) { basetype_name = Z_STRVAL_PP(z_basetype_name); - } else { - class_name = get_active_class_name(&space TSRMLS_CC); + } else { + class_name = get_active_class_name(&space TSRMLS_CC); sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, "%s%s%s(): invalid value for %s type name", class_name, space, get_active_function_name(TSRMLS_C), key_string); @@ -312,34 +313,34 @@ } continue; } /* end basetype */ - + class_name = get_active_class_name(&space TSRMLS_CC); sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, "%s%s%s(): unrecognized option %s in parameter array", - class_name, space, get_active_function_name(TSRMLS_C), key_string); - + class_name, space, get_active_function_name(TSRMLS_C), key_string); + } else { class_name = get_active_class_name(&space TSRMLS_CC); sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, - "%s%s%s(): option name must be a string in parameter array #%i", + "%s%s%s(): option name must be a string in parameter array #%i", class_name, space, get_active_function_name(TSRMLS_C), key_index); } - } + } } - + my_object = sdo_das_df_get_instance(getThis() TSRMLS_CC); - + try { - my_object->dfp->addType(type_uri, type_name, + my_object->dfp->addType(type_uri, type_name, ZEND_TRUTH(is_sequenced), ZEND_TRUTH(is_open), ZEND_TRUTH(is_abstract)); - + if (is_derived) { my_object->dfp->setBaseType(type_uri, type_name, basetype_uri, basetype_name); } } catch (SDORuntimeException e) { sdo_throw_runtimeexception(&e TSRMLS_CC); } - + return; } /* }}} */ @@ -347,7 +348,7 @@ /* {{{ SDO_DAS_DataFactoryImpl::addPropertyToType * This is a static factory method */ -PHP_METHOD(SDO_DAS_DataFactoryImpl, addPropertyToType) +PHP_METHOD(SDO_DAS_DataFactoryImpl, addPropertyToType) { char *parent_type_uri; int parent_type_uri_len; @@ -386,13 +387,13 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sssss|a", &parent_type_uri, &parent_type_uri_len, &parent_type_name, &parent_type_name_len, - &property_name, &property_name_len, + &property_name, &property_name_len, &type_uri, &type_uri_len, &type_name, &type_name_len, &args) == FAILURE) { - return; + return; } else if (args != NULL) { args_hash = Z_ARRVAL_P(args); - + for (zend_hash_internal_pointer_reset_ex(args_hash, &args_pointer); zend_hash_get_current_data_ex(args_hash, (void **)&value, &args_pointer) == SUCCESS; zend_hash_move_forward_ex(args_hash, &args_pointer)) { @@ -401,65 +402,65 @@ if (strcmp(key_string, "many") == SUCCESS) { many = sdo_get_boolean_value (*value); continue; - } + } if (strcmp(key_string, "readonly") == SUCCESS) { read_only = sdo_get_boolean_value (*value); class_name = get_active_class_name(&space TSRMLS_CC); - php_error(E_WARNING, "%s%s%s(): option %s not yet implemented", + php_error(E_WARNING, "%s%s%s(): option %s not yet implemented", class_name, space, get_active_function_name(TSRMLS_C), key_string); continue; } if (strcmp(key_string, "containment") == SUCCESS) { containment = sdo_get_boolean_value (*value); continue; - } + } if (strcmp(key_string, "opposite") == SUCCESS) { class_name = get_active_class_name(&space TSRMLS_CC); - php_error(E_WARNING, "%s%s%s(): option %s not yet implemented", + php_error(E_WARNING, "%s%s%s(): option %s not yet implemented", class_name, space, get_active_function_name(TSRMLS_C), key_string); continue; - } + } if (strcmp(key_string, "default") == SUCCESS) { - default_value = *value; + default_value = *value; continue; - } - + } + sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, "%s::%s: unrecognized option %s in parameter array", - CLASS_NAME, get_active_function_name(TSRMLS_C), key_string); - + CLASS_NAME, get_active_function_name(TSRMLS_C), key_string); + } else { sdo_throw_exception_ex (sdo_unsupportedoperationexception_class_entry, 0, 0 TSRMLS_CC, - "%s::%s: option name must be a string in parameter array #%i", + "%s::%s: option name must be a string in parameter array #%i", CLASS_NAME, get_active_function_name(TSRMLS_C), key_index); - } - - } - } - + } + + } + } + my_object = sdo_das_df_get_instance(getThis() TSRMLS_CC); try { my_object->dfp->addPropertyToType(parent_type_uri, parent_type_name, property_name, type_uri, type_name, ZEND_TRUTH(many), ZEND_TRUTH(read_only), ZEND_TRUTH(containment)); - - if (default_value) { + + if (default_value) { if (many) { - zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, - "%s:%i: multivalued property %s cannot have a default value", CLASS_NAME, __LINE__, property_name); + zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, + "multivalued property %s cannot have a default value", property_name); } else if (Z_TYPE_P(default_value) == IS_NULL) { - zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, - "%s:%i: property %s cannot have a NULL default value", CLASS_NAME, __LINE__, property_name); - } else { + zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, + "property %s cannot have a NULL default value", property_name); + } else { /* copy the value so that the original is not modified */ - zval temp_zval = *default_value; + zval temp_zval = *default_value; zval_copy_ctor(&temp_zval); - + const Type& type = my_object->dfp->getType(type_uri, type_name); const Type& parentType = my_object->dfp->getType(parent_type_uri, parent_type_name); switch (type.getTypeEnum()) { case Type::OtherTypes: class_name = get_active_class_name(&space TSRMLS_CC); - php_error(E_ERROR, "%s%s%s(): internal error (%i) - unexpected DataObject type 'OtherTypes'", + php_error(E_ERROR, "%s%s%s(): internal error (%i) - unexpected DataObject type 'OtherTypes'", class_name, space, get_active_function_name(TSRMLS_C), __LINE__); break; case Type::BigDecimalType: @@ -479,7 +480,7 @@ convert_to_string(&temp_zval); my_object->dfp->setDefault(parentType, property_name, Z_STRVAL(temp_zval), Z_STRLEN(temp_zval)); break; - case Type::CharacterType: + case Type::CharacterType: convert_to_string(&temp_zval); my_object->dfp->setDefault(parentType, property_name, (char)(Z_STRVAL(temp_zval)[0])); break; @@ -489,8 +490,8 @@ break; case Type::DoubleType: convert_to_double(&temp_zval); - /*TODO this may need more work. On Windows, simply omitting the cast, or casting to double, - * leads to an ambiguous overloaded function message. But some platforms may baulk at long double. + /*TODO this may need more work. On Windows, simply omitting the cast, or casting to double, + * leads to an ambiguous overloaded function message. But some platforms may baulk at long double. */ my_object->dfp->setDefault(parentType, property_name, (long double)Z_DVAL(temp_zval)); break; @@ -505,7 +506,7 @@ case Type::LongType: if (Z_TYPE(temp_zval) == IS_LONG) { my_object->dfp->setDefault(parentType, property_name, (int64_t)Z_LVAL(temp_zval)); - } else { + } else { convert_to_string(&temp_zval); my_object->dfp->setDefault(parentType, property_name, Z_STRVAL(temp_zval)); } @@ -521,30 +522,30 @@ my_object->dfp->setDefault(parentType, property_name, Z_STRVAL(temp_zval)); break; case Type::DataObjectType: - zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, - "%s:%i: DataObject property %s cannot have a default value", - CLASS_NAME, __LINE__, property_name); + zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, + "DataObject property %s cannot have a default value", + property_name); break; case Type::ChangeSummaryType: - zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, - "%s:%i: ChangeSummary property %s cannot have a default value", - CLASS_NAME, __LINE__, property_name); + zend_throw_exception_ex(sdo_unsupportedoperationexception_class_entry, 0 TSRMLS_CC, + "ChangeSummary property %s cannot have a default value", + property_name); break; default: class_name = get_active_class_name(&space TSRMLS_CC); - php_error(E_ERROR, "%s%s%s(): internal error (%i) - unexpected DataObject type '%s' for property '%s'", - class_name, space, get_active_function_name(TSRMLS_C), __LINE__, + php_error(E_ERROR, "%s%s%s(): internal error (%i) - unexpected DataObject type '%s' for property '%s'", + class_name, space, get_active_function_name(TSRMLS_C), __LINE__, type.getName(), property_name); } - + zval_dtor(&temp_zval); } } - + } catch (SDORuntimeException e) { sdo_throw_runtimeexception(&e TSRMLS_CC); } - + return; }/* }}} */ http://cvs.php.net/viewcvs.cgi/pecl/sdo/SDO_Exception.cpp?r1=1.1&r2=1.2&diff_format=u Index: pecl/sdo/SDO_Exception.cpp diff -u pecl/sdo/SDO_Exception.cpp:1.1 pecl/sdo/SDO_Exception.cpp:1.2 --- pecl/sdo/SDO_Exception.cpp:1.1 Mon Feb 20 18:50:25 2006 +++ pecl/sdo/SDO_Exception.cpp Fri Mar 17 16:43:46 2006 @@ -1,25 +1,25 @@ -/* +/* +----------------------------------------------------------------------+ -| (c) Copyright IBM Corporation 2005. | +| (c) Copyright IBM Corporation 2005, 2006. | | All Rights Reserved. | -+----------------------------------------------------------------------+ -| | -| Licensed under the Apache License, Version 2.0 (the "License"); you | -| may not use this file except in compliance with the License. You may | -| obtain a copy of the License at | ++----------------------------------------------------------------------+ +| | +| Licensed under the Apache License, Version 2.0 (the "License"); you | +| may not use this file except in compliance with the License. You may | +| obtain a copy of the License at | | http://www.apache.org/licenses/LICENSE-2.0 | -| | -| Unless required by applicable law or agreed to in writing, software | -| distributed under the License is distributed on an "AS IS" BASIS, | -| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | -| implied. See the License for the specific language governing | -| permissions and limitations under the License. | -+----------------------------------------------------------------------+ -| Author: Caroline Maynard | -+----------------------------------------------------------------------+ +| | +| Unless required by applicable law or agreed to in writing, software | +| distributed under the License is distributed on an "AS IS" BASIS, | +| WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or | +| implied. See the License for the specific language governing | +| permissions and limitations under the License. | ++----------------------------------------------------------------------+ +| Author: Caroline Maynard | ++----------------------------------------------------------------------+ */ -static char rcs_id[] = "$Id: SDO_Exception.cpp,v 1.1 2006/02/20 18:50:25 mfp Exp $"; +static char rcs_id[] = "$Id: SDO_Exception.cpp,v 1.2 2006/03/17 16:43:46 cem Exp $"; #ifdef PHP_WIN32 #include <iostream> @@ -35,7 +35,6 @@ #include "php_sdo_int.h" #define CLASS_NAME "SDO_Exception" -#define MAX_MSG 4096 static zend_class_entry *exception_class_entry; static zend_object_handlers sdo_exception_object_handlers; @@ -67,7 +66,7 @@ z_trace->refcount = 0; zend_fetch_debug_backtrace(z_trace, 0, 0 TSRMLS_CC); - zend_update_property(exception_class_entry, &z_object, + zend_update_property(exception_class_entry, &z_object, "trace", sizeof("trace") - 1, z_trace TSRMLS_CC); return z_object.value.obj; } @@ -77,27 +76,27 @@ */ void sdo_exception_minit(zend_class_entry *ce TSRMLS_DC) { -#if (PHP_MAJOR_VERSION < 6) +#if (PHP_MAJOR_VERSION < 6) exception_class_entry = zend_exception_get_default(); -#else +#else exception_class_entry = zend_exception_get_default(TSRMLS_C); #endif sdo_exception_class_entry = zend_register_internal_class_ex( ce, exception_class_entry, NULL TSRMLS_CC); - - sdo_exception_class_entry->create_object = sdo_exception_create_object; - + + sdo_exception_class_entry->create_object = sdo_exception_create_object; + /* * The SDO_Exception adds a cause property to the base Exception class. * This may be set to any value, normally the original SDO_CPPException. */ - zend_declare_property_null(sdo_exception_class_entry, + zend_declare_property_null(sdo_exception_class_entry, "cause", sizeof("cause") - 1, ZEND_ACC_PUBLIC TSRMLS_CC); - + memcpy(&sdo_exception_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers)); sdo_exception_object_handlers.clone_obj = NULL; - + } /* }}} */ @@ -108,14 +107,14 @@ { char *class_name, *space; - Z_TYPE_P(z_ex) = IS_OBJECT; + Z_TYPE_P(z_ex) = IS_OBJECT; if (object_init_ex(z_ex, ce) == FAILURE) { class_name = get_active_class_name(&space TSRMLS_CC); - php_error(E_ERROR, "%s%s%s(): internal error (%i) - failed to instantiate %s object", + php_error(E_ERROR, "%s%s%s(): internal error (%i) - failed to instantiate %s object", class_name, space, get_active_function_name(TSRMLS_C), __LINE__, CLASS_NAME); return; } - + if (message) { zend_update_property_string(exception_class_entry, z_ex, "message", sizeof("message") - 1, (char *)message TSRMLS_CC); @@ -123,9 +122,9 @@ zend_update_property_long(exception_class_entry, z_ex, "code", sizeof("code") - 1, code TSRMLS_CC); - + if (z_cause) { - zend_update_property(sdo_exception_class_entry, z_ex, + zend_update_property(sdo_exception_class_entry, z_ex, "cause", sizeof("cause") - 1, z_cause TSRMLS_CC); } } @@ -155,15 +154,9 @@ va_list arg; char *message; zval *z_ex; - int len; - /* TODO: for some reason I don't understand, I get a link error for - * zend_vspprintf. So use a temporary buffer and truncate the message - * if necessary. - */ - message = (char *)emalloc(MAX_MSG); - va_start(arg, format); - len = snprintf(message, MAX_MSG, format, arg); + va_start(arg, format); + vspprintf(&message, 0, format, arg); va_end(arg); z_ex = sdo_throw_exception(ce, message, code, z_cause TSRMLS_CC); @@ -176,9 +169,9 @@ /* {{{ sdo_exception_set_cause */ void sdo_exception_set_cause(zval *me, zval *z_cause TSRMLS_DC) -{ +{ - zend_update_property(sdo_exception_class_entry, me, + zend_update_property(sdo_exception_class_entry, me, "cause", sizeof("cause") - 1, z_cause TSRMLS_CC); } /* }}} */ @@ -186,9 +179,9 @@ /* {{{ sdo_exception_get_cause */ zval *sdo_exception_get_cause(zval *me TSRMLS_DC) -{ - return - zend_read_property(sdo_exception_class_entry, me, +{ + return + zend_read_property(sdo_exception_class_entry, me, "cause", sizeof("cause") - 1, 0 TSRMLS_CC); } /* }}} */ @@ -196,11 +189,11 @@ /* {{{ SDO_Exception::getCause */ PHP_METHOD(SDO_Exception, getCause) -{ +{ if (ZEND_NUM_ARGS() != 0) { WRONG_PARAM_COUNT; } - + zval *z_cause = sdo_exception_get_cause(getThis() TSRMLS_CC); RETURN_ZVAL(z_cause, 1, 0); } http://cvs.php.net/viewcvs.cgi/pecl/sdo/php_sdo_das_xml.h?r1=1.8&r2=1.9&diff_format=u Index: pecl/sdo/php_sdo_das_xml.h diff -u pecl/sdo/php_sdo_das_xml.h:1.8 pecl/sdo/php_sdo_das_xml.h:1.9 --- pecl/sdo/php_sdo_das_xml.h:1.8 Mon Feb 20 19:25:54 2006 +++ pecl/sdo/php_sdo_das_xml.h Fri Mar 17 16:43:46 2006 @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ -| (c) Copyright IBM Corporation 2005. | +| (c) Copyright IBM Corporation 2005, 2006. | | All Rights Reserved. | +----------------------------------------------------------------------+ | | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_sdo_das_xml.h,v 1.8 2006/02/20 19:25:54 mfp Exp $ */ +/* $Id: php_sdo_das_xml.h,v 1.9 2006/03/17 16:43:46 cem Exp $ */ #ifndef PHP_SDO_DAS_XML_H #define PHP_SDO_DAS_XML_H @@ -29,7 +29,7 @@ #include "TSRM.h" #endif -#define SDO_DAS_XML_VERSION "0.9.0" +#define SDO_DAS_XML_VERSION "1.0.1" #ifdef PHP_WIN32 # if defined (SDO_DAS_XML_EXPORTS) http://cvs.php.net/viewcvs.cgi/pecl/sdo/php_sdo_int.h?r1=1.14&r2=1.15&diff_format=u Index: pecl/sdo/php_sdo_int.h diff -u pecl/sdo/php_sdo_int.h:1.14 pecl/sdo/php_sdo_int.h:1.15 --- pecl/sdo/php_sdo_int.h:1.14 Mon Feb 20 19:25:54 2006 +++ pecl/sdo/php_sdo_int.h Fri Mar 17 16:43:46 2006 @@ -1,6 +1,6 @@ /* +----------------------------------------------------------------------+ -| (c) Copyright IBM Corporation 2005. | +| (c) Copyright IBM Corporation 2005, 2006. | | All Rights Reserved. | +----------------------------------------------------------------------+ | | @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: php_sdo_int.h,v 1.14 2006/02/20 19:25:54 mfp Exp $ */ +/* $Id: php_sdo_int.h,v 1.15 2006/03/17 16:43:46 cem Exp $ */ #ifndef PHP_SDO_INT_H #define PHP_SDO_INT_H @@ -35,7 +35,7 @@ using namespace commonj::sdo; -#define SDO_VERSION "0.9.0" +#define SDO_VERSION "1.0.1" #define SDO_NAMESPACE_URI "namespaceURI" #define SDO_TYPE_NAME "typeName" @@ -134,7 +134,7 @@ extern PHP_SDO_API xmldas::XMLDAS *sdo_get_XMLDAS(); -extern PHP_SDO_API int sdo_parse_offset_param(DataObjectPtr dop, zval *z_offset, +extern PHP_SDO_API int sdo_parse_offset_param(DataObjectPtr dop, zval *z_offset, const Property **return_property, const char **return_xpath, int property_required, int quiet TSRMLS_DC); extern PHP_SDO_API Type::Types sdo_map_zval_type (zval *z_value); http://cvs.php.net/viewcvs.cgi/pecl/sdo/commonj/sdo/DataFactory.h?r1=1.4&r2=1.5&diff_format=u Index: pecl/sdo/commonj/sdo/DataFactory.h diff -u pecl/sdo/commonj/sdo/DataFactory.h:1.4 pecl/sdo/commonj/sdo/DataFactory.h:1.5 --- pecl/sdo/commonj/sdo/DataFactory.h:1.4 Wed Mar 1 13:46:05 2006 +++ pecl/sdo/commonj/sdo/DataFactory.h Fri Mar 17 16:43:47 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/03/01 13:46:05 $ */ +/* $Rev$ $Date: 2006/03/17 16:43:47 $ */ #ifndef _DATAFACTORY_H_ #define _DATAFACTORY_H_ @@ -36,7 +36,7 @@ class DataObject; class Type; -/** +/** * DataFactory holds metadata and creates DataObjects. * * The DataFactory holds properties and types loaded from XSD, or @@ -51,20 +51,20 @@ /** * getDataFactory is static and gets a data factory * - * Static method to get a new data factory, with a set of base Types defined. - * With the data factory returned, either load Type definitions + * Static method to get a new data factory, with a set of base Types defined. + * With the data factory returned, either load Type definitions * from XSD, or use the DataFactory APIs to define the types. */ static SDO_API DataFactoryPtr getDataFactory(); - + virtual SDO_API ~DataFactory(); /** * DataFactory::clone copies a data factory * - * Copy the data factory, and return a new data factory which + * Copy the data factory, and return a new data factory which * has the same properties and types, but is still able to have * new types added to it. */ @@ -96,8 +96,8 @@ /** * DataFactory::getTypes gets a list of types back from the factory. * - * Get all the types available within this data factory. Useful for - * validating whether a data object is of the correct type to be + * Get all the types available within this data factory. Useful for + * validating whether a data object is of the correct type to be * usable. */ @@ -114,17 +114,17 @@ * -# The type may be abstract, so the data factory will not permit creation * of instances. * -# The type may be a data type, indicating that is will not have properties. - * The Type may inherit from another type, but that is specified later with a + * The Type may inherit from another type, but that is specified later with a * call to setBaseType(). */ - + virtual SDO_API void addType(const char* uri, const char* inTypeName, - bool isSequenced = false, + bool isSequenced = false, bool isOpen = false, bool isAbstract = false, bool isDataType = false) = 0; - + /** * DataFactory::setBaseType allows inheritance @@ -137,27 +137,36 @@ * properties of the supertype * This relationship is fixed when the first data object of any type is * created by the factory. Up to that point the base type may be changed. - * + * */ - virtual SDO_API void setBaseType( + virtual SDO_API void setBaseType( const Type& type, const Type& base, bool isRestriction = false) = 0; - - virtual SDO_API void setBaseType( + + virtual SDO_API void setBaseType( const char* typeuri, const char* typenam, const char* baseuri, const char* basename, bool isRestriction = false) = 0; + + /** + * Generate a typesafe interface for a given data factory + * test code. + */ + + virtual SDO_API bool generateInterface(const char* fileroot) = 0; + + /** * DataFactory::setAlias sets an alternative name * * A Type may be known to the data factory by several different names. * This method adds a new name for an existing property. - * + * */ virtual SDO_API void setAlias(const char* typeuri, @@ -167,79 +176,79 @@ /** * DataFactory::addPropertyToType adds properties * - * The various addPropertyToType methods add a property to an + * The various addPropertyToType methods add a property to an * existing type in the factory, specifying the name of the new property, * and the type of the new property - which must also be an existing type * in this factory. * -# The new property may be many-valued - so it will be a list of values. - * -# The property may be read-only , and may not be altered by user code - + * -# The property may be read-only , and may not be altered by user code - * However the value may be changed by data access service code. * -# The property may be containment. * The type of a property may be DataType, or DataObjectType (see Types). * If the property is a DataType, then the actual value of the property is held * within the data object containing the property. - * If the property is a DataObjectType, it may be containment, or reference. - * Containment indicates that the value of the property is contained in the + * If the property is a DataObjectType, it may be containment, or reference. + * Containment indicates that the value of the property is contained in the * data object, whilst reference indicates that the property is only a pointer to * a value somewhere else in the data graph. - * + * */ - virtual SDO_API void addPropertyToType(const char* uri, + virtual SDO_API void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany , bool isReadOnly , bool isContainment ) = 0; - - virtual SDO_API void addPropertyToType(const char* uri, + + virtual SDO_API void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, const Type& propType, bool isMany , bool isReadOnly , bool isContainment ) = 0; - - virtual SDO_API void addPropertyToType(const Type& type, + + virtual SDO_API void addPropertyToType(const Type& type, const char* propname, const Type& propType, bool isMany , bool isReadOnly , bool isContainment ) = 0; - - virtual SDO_API void addPropertyToType(const Type& type, + + virtual SDO_API void addPropertyToType(const Type& type, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany , bool isReadOnly , bool isContainment ) = 0; - - - virtual SDO_API void addPropertyToType(const char* uri, + + + virtual SDO_API void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany = false) =0; - - virtual SDO_API void addPropertyToType(const char* uri, + + virtual SDO_API void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, const Type& propType, bool isMany = false) =0; - - virtual SDO_API void addPropertyToType(const Type& type, + + virtual SDO_API void addPropertyToType(const Type& type, const char* propname, const Type& propType, bool isMany = false) =0; - - virtual SDO_API void addPropertyToType(const Type& type, + + virtual SDO_API void addPropertyToType(const Type& type, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany = false) =0; @@ -247,16 +256,16 @@ * DataFactory::setOpposite sets an opposite name * * NOT IMPLEMENTED. - * + * */ - virtual SDO_API void setOpposite( + virtual SDO_API void setOpposite( const Type& type, const char* propName, const Type& oppositetype, const char* oppositePropName) = 0; - - + + /** * DataFactory::setAlias sets a property alias name * @@ -264,8 +273,8 @@ * names. */ - virtual SDO_API void setAlias(const char* typeuri, - const char* typname, + virtual SDO_API void setAlias(const char* typeuri, + const char* typname, const char* propname, const char* alias) = 0; @@ -281,13 +290,13 @@ */ virtual SDO_API void setPropertySubstitute( - const char* uri, + const char* uri, const char* inTypeName, const char* propname, const char* subname, - const char* subTypeUri, + const char* subTypeUri, const char* subTypeName) = 0; - + virtual SDO_API void setPropertySubstitute( const Type& containertype, @@ -303,155 +312,155 @@ * may be set - indicating that a value has been assigned, or unset - indicating that * no value has yet been assigned. * If there is no value assigned, then a default value may be returned for that - * property. - * This method allows the data factory to define that default value. - * There is no default value for a DataObjectType. There are overloads for + * property. + * This method allows the data factory to define that default value. + * There is no default value for a DataObjectType. There are overloads for * each of the primitive DataTypes. */ virtual SDO_API void setDefault( - const Type& t, - const char* propname, + const Type& t, + const char* propname, bool b ) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , char c) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , wchar_t c) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , char* c) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , short s) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , long l) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , int64_t i) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , float f) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , long double d) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , - const wchar_t* c, + const Type& t, + const char* propname , + const wchar_t* c, unsigned int len) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , - const char* c, + const Type& t, + const char* propname , + const char* c, unsigned int len) = 0; virtual SDO_API void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , const SDODate dat) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname, + const char* typuri, + const char* typnam, + const char* propname, bool b ) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , char c) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, + const char* typuri, + const char* typnam, const char* propname , wchar_t c) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , char* c) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , short s) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, + const char* typuri, + const char* typnam, const char* propname , long l) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , int64_t i) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , float f) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , long double d) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, + const char* typuri, + const char* typnam, const char* propname , - const wchar_t* c, + const wchar_t* c, unsigned int len) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , - const char* c, + const char* typuri, + const char* typnam, + const char* propname , + const char* c, unsigned int len) = 0; virtual SDO_API void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , const SDODate dat) = 0; - + /** * DAS values are used by a DAS implementation */ - virtual SDO_API void setDASValue( + virtual SDO_API void setDASValue( const Type& type, const char* name, DASValue* value) = 0; @@ -462,29 +471,29 @@ const char* name, DASValue* value) = 0; - virtual SDO_API DASValue* getDASValue( + virtual SDO_API DASValue* getDASValue( const Type& type, const char* name) const = 0; virtual SDO_API DASValue* getDASValue( const char* typeuri, - const char* typenam, + const char* typenam, const char* name) const = 0; - virtual SDO_API void setDASValue( + virtual SDO_API void setDASValue( const Type& type, const char* propertyName, const char* name, DASValue* value) = 0; - virtual SDO_API void setDASValue( + virtual SDO_API void setDASValue( const char* typeuri, const char* typenam, const char* propertyName, const char* name, DASValue* value) = 0; - virtual SDO_API DASValue* getDASValue( + virtual SDO_API DASValue* getDASValue( const Type& type, const char* propertyName, const char* name) const = 0; @@ -492,7 +501,7 @@ virtual SDO_API DASValue* getDASValue( const char* typeuri, const char* typenam, - const char* propertyName, + const char* propertyName, const char* name) const = 0; virtual void resolve() = 0; http://cvs.php.net/viewcvs.cgi/pecl/sdo/commonj/sdo/DataFactoryImpl.cpp?r1=1.7&r2=1.8&diff_format=u Index: pecl/sdo/commonj/sdo/DataFactoryImpl.cpp diff -u pecl/sdo/commonj/sdo/DataFactoryImpl.cpp:1.7 pecl/sdo/commonj/sdo/DataFactoryImpl.cpp:1.8 --- pecl/sdo/commonj/sdo/DataFactoryImpl.cpp:1.7 Wed Mar 1 14:15:04 2006 +++ pecl/sdo/commonj/sdo/DataFactoryImpl.cpp Fri Mar 17 16:43:47 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/03/01 14:15:04 $ */ +/* $Rev$ $Date: 2006/03/17 16:43:47 $ */ ////////////////////////////////////////////////////////////////////// // DataFactoryImpl.cpp: implementation of the DataFactory class. @@ -85,7 +85,7 @@ TYPES_MAP::iterator typeIter; for (typeIter = types.begin() ; typeIter != types.end() ; ++typeIter) { - if (strncmp((typeIter->first).c_str(),"ALIAS::", 7)) + if (strncmp((typeIter->first).c_str(),"ALIAS::", 7)) { delete typeIter->second; } @@ -99,7 +99,7 @@ } // =================================================================== -// get the root element name +// get the root element name // =================================================================== const char* DataFactoryImpl::getRootElementName() const { @@ -107,7 +107,7 @@ } // =================================================================== -// set the root element name +// set the root element name // =================================================================== void DataFactoryImpl::setRootElementName(const char* ren) { @@ -116,7 +116,7 @@ delete rootElementName; rootElementName = 0; } - if (ren != 0 && (strlen(ren) != 0)) + if (ren != 0 && (strlen(ren) != 0)) { rootElementName = new char[strlen(ren) +1]; strcpy(rootElementName, ren); @@ -171,7 +171,7 @@ // re-find the type we just added. fullTypeName = getFullTypeName( - (typeIter->second)->getURI(), + (typeIter->second)->getURI(), (typeIter->second)->getName()); typeIter2 = types.find(fullTypeName); if (fullTypeName)delete fullTypeName; @@ -187,7 +187,7 @@ } } - + // Now add all the properties PropertyList props = typeIter->second->getProperties(); for (int i=0; i < props.size(); i++) @@ -200,14 +200,14 @@ addPropertyToType((typeIter->second)->getURI(), (typeIter->second)->getName(), props[i].getName(), - propType.getURI(), + propType.getURI(), propType.getName(), props[i].isMany(), props[i].isReadOnly(), props[i].isContainment()); // copy the aliases if there are any. - if (props[i].getAliasCount() > 0) + if (props[i].getAliasCount() > 0) { PropertyImpl* p = (typeIter2->second)-> @@ -229,7 +229,7 @@ // =================================================================== // addType - adds a new Type if it does not already exist // =================================================================== -void DataFactoryImpl::addType(const char* uri, const char* inTypeName, +void DataFactoryImpl::addType(const char* uri, const char* inTypeName, bool isSeq, bool isOp, bool isAbs, @@ -247,8 +247,8 @@ SDOIllegalArgumentException, " Type has empty name"); } - - if (findType(uri, inTypeName) == 0) + + if (findType(uri, inTypeName) == 0) { char* fullTypeName = getFullTypeName(uri, inTypeName); types[fullTypeName] = new TypeImpl(uri, inTypeName, isSeq, isOp, isAbs, isData); @@ -272,7 +272,7 @@ } PropertyList pl = cs->getProperties(); - + for (int i=0 ; i < pl.size() ; i++ ) { if (recursiveCheck((TypeImpl*)&(pl[i].getType()), t)) return true; @@ -295,9 +295,9 @@ } if (cstypes.size() > 0) { - for (int i = 0 ;i < cstypes.size(); i++) + for (int i = 0 ;i < cstypes.size(); i++) { - if (recursiveCheck(cstypes[i], t)) + if (recursiveCheck(cstypes[i], t)) { return false; @@ -311,8 +311,8 @@ // =================================================================== // addPropertyToType - adds a Property to an existing Type // =================================================================== -void DataFactoryImpl::addPropertyToType(const char* uri, - const char* inTypeName, +void DataFactoryImpl::addPropertyToType(const char* uri, + const char* inTypeName, const char* propname, const char* propTypeUri, const char* propTypeName, @@ -324,18 +324,18 @@ if (fullPropTypeName)delete fullPropTypeName; if (typeIter != types.end()) { - addPropertyToType(uri,inTypeName, + addPropertyToType(uri,inTypeName, propname, propTypeUri, propTypeName, - many, + many, false, !(typeIter->second)->isDataType()); } } -void DataFactoryImpl::addPropertyToType(const char* uri, - const char* inTypeName, +void DataFactoryImpl::addPropertyToType(const char* uri, + const char* inTypeName, const char* propname, const char* propTypeUri, const char* propTypeName, @@ -377,7 +377,7 @@ fullTypeName = getFullTypeName(propTypeUri, propTypeName); typeIter2 = types.find(fullTypeName); if (fullTypeName)delete fullTypeName; - + if (typeIter2 == types.end()) { string msg("Type not found: "); @@ -387,16 +387,16 @@ SDO_THROW_EXCEPTION("addPropertyToType", SDOTypeNotFoundException, msg.c_str()); } - + // Check if its a ChangeSummary if (propTypeUri != 0 && !strcmp(propTypeUri,Type::SDOTypeNamespaceURI) && !strcmp(propTypeName,"ChangeSummary") ) { - if (checkForValidChangeSummary(typeIter->second)) + if (checkForValidChangeSummary(typeIter->second)) { // The change summary is allowable if we got to here - force the right params. // we will not use this property - its just for compatibility. - // we have to use getChangeSummary to get the change summary, + // we have to use getChangeSummary to get the change summary, // and isChangeSummaryType to see if this is a type which may have // a change summary. (typeIter->second)->addChangeSummary(); @@ -406,7 +406,7 @@ } return; } - + if ((typeIter->second)->isDataType()) { @@ -435,14 +435,14 @@ // addPropertyToType - adds a Property to an existing Type // =================================================================== -void DataFactoryImpl::addPropertyToType(const char* uri, - const char* inTypeName, +void DataFactoryImpl::addPropertyToType(const char* uri, + const char* inTypeName, const char* propname, const Type& tprop, bool many) { - addPropertyToType(uri, - inTypeName, + addPropertyToType(uri, + inTypeName, propname, tprop, many, @@ -451,15 +451,15 @@ } -void DataFactoryImpl::addPropertyToType(const char* uri, - const char* inTypeName, +void DataFactoryImpl::addPropertyToType(const char* uri, + const char* inTypeName, const char* propname, const Type& tprop, bool many, bool rdonly, bool cont) { - addPropertyToType(uri, + addPropertyToType(uri, inTypeName, propname, tprop.getURI(), @@ -542,7 +542,7 @@ char* DataFactoryImpl::getFullTypeName(const char* uri, const char* inTypeName) const { char* c; - if (uri != 0 && inTypeName != 0) + if (uri != 0 && inTypeName != 0) { c = new char[strlen(uri) + strlen(inTypeName) + 2]; sprintf(c,"%s#%s",uri,inTypeName); @@ -565,7 +565,7 @@ char* DataFactoryImpl::getAliasTypeName(const char* uri, const char* inTypeName) const { char* c; - if (uri != 0 && inTypeName != 0) + if (uri != 0 && inTypeName != 0) { c = new char[strlen(uri) + strlen(inTypeName) + 9]; sprintf(c,"ALIAS::%s#%s",uri,inTypeName); @@ -599,7 +599,7 @@ SDO_THROW_EXCEPTION("getType" , SDOTypeNotFoundException, msg.c_str()); } - + return *type; } @@ -608,7 +608,7 @@ // =================================================================== void DataFactoryImpl::setBaseType( const Type& type, - const Type& base, bool isRestriction) + const Type& base, bool isRestriction) { setBaseType(type.getURI(),type.getName(),base.getURI(), base.getName(), isRestriction); @@ -640,7 +640,7 @@ char* fullTypeName = getFullTypeName(typeuri, typenam); typeIter = types.find(fullTypeName); if (fullTypeName)delete fullTypeName; - + if(typeIter == types.end()) { string msg("Type not found :"); @@ -660,11 +660,11 @@ // =================================================================== void DataFactoryImpl::setPropertySubstitute( - const char* uri, + const char* uri, const char* inTypeName, const char* propname, const char* subname, - const char* subTypeUri, + const char* subTypeUri, const char* subTypeName) { const TypeImpl* cont = findTypeImpl(uri, inTypeName); @@ -683,7 +683,7 @@ if (pi != 0)pi->setSubstitution(this,subname,tsub); } - + void DataFactoryImpl::setPropertySubstitute( const Type& containertype, @@ -703,82 +703,82 @@ // =================================================================== void DataFactoryImpl::setDefault( - const Type& t, const char* propname, bool b ) + const Type& t, const char* propname, bool b ) { setDefault(t.getURI(), t.getName(), propname, b); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , char c) - + const Type& t, const char* propname , char c) + { setDefault(t.getURI(), t.getName(), propname, c); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , wchar_t c) + const Type& t, const char* propname , wchar_t c) { setDefault(t.getURI(), t.getName(), propname, c); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , char* c) + const Type& t, const char* propname , char* c) { setDefault(t.getURI(), t.getName(), propname, c); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , short s) + const Type& t, const char* propname , short s) { setDefault(t.getURI(), t.getName(), propname, s); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , long l) + const Type& t, const char* propname , long l) { setDefault(t.getURI(), t.getName(), propname, l); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , int64_t i) + const Type& t, const char* propname , int64_t i) { setDefault(t.getURI(), t.getName(), propname, i); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , float f) + const Type& t, const char* propname , float f) { setDefault(t.getURI(), t.getName(), propname, f); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , long double d) + const Type& t, const char* propname , long double d) { setDefault(t.getURI(), t.getName(), propname, d); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , const SDODate d) + const Type& t, const char* propname , const SDODate d) { setDefault(t.getURI(), t.getName(), propname, d); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , const wchar_t* c, unsigned int len) + const Type& t, const char* propname , const wchar_t* c, unsigned int len) { setDefault(t.getURI(), t.getName(), propname, c, len); } void DataFactoryImpl::setDefault( - const Type& t, const char* propname , const char* c, unsigned int len) + const Type& t, const char* propname , const char* c, unsigned int len) { setDefault(t.getURI(), t.getName(), propname, c, len); } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname, bool b ) + const char* typuri, const char* typnam, + const char* propname, bool b ) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -786,8 +786,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , char c) + const char* typuri, const char* typnam, + const char* propname , char c) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -795,8 +795,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , wchar_t c) + const char* typuri, const char* typnam, + const char* propname , wchar_t c) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -804,8 +804,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , char* c) + const char* typuri, const char* typnam, + const char* propname , char* c) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -813,8 +813,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , short s) + const char* typuri, const char* typnam, + const char* propname , short s) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -822,8 +822,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , long l) + const char* typuri, const char* typnam, + const char* propname , long l) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -831,8 +831,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , int64_t i) + const char* typuri, const char* typnam, + const char* propname , int64_t i) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -840,8 +840,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , float f) + const char* typuri, const char* typnam, + const char* propname , float f) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -849,8 +849,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , long double d) + const char* typuri, const char* typnam, + const char* propname , long double d) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -858,8 +858,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , const SDODate d) + const char* typuri, const char* typnam, + const char* propname , const SDODate d) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -867,8 +867,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , const wchar_t* c, unsigned int len) + const char* typuri, const char* typnam, + const char* propname , const wchar_t* c, unsigned int len) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -876,8 +876,8 @@ } void DataFactoryImpl::setDefault( - const char* typuri, const char* typnam, - const char* propname , const char* c, unsigned int len) + const char* typuri, const char* typnam, + const char* propname , const char* c, unsigned int len) { const TypeImpl* ti = findTypeImpl(typuri,typnam); PropertyImpl* pi = ti->getPropertyImpl(propname); @@ -885,10 +885,10 @@ } void DataFactoryImpl::setOpposite( - const Type& typ, - const char* propnam, + const Type& typ, + const char* propnam, const Type& opptyp, - const char* opppropnam) + const char* opppropnam) { SDO_THROW_EXCEPTION("setOpposite" , SDOUnsupportedOperationException, " Not implemented"); @@ -910,7 +910,7 @@ SDO_THROW_EXCEPTION("getTypeImpl" , SDOTypeNotFoundException, msg.c_str()); } - + return *type; } @@ -977,13 +977,13 @@ // setAlias - sets a new alias for this type // =================================================================== -void DataFactoryImpl::setAlias(const char* typeuri, - const char* typenam, +void DataFactoryImpl::setAlias(const char* typeuri, + const char* typenam, const char* propname, const char* alias) { const TypeImpl& t = getTypeImpl(typeuri, typenam); - PropertyImpl* p = t.getPropertyImpl(propname); + PropertyImpl* p = t.getPropertyImpl(propname); if (p != 0)p->setAlias(alias); } @@ -995,7 +995,7 @@ TypeList DataFactoryImpl::getTypes() const { TYPES_MAP::const_iterator typeIter; - + std::vector<const Type*> typeVector; @@ -1019,11 +1019,11 @@ void DataFactoryImpl::resolve() { - if (isResolved) return; + if (isResolved) return; TYPES_MAP::iterator typeIter; for (typeIter = types.begin() ; typeIter != types.end(); - ++typeIter) + ++typeIter) { (typeIter->second)->initCompoundProperties(); (typeIter->second)->validateChangeSummary(); @@ -1039,7 +1039,7 @@ // =================================================================== -RefCountingPointer<DataObject> DataFactoryImpl::create(const char* uri, const char* typeName) +RefCountingPointer<DataObject> DataFactoryImpl::create(const char* uri, const char* typeName) { if (!isResolved) @@ -1082,7 +1082,7 @@ // =================================================================== // The openProperties map is a list of the curently present open -// properties as used by this factory. It will cause the +// properties as used by this factory. It will cause the // open properties to be written out as attributes and elements // of the root data object when a graph is serialized. // =================================================================== @@ -1104,7 +1104,7 @@ void DataFactoryImpl::removeOpenProperty(const char* name) { - propertyMap::iterator i = + propertyMap::iterator i = openProperties.find(name); if (i != openProperties.end()) { @@ -1119,7 +1119,7 @@ // to the type hierarchy are allowed. // =================================================================== -RefCountingPointer<DataObject> DataFactoryImpl::create(const Type& type) +RefCountingPointer<DataObject> DataFactoryImpl::create(const Type& type) { return create( type.getURI(), type.getName()); } @@ -1129,7 +1129,7 @@ // setDASValue - Set a value on a Type // =================================================================== void DataFactoryImpl::setDASValue(const Type& type, - const char* name, + const char* name, DASValue* value) { setDASValue(type.getURI(), type.getName(), name, value); @@ -1137,8 +1137,8 @@ void DataFactoryImpl::setDASValue(const char* typeuri, - const char* typenam, - const char* name, + const char* typenam, + const char* name, DASValue* value) { TypeImpl* type = (TypeImpl*)findTypeImpl(typeuri, typenam); @@ -1168,13 +1168,13 @@ return type->getDASValue(name); } - return NULL; + return NULL; } // =================================================================== // setDASValue - Set a value on a Property // =================================================================== -void DataFactoryImpl::setDASValue( +void DataFactoryImpl::setDASValue( const Type& type, const char* propertyName, const char* name, @@ -1184,7 +1184,7 @@ } -void DataFactoryImpl::setDASValue( +void DataFactoryImpl::setDASValue( const char* typeuri, const char* typenam, const char* propertyName, @@ -1202,7 +1202,7 @@ // =================================================================== // getDASValue - retrieve a value from a Property // =================================================================== -DASValue* DataFactoryImpl::getDASValue( +DASValue* DataFactoryImpl::getDASValue( const Type& type, const char* propertyName, const char* name) const @@ -1213,7 +1213,7 @@ DASValue* DataFactoryImpl::getDASValue( const char* typeuri, const char* typenam, - const char* propertyName, + const char* propertyName, const char* name) const { const TypeImpl* type = findTypeImpl(typeuri, typenam); @@ -1230,7 +1230,7 @@ } } - return NULL; + return NULL; } @@ -1251,34 +1251,421 @@ return true; } -bool DataFactoryImpl::isCompatible(DataFactory* df) + + +bool DataFactoryImpl::checkType(const Type& t) { - //for (int i=0;i<compatibleFactories.size();i++) - //{ - // if (compatibleFactories[i] == df)return true; - //} - - TypeList tl = df->getTypes(); - for (int j=0;j<tl.size();j++) + const TypeImpl* t2 = findTypeImpl(t.getURI(), + t.getName()); + + if (t2 == 0) return false; + + if (!compareTypes(t2,t)) return false; + + PropertyList pl = t.getProperties(); + for (int i=0;i<pl.size();i++) { - const TypeImpl* t = findTypeImpl(tl[j].getURI(), + if (pl[i].getType().isDataObjectType()) + { + if (!checkType(pl[i].getType())) return false; + } + } + return true; +} + + +// only checks the tree dirctly descended from this object if the +// object is specified, otherwise validates the whole factory + +bool DataFactoryImpl::isCompatible(DataFactory* df, DataObject* d) +{ + if (d == 0) + { + TypeList tl = df->getTypes(); + for (int j=0;j<tl.size();j++) + { + const TypeImpl* t = findTypeImpl(tl[j].getURI(), tl[j].getName()); - - if (t == 0) return false; - if (!compareTypes(t,tl[j]))return false; - } - // the factories are compatible for a copy in this - // direction. - // This is commented out for now - it would give a - // big improvement if the same two factories are used - //for many copies, but we would have to overcome the problem - // that factory pointers are just pointers, so a factory might have - // been deallocated and re-allocated at the same address with different - // contents.... - //compatibleFactories.push_back(df); + + if (t == 0) return false; + if (!compareTypes(t,tl[j]))return false; + } + return true; + } + else + { + return checkType(d->getType()); + } +} + +bool DataFactoryImpl::generateInterface(const char* fileroot) +{ + + FILE* header; + FILE* body; + + if ((fileroot == 0) || (strlen(fileroot) == 0)) return false; + + char *headername = new char[strlen(fileroot) + 5]; + char *bodyname = new char[strlen(fileroot) + 5]; + strcpy(headername,fileroot); + strcpy(bodyname,fileroot); + strcat(headername,".h"); + strcat(bodyname,".cpp"); + + // here we should check the files - and if they are present with + // contents we should read them, and merge the new generated code + // I think the way to do that is to allow sections in between comment + // pairs in three locations: + // a) outside any method in the CPP file. + // b) in the header file anywhere. + // c) inside method definitions in cpp, either before, or after the + // entire generated contents. + // + // + + header = fopen(headername,"w+"); + if (header == 0) return false; + + body = fopen(bodyname,"w+"); + if (body == 0) return false; + + + fprintf(header,"/*******************************************\n"); + fprintf(header," * Generated Typesafe Interface Header *\n"); + fprintf(header," *******************************************/\n"); + fprintf(header,"#include \"commonj/sdo/DataObject.h\"\n"); + fprintf(header,"#include \"commonj/sdo/SDODate.h\"\n"); + fprintf(header,"using namespace commonj::sdo;\n"); + + fprintf(body,"/*******************************************\n"); + fprintf(body," * Generated Typesafe Interface Body *\n"); + fprintf(body," *******************************************/\n"); + fprintf(body,"#include \"%s\"\n",headername); + fprintf(body,"using namespace commonj::sdo;\n"); + + delete headername; + delete bodyname; + + try { + + int nscount; + + TypeList& tl = getTypes(); + + // forward declarations and smart pointers + for (int i=0;i<tl.size();i++) + { + nscount = 0; + + if (!strcmp(tl[i].getURI(),"commonj.sdo")) continue; + + const char *uri = tl[i].getURI(); + char *c = strchr(uri,'.'); + + if (c == 0) + { + fprintf(header,"namespace %s{\n",uri); + nscount = 1; + } + else + { + char* buf = new char[strlen(uri) + 1]; + strcpy(buf, uri); + c = buf; + char* c1; + do { + c1 = strchr(c,'.'); + if (c1) *c1 = 0; + fprintf(header,"namespace %s{\n", c); + nscount++; + if (c1) c = c1+1; + } while (c1 != 0); + delete buf; + } + + + fprintf(header,"class %s;\n",tl[i].getName()); + fprintf(header,"typedef RefCountingPointer<%s> %sPtr;\n", + tl[i].getName(), tl[i].getName()); + + for (int i=0;i<nscount;i++) + { + fprintf(header,"}\n"); + } + } + + + for (i=0;i<tl.size();i++) + { + nscount = 0; + + if (!strcmp(tl[i].getURI(),"commonj.sdo")) continue; + const char *uri = tl[i].getURI(); + char *c = strchr(uri,'.'); + + if (c == 0) + { + fprintf(header,"namespace %s{\n",uri); + fprintf(body, "namespace %s{\n",uri); + nscount = 1; + } + else + { + char* buf = new char[strlen(uri) + 1]; + strcpy(buf, uri); + c = buf; + char* c1; + do { + c1 = strchr(c,'.'); + if (c1) *c1 = 0; + fprintf(header,"namespace %s{\n", c); + fprintf(body, "namespace %s{\n", c); + nscount++; + if (c1) c = c1+1; + } while (c1 != 0); + delete buf; + } + + + + fprintf(header,"class %s :public DataObject {\n", tl[i].getName()); + fprintf(header,"public:\n"); + + PropertyList& pl = tl[i].getProperties(); + for (int j=0;j<pl.size();j++) + { + if (pl[j].isMany()) + { + + fprintf(header,"DataObjectList& get%s();\n",pl[j].getName()); + fprintf(body, "DataObjectList& %s::get%s\n{\n", + tl[i].getName(),pl[j].getName()); + fprintf(body, "return getList(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + + } + else + { + if (pl[j].getType().isDataType()) + { + switch (pl[j].getTypeEnum()) + { + case Type::BooleanType: + + fprintf(header,"bool get%s();\n",pl[j].getName()); + fprintf(body, "bool %s::get%s\n(){\n", + tl[i].getName(), pl[j].getName()); + fprintf(body, "return getBoolean(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(bool b);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(bool b)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setBoolean(\"%s\",b);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::ByteType: + + fprintf(header,"char get%s();\n",pl[j].getName()); + fprintf(body, "char %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getByte(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(char c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(char c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setByte(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::BytesType: + + fprintf(header,"unsigned int get%s(char *buf, unsigned int len);\n",pl[j].getName()); + fprintf(body, "unsigned int %s::get%s(char *buf, unsigned int len)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getBytes(\"%s\", buf,len);\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(char *buf,unsigned int len);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(char *buf, unsigned int len)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setBytes(\"%s\", buf,len);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::CharacterType: + + fprintf(header,"wchar_t get%s();\n",pl[j].getName()); + fprintf(body, "wchar_t %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getCharacter(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(wchar_t c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(wchar_t c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setCharacter(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::DateType: + + fprintf(header,"SDODate get%s();\n",pl[j].getName()); + fprintf(body, "SDODate %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getDate(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(const SDODate c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(const SDODate c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setDate(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::DoubleType: + + fprintf(header,"long double get%s();\n",pl[j].getName()); + fprintf(body, "long double %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getDouble(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(long double c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(long double c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setDouble(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::FloatType: + + fprintf(header,"float get%s();\n",pl[j].getName()); + fprintf(body, "float %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getFloat(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(float c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(float c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setFloat(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::IntegerType: + + fprintf(header,"long get%s();\n",pl[j].getName()); + fprintf(body, "long %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getInteger(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(long c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(long c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setInteger(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::LongType: + + fprintf(header,"int64_t get%s();\n",pl[j].getName()); + fprintf(body, "int64_t %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getLong(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(int64_t c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(int64_t c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setLong(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::ShortType: + + fprintf(header,"short get%s();\n",pl[j].getName()); + fprintf(body, "short %s::get%s\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getShort(\"%s\");\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(short c);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(short c)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setShort(\"%s\",c);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + case Type::StringType: + case Type::UriType: + + fprintf(header,"unsigned int get%s(wchar_t *buf, unsigned int len);\n",pl[j].getName()); + fprintf(body, "unsigned int %s::get%s(wchar_t *buf, unsigned int len)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "return getString(\"%s\", buf,len);\n",pl[j].getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(wchar_t *buf,unsigned int len);\n",pl[j].getName()); + fprintf(body, "void %s::set%s(wchar_t *buf, unsigned int len)\n{\n",tl[i].getName(), + pl[j].getName()); + fprintf(body, "setString(\"%s\", buf,len);\nreturn;\n",pl[j].getName()); + fprintf(body, "}\n\n"); + + break; + + default: + fprintf(header,"// unknown primitive:%s\n",pl[j].getName()); + break; + } + } + else + { + fprintf(header,"%sPtr get%s();\n",pl[j].getType().getName(), + pl[j].getName()); + + fprintf(body, "%sPtr %s::get%s()\n{\n", + pl[j].getType().getName(), + tl[i].getName(), + pl[j].getName()); + fprintf(body, "DataObjectPtr dob = getDataObject(\"%s\");\n",pl[j].getName()); + fprintf(body, "DataObject* d = (DataObject*)dob;\n"); + fprintf(body, "return (%s*)d;\n", pl[j].getType().getName()); + fprintf(body, "}\n\n"); + fprintf(header,"void set%s(%sPtr dob);\n",pl[j].getName(), pl[j].getType().getName()); + fprintf(body, "void %s::set%s(%sPtr dob)\n{\n", + tl[i].getName(),pl[j].getName(),pl[j].getType().getName()); + fprintf(body, "%s* ptr = dob;\nsetDataObject(\"%s\", (DataObjectPtr)ptr);\nreturn;\n", + pl[j].getType().getName(),pl[j].getName()); + fprintf(body, "}\n\n"); + + } + } + + } // for + fprintf(header,"};\n"); + for (int i=0;i<nscount;i++) + { + fprintf(header,"}\n"); + fprintf(body,"}\n"); + } + } + fclose (header); + fclose (body); + } + catch (SDORuntimeException e) + { + cout << "Exception in code Generation" << endl; + cout << e << endl; + } return true; } + }; }; http://cvs.php.net/viewcvs.cgi/pecl/sdo/commonj/sdo/DataFactoryImpl.h?r1=1.4&r2=1.5&diff_format=u Index: pecl/sdo/commonj/sdo/DataFactoryImpl.h diff -u pecl/sdo/commonj/sdo/DataFactoryImpl.h:1.4 pecl/sdo/commonj/sdo/DataFactoryImpl.h:1.5 --- pecl/sdo/commonj/sdo/DataFactoryImpl.h:1.4 Wed Mar 1 13:46:05 2006 +++ pecl/sdo/commonj/sdo/DataFactoryImpl.h Fri Mar 17 16:43:47 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/03/01 13:46:05 $ */ +/* $Rev$ $Date: 2006/03/17 16:43:47 $ */ #ifndef _DataFactoryIMPL_H_ #define _DataFactoryIMPL_H_ @@ -38,7 +38,7 @@ typedef map<string, PropertyImpl> propertyMap; -/** +/** * DataFactoryImpl implements the abstract class DataFactory. * DataFactoryImpl holds metadata and creates DataObjects. * @@ -55,64 +55,64 @@ DataFactoryImpl& operator=(const DataFactoryImpl& inmdg); virtual void addType(const char* uri, const char* inTypeName, - bool isSeqenced = false, + bool isSeqenced = false, bool isOpen = false, bool isAbstract = false, bool isDataType = false); - virtual void addPropertyToType(const char* uri, + virtual void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany = false); - virtual void addPropertyToType(const char* uri, + virtual void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, const Type& propType, bool isMany = false); - virtual void addPropertyToType(const Type& type, + virtual void addPropertyToType(const Type& type, const char* propname, const Type& propType, bool isMany = false); - - virtual void addPropertyToType(const Type& type, + + virtual void addPropertyToType(const Type& type, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany = false); - virtual void addPropertyToType(const char* uri, + virtual void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany , bool isReadOnly, bool isContainment); - virtual void addPropertyToType(const char* uri, + virtual void addPropertyToType(const char* uri, const char* inTypeName, const char* propname, const Type& propType, bool isMany, bool isReadOnly, bool isContainment); - - virtual void addPropertyToType(const Type& type, + + virtual void addPropertyToType(const Type& type, const char* propname, const Type& propType, bool isMany, bool isReadOnly, bool isContainment); - virtual void addPropertyToType(const Type& type, + virtual void addPropertyToType(const Type& type, const char* propname, - const char* propTypeUri, + const char* propTypeUri, const char* propTypeName, bool isMany, bool isReadOnly, @@ -141,8 +141,8 @@ const char* typenam, const char* alias) ; - virtual void setAlias(const char* typeuri, - const char* typname, + virtual void setAlias(const char* typeuri, + const char* typname, const char* propname, const char* alias) ; @@ -153,13 +153,13 @@ virtual void setPropertySubstitute( - const char* uri, + const char* uri, const char* inTypeName, const char* propname, const char* subname, - const char* subTypeUri, + const char* subTypeUri, const char* subTypeName); - + virtual void setPropertySubstitute( const Type& containertype, @@ -169,142 +169,142 @@ //////////////////////////////////////////////////////// virtual void setDefault( - const Type& t, - const char* propname, + const Type& t, + const char* propname, bool b ) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , char c) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , wchar_t c) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , char* c) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , short s) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , long l) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , int64_t i) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , float f) ; virtual void setDefault( - const Type& t, + const Type& t, const char* propname , long double d) ; virtual void setDefault( - const Type& t, - const char* propname , + const Type& t, + const char* propname , const SDODate d) ; virtual void setDefault( - const Type& t, - const char* propname , - const wchar_t* c, + const Type& t, + const char* propname , + const wchar_t* c, unsigned int len) ; virtual void setDefault( - const Type& t, - const char* propname , - const char* c, + const Type& t, + const char* propname , + const char* c, unsigned int len) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname, + const char* typuri, + const char* typnam, + const char* propname, bool b ) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , char c) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , wchar_t c) ; virtual void setDefault( - const char* typuri, - const char* typnam, + const char* typuri, + const char* typnam, const char* propname , char* c) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , short s) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , long l) ; virtual void setDefault( - const char* typuri, - const char* typnam, + const char* typuri, + const char* typnam, const char* propname , int64_t i) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , float f) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , long double d) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , + const char* typuri, + const char* typnam, + const char* propname , const SDODate d) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , - const wchar_t* c, + const char* typuri, + const char* typnam, + const char* propname , + const wchar_t* c, unsigned int len) ; virtual void setDefault( - const char* typuri, - const char* typnam, - const char* propname , - const char* c, + const char* typuri, + const char* typnam, + const char* propname , + const char* c, unsigned int len) ; - virtual void setDASValue( + virtual void setDASValue( const Type& type, const char* name, DASValue* value); @@ -321,23 +321,23 @@ virtual DASValue* getDASValue( const char* typeuri, - const char* typenam, + const char* typenam, const char* name) const; - virtual void setDASValue( + virtual void setDASValue( const Type& type, const char* propertyName, const char* name, DASValue* value); - virtual void setDASValue( + virtual void setDASValue( const char* typeuri, const char* typenam, const char* propertyName, const char* name, DASValue* value); - virtual DASValue* getDASValue( + virtual DASValue* getDASValue( const Type& type, const char* propertyName, const char* name) const; @@ -345,7 +345,7 @@ virtual DASValue* getDASValue( const char* typeuri, const char* typenam, - const char* propertyName, + const char* propertyName, const char* name) const; virtual void resolve(); @@ -359,9 +359,11 @@ virtual const TypeImpl& getTypeImpl(const char* uri, const char* inTypeName) const; virtual const char* getRootElementName() const; virtual void setRootElementName(const char* ren); - virtual bool isCompatible(DataFactory* df); + virtual bool checkType(const Type& t); + virtual bool isCompatible(DataFactory* df, DataObject* d); virtual bool compareTypes(const TypeImpl* t1, const Type& t2); + virtual bool generateInterface(const char* fileroot); private: typedef map<string, TypeImpl*> TYPES_MAP; @@ -377,13 +379,13 @@ // work properly. bool isResolved; - + bool recursiveCheck(TypeImpl* cs, TypeImpl* t); bool checkForValidChangeSummary(TypeImpl* t); typedef vector<TypeImpl*> TYPES_VECTOR; TYPES_VECTOR cstypes; - + char* getFullTypeName(const char* uri, const char* inTypeName) const; char* getAliasTypeName(const char* uri, const char* inTypeName) const; http://cvs.php.net/viewcvs.cgi/pecl/sdo/commonj/sdo/DataObjectImpl.cpp?r1=1.8&r2=1.9&diff_format=u Index: pecl/sdo/commonj/sdo/DataObjectImpl.cpp diff -u pecl/sdo/commonj/sdo/DataObjectImpl.cpp:1.8 pecl/sdo/commonj/sdo/DataObjectImpl.cpp:1.9 --- pecl/sdo/commonj/sdo/DataObjectImpl.cpp:1.8 Wed Mar 1 14:15:04 2006 +++ pecl/sdo/commonj/sdo/DataObjectImpl.cpp Fri Mar 17 16:43:47 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,13 +15,13 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/03/01 14:15:04 $ */ +/* $Rev$ $Date: 2006/03/17 16:43:47 $ */ #include "commonj/sdo/disable_warn.h" #include "commonj/sdo/DataObjectImpl.h" - + #include "commonj/sdo/SDORuntimeException.h" #include "commonj/sdo/Property.h" @@ -536,29 +536,29 @@ /** DataObject * DataObjects are the non-primitive members of a Data graph. * - * A data object is a representation of some structured data. + * A data object is a representation of some structured data. * it is the fundamental component in the SDO (Service Data Objects) package. - * Data objects support reflection, path-based accesss, convenience creation + * Data objects support reflection, path-based accesss, convenience creation * and deletion methods,and the ability to be part of a data graph. - * Each data object holds its data as a series of properties. - * Properties can be accessed by name, property index, or using the property - * meta object itself. - * A data object can also contain references to other data objects, through + * Each data object holds its data as a series of properties. + * Properties can be accessed by name, property index, or using the property + * meta object itself. + * A data object can also contain references to other data objects, through * reference-type properties. - * A data object has a series of convenience accessors for its properties. - * These methods either use a path (String), a property index, + * A data object has a series of convenience accessors for its properties. + * These methods either use a path (String), a property index, * or the property's meta object itself, to identify the property. * Some examples of the path-based accessors are as follows: * DataObjectPtr company = ...; - * company->getString("name"); + * company->getString("name"); * company->setString("name", "acme"); - * company->getString("department.0/name") + * company->getString("department.0/name") * .n indexes from 0. * company->getString("department[1]/name") [] indexes from 1. * company->getDataObject("department[number=123]") returns the department where number=123 * company->getDataObject("..") returns the containing data object * company->getDataObject("/") returns the root containing data object - * There are specific accessors for the primitive types and commonly used + * There are specific accessors for the primitive types and commonly used * data types like String. */ @@ -575,7 +575,7 @@ - // setters and getters from a path specification + // setters and getters from a path specification getCharsFromPath(String, wchar_t* , 0); getCharsFromPath(Bytes, char* , 0); @@ -659,23 +659,23 @@ if (prop == 0 || (strlen(prop) == 0)) { return 0; } - else + else { const Property& p = d->getProperty(prop); delete prop; return getLength(p); } } - else + else { if (prop) { const Property& p = getProperty(prop); delete prop; - + return getLength(p); } - else + else { return 0; } @@ -753,7 +753,7 @@ // open type support - const PropertyImpl* DataObjectImpl::defineProperty(const char* propname, + const PropertyImpl* DataObjectImpl::defineProperty(const char* propname, const Type& t) { openProperties.insert( @@ -788,17 +788,17 @@ } } - // then remove this property from the list + // then remove this property from the list - std::list<PropertyImpl>::iterator it = + std::list<PropertyImpl>::iterator it = openProperties.begin(); for (int i=0;i<point;i++)++it; /* there must be a better way */ DataFactory* df = factory; ((DataFactoryImpl*)df)->removeOpenProperty((*it).getName()); - + openProperties.erase(it); - + return; } @@ -894,7 +894,7 @@ // Useful for debug, so not included in the macros above - but // could be. - // getters and setters for strings + // getters and setters for strings const char* DataObjectImpl::getCString(unsigned int propertyIndex) { @@ -912,7 +912,7 @@ return 0; } PropertyImpl* p = (PropertyImpl*)getPropertyImpl(propertyIndex); - if (p != 0) + if (p != 0) { if (isSet(propertyIndex)) return 0; //if (p->isDefaulted()) @@ -978,7 +978,7 @@ } else { PropertyImpl* p = d->getPropertyImpl(prop); - if (p != 0) + if (p != 0) { if (p->isMany()) { @@ -1026,7 +1026,7 @@ SDO_RETHROW_EXCEPTION("getCString",e); } } - + void DataObjectImpl::setCString(const char* path, const char* value) @@ -1045,7 +1045,7 @@ if (prop == 0 || (strlen(prop) == 0)) { d->setCString(value); } - else { + else { const PropertyImpl* p = d->getPropertyImpl(prop); if (p == 0 && d->getType().isOpenType()) { @@ -1061,7 +1061,7 @@ { doi->setCString(value); } - else + else { dol.append(value); } @@ -1184,7 +1184,7 @@ // The property was not set yet... logChange(propertyIndex); DataFactory* df = getDataFactory(); - DataObjectImpl* b = new DataObjectImpl(df, + DataObjectImpl* b = new DataObjectImpl(df, getProperty(propertyIndex).getType()); b->setContainer(this); b->setApplicableChangeSummary(); @@ -1267,14 +1267,14 @@ - // getters and setters for a List data object + // getters and setters for a List data object DataObjectList& DataObjectImpl::getList(const char* path) { DataObjectImpl *d; char* spath = DataObjectImpl::stripPath(path); char* prop = findPropertyContainer(spath,&d); - if (spath) delete spath; + if (spath) delete spath; if (d != 0) { if (prop == 0 || (strlen(prop) == 0)) { return d->getList(); @@ -1335,21 +1335,21 @@ int propIndex = getPropertyIndex(p); DataObjectImpl* d = getDataObjectImpl(propIndex); if (d == 0) { - // There is no list yet, so we need to create an + // There is no list yet, so we need to create an // empty data object to hold the list DataFactory* df = getDataFactory(); d = new DataObjectImpl(df, df->getType(Type::SDOTypeNamespaceURI,"DataObject")); PropertyValues.insert(PropertyValues.end(),rdo(propIndex,d)); d->setContainer(this); d->setApplicableChangeSummary(); - + DataObjectListImpl* list = new DataObjectListImpl(df,this, propIndex,p.getType().getURI(),p.getType().getName()); - d->setList(list); + d->setList(list); } return d->getList(); - } + } @@ -1366,15 +1366,15 @@ ///////////////////////////////////////////////////////////////////////////// - // Utilities + // Utilities ///////////////////////////////////////////////////////////////////////////// - - // get an index, or throw if the prop is not part of this DO + + // get an index, or throw if the prop is not part of this DO unsigned int DataObjectImpl::getPropertyIndex(const Property& p) { - PropertyList props = getType().getProperties(); + PropertyList props = getType().getProperties(); for (int i = 0; i < props.size() ; ++i) { @@ -1387,7 +1387,7 @@ { std::list<PropertyImpl>::iterator j; int count = 0; - for (j = openProperties.begin() ; + for (j = openProperties.begin() ; j != openProperties.end() ; ++j) { if (!strcmp((*j).getName(),p.getName())) @@ -1429,7 +1429,7 @@ PropertyImpl* DataObjectImpl::getPropertyImpl(unsigned int index) { - PropertyList props = getType().getProperties(); + PropertyList props = getType().getProperties(); if (index < props.size()) { return (PropertyImpl*)&props[index]; @@ -1460,7 +1460,7 @@ // recognise later (a-z, A-Z _ [ ] .) ////////////////////////////////////////////////////////////////////// - const char* DataObjectImpl::templateString = + const char* DataObjectImpl::templateString = " /abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890=[]._#"; char* DataObjectImpl::stripPath(const char* path) @@ -1471,7 +1471,7 @@ s = new char[strlen(path)+1]; - for (int i=0;i < strlen(path); i++) + for (int i=0;i < strlen(path); i++) { if (strchr(templateString,path[i]) != 0) { s[pos++] = path[i]; @@ -1488,7 +1488,7 @@ DataObjectImpl* DataObjectImpl::findDataObject(char* token, long* index) { - // name , name[int], name[x=y] name.int + // name , name[int], name[x=y] name.int char c = 0; char* beginbrace = strchr(token,'['); char* endbrace = strchr(token,']'); @@ -1498,26 +1498,26 @@ if (dot != 0) { - if (beginbrace != 0) + if (beginbrace != 0) { breaker = (beginbrace < dot)? beginbrace:dot; } - else + else { breaker = dot; } } - else + else { breaker = beginbrace; } if (breaker == 0){ - // its this object, and a property thereof + // its this object, and a property thereof *index = -1; const Property& p = getProperty(token); return getDataObjectImpl(p); - + } c = *breaker; @@ -1525,7 +1525,7 @@ const Property& p = getProperty(token); *breaker = c; - + breaker++; if (endbrace != 0) @@ -1541,8 +1541,8 @@ DataObjectList& list = getList(p); // The spec says that depts[1] is the first element, - // as is depts.0 - + // as is depts.0 + if (beginbrace != 0)val--; if (endbrace != 0)*endbrace = ']'; @@ -1602,13 +1602,13 @@ } break; - case Type::DateType: + case Type::DateType: { long dc = atol(eq); if (dc == (long)(list[li]->getDate(p).getTime())) ok = 1; } break; - + case Type::DoubleType: { // TODO - double needs a bigger size than float @@ -1720,7 +1720,7 @@ { // initially check for "#/" which indicates that we need to find the root - // object first + // object first if (path == 0) return 0; if (strlen(path) <= 2) @@ -1736,7 +1736,7 @@ return 0; } } - + if (path[0] == '#' && path[1] == '/') { DataObjectImpl* root = this; @@ -1752,30 +1752,30 @@ char* remaining = 0; char* token = 0; - if (i != 0) + if (i != 0) { int j = strlen(path) - strlen(i); - if (j > 0) + if (j > 0) { token = new char[j + 1]; strncpy(token,path, j); token[j] = 0; } - if (strlen(i) > 1) + if (strlen(i) > 1) { remaining = new char[strlen(i)]; strcpy(remaining, i+1); } } - else + else { remaining = new char[strlen(path) + 1]; strcpy(remaining,path); } - - if (token == 0) + + if (token == 0) { - if (remaining != 0 && !strcmp(remaining,"..")) + if (remaining != 0 && !strcmp(remaining,"..")) { /* Its the container itself */ *din = getContainerImpl(); @@ -1833,13 +1833,13 @@ // and any properties where isSet(property) is true. // For example, properties resulting from the use of // open or mixed XML content are present if allowed by the Type. - // The list does not contain duplicates. + // The list does not contain duplicates. // The order of the properties in the list begins with getType().getProperties() // and the order of the remaining properties is determined by the implementation. - // The same list will be returned unless the DataObject is updated so that + // The same list will be returned unless the DataObject is updated so that // the contents of the list change // @return the list of Properties currently used in thIs DataObject. - + PropertyList /* Property */ DataObjectImpl::getInstanceProperties() { std::vector<PropertyImpl*> theVec; @@ -1857,7 +1857,7 @@ } return PropertyList(theVec); } - + void DataObjectImpl::setInstancePropertyType(unsigned int index, const Type* t) { @@ -1888,7 +1888,7 @@ (*j).isContainment())); openProperties.erase(j); - + return; } count++; @@ -1896,14 +1896,14 @@ } return; } - + // Returns the Sequence for thIs DataObject. // When Type.isSequencedType() == true, // the Sequence of a DataObject corresponds to the // XML elements representing the values of its properties. // Updates through DataObject and the Lists or Sequences returned // from DataObject operate on the same data. - // When Type.isSequencedType() == false, null is returned. + // When Type.isSequencedType() == false, null is returned. // @return the <code>Sequence</code> or null. SequenceImpl* DataObjectImpl::getSequenceImpl() @@ -1938,7 +1938,7 @@ return 0; } - + ChangeSummaryPtr DataObjectImpl::getChangeSummary(const char* path) { @@ -1969,7 +1969,7 @@ // but as an additional check against looping, I will use // a redundent getSummary() method. // TODO - remove this. - if (changesummaryobject != 0) return + if (changesummaryobject != 0) return (ChangeSummaryPtr)(changesummaryobject->getSummary()); return 0; } @@ -1994,7 +1994,7 @@ return localCS; } - // sets a property of either this object or an object reachable from it, + // sets a property of either this object or an object reachable from it, // as identified by the specified path, // to the specified value. // @param path the path to a valid object and property. @@ -2028,7 +2028,7 @@ { dol.setDataObject((unsigned int)index,value); } - else + else { dol.append(value); } @@ -2040,7 +2040,7 @@ SDO_THROW_EXCEPTION("setDataObject", SDOUnsupportedOperationException, msg.c_str()); } - else + else { d->setDataObject((Property&)*p,value); delete(prop); @@ -2096,7 +2096,7 @@ DataObjectList& dl = d->getList(pl[i]); for (int j=0;j<dl.size();j++) { - + DataObject* d2 = dl[j]; if (d2) { ((DataObjectImpl*)d2)->setDataFactory(f); @@ -2108,7 +2108,7 @@ { DataObject* d3 = d->getDataObject(pl[i]); if (d3) - { + { ((DataObjectImpl*)d3)->setDataFactory(f); transferChildren(d3,f); } @@ -2118,9 +2118,10 @@ - void DataObjectImpl::checkFactory(DataObjectPtr dob) + void DataObjectImpl::checkFactory(DataObjectPtr dob, + unsigned int propertyIndex) { - + DataObjectImpl* d = (DataObjectImpl*)(DataObject*)dob; if (d->getDataFactory() == getDataFactory()) return; @@ -2129,11 +2130,27 @@ // problems associated with allowing data object 'migration' // lets move this one and all its children to the factory of the // new parent if the factories are compatible. - + DataFactoryImpl* f = (DataFactoryImpl*)getDataFactory(); - if ((d->getContainer() == 0) && - (f->isCompatible(d->getDataFactory()))) + if (d->getContainer() != 0) + { + string msg("Insertion of object from another factory is only allowed if the parent is null: "); + const Type& t = d->getType(); + msg += t.getURI(); + msg += "#"; + msg += t.getName(); + msg += " into property "; + msg += getProperty(propertyIndex).getName(); + msg += " of "; + msg += getType().getURI(); + msg += "#"; + msg += getType().getName(); + SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException, + msg.c_str()); + } + + if (f->isCompatible(d->getDataFactory(),d)) { d->setDataFactory(getDataFactory()); transferChildren(d,getDataFactory()); @@ -2142,13 +2159,15 @@ // This is the default position.... - + string msg("Insertion from incompatible factory "); const Type& t = d->getType(); msg += t.getURI(); msg += "#"; msg += t.getName(); - msg += " into data object "; + msg += " into property "; + msg += getProperty(propertyIndex).getName(); + msg += " of "; msg += getType().getURI(); msg += "#"; msg += getType().getName(); @@ -2169,7 +2188,7 @@ (objectType.getURI(),objectType.getName()); if (ti != 0) { - do + do { ti = (const TypeImpl*)ti->getBaseType(); if (ti == 0) break; @@ -2177,9 +2196,9 @@ } while (ti != 0); // allow types of any substitutes - const PropertyImpl* pi = + const PropertyImpl* pi = getPropertyImpl(getPropertyIndex(prop)); - if (pi != 0) + if (pi != 0) { unsigned int subcount = pi->getSubstitutionCount(); for (int i=0;i<subcount;i++) @@ -2212,10 +2231,10 @@ { unsigned int propertyIndex = getPropertyIndex(prop); - + if (value != 0) { - checkFactory(value); + checkFactory(value, propertyIndex); checkType(prop,value->getType()); } @@ -2252,7 +2271,7 @@ } - if (value == 0) + if (value == 0) { PropertyValueMap::iterator j; for (j = PropertyValues.begin(); j != PropertyValues.end(); ++j) @@ -2264,13 +2283,13 @@ } else { - // log both deletion and change - change is not + // log both deletion and change - change is not // automatically recorded by deletion. ((*j).second)->logDeletion(); } logChange(prop); (*j).second = RefCountingPointer<DataObjectImpl>(0); - + return; } } @@ -2291,7 +2310,7 @@ } else { - // log both deletion and change - change is not + // log both deletion and change - change is not // automatically recorded by deletion. ((*i).second)->logDeletion(); } @@ -2299,7 +2318,7 @@ (*i).second = RefCountingPointer<DataObjectImpl>((DataObjectImpl*)dob); - + if (prop.isReference()) { ((DataObjectImpl*)dob)->setReference(this, prop); @@ -2349,12 +2368,12 @@ msg.c_str()); } - - // Returns whether a property of either this object or an object reachable + + // Returns whether a property of either this object or an object reachable // from it, as identified by the specified path, // is considered to be set. // @param path the path to a valid Object* and property. - + bool DataObjectImpl::isSet(const char* path) { DataObjectImpl* d; @@ -2416,14 +2435,14 @@ } - // unSets a property of either this Object or an Object reachable from it, + // unSets a property of either this Object or an Object reachable from it, // as identified by the specified path. // @param path the path to a valid Object and property. // @see #unSet(Property) void DataObjectImpl::unset(const char* path) { - + DataObjectImpl* d; char* prop = findPropertyContainer(path,&d); if (d != 0) @@ -2494,7 +2513,7 @@ logChange(index); if (p.isMany()) { DataObjectList& dl = dol->getList(); - while (dl.size() > 0) + while (dl.size() > 0) { RefCountingPointer<DataObject> dli = dl.remove(0); } @@ -2508,11 +2527,11 @@ // if its a reference, we dont want to delete anything if (!p.isReference()) { - if (dol) { + if (dol) { dol->clearReferences(); if (p.isMany()) { DataObjectList& dl = dol->getList(); - while (dl.size() > 0) + while (dl.size() > 0) { if (p.getType().isDataObjectType()) { @@ -2524,7 +2543,7 @@ RefCountingPointer<DataObject> dli = dl.remove(0); } } - else + else { PropertyValues.erase(i); dol->logDeletion(); @@ -2556,9 +2575,9 @@ return; } - - // Returns the value of a DataObject property identified by + + // Returns the value of a DataObject property identified by // the specified path. // @param path the path to a valid object and property. // @return the DataObject value of the specified property. @@ -2571,7 +2590,7 @@ DataObjectImpl* DataObjectImpl::getDataObjectImpl(const char* path) { - + DataObjectImpl* d = 0; char* prop = findPropertyContainer(path,&d); if (d != 0) { @@ -2589,9 +2608,9 @@ } return theob; } - else + else { - if (strlen(prop) == 0) + if (strlen(prop) == 0) { delete prop; prop = 0; @@ -2643,7 +2662,7 @@ return 0; } - + RefCountingPointer<DataObject> DataObjectImpl::getDataObject(const Property& property) { DataObjectImpl* ptr = getDataObjectImpl(property); @@ -2665,7 +2684,7 @@ RefCountingPointer<DataObject> DataObjectImpl::createDataObject(const char* propertyName) { - // Throws runtime exception for type or property not found + // Throws runtime exception for type or property not found const Property& p = getProperty(propertyName); return createDataObject(p); @@ -2684,7 +2703,7 @@ // Returns a new DataObject contained by this Object using the specified property, // which must be a containment property. // The type of the created Object is the declared type of the specified property. - + RefCountingPointer<DataObject> DataObjectImpl::createDataObject(const Property& property) { const Type& tp = property.getType(); @@ -2696,7 +2715,7 @@ // which must be a containment property. // The type of the created Object is the declared type of the specified property. - RefCountingPointer<DataObject> DataObjectImpl::createDataObject(const Property& property, const char* namespaceURI, + RefCountingPointer<DataObject> DataObjectImpl::createDataObject(const Property& property, const char* namespaceURI, const char* typeName) { if (!property.isContainment()) @@ -2714,8 +2733,8 @@ DataObject* dob = ptr; ((DataObjectImpl*)dob)->setContainer(this); ((DataObjectImpl*)dob)->setApplicableChangeSummary(); - - // log creation before adding to list - the change must record the old state + + // log creation before adding to list - the change must record the old state // of the list logCreation(((DataObjectImpl*)dob), this, property); //logChange(property); @@ -2723,7 +2742,7 @@ DataObjectImpl* theDO = getDataObjectImpl(property); if ( theDO == 0) { /* No value set yet */ unsigned int ind = getPropertyIndex(property); - RefCountingPointer<DataObject> listptr = + RefCountingPointer<DataObject> listptr = df->create(Type::SDOTypeNamespaceURI,"DataObject"); DataObject* doptr = listptr; @@ -2745,10 +2764,10 @@ // sq->push(property,0); //} } - else + else { DataObjectList& list = theDO->getList(); - // the append will log a change to the property, and update the + // the append will log a change to the property, and update the // sequence list.append(ptr); //if (getType().isSequencedType()) @@ -2763,7 +2782,7 @@ } else { unset(property); - DataObjectImpl* ditem = + DataObjectImpl* ditem = new DataObjectImpl(df, df->getType(namespaceURI, typeName)); ditem->setContainer(this); ditem->setApplicableChangeSummary(); @@ -2831,7 +2850,7 @@ { // remove this data object from its tree clearReferences(); - if (container == 0) return; + if (container == 0) return; container->remove(this); return ; } @@ -2841,7 +2860,7 @@ // clear this objects state PropertyValueMap::iterator i = PropertyValues.begin(); - while (i != PropertyValues.end()) + while (i != PropertyValues.end()) { unset((*i).first); i = PropertyValues.begin(); @@ -2885,15 +2904,15 @@ } } } - else + else { - if ((*i).second == ob) + if ((*i).second == ob) { return &(getProperty((*i).first)); } } } - return 0; // this can happen if the object has been detached + return 0; // this can happen if the object has been detached //string msg("Object cannot find its containing property"); //SDO_THROW_EXCEPTION("FindInProperties" ,SDOPropertyNotFoundException, @@ -2957,7 +2976,7 @@ if (getType().isOpenType()) { std::list<PropertyImpl>::iterator j; - for (j=openProperties.begin(); + for (j=openProperties.begin(); j != openProperties.end(); ++j) { if (!strcmp((*j).getName(), prop)) @@ -2983,7 +3002,7 @@ // These finally are the setters/getters for primitives given // that the data object is a primitive type. /////////////////////////////////////////////////////////////////////////// - + bool DataObjectImpl::getBoolean() { @@ -3004,7 +3023,7 @@ } - long DataObjectImpl::getInteger() + long DataObjectImpl::getInteger() { return getTypeImpl().convertToInteger(value,valuelength); @@ -3103,7 +3122,7 @@ return; } - void DataObjectImpl::setInteger(long invalue) + void DataObjectImpl::setInteger(long invalue) { valuelength = getTypeImpl().convert(&value,invalue); return; @@ -3179,7 +3198,7 @@ asStringBuffer = 0; // asXPathBuffer = 0; isnull = false; - + // open type support openBase = t.getPropertiesSize() ; @@ -3190,7 +3209,7 @@ changesummaryobject = 0; localCS = new ChangeSummaryImpl(); } - else + else { changesummaryobject = 0; localCS = 0; @@ -3222,17 +3241,17 @@ changesummaryobject = 0; localCS = new ChangeSummaryImpl(); } - else + else { changesummaryobject = 0; localCS = 0; } - if (getType().isSequencedType()) + if (getType().isSequencedType()) { sequence = new SequenceImpl(this); } - else + else { sequence = 0; } @@ -3245,8 +3264,8 @@ case Type::BooleanType: case Type::ByteType: case Type::CharacterType: - case Type::IntegerType: - case Type::DateType: + case Type::IntegerType: + case Type::DateType: case Type::DoubleType: case Type::FloatType: case Type::LongType: @@ -3290,12 +3309,12 @@ clearReferences(); PropertyValueMap::iterator i = PropertyValues.begin(); - while (i != PropertyValues.end()) + while (i != PropertyValues.end()) { unset((*i).first); if (i == PropertyValues.begin()) { - // unset has not removed the item from the list - do it + // unset has not removed the item from the list - do it // here instead PropertyValues.erase(i); } @@ -3306,18 +3325,18 @@ //so we dont need to detach.... //detach(); - + if (asStringBuffer != 0) delete asStringBuffer; // if (asXPathBuffer != 0) delete asXPathBuffer; - if (value != 0) + if (value != 0) { if (getType().isDataType())deleteValue(); } - - - if (getType().isSequencedType()) + + + if (getType().isSequencedType()) { if (sequence != 0) delete sequence; } @@ -3325,9 +3344,9 @@ if (getTypeImpl().isChangeSummaryType() ) { - if (getChangeSummary() != 0) + if (getChangeSummary() != 0) { - delete localCS; + delete localCS; localCS = 0; } } @@ -3360,7 +3379,7 @@ { if (getChangeSummaryImpl() != 0 && getChangeSummaryImpl()->isLogging()) { - getChangeSummaryImpl()->logCreation(dol,cont,theprop); + getChangeSummaryImpl()->logCreation(dol,cont,theprop); } } @@ -3493,7 +3512,7 @@ temp1 = new char[strlen(name) + 34]; temp1[0] = 0; - + if (p.isMany()) { DataObjectList& dol = dob->getList(p); for (int i=0;i<dol.size();i++) @@ -3540,7 +3559,7 @@ delete spath; spath = 0; } - if (d != 0) + if (d != 0) { if (prop != 0) { @@ -3569,7 +3588,7 @@ if (spath) delete spath; return 0; } - + } void* DataObjectImpl::getUserData(unsigned int propertyIndex) @@ -3620,7 +3639,7 @@ delete spath; spath = 0; } - if (d != 0) + if (d != 0) { if (prop != 0) { @@ -3649,7 +3668,7 @@ if (spath) delete spath; return; } - + } void DataObjectImpl::setUserData(unsigned int propertyIndex, void* value) http://cvs.php.net/viewcvs.cgi/pecl/sdo/commonj/sdo/DataObjectImpl.h?r1=1.6&r2=1.7&diff_format=u Index: pecl/sdo/commonj/sdo/DataObjectImpl.h diff -u pecl/sdo/commonj/sdo/DataObjectImpl.h:1.6 pecl/sdo/commonj/sdo/DataObjectImpl.h:1.7 --- pecl/sdo/commonj/sdo/DataObjectImpl.h:1.6 Wed Mar 1 13:46:05 2006 +++ pecl/sdo/commonj/sdo/DataObjectImpl.h Fri Mar 17 16:43:47 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/03/01 13:46:05 $ */ +/* $Rev$ $Date: 2006/03/17 16:43:47 $ */ #ifndef _DATAOBJECTIMPL_H_ #define _DATAOBJECTIMPL_H_ @@ -43,9 +43,9 @@ namespace commonj{ namespace sdo{ - + class DataGraph; -class DataObjectImpl; +class DataObjectImpl; class DataObjectListImpl; class DataFactory; @@ -70,32 +70,32 @@ typedef std::list< rdo > PropertyValueMap; - /** + /** * DataObjectImpl implements the abstract class DataObject. * - * A data object is a representation of some structured data. + * A data object is a representation of some structured data. * it is the fundamental component in the SDO (Service Data Objects) package. - * Data objects support reflection, path-based accesss, convenience creation + * Data objects support reflection, path-based accesss, convenience creation * and deletion methods,and the ability to be part of a data graph. - * Each data object holds its data as a series of properties. - * Properties can be accessed by name, property index, or using the property - * meta object itself. - * A data object can also contain references to other data objects, through + * Each data object holds its data as a series of properties. + * Properties can be accessed by name, property index, or using the property + * meta object itself. + * A data object can also contain references to other data objects, through * reference-type properties. - * A data object has a series of convenience accessors for its properties. - * These methods either use a path (String), a property index, + * A data object has a series of convenience accessors for its properties. + * These methods either use a path (String), a property index, * or the property's meta object itself, to identify the property. * Some examples of the path-based accessors are as follows: * DataObjectPtr company = ...; - * company->getString("name"); + * company->getString("name"); * company->setString("name", "acme"); - * company->getString("department.0/name") + * company->getString("department.0/name") * .n indexes from 0. * company->getString("department[1]/name") [] indexes from 1. * company->getDataObject("department[number=123]") returns the department where number=123 * company->getDataObject("..") returns the containing data object * company->getDataObject("/") returns the root containing data object - * There are specific accessors for the primitive types and commonly used + * There are specific accessors for the primitive types and commonly used * data types like String. */ @@ -124,25 +124,25 @@ /** getPropertyIndex gets the unique index of a property * - * A property of a data object has a unique index associated with it. - * This method gets a property index for this object from the property, - * or throw SDOPropertyNotFoundException if the property is not part + * A property of a data object has a unique index associated with it. + * This method gets a property index for this object from the property, + * or throw SDOPropertyNotFoundException if the property is not part * of this data object. */ virtual unsigned int getPropertyIndex(const Property& p); - + /** * These are just like getType().getProperty(), but may return * values other than the property list for open types. */ virtual const Property& getProperty(unsigned int index); - + virtual const Property& getProperty(const char* prop); - + virtual PropertyImpl* getPropertyImpl(const char* prop); - + virtual PropertyImpl* getPropertyImpl(unsigned int index); /** getInstanceProperties gets the props of the current object. @@ -152,14 +152,14 @@ * and any properties where isSet(property) is true. * For example, properties resulting from the use of * open or mixed XML content are present if allowed by the Type. - * The list does not contain duplicates. + * The list does not contain duplicates. * The order of the properties in the list begins with getType().getProperties() * and the order of the remaining properties is determined by the implementation. - * The same list will be returned unless the DataObject is updated so that + * The same list will be returned unless the DataObject is updated so that * the contents of the list change * Returns the list of Properties currently used in this DataObject. */ - + virtual PropertyList getInstanceProperties(); /** getContainer get the containing object @@ -177,15 +177,15 @@ */ virtual const Property& getContainmentProperty(); - + /** getType returns the data object's type. * * getType returns the data object's type. * The type defines the properties available for reflective access. */ - + virtual const Type& getType(); - + virtual const Type::Types getTypeEnum(); @@ -193,17 +193,17 @@ /////////////////////////////////////////////////////////////////////////// // get/set /////////////////////////////////////////////////////////////////////////// - - + + /** getDataObject returns a data object by path, index or property * - * Returns the value of a property of either this object or an object + * Returns the value of a property of either this object or an object * reachable from it, as identified by the specified path. */ - virtual DataObjectPtr getDataObject(const char* path); - virtual DataObjectPtr getDataObject(unsigned int propertyIndex); - virtual DataObjectPtr getDataObject(const Property& property); + virtual DataObjectPtr getDataObject(const char* path); + virtual DataObjectPtr getDataObject(unsigned int propertyIndex); + virtual DataObjectPtr getDataObject(const Property& property); /** setDataObject sets a value by path, index or property * @@ -211,21 +211,21 @@ * as identified by the specified path, * to the specified value. */ - - virtual void setDataObject(const char* path, DataObjectPtr value); - virtual void setDataObject(unsigned int propertyIndex, DataObjectPtr value); - virtual void setDataObject(const Property& property, DataObjectPtr value); + + virtual void setDataObject(const char* path, DataObjectPtr value); + virtual void setDataObject(unsigned int propertyIndex, DataObjectPtr value); + virtual void setDataObject(const Property& property, DataObjectPtr value); /** getBoolean returns a boolean by path, index or property * - * Returns the value of a property of either this object or an object + * Returns the value of a property of either this object or an object * reachable from it, as identified by the specified path. */ virtual bool getBoolean(const char* path); virtual bool getBoolean(unsigned int propindex); virtual bool getBoolean(const Property& p); - + virtual void setBoolean(const char* path, bool b); virtual void setBoolean(unsigned int propindex, bool b); virtual void setBoolean(const Property& p, bool b); @@ -233,7 +233,7 @@ virtual char getByte(const char* path); virtual char getByte(unsigned int propindex); virtual char getByte(const Property& p); - + virtual void setByte(const char* path, char c); virtual void setByte(unsigned int propindex, char c); virtual void setByte(const Property& p, char c); @@ -241,7 +241,7 @@ virtual wchar_t getCharacter(const char* path); virtual wchar_t getCharacter(unsigned int propindex); virtual wchar_t getCharacter(const Property& p); - + virtual void setCharacter(const char* path, wchar_t c); virtual void setCharacter(unsigned int propindex, wchar_t c); virtual void setCharacter(const Property& p, wchar_t c); @@ -254,7 +254,7 @@ virtual unsigned int getBytes(const char* path, char* buf, unsigned int max) ; virtual unsigned int getBytes(unsigned int propindex, char* buf, unsigned int max) ; virtual unsigned int getBytes(const Property& p, char* buf, unsigned int max) ; - + virtual void setBytes(const char* path, const char* c, unsigned int len) ; virtual void setBytes(unsigned int propindex, const char* c,unsigned int len) ; virtual void setBytes(const Property& p, const char* c,unsigned int len) ; @@ -262,7 +262,7 @@ virtual unsigned int getString(const char* path, wchar_t* buf, unsigned int max) ; virtual unsigned int getString(unsigned int propindex,wchar_t* buf, unsigned int max) ; virtual unsigned int getString(const Property& p,wchar_t* buf, unsigned int max) ; - + virtual void setString(const char* path, const wchar_t* c,unsigned int len) ; virtual void setString(unsigned int propindex, const wchar_t* c,unsigned int len) ; virtual void setString(const Property& p, const wchar_t* c,unsigned int len) ; @@ -270,7 +270,7 @@ virtual const SDODate getDate(const char* path); virtual const SDODate getDate(unsigned int propindex); virtual const SDODate getDate(const Property& p); - + virtual void setDate(const char* path, const SDODate d); virtual void setDate(unsigned int propindex, const SDODate d); virtual void setDate(const Property& p, const SDODate d); @@ -278,7 +278,7 @@ virtual long double getDouble(const char* path); virtual long double getDouble(unsigned int propindex); virtual long double getDouble(const Property& p); - + virtual void setDouble(const char* path, long double d); virtual void setDouble(unsigned int propindex, long double d); virtual void setDouble(const Property& p, long double d); @@ -286,7 +286,7 @@ virtual float getFloat(const char* path); virtual float getFloat(unsigned int propindex); virtual float getFloat(const Property& p); - + virtual void setFloat(const char* path, float f); virtual void setFloat(unsigned int propindex, float f); virtual void setFloat(const Property& p, float f); @@ -294,7 +294,7 @@ virtual long getInteger(const char* path); virtual long getInteger(unsigned int propindex); virtual long getInteger(const Property& p); - + virtual void setInteger(const char* path, long i); virtual void setInteger(unsigned int propindex, long i); virtual void setInteger(const Property& p, long i); @@ -302,7 +302,7 @@ virtual /*long long*/ int64_t getLong(const char* path); virtual /*long long*/ int64_t getLong(unsigned int propindex); virtual /*long long*/ int64_t getLong(const Property& p); - + virtual void setLong(const char* path, /*long long*/ int64_t l); virtual void setLong(unsigned int propindex, /*long long*/ int64_t l); virtual void setLong(const Property& p, /*long long*/ int64_t l); @@ -310,7 +310,7 @@ virtual short getShort(const char* path); virtual short getShort(unsigned int propindex); virtual short getShort(const Property& p); - + virtual void setShort(const char* path, short s); virtual void setShort(unsigned int propindex, short s); virtual void setShort(const Property& p, short s); @@ -318,11 +318,11 @@ virtual const char* getCString(const char* path); virtual const char* getCString(unsigned int propertyIndex); virtual const char* getCString(const Property& prop); - + virtual void setCString(const char* path, const char* value); virtual void setCString(unsigned int propertyIndex, const char* value); virtual void setCString (const Property& prop, const char* value); - + /** setNull sets a data object value to null. * * A DataObjectType or DataType value may be set or unset. If it is set, then @@ -335,11 +335,11 @@ virtual void setNull(const char* path); virtual void setNull(unsigned int propertyIndex); virtual void setNull(const Property& prop); - + virtual bool isNull(const char* path); virtual bool isNull(unsigned int propertyIndex); virtual bool isNull(const Property& prop); - + virtual bool isSet(const char* path); virtual bool isSet(unsigned int propertyIndex); virtual bool isSet(const Property& property); @@ -359,7 +359,7 @@ /** getSequence returns the sequence for a data object * - * Returns the value of a Sequence property identified by + * Returns the value of a Sequence property identified by * the specified path. See Sequence. */ @@ -370,20 +370,20 @@ virtual SequencePtr getSequence(const Property& property); - /////////////////////////////////////////////////////////////////////////// - // Creation of dataobjects + /////////////////////////////////////////////////////////////////////////// + // Creation of dataobjects /////////////////////////////////////////////////////////////////////////// /** createDataObject creates a data object value * - * Returns a new data object contained by this object using the + * Returns a new data object contained by this object using the * specified property,which must be a containment property. * The type of the created object is the declared type * of the specified property. * If the property is many valued, this method adds an element to the * list, otherwise it sets the value, removing any old value. */ - + virtual DataObjectPtr createDataObject(const char* propertyName); virtual DataObjectPtr createDataObject(unsigned int propertyIndex); virtual DataObjectPtr createDataObject(const Property& property); @@ -425,13 +425,13 @@ /////////////////////////////////////////////////////////////////////////// // Change Summary /////////////////////////////////////////////////////////////////////////// - + /** getChangeSummary get the applicable change summary * * This method gets the applicable change summary for a data object. * The summary is not necessarily attached to the data object, it may be * the summary for a parent data object. No object with a summary attached - * may be a child of another object with a summary attached. + * may be a child of another object with a summary attached. * See the ChangeSummary API for details of using the change sumamry. */ @@ -484,7 +484,7 @@ virtual void setReference(DataObject* dob, const Property& prop); virtual void unsetReference(DataObject* dob, const Property& prop); virtual void clearReferences(); - + // user data support virtual void setUserData(const char* path,void* value); virtual void setUserData(unsigned int propertyIndex, void* value); @@ -503,8 +503,8 @@ // The data factory can be used to create new data objects within // the Type system of this data object - // - + // + SDO_API DataFactory* getDataFactory(); @@ -518,13 +518,13 @@ virtual void setInstancePropertyType(unsigned int index, const Type* t); - /** + /** * defineProperty is used by open type support. * This method and its siblings define a new property on an * open type when a setting is requested. */ - virtual const PropertyImpl* defineProperty(const char* propname, + virtual const PropertyImpl* defineProperty(const char* propname, const Type& t); virtual const PropertyImpl* defineBoolean(const char* propname); @@ -552,20 +552,20 @@ private: virtual void validateIndex(unsigned int index); - virtual void checkFactory(DataObjectPtr dob); + virtual void checkFactory(DataObjectPtr dob, unsigned int proeprtyIndex); virtual void checkType( const Property& prop, const Type& objectType); - + virtual bool remove(DataObjectImpl* indol); virtual bool isSet(const Property& prop, unsigned int propertyIndex); - - virtual DataObjectImpl* getDataObjectImpl(const char* path); - virtual DataObjectImpl* getDataObjectImpl(unsigned int propertyIndex); - virtual DataObjectImpl* getDataObjectImpl(const Property& property); + + virtual DataObjectImpl* getDataObjectImpl(const char* path); + virtual DataObjectImpl* getDataObjectImpl(unsigned int propertyIndex); + virtual DataObjectImpl* getDataObjectImpl(const Property& property); virtual DataObjectPtr - createDataObject(const Property& property, + createDataObject(const Property& property, const char* namespaceURI, const char* typeName); @@ -577,25 +577,25 @@ // Does not keep a reference counted pointer to the container. DataObjectImpl* container; - + // remove the value from the data object. void deleteValue(); PropertyValueMap PropertyValues; - + const TypeImpl& ObjectType; DataObjectListImpl* listValue; - + // Holds the value , reallocated as necessary for strings - void* value; + void* value; // In the case of a bytes/string - this holds the length; unsigned int valuelength; - + // holds the value as a string - if requested. - char* asStringBuffer; + char* asStringBuffer; // holds the Xpath to this object if requested. std::string asXPathBuffer; @@ -603,7 +603,7 @@ // The data object holds a counted reference to the data factory. DataFactoryPtr factory; - + // Support for open types int openBase; std::list<PropertyImpl> openProperties; @@ -661,9 +661,9 @@ REFERENCE_LIST refs; - + }; }; }; - + #endif //_DATAOBJECTIMPL_H_ http://cvs.php.net/viewcvs.cgi/pecl/sdo/commonj/sdo/DataObjectListImpl.cpp?r1=1.6&r2=1.7&diff_format=u Index: pecl/sdo/commonj/sdo/DataObjectListImpl.cpp diff -u pecl/sdo/commonj/sdo/DataObjectListImpl.cpp:1.6 pecl/sdo/commonj/sdo/DataObjectListImpl.cpp:1.7 --- pecl/sdo/commonj/sdo/DataObjectListImpl.cpp:1.6 Wed Mar 1 13:46:05 2006 +++ pecl/sdo/commonj/sdo/DataObjectListImpl.cpp Fri Mar 17 16:43:47 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/03/01 13:46:05 $ */ +/* $Rev$ $Date: 2006/03/17 16:43:47 $ */ #include "commonj/sdo/DataObjectListImpl.h" @@ -35,12 +35,12 @@ namespace commonj{ namespace sdo { -/** +/** * DataObjectListImpl implements DataObjectList. * List for retrieving many valued property values. * * DataObjectList provides an API for getting and setting values in - * many valued properties. The list deals with both DataType and + * many valued properties. The list deals with both DataType and * DataObjectType properties. */ DataObjectListImpl::DataObjectListImpl(DATAOBJECT_VECTOR p) : plist (p) @@ -81,7 +81,7 @@ isReference = false; } -DataObjectListImpl::DataObjectListImpl(DataFactory* df, +DataObjectListImpl::DataObjectListImpl(DataFactory* df, DataObjectImpl* cont, unsigned int inpindex, const char* intypeURI, @@ -213,8 +213,8 @@ msg.c_str()); } } - if (strcmp(typeURI,d->getType().getURI()) - || + if (strcmp(typeURI,d->getType().getURI()) + || strcmp(typeName,d->getType().getName())) { string msg("Insertion of object of the wrong type to a list:"); @@ -230,7 +230,7 @@ } DataObject* dob = d; // unwrap the data object ready for a downcasting hack. - DataObjectImpl* con = ((DataObjectImpl*)dob)->getContainerImpl(); + DataObjectImpl* con = ((DataObjectImpl*)dob)->getContainerImpl(); if (!isReference) { if (con != 0) @@ -246,7 +246,7 @@ msg.c_str()); } } - else + else { ((DataObjectImpl*)dob)->setContainer(container); ((DataObjectImpl*)dob)->setApplicableChangeSummary(); @@ -258,7 +258,7 @@ plist.insert(plist.begin()+index, RefCountingPointer<DataObjectImpl>((DataObjectImpl*)dob)); - if (container != 0) + if (container != 0) { if (container->getType().isSequencedType()) { @@ -273,19 +273,37 @@ void DataObjectListImpl::checkFactory(DataObjectPtr dob) { - + DataObjectImpl* d = (DataObjectImpl*)(DataObject*)dob; if (d->getDataFactory() == theFactory) return; // temporary experiment with allowing data objects - // to move from factory to factory if the type is + // to move from factory to factory if the type is // nominally present, and the type systems match DataFactoryImpl* f = (DataFactoryImpl*)theFactory; - if ((d->getContainer() == 0) && - (f->isCompatible(d->getDataFactory()))) + + if (d->getContainer() != 0) + { + string msg("Insertion of object into list from another factory is only allowed if the parent is null: "); + + const Type& t = d->getType(); + msg += t.getURI(); + msg += "#"; + msg += t.getName(); + msg += " into property "; + msg += container->getProperty(pindex).getName(); + msg += " of type "; + msg += typeURI; + msg += "#"; + msg += typeName; + SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException, + msg.c_str()); + } + + if (f->isCompatible(d->getDataFactory(),d)) { d->setDataFactory(theFactory); // we will also need to transfer any children - assuming they @@ -294,17 +312,21 @@ return; } - string msg("Insertion from incompatible factory "); + string msg("Insertion into list fromm incompatible factory:"); + const Type& t = d->getType(); msg += t.getURI(); msg += "#"; msg += t.getName(); - msg += " into list "; + msg += " into property "; + msg += container->getProperty(pindex).getName(); + msg += " of type "; msg += typeURI; msg += "#"; msg += typeName; SDO_THROW_EXCEPTION("checkFactory", SDOInvalidConversionException, msg.c_str()); + } @@ -316,7 +338,7 @@ (objectType.getURI(),objectType.getName()); if (ti != 0) { - do + do { ti = (const TypeImpl*)ti->getBaseType(); if (ti == 0) break; @@ -326,7 +348,7 @@ // allow types of any substitutes if (container != 0) { - PropertyImpl* pi = + PropertyImpl* pi = container->getPropertyImpl(pindex); if (pi != 0) { @@ -354,7 +376,7 @@ } -void DataObjectListImpl::setType(const char* uri, const char* name) +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; @@ -369,12 +391,12 @@ typeName = new char[strlen(name)+1]; strcpy(typeName, name); delete typeURI; - if (uri == 0) + if (uri == 0) { typeURI = new char[1]; typeURI[0] = 0; } - else + else { typeURI = new char[strlen(uri)+1]; strcpy(typeURI, uri); @@ -412,8 +434,8 @@ d->getType()); DataObject* dob = d; // unwrap the data object ready for a downcasting hack. - DataObjectImpl* con = ((DataObjectImpl*)dob)->getContainerImpl(); - + DataObjectImpl* con = ((DataObjectImpl*)dob)->getContainerImpl(); + if (!isReference) { if (con != 0) @@ -429,7 +451,7 @@ msg.c_str()); } } - else + else { ((DataObjectImpl*)dob)->setContainer(container); ((DataObjectImpl*)dob)->setApplicableChangeSummary(); @@ -455,7 +477,7 @@ void DataObjectListImpl::insert (unsigned int index, bool d) { if (theFactory == 0) return; - + if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Boolean"); RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName); @@ -464,12 +486,12 @@ insert(index, dol); } -void DataObjectListImpl::append (bool d) +void DataObjectListImpl::append (bool d) { if (theFactory == 0) return; if (typeUnset)setType(Type::SDOTypeNamespaceURI, "Boolean"); - + RefCountingPointer<DataObject> dol = theFactory->create(typeURI, typeName); DataObject* dob = dol; ((DataObjectImpl*)dob)->setBoolean(d); @@ -754,9 +776,9 @@ container->logChange(pindex); } RefCountingPointer<DataObject> d = (*this)[index]; - + // log deletion only if the list is of data objects. - if (theFactory != 0) + if (theFactory != 0) { const Type& t = theFactory->getType(typeURI,typeName); const Property& p = container->getProperty(pindex); @@ -842,14 +864,14 @@ DataObject* dob = d; return ((DataObjectImpl*)dob)->getLong(); } -float DataObjectListImpl::getFloat(unsigned int index) const +float DataObjectListImpl::getFloat(unsigned int index) const { validateIndex(index); - RefCountingPointer<DataObject> d = ((*this)[index]); + RefCountingPointer<DataObject> d = ((*this)[index]); DataObject* dob = d; return ((DataObjectImpl*)dob)->getFloat(); } -long double DataObjectListImpl::getDouble(unsigned int index) const +long double DataObjectListImpl::getDouble(unsigned int index) const { validateIndex(index); RefCountingPointer<DataObject> d = ((*this)[index]); @@ -877,7 +899,7 @@ return (*this)[index]; } -void DataObjectListImpl::setBoolean(unsigned int index, bool d) +void DataObjectListImpl::setBoolean(unsigned int index, bool d) { validateIndex(index); if (container != 0) @@ -888,7 +910,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setBoolean(d); } -void DataObjectListImpl::setByte(unsigned int index, char d) +void DataObjectListImpl::setByte(unsigned int index, char d) { validateIndex(index); if (container != 0) @@ -899,7 +921,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setByte(d); } -void DataObjectListImpl::setCharacter(unsigned int index, wchar_t d) +void DataObjectListImpl::setCharacter(unsigned int index, wchar_t d) { validateIndex(index); if (container != 0) @@ -911,7 +933,7 @@ ((DataObjectImpl*)dob)->setCharacter(d); } -void DataObjectListImpl::setString(unsigned int index, const wchar_t* d, unsigned int len) +void DataObjectListImpl::setString(unsigned int index, const wchar_t* d, unsigned int len) { validateIndex(index); if (container != 0) @@ -922,7 +944,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setString(d, len); } -void DataObjectListImpl::setBytes(unsigned int index, const char* d, unsigned int len) +void DataObjectListImpl::setBytes(unsigned int index, const char* d, unsigned int len) { validateIndex(index); if (container != 0) @@ -934,7 +956,7 @@ ((DataObjectImpl*)dob)->setBytes(d, len); } -void DataObjectListImpl::setShort(unsigned int index, short d) +void DataObjectListImpl::setShort(unsigned int index, short d) { validateIndex(index); if (container != 0) @@ -945,7 +967,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setShort(d); } -void DataObjectListImpl::setInteger(unsigned int index, long d) +void DataObjectListImpl::setInteger(unsigned int index, long d) { validateIndex(index); if (container != 0) @@ -956,7 +978,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setInteger(d); } -void DataObjectListImpl::setLong(unsigned int index, int64_t d) +void DataObjectListImpl::setLong(unsigned int index, int64_t d) { validateIndex(index); if (container != 0) @@ -967,7 +989,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setLong(d); } -void DataObjectListImpl::setFloat(unsigned int index, float d) +void DataObjectListImpl::setFloat(unsigned int index, float d) { validateIndex(index); if (container != 0) @@ -978,7 +1000,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setFloat(d); } -void DataObjectListImpl::setDouble(unsigned int index, long double d) +void DataObjectListImpl::setDouble(unsigned int index, long double d) { validateIndex(index); if (container != 0) @@ -989,7 +1011,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setDouble(d); } -void DataObjectListImpl::setDate(unsigned int index, const SDODate d) +void DataObjectListImpl::setDate(unsigned int index, const SDODate d) { validateIndex(index); if (container != 0) @@ -1000,7 +1022,7 @@ DataObject* dob = dd; ((DataObjectImpl*)dob)->setDate(d); } -void DataObjectListImpl::setCString(unsigned int index, char* d) +void DataObjectListImpl::setCString(unsigned int index, char* d) { validateIndex(index); if (container != 0) @@ -1012,7 +1034,7 @@ ((DataObjectImpl*)dob)->setCString(d); } -void DataObjectListImpl::setDataObject(unsigned int index, DataObjectPtr dob) +void DataObjectListImpl::setDataObject(unsigned int index, DataObjectPtr dob) { if (dob != 0) http://cvs.php.net/viewcvs.cgi/pecl/sdo/commonj/sdo/SDOXMLWriter.cpp?r1=1.5&r2=1.6&diff_format=u Index: pecl/sdo/commonj/sdo/SDOXMLWriter.cpp diff -u pecl/sdo/commonj/sdo/SDOXMLWriter.cpp:1.5 pecl/sdo/commonj/sdo/SDOXMLWriter.cpp:1.6 --- pecl/sdo/commonj/sdo/SDOXMLWriter.cpp:1.5 Mon Feb 20 18:50:25 2006 +++ pecl/sdo/commonj/sdo/SDOXMLWriter.cpp Fri Mar 17 16:43:47 2006 @@ -1,6 +1,6 @@ /* * - * Copyright 2005 The Apache Software Foundation or its licensors, as applicable. + * Copyright 2005, 2006 The Apache Software Foundation or its licensors, as applicable. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ * limitations under the License. */ -/* $Rev$ $Date: 2006/02/20 18:50:25 $ */ +/* $Rev$ $Date: 2006/03/17 16:43:47 $ */ #include "commonj/sdo/SDOXMLWriter.h" #include "commonj/sdo/SDOXMLString.h" @@ -34,27 +34,27 @@ { namespace sdo { - - - - + + + + SDOXMLWriter::SDOXMLWriter( DataFactoryPtr dataFact) : dataFactory(dataFact) { - + } - + SDOXMLWriter::~SDOXMLWriter() { freeWriter(); } - + void SDOXMLWriter::setWriter(xmlTextWriterPtr textWriter) { writer = textWriter; } - + void SDOXMLWriter::freeWriter() { if (writer != NULL) @@ -63,28 +63,28 @@ writer = NULL; } } - + int SDOXMLWriter::write(XMLDocumentPtr doc, int indent) { if (!doc) { return 0; } - + if (writer == NULL) { // Throw exception return -1; } - + int rc = 0; - + //namespaceUriStack.empty(); //namespaceUriStack.push(SDOXMLString()); //namespaces.empty(); //namespaceStack.push(namespaces); namespaceMap.empty(); - + if (indent >= 0) { xmlTextWriterSetIndent(writer, 1); @@ -101,7 +101,7 @@ xmlTextWriterSetIndentString(writer, SDOXMLString("")); } } - + if (doc->getXMLDeclaration()) { rc = xmlTextWriterStartDocument(writer, doc->getXMLVersion(), doc->getEncoding(), NULL); @@ -109,7 +109,7 @@ SDO_THROW_EXCEPTION("write", SDOXMLParserException, "xmlTextWriterStartDocument failed"); } } - + DataObjectPtr root = doc->getRootDataObject(); if (root) { @@ -127,7 +127,7 @@ elementName = elementName.toLower(0,1); writeXSIType = true; } - + writeDO(root, elementURI, elementName, true, true); } rc = xmlTextWriterEndDocument(writer); @@ -135,10 +135,10 @@ SDO_THROW_EXCEPTION("write", SDOXMLParserException, "xmlTextWriterEndDocument failed"); return rc; } - + xmlTextWriterFlush(writer); freeWriter(); - + return rc; } @@ -147,13 +147,13 @@ ////////////////////////////////////////////////////////////////////////// void SDOXMLWriter::handleChangeSummaryAttributes( - ChangeSummaryPtr cs, + ChangeSummaryPtr cs, DataObjectPtr dol) { int rc; SettingList& sl = cs->getOldValues(dol); - if (sl.size() == 0) + if (sl.size() == 0) { // no attributes return; @@ -162,40 +162,40 @@ { try { - if (sl.get(j)->getProperty().isMany()) + if (sl.get(j)->getProperty().isMany()) { // manys are elements continue; } - + if (sl.get(j)->getProperty().getType().isDataType()) { // data types are OK - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, SDOXMLString(sl.get(j)->getProperty().getName()), SDOXMLString(sl.get(j)->getCStringValue())); } - else + else { DataObjectPtr dob = sl.get(j)->getDataObjectValue(); - if (dob) + if (dob) { if (cs->isDeleted(dob)) { - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, SDOXMLString(sl.get(j)->getProperty().getName()), SDOXMLString(cs->getOldXpath(dob))); } - else + else { - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, SDOXMLString(sl.get(j)->getProperty().getName()), SDOXMLString(dob->objectToXPath())); } } else { - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, SDOXMLString(sl.get(j)->getProperty().getName()), SDOXMLString("")); } @@ -211,29 +211,29 @@ ////////////////////////////////////////////////////////////////////////// // Write Change Summary elements ////////////////////////////////////////////////////////////////////////// - + void SDOXMLWriter::handleChangeSummaryElements( - ChangeSummaryPtr cs, + ChangeSummaryPtr cs, DataObjectPtr dob) { int rc; SettingList& sl = cs->getOldValues(dob); - - if (sl.size() == 0) + + if (sl.size() == 0) { // there are no setting for this element. return; } - + for (int j=0;j< sl.size(); j++) { - try + try { // single values will have been covered by the attributes. if (!sl.get(j)->getProperty().isMany()) continue; - + if (sl.get(j)->getProperty().getType().isDataType()) { @@ -241,12 +241,12 @@ writer, SDOXMLString(sl.get(j)->getProperty().getName()), SDOXMLString(sl.get(j)->getCStringValue())); - + } // if datatype else { DataObjectPtr dob2 = sl.get(j)->getDataObjectValue(); - if (!dob2) + if (!dob2) { continue; } @@ -266,14 +266,14 @@ rc = xmlTextWriterEndElement( writer); } - } + } } catch (SDORuntimeException e) { // ignore this element } } // for - } + } ////////////////////////////////////////////////////////////////////////// @@ -281,42 +281,42 @@ ////////////////////////////////////////////////////////////////////////// void SDOXMLWriter::handleChangeSummaryDeletedObject( - const char* name, - ChangeSummaryPtr cs, + const char* name, + ChangeSummaryPtr cs, DataObjectPtr dob) { - + int rc, k; // TODO error handling - + SettingList& sl = cs->getOldValues(dob); - + rc = xmlTextWriterStartElement( writer, SDOXMLString(name)); - if (sl.size() == 0) + if (sl.size() == 0) { - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, SDOXMLString("sdo:ref"), SDOXMLString(cs->getOldXpath(dob))); rc = xmlTextWriterEndElement(writer); return; } - - try + + try { // print single valued datatypes as attributes - + for (int j=0;j< sl.size(); j++) { - //if (!sl.get(j)->isSet()) + //if (!sl.get(j)->isSet()) //{ // // unset properties dont need recording - ah but they do! // // continue; //} - if ( sl.get(j)->getProperty().isMany()) + if ( sl.get(j)->getProperty().isMany()) { // manys are elements continue; @@ -327,16 +327,16 @@ continue; } - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, SDOXMLString(sl.get(j)->getProperty().getName()), SDOXMLString(sl.get(j)->getCStringValue())); } // for attributes - - - // now we are onto the many-values, + + + // now we are onto the many-values, // and dataobject single values. - // + // // handle deletions within deletions in reverse order, so they match the // deletion records above. @@ -344,7 +344,7 @@ { if ( !sl.get(k)->getProperty().getType().isDataType() && - sl.get(k)->getProperty().isMany()) + sl.get(k)->getProperty().isMany()) { // its a dataobject type DataObjectPtr dob2 = sl.get(k)->getDataObjectValue(); @@ -360,7 +360,7 @@ if ( !sl.get(k)->getProperty().getType().isDataType()) { - if (sl.get(k)->getProperty().isMany()) continue; + if (sl.get(k)->getProperty().isMany()) continue; // its a single valued dataobject type DataObjectPtr dob2 = sl.get(k)->getDataObjectValue(); @@ -370,13 +370,13 @@ getProperty().getName(),cs,dob2); } - else + else { - if ( !sl.get(k)->getProperty().isMany()) continue; - + if ( !sl.get(k)->getProperty().isMany()) continue; + // could only be many valued data type - - rc = xmlTextWriterWriteElement(writer, + + rc = xmlTextWriterWriteElement(writer, SDOXMLString(sl.get(k)->getProperty().getName()), SDOXMLString(sl.get(k)->getCStringValue())); } @@ -388,7 +388,7 @@ } rc = xmlTextWriterEndElement(writer); - } + } ////////////////////////////////////////////////////////////////////////// @@ -396,14 +396,14 @@ ////////////////////////////////////////////////////////////////////////// void SDOXMLWriter::handleSummaryChange( - const SDOXMLString& elementName, - ChangeSummaryPtr cs, + const SDOXMLString& elementName, + ChangeSummaryPtr cs, DataObjectPtr dob) { - int rc; + int rc; DataObject* temp = dob; const char* name; - try + try { name = temp->getContainmentProperty().getName(); } @@ -411,9 +411,9 @@ { // This could be a root, and have no name. name = 0; - } + } - if (name == 0) + if (name == 0) { rc = xmlTextWriterStartElement( writer, @@ -432,7 +432,7 @@ return; } - try + try { name = temp->objectToXPath(); } @@ -441,7 +441,7 @@ name = 0; } - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, SDOXMLString("sdo:ref"), SDOXMLString(name)); @@ -462,16 +462,21 @@ ChangeSummaryPtr cs) { int i; - int rc; + int rc; ChangedDataObjectList& changedDOs = cs->getChangedDataObjects(); + rc = xmlTextWriterStartElementNS(writer, + SDOXMLString("sdo"), SDOXMLString("changeSummary"), SDOXMLString(Type::SDOTypeNamespaceURI)); + if (rc != 0) return; + if (cs->isLogging()) + { + rc = xmlTextWriterWriteAttribute(writer, + SDOXMLString("logging"), + SDOXMLString("true")); + } + if (changedDOs.size() > 0) { - rc = xmlTextWriterStartElementNS(writer, - SDOXMLString("sdo"), SDOXMLString("changeSummary"), SDOXMLString(Type::SDOTypeNamespaceURI)); - - // Fall at the first hurdle - dont write anything. - if (rc != 0) return; // write the creates/deletes in the order they // happened, as elements. @@ -479,13 +484,13 @@ for (i=0;i< changedDOs.size();i++) { if (cs->isCreated(changedDOs[i]) - && changedDOs.getType(i) == ChangedDataObjectList::Create) + && changedDOs.getType(i) == ChangedDataObjectList::Create) { // TODO - should work out if theres a IDREF here // TODO - can we have more than one create like this? try { - rc = xmlTextWriterWriteElement(writer, + rc = xmlTextWriterWriteElement(writer, SDOXMLString("create"), SDOXMLString(changedDOs[i]->objectToXPath())); } @@ -495,12 +500,12 @@ } } if (cs->isDeleted(changedDOs[i]) - && changedDOs.getType(i) == ChangedDataObjectList::Delete) + && changedDOs.getType(i) == ChangedDataObjectList::Delete) { // TODO - should work out if theres a IDREF here - try + try { - rc = xmlTextWriterWriteElement(writer, + rc = xmlTextWriterWriteElement(writer, SDOXMLString("delete"), SDOXMLString(cs->getOldXpath(changedDOs[i]))); } @@ -511,14 +516,7 @@ } } - if (cs->isLogging()) - { - rc = xmlTextWriterWriteAttribute(writer, - SDOXMLString("logging"), - SDOXMLString("true")); - } - - + for (i=0;i< changedDOs.size();i++) { if (cs->isModified(changedDOs[i])) @@ -527,20 +525,19 @@ } } - rc = xmlTextWriterEndElement(writer); - - } + } + rc = xmlTextWriterEndElement(writer); } - + ////////////////////////////////////////////////////////////////////////// // Add to namespaces ////////////////////////////////////////////////////////////////////////// - + void SDOXMLWriter::addToNamespaces(DataObjectImpl* dob) { std::map<SDOXMLString,SDOXMLString>::iterator it; SDOXMLString uri = dob->getType().getURI(); - + it = namespaceMap.find(uri); if (it == namespaceMap.end()) { @@ -575,7 +572,7 @@ if (d != 0)addToNamespaces(d); } else - { + { XSDPropertyInfo* pi = getPropertyInfo(dob->getType(), pl[i]); if (pi) { @@ -583,10 +580,10 @@ propdef = pi->getPropertyDefinition(); if (propdef.isElement)continue; if (!propdef.isQName)continue; - + SDOXMLString propertyValue = (dob->getCString(pl[i])); XMLQName qname(propertyValue); - + it = namespaceMap.find(qname.getURI()); if (it == namespaceMap.end()) { @@ -600,14 +597,14 @@ } } } - - - + + + ////////////////////////////////////////////////////////////////////////// // Write a DatObject tree ////////////////////////////////////////////////////////////////////////// - + int SDOXMLWriter::writeDO( DataObjectPtr dataObject, const SDOXMLString& elementURI, @@ -638,16 +635,16 @@ { if (dataObject->isNull("")) { - rc = xmlTextWriterStartElementNS(writer, + rc = xmlTextWriterStartElementNS(writer, NULL, elementName, elementURI); - if (rc < 0) + if (rc < 0) { - SDO_THROW_EXCEPTION("writeDO", - SDOXMLParserException, + SDO_THROW_EXCEPTION("writeDO", + SDOXMLParserException, "xmlTextWriterStartElementNS failed"); - } - rc = xmlTextWriterWriteAttribute(writer, - (const unsigned char*)"xsi:nil", + } + rc = xmlTextWriterWriteAttribute(writer, + (const unsigned char*)"xsi:nil", (const unsigned char*)"true"); rc = xmlTextWriterEndElement(writer); } @@ -667,7 +664,7 @@ return 0; } - + //namespaceStack.push(namespaces); @@ -706,23 +703,23 @@ rc = xmlTextWriterStartElementNS(writer, NULL, theName, NULL); if (rc < 0) { SDO_THROW_EXCEPTION("writeDO", SDOXMLParserException, "xmlTextWriterStartElementNS failed"); - } + } } - + if (writeXSIType) { - rc = xmlTextWriterWriteAttributeNS(writer, - SDOXMLString("xsi"), SDOXMLString("type"), + rc = xmlTextWriterWriteAttributeNS(writer, + SDOXMLString("xsi"), SDOXMLString("type"), NULL, - /*SDOXMLString("http://www.w3.org/2001/XMLSchema-instance"),*/ + /*SDOXMLString("http://www.w3.org/2001/XMLSchema-instance"),*/ SDOXMLString(dataObject->getType().getName())); if (isRoot) { namespaceMap.insert(make_pair( SDOXMLString("http://www.w3.org/2001/XMLSchema-instance"), SDOXMLString("xsi"))); - + } } @@ -738,7 +735,7 @@ DataObjectImpl* d = (DataObjectImpl*)(DataObject*)dataObject; spacescount = 1; addToNamespaces(d); - + ///////////////////////////////////////////////////////////////////////////////////// // // build the namespace map, and write the items out at the // // top of the tree. @@ -748,7 +745,7 @@ // { // TypeList types = (d->getDataFactory())->getTypes(); // std::map<SDOXMLString,SDOXMLString>::iterator it; -// +// // for (int i = 0; i<types.size(); i++) // { // SDOXMLString uri = types[i].getURI(); @@ -757,7 +754,7 @@ // if (it == namespaceMap.end()) // { // char buf[4]; -// if (!elementURI.isNull()) +// if (!elementURI.isNull()) // { // if (elementURI.equals(uri)) // { @@ -774,7 +771,7 @@ // } // } //////////////////////////////////////////////////////////////////////////////////// - + for (it = namespaceMap.begin();it != namespaceMap.end(); ++it) { if ((*it).first.equals("")) continue; @@ -790,7 +787,7 @@ // and the property is not one of the declared properties ////////////////////////////////////////////////////////////////////////// DataObject* dob = dataObject; - DataObjectImpl* cont = + DataObjectImpl* cont = ((DataObjectImpl*)dob)->getContainerImpl(); if (cont != 0) { @@ -798,20 +795,20 @@ { //if (dataObject->getType().getURI() != 0) //{ - // std::string value = + // std::string value = // dataObject->getType().getURI(); // value += ":"; // value += dataObject->getType().getName(); - // rc = xmlTextWriterWriteAttribute(writer, - // (const unsigned char*)"xsi:type", + // rc = xmlTextWriterWriteAttribute(writer, + // (const unsigned char*)"xsi:type", // (const unsigned char*)value.c_str()); //} //else //{ if (cont->getTypeImpl().getPropertyImpl(elementName) == 0) { - rc = xmlTextWriterWriteAttribute(writer, - (const unsigned char*)"xsi:type", + rc = xmlTextWriterWriteAttribute(writer, + (const unsigned char*)"xsi:type", (const unsigned char*)dataObject->getType().getName()); } } @@ -820,8 +817,8 @@ // write nil if required if (dataObject->isNull("")) { - rc = xmlTextWriterWriteAttribute(writer, - (const unsigned char*)"xsi:nil", + rc = xmlTextWriterWriteAttribute(writer, + (const unsigned char*)"xsi:nil", (const unsigned char*)"true"); } @@ -835,7 +832,7 @@ for (i = 0; i < pl.size(); i++) { if (dataObject->isSet(pl[i])) - { + { SDOXMLString propertyName(pl[i].getName()); XSDPropertyInfo* pi = getPropertyInfo(dataObjectType, pl[i]); PropertyDefinition propdef; @@ -844,15 +841,15 @@ propdef = pi->getPropertyDefinition(); propertyName = propdef.localname; } - + // Elements are written as <element> if (propdef.isElement) continue; - + // Many-valued properties are written as <element> if (pl[i].isMany()) continue; - + // if (pl[i].isContainment()) // continue; @@ -860,14 +857,14 @@ // Non contained properties become attributes ////////////////////////////////////////////////////////////////////// const Type& propertyType = pl[i].getType(); - + if (propertyType.isDataType()) { SDOXMLString propertyValue = (dataObject->getCString(pl[i])); if (pi && pi->getPropertyDefinition().isQName) { XMLQName qname(propertyValue); - + //{ //const SDOXMLString* prefix = namespaces.findPrefix(qname.getURI()); //if (prefix == 0) @@ -887,19 +884,19 @@ { propertyValue = (*it).second + ":" + qname.getLocalName(); } - else + else { char buffer[20]; SDOXMLString pref = "tnss"; sprintf(buffer, "%d", j++); pref += buffer; - rc = xmlTextWriterWriteAttributeNS(writer, + rc = xmlTextWriterWriteAttributeNS(writer, SDOXMLString("xmlns"), pref, NULL, qname.getURI()); propertyValue = pref + ":" + qname.getLocalName(); } - + } - rc = xmlTextWriterWriteAttribute(writer, + rc = xmlTextWriterWriteAttribute(writer, propertyName, propertyValue); } else @@ -912,7 +909,7 @@ } } } - + // -------------------- // Handle ChangeSummary // -------------------- @@ -924,7 +921,7 @@ handleChangeSummary(elementName, changeSummary); } } - + if (dataObjectType.isSequencedType()) { SequencePtr sequence = dataObject->getSequence(); @@ -932,7 +929,7 @@ { for (i=0; i<sequence->size(); i++) { - + if (sequence->isText(i)) { rc = xmlTextWriterWriteString( @@ -946,7 +943,7 @@ const Type& seqPropType = seqProp.getType(); if (seqPropType.isDataObjectType()) - { + { DataObjectPtr doValue; if (seqProp.isMany()) { @@ -980,17 +977,17 @@ writer, seqPropName, SDOXMLString(sequence->getCStringValue(i))); - + } // end DataType } // end - iterate over sequence - + } - + } // end sequence handling - + else { - + ////////////////////////////////////////////////////////////////////////// // Iterate over all the properties to find elements ////////////////////////////////////////////////////////////////////////// @@ -998,7 +995,7 @@ { if (dataObject->isSet(pl[i])) { - + SDOXMLString propertyName(pl[i].getName()); XSDPropertyInfo* pi = getPropertyInfo(dataObjectType, pl[i]); if (pi) @@ -1007,9 +1004,9 @@ continue; propertyName = pi->getPropertyDefinition().localname; } - + const Type& propertyType = pl[i].getType(); - + ////////////////////////////////////////////////////////////////////// // For a many-valued property get the list of values ////////////////////////////////////////////////////////////////////// @@ -1024,13 +1021,13 @@ writeReference(dataObject, pl[i], true, dol[j]); } else - { + { SDOXMLString typeURI = dol[j]->getType().getURI(); writeDO(dol[j], dol[j]->getType().getURI(), propertyName); } } } // end IsMany - + ////////////////////////////////////////////////////////////////////// // For a dataobject write the do ////////////////////////////////////////////////////////////////////// @@ -1044,11 +1041,11 @@ } else { - DataObjectPtr propDO = dataObject->getDataObject(pl[i]); + DataObjectPtr propDO = dataObject->getDataObject(pl[i]); writeDO(propDO, propDO->getType().getURI(), propertyName); } } - + ////////////////////////////////////////////////////////////////////// // For a primitive ////////////////////////////////////////////////////////////////////// @@ -1070,16 +1067,16 @@ { if (dataObject->isNull(propertyName)) { - rc = xmlTextWriterStartElementNS(writer, + rc = xmlTextWriterStartElementNS(writer, NULL, elementName, elementURI); - if (rc < 0) + if (rc < 0) { - SDO_THROW_EXCEPTION("writeDO", - SDOXMLParserException, + SDO_THROW_EXCEPTION("writeDO", + SDOXMLParserException, "xmlTextWriterStartElementNS failed"); } - rc = xmlTextWriterWriteAttribute(writer, - (const unsigned char*)"xsi:nil", + rc = xmlTextWriterWriteAttribute(writer, + (const unsigned char*)"xsi:nil", (const unsigned char*)"true"); rc = xmlTextWriterEndElement(writer); } @@ -1106,7 +1103,7 @@ // namespaceUriStack.pop(); //} } - + XSDPropertyInfo* SDOXMLWriter::getPropertyInfo(const Type& type, const Property& property) { if (dataFactory) @@ -1117,11 +1114,11 @@ { return (XSDPropertyInfo*)((DASProperty*)&property)->getDASValue("XMLDAS::PropertyInfo"); } - + } void SDOXMLWriter::writeReference( - DataObjectPtr dataObject, + DataObjectPtr dataObject, const Property& property, bool isElement, DataObjectPtr refferedToObject) @@ -1144,30 +1141,30 @@ refValue = reffedObject->getCString(typeDef.IDPropertyName); } } - + if (refValue.isNull()) { // need to get XPATH refValue = ((DataObjectImpl*)(DataObject*)reffedObject)->objectToXPath(); } - + if (!refValue.isNull()) { if (isElement) { // Set the IDREF value - xmlTextWriterWriteElement(writer, + xmlTextWriterWriteElement(writer, SDOXMLString(property.getName()), refValue); } else { // Set the IDREF value - xmlTextWriterWriteAttribute(writer, + xmlTextWriterWriteAttribute(writer, SDOXMLString(property.getName()), refValue); } } - } - + } + } // End - namespace sdo } // End - namespace commonj http://cvs.php.net/viewcvs.cgi/pecl/sdo/tests/SDOAPITest.php?r1=1.8&r2=1.9&diff_format=u Index: pecl/sdo/tests/SDOAPITest.php diff -u pecl/sdo/tests/SDOAPITest.php:1.8 pecl/sdo/tests/SDOAPITest.php:1.9 --- pecl/sdo/tests/SDOAPITest.php:1.8 Mon Feb 20 18:50:26 2006 +++ pecl/sdo/tests/SDOAPITest.php Fri Mar 17 16:43:47 2006 @@ -68,7 +68,7 @@ // Create the types $this->dmsDf->addType(ROOT_NS, ROOT_TYPE); - $this->dmsDf->addType(COMPANY_NS, COMPANY_TYPE, array('sequenced'=>'true')); + $this->dmsDf->addType(COMPANY_NS, COMPANY_TYPE, array('sequenced'=>true)); $this->dmsDf->addType(COMPANY_NS, DEPARTMENT_TYPE); $this->dmsDf->addType(COMPANY_NS, EMPLOYEE_TYPE); @@ -439,6 +439,7 @@ $this->assertEquals($acme->name, $it_parent->name, 'Container test 2b failed;'); $this->assertEquals($shoe, $sue_parent, 'Container test 2c failed;'); $this->assertEquals($it, $ron_parent, 'Container test 2d failed;'); + $this->assertEquals($it, $acme->employeeOfTheMonth->getContainer(), 'Container test 2e failed;'); } public function testList() { @@ -1156,6 +1157,10 @@ $this->assertTrue($do_property->isContainment(), 'Unexpected value for SDO_Model_Property->isContainment()'); $this->assertNull($do_property->getOpposite(), 'Unexpected value for SDO_Model_Property->getOpposite()'); + $eotm_property = $do_type->getProperty('employeeOfTheMonth'); + $this->assertFalse($eotm_property->isMany(), 'Unexpected value for SDO_Model_Property->isMany()'); + $this->assertFalse($eotm_property->isContainment(), 'Unexpected value for SDO_Model_Property->isContainment()'); + $all_props = $do_type->getProperties(); $this->assertEquals(count($all_props), count($this->company), 'Different number of properties in reflected data object');
« previous php.pecl.cvs (#5486) next »