[cig-commits] r4330 - in long/3D/Gale/trunk/src/StGermain: .
Base/IO/src Base/IO/tests
walter at geodynamics.org
walter at geodynamics.org
Thu Aug 17 17:17:24 PDT 2006
Author: walter
Date: 2006-08-17 17:17:23 -0700 (Thu, 17 Aug 2006)
New Revision: 4330
Modified:
long/3D/Gale/trunk/src/StGermain/
long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.c
long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.h
long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.c
long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.h
long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.c
long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.h
long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.c
long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.h
long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.c
long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.h
long/3D/Gale/trunk/src/StGermain/Base/IO/src/types.h
long/3D/Gale/trunk/src/StGermain/Base/IO/tests/testIO_Handler-normal.c
Log:
r2708 at earth: boo | 2006-08-17 17:14:21 -0700
r2662 at earth (orig r3743): KentHumphries | 2006-08-02 20:14:38 -0700
Modified Dictionary entries to also contain a source attribute. ie the Dictionary_Entry struct is now:
Dictionary_Entry{
Dictionary_Entry_Key name,
Dictionary_Entry_Value* value,
Dictionary_Entry_Source source
}
The source attribute is used by the composer to store the xml file from which the dictionary entry was created.
For example:
<struct name="components" source="../Components/components.xml">
</struct>
So that regular behaviour is not disrupted, xml structs/params/lists without source attributes are parsed with NO source information. ie: dict_entry = {name="component", value=0x032840, source=NULL}. Functions for handling dicionary_entries with source attributes were added in addition to existing functions (except XML_IO_Handler_WriteEntryToFile which has a Dictionary_Entry_Source argument added - this argument may be NULL).
testIO_Handler-normal.c is the only portion of the code to be affected -> testing the XML_IO_Handler_WriteEntryToFile function which now takes a Dictionary_Entry_Source argument (which may be NULL).
Property changes on: long/3D/Gale/trunk/src/StGermain
___________________________________________________________________
Name: svk:merge
- 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2707
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3742
+ 1ef209d2-b310-0410-a72d-e20c9eb0015c:/cig:2708
afb6c753-b9d0-0310-b4e7-dbd8d91cdd35:/trunk/StGermain:3743
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.c 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.c 2006-08-18 00:17:23 UTC (rev 4330)
@@ -54,8 +54,8 @@
static const int STRUCT_DELTA = 2;
Dictionary* Dictionary_New( void ) {
- return _Dictionary_New( sizeof(Dictionary), Dictionary_Type, _Dictionary_Delete, _Dictionary_Print, NULL, _Dictionary_Add,
- _Dictionary_Set, _Dictionary_Get );
+ return _Dictionary_New( sizeof(Dictionary), Dictionary_Type, _Dictionary_Delete, _Dictionary_Print, NULL,
+ _Dictionary_Add, _Dictionary_AddWithSource, _Dictionary_Set, _Dictionary_SetWithSource, _Dictionary_Get, _Dictionary_GetSource );
}
Dictionary* _Dictionary_New(
@@ -65,8 +65,11 @@
Stg_Class_PrintFunction* _print,
Stg_Class_CopyFunction* _copy,
Dictionary_AddFunction* add,
+ Dictionary_AddWithSourceFunction* addWithSource,
Dictionary_SetFunction* set,
- Dictionary_GetFunction* get)
+ Dictionary_SetWithSourceFunction* setWithSource,
+ Dictionary_GetFunction* get,
+ Dictionary_GetSourceFunction getSource)
{
Dictionary* self;
@@ -78,8 +81,11 @@
/* virtual functions */
self->add = add;
+ self->addWithSource = addWithSource;
self->set = set;
+ self->setWithSource = setWithSource;
self->get = get;
+ self->getSource = getSource;
/* Dictionary info */
_Dictionary_Init( self );
@@ -98,8 +104,11 @@
self->_print = _Dictionary_Print;
self->_delete = _Dictionary_Delete;
self->add = _Dictionary_Add;
+ self->addWithSource = _Dictionary_AddWithSource;
self->set = _Dictionary_Set;
+ self->setWithSource = _Dictionary_SetWithSource;
self->get = _Dictionary_Get;
+ self->getSource = _Dictionary_GetSource;
_Stg_Class_Init( (Stg_Class*)self );
/* Dictionary info */
@@ -175,6 +184,13 @@
self->add( dictionary, key, value );
}
+void Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value,
+ Dictionary_Entry_Source source )
+{
+ Dictionary* self = (Dictionary*)dictionary;
+ self->addWithSource( dictionary, key, value, source );
+}
+
Bool Dictionary_Set( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value ) {
Dictionary* self = (Dictionary*)dictionary;
return self->set( dictionary, key, value );
@@ -185,6 +201,11 @@
return self->get( dictionary, key );
}
+Dictionary_Entry_Source Dictionary_GetSource( void* dictionary, Dictionary_Entry_Key key ) {
+ Dictionary* self = (Dictionary*)dictionary;
+ return self->getSource( dictionary, key );
+}
+
Dictionary_Entry_Value* Dictionary_GetByIndex( void* dictionary, Dictionary_Index index ) {
return _Dictionary_GetByIndex( dictionary, index );
}
@@ -225,6 +246,19 @@
self->count++;
}
+void _Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value,
+ Dictionary_Entry_Source source )
+{
+ Dictionary* self = (Dictionary*) dictionary;
+ assert( self->count <= self->size );
+ if( self->count == self->size ) {
+ self->size += self->delta;
+ self->entryPtr = Memory_Realloc_Array( self->entryPtr, Dictionary_Entry*, self->size );
+ }
+
+ self->entryPtr[self->count] = Dictionary_Entry_NewWithSource( key, value, source );
+ self->count++;
+}
Dictionary_Entry_Value* Dictionary_AddMerge(
void* dictionary,
@@ -325,6 +359,108 @@
return updatedValue;
}
+Dictionary_Entry_Value* Dictionary_AddMergeWithSource(
+ void* dictionary,
+ Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value,
+ Dictionary_MergeType mergeType,
+ Dictionary_Entry_Source source )
+{
+ Dictionary* self = (Dictionary*)dictionary;
+ Dictionary_Entry* existingEntry = Dictionary_GetEntry( self, key );
+ Dictionary_Entry_Value* newValue = value;
+ Dictionary_Entry_Value* updatedValue = value;
+ Dictionary_Entry_Value* curValue;
+
+ if( existingEntry ) {
+ Dictionary_Entry_Value* existingValue = Dictionary_Entry_Get( existingEntry );
+ Index i;
+
+ switch( existingValue->type ) {
+ /* parameters... all behave the same */
+ case Dictionary_Entry_Value_Type_String:
+ case Dictionary_Entry_Value_Type_Double:
+ case Dictionary_Entry_Value_Type_UnsignedInt:
+ case Dictionary_Entry_Value_Type_Int:
+ case Dictionary_Entry_Value_Type_Bool:
+ case Dictionary_Entry_Value_Type_UnsignedLong:
+ case Dictionary_Entry_Value_Type_VoidPtr:
+ switch( mergeType ) {
+ /* "Append", means add to end... default add behaviour */
+ case Dictionary_MergeType_Append:
+ _Dictionary_AddWithSource( dictionary, key, newValue, source );
+ break;
+ /* "Merge" and "Replace" means override */
+ case Dictionary_MergeType_Merge:
+ case Dictionary_MergeType_Replace:
+ Dictionary_Entry_SetWithSource( existingEntry, newValue, source );
+ break;
+ };
+ break;
+ case Dictionary_Entry_Value_Type_Struct:
+ switch( mergeType ) {
+ /* "Append", means add to end... default add behaviour */
+ case Dictionary_MergeType_Append: /* create at end */
+ _Dictionary_AddWithSource( dictionary, key, newValue, source );
+ break;
+ /* "Merge" means for all struct items, add to end... i.e. do nothing here .*/
+ case Dictionary_MergeType_Merge:
+ for( i = 0; i < newValue->as.typeStruct->count; i++ ) {
+ Dictionary_AddMergeWithSource( existingValue->as.typeStruct,
+ newValue->as.typeStruct->entryPtr[i]->key,
+ newValue->as.typeStruct->entryPtr[i]->value,
+ mergeType, source );
+ }
+
+ newValue->as.typeStruct->count = 0;
+ Stg_Class_Delete( newValue->as.typeStruct );
+ Memory_Free( newValue );
+ updatedValue = existingValue;
+ break;
+ /* "Replace" means remove current entry and create a newey */
+ case Dictionary_MergeType_Replace:
+ Dictionary_Entry_SetWithSource( existingEntry, newValue, source );
+ break;
+ };
+ break;
+ case Dictionary_Entry_Value_Type_List:
+ switch( mergeType ) {
+ /* "Append", means add to end... default add behaviour */
+ case Dictionary_MergeType_Append: /* create at end */
+ _Dictionary_AddWithSource( dictionary, key, newValue, source );
+ break;
+ /* "Merge": 2 different cases... */
+ /* means for all list items, add to end... i.e. do nothing here .*/
+ case Dictionary_MergeType_Merge:
+ curValue = newValue->as.typeList->first;
+ for( i = 0; i < newValue->as.typeList->count; i++ ) {
+ Dictionary_Entry_Value_AddElementWithSource( existingValue, curValue,
+ source );
+ curValue = curValue->next;
+ }
+
+ Memory_Free( newValue );
+ updatedValue = existingValue;
+ break;
+ /* "Replace" means remove current entry and create a newey */
+ case Dictionary_MergeType_Replace:
+ Dictionary_Entry_SetWithSource( existingEntry, newValue, source );
+ break;
+ };
+ break;
+ default:
+ Journal_Firewall( False, Journal_Register( Error_Type, self->type ),
+ "Error in func %s: Bad existingValue type '%u'\n", __func__, existingValue->type );
+ break;
+ }
+ }
+ else {
+ _Dictionary_AddWithSource( self, key, value, source );
+ }
+
+ return updatedValue;
+}
+
Bool _Dictionary_Set( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value ) {
Dictionary* self = (Dictionary*) dictionary;
Dictionary_Index index;
@@ -342,6 +478,25 @@
return True;
}
+Bool _Dictionary_SetWithSource( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value,
+ Dictionary_Entry_Source source )
+{
+ Dictionary* self = (Dictionary*) dictionary;
+ Dictionary_Index index;
+
+ for( index = 0; index < self->count; index++ ) {
+ if( Dictionary_Entry_CompareWithSource( self->entryPtr[index], key, source ) != 0 ) {
+ Dictionary_Entry_SetWithSource( self->entryPtr[index], value, source );
+ return True;
+ }
+ }
+
+ /* If we reach here and haven't found it, add new entry */
+ Dictionary_AddWithSource( self, key, value, source );
+
+ return True;
+}
+
Dictionary_Entry_Value* _Dictionary_Get( void* dictionary, Dictionary_Entry_Key key ) {
Dictionary* self = (Dictionary*) dictionary;
Dictionary_Index index;
@@ -354,6 +509,19 @@
return 0;
}
+Dictionary_Entry_Source _Dictionary_GetSource( void* dictionary, Dictionary_Entry_Key key) {
+ Dictionary* self = (Dictionary*) dictionary;
+ Dictionary_Index index;
+
+ for( index = 0; index < self->count; index++ ) {
+ if( Dictionary_Entry_Compare( self->entryPtr[index], key ) != 0 ) {
+ return Dictionary_Entry_GetSource( self->entryPtr[index] );
+ }
+ }
+ return 0;
+}
+
+
Dictionary_Entry_Value* _Dictionary_GetByIndex( void* dictionary, Dictionary_Index index ) {
Dictionary* self = (Dictionary*) dictionary;
return Dictionary_Entry_Get(self->entryPtr[index]);
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.h 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary.h 2006-08-18 00:17:23 UTC (rev 4330)
@@ -66,8 +66,13 @@
/* Virtual Function pointers */
typedef void (Dictionary_AddFunction) (void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
+ typedef void (Dictionary_AddWithSourceFunction) (void* dictionary, Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
typedef Bool (Dictionary_SetFunction) (void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
+ typedef Bool (Dictionary_SetWithSourceFunction) (void* dictionary, Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
typedef Dictionary_Entry_Value* (Dictionary_GetFunction) (void* dictionary, Dictionary_Entry_Key key );
+ typedef Dictionary_Entry_Source (Dictionary_GetSourceFunction) (void* dictionary, Dictionary_Entry_Key key );
/** \def __Dictionary See Dictionary */
#define __Dictionary \
@@ -76,8 +81,11 @@
\
/* Virtual info */ \
Dictionary_AddFunction* add; \
+ Dictionary_AddWithSourceFunction* addWithSource; \
Dictionary_SetFunction* set; \
+ Dictionary_SetWithSourceFunction* setWithSource; \
Dictionary_GetFunction* get; \
+ Dictionary_GetSourceFunction* getSource; \
\
/* Dictionary info */ \
Dictionary_Index size; \
@@ -104,8 +112,11 @@
Stg_Class_PrintFunction* _print,
Stg_Class_CopyFunction* _copy,
Dictionary_AddFunction* add,
+ Dictionary_AddWithSourceFunction* addWithSource,
Dictionary_SetFunction* set,
- Dictionary_GetFunction* get);
+ Dictionary_SetWithSourceFunction* setWithSource,
+ Dictionary_GetFunction* get,
+ Dictionary_GetSourceFunction* getSource);
/** Initialises a Dictionary. */
void Dictionary_Init( Dictionary* self );
@@ -124,6 +135,10 @@
/** Add an entry to the dictionary... orignal implementation... appends keys */
void Dictionary_Add( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
+
+ /** Add an entry to the dictionary... orignal implementation... appends keys, with source file */
+ void Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
/** Add an entry to the dictionary... specifying how the entry values are merged if key present already */
Dictionary_Entry_Value* Dictionary_AddMerge(
@@ -132,12 +147,27 @@
Dictionary_Entry_Value* value,
Dictionary_MergeType mergeType );
+ /** Add an entry to the dictionary... specifying how the entry values are merged if key present already */
+ Dictionary_Entry_Value* Dictionary_AddMergeWithSource(
+ void* dictionary,
+ Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value,
+ Dictionary_MergeType mergeType,
+ Dictionary_Entry_Source source );
+
/** Set a value in the dictionary */
Bool Dictionary_Set( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
+ /** Set a value in the dictionary */
+ Bool Dictionary_SetWithSource( void* dictionary, Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+
/** Get a value from the dictionary */
Dictionary_Entry_Value* Dictionary_Get( void* dictionary, Dictionary_Entry_Key key );
+ /** Get a source from the dictionary */
+ Dictionary_Entry_Source Dictionary_GetSource( void* dictionary, Dictionary_Entry_Key key );
+
/** Get a value from the dictionary by index */
Dictionary_Entry_Value* Dictionary_GetByIndex( void* dictionary, Dictionary_Index index );
@@ -148,12 +178,23 @@
/** Add an entry to the dictionary implementation */
void _Dictionary_Add( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
+ /** Add an entry to the dictionary implementation */
+ void _Dictionary_AddWithSource( void* dictionary, Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+
/** Set a value in the dictionary implementation */
Bool _Dictionary_Set( void* dictionary, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
+ /** Set a value in the dictionary implementation */
+ Bool _Dictionary_SetWithSource( void* dictionary, Dictionary_Entry_Key key,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+
/** Get a value from the dictionary implementation */
Dictionary_Entry_Value* _Dictionary_Get( void* dictionary, Dictionary_Entry_Key key );
+ /** Get a source from the dictionary implementation */
+ Dictionary_Entry_Source _Dictionary_GetSource( void* dictionary, Dictionary_Entry_Key key );
+
Dictionary_Entry_Value* _Dictionary_GetByIndex( void* dictionary, Dictionary_Index index );
/** Get an entry from the dictionary */
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.c 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.c 2006-08-18 00:17:23 UTC (rev 4330)
@@ -53,19 +53,45 @@
return self;
}
+Dictionary_Entry* Dictionary_Entry_NewWithSource( Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source )
+{
+ Dictionary_Entry* self;
+
+ self = Memory_Alloc( Dictionary_Entry, "Entry" );
+ Dictionary_Entry_InitWithSource( self, key, value, source );
+
+ return self;
+}
+
void Dictionary_Entry_Init( Dictionary_Entry* self, Dictionary_Entry_Key key, Dictionary_Entry_Value* value )
{
assert( key );
assert( value );
+
+ self->key = StG_Strdup( key );
+ self->value = value;
+ self->source = NULL;
+}
+
+void Dictionary_Entry_InitWithSource( Dictionary_Entry* self, Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source )
+{
+ assert( key );
+ assert( value );
self->key = StG_Strdup( key );
self->value = value;
+ if( source != NULL )
+ self->source = StG_Strdup( source );
+ else
+ self->source = NULL;
}
void Dictionary_Entry_Delete( Dictionary_Entry* self )
{
Memory_Free( self->key );
Dictionary_Entry_Value_Delete( self->value );
+ if( self->source != NULL )
+ Memory_Free( self->source );
Memory_Free( self );
}
@@ -73,6 +99,8 @@
{
Journal_Printf( stream, "%s: ", self->key );
Dictionary_Entry_Value_Print( self->value, stream );
+ if( self->source != NULL )
+ Journal_Printf( stream, " (original source file: %s)", self->source );
}
Bool Dictionary_Entry_Compare( Dictionary_Entry* self, Dictionary_Entry_Key key )
@@ -80,6 +108,24 @@
return !strcmp( self->key, key );
}
+Bool Dictionary_Entry_CompareWithSource( Dictionary_Entry* self, Dictionary_Entry_Key key, Dictionary_Entry_Source source )
+{
+ if( self->source == NULL )
+ {
+ if( source == NULL )
+ return !strcmp( self->key, key );
+ else
+ return False;
+ }
+ else
+ {
+ if( source == NULL )
+ return False;
+ else
+ return ( !strcmp( self->key, key ) && !strcmp( self->source, source ) );
+ }
+}
+
void Dictionary_Entry_Set( Dictionary_Entry* self, Dictionary_Entry_Value* value )
{
assert( value );
@@ -87,9 +133,24 @@
self->value = value;
}
+void Dictionary_Entry_SetWithSource( Dictionary_Entry* self, Dictionary_Entry_Value* value, Dictionary_Entry_Source source )
+{
+ assert( value );
+ Dictionary_Entry_Value_Delete( self->value );
+ self->value = value;
+
+ if( self->source != NULL )
+ Memory_Free( self->source );
+ if( source != NULL )
+ self->source = StG_Strdup( source );
+}
+
Dictionary_Entry_Value* Dictionary_Entry_Get( Dictionary_Entry* self )
{
return self->value;
}
-
+Dictionary_Entry_Source Dictionary_Entry_GetSource( Dictionary_Entry* self )
+{
+ return self->source;
+}
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.h 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry.h 2006-08-18 00:17:23 UTC (rev 4330)
@@ -9,6 +9,7 @@
** Siew-Ching Tan, Software Engineer, VPAC. (siew at vpac.org)
** Alan H. Lo, Computational Engineer, VPAC. (alan at vpac.org)
** Raquibul Hassan, Computational Engineer, VPAC. (raq at vpac.org)
+** Kent Humphries, Software Engineer, VPAC. (kenth at vpac.org)
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
@@ -33,10 +34,11 @@
**
** <b>Comments:</b>
** - A copy of the entry key is created and deleted internally.
+** - If not NULL, a copy of the originalSource is created and deleted internally.
** - Assumes ownership of the entry value, and will destroy it when Dictionary_Entry_Delete() is called.
**
** <b>Description:</b>
-** A data structure which holds a key-value pair for a dictionary.
+** A data structure which holds a key-value-originalSource (third may be NULL) triplet for a dictionary.
**
** $Id$
**
@@ -48,31 +50,51 @@
/** \def __Dictionary_Entry See Dictionary_Entry */
#define __Dictionary_Entry \
Dictionary_Entry_Key key; \
- Dictionary_Entry_Value* value;
+ Dictionary_Entry_Value* value; \
+ Dictionary_Entry_Source source;
+
struct _Dictionary_Entry { __Dictionary_Entry };
+
+ /** Constant value used for Dictionary_Entry source when no source file was specified */
+ #define NO_SOURCEFILE "created_in_code"
/** Create a new Dictionary_Entry (assumes ownership of the value) */
Dictionary_Entry* Dictionary_Entry_New( Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
-
+
+ /** Create a new Dictionary_Entry with a source file (assumes ownership of the value) */
+ Dictionary_Entry* Dictionary_Entry_NewWithSource( Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+
/** Initialise a Dictionary_Entry (assumes ownership of the value) */
void Dictionary_Entry_Init( Dictionary_Entry* self, Dictionary_Entry_Key key, Dictionary_Entry_Value* value );
+ /** Initialise a Dictionary_Entry with a source file (assumes ownership of the value) */
+ void Dictionary_Entry_InitWithSource( Dictionary_Entry* self, Dictionary_Entry_Key key, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+
/** Destroy a Dictionary_Entry instance */
void Dictionary_Entry_Delete( Dictionary_Entry* self );
/** Print the contents of a Dictionary_Entry construct */
void Dictionary_Entry_Print( Dictionary_Entry* self, Stream* stream );
-
+
/** Compare a Dictionary_Entry to a key */
Bool Dictionary_Entry_Compare( Dictionary_Entry* self, Dictionary_Entry_Key key );
-
+
+ /** Compare a Dictionary_Entry to a key, and source */
+ Bool Dictionary_Entry_CompareWithSource( Dictionary_Entry* self, Dictionary_Entry_Key key, Dictionary_Entry_Source source );
+
/** Set/Replace an entry's value (assumes ownership of the value) */
void Dictionary_Entry_Set( Dictionary_Entry* self, Dictionary_Entry_Value* value );
+ /** Set/Replace an entry's value with new source file (assumes ownership of the value) */
+ void Dictionary_Entry_SetWithSource( Dictionary_Entry* self, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
+
/** Get an entry's value */
Dictionary_Entry_Value* Dictionary_Entry_Get( Dictionary_Entry* self );
+
+ /** Get an entry's originalSource */
+ Dictionary_Entry_Source Dictionary_Entry_GetSource( Dictionary_Entry* self );
#endif /* __Base_IO_Dictionary_Entry_h__ */
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.c 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.c 2006-08-18 00:17:23 UTC (rev 4330)
@@ -288,6 +288,11 @@
self->as.typeStruct->add( self->as.typeStruct, name, value);
}
+void Dictionary_Entry_Value_AddMemberWithSource( Dictionary_Entry_Value* self, Dictionary_Entry_Key name,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source )
+{
+ self->as.typeStruct->addWithSource( self->as.typeStruct, name, value, source);
+}
void Dictionary_Entry_Value_AddElement( Dictionary_Entry_Value* self, Dictionary_Entry_Value* element )
{
@@ -338,6 +343,56 @@
}
+void Dictionary_Entry_Value_AddElementWithSource( Dictionary_Entry_Value* self, Dictionary_Entry_Value* element,
+ Dictionary_Entry_Source source )
+{
+ /* check type - convert to a list if not so... */
+ if (Dictionary_Entry_Value_Type_List != self->type) {
+ Dictionary_Entry_Value* copy;
+
+ switch (self->type) {
+ case Dictionary_Entry_Value_Type_String:
+ copy = Dictionary_Entry_Value_FromString( self->as.typeString );
+ break;
+ case Dictionary_Entry_Value_Type_Double:
+ copy = Dictionary_Entry_Value_FromDouble( self->as.typeDouble );
+ break;
+ case Dictionary_Entry_Value_Type_UnsignedInt:
+ copy = Dictionary_Entry_Value_FromUnsignedInt( self->as.typeUnsignedInt );
+ break;
+ case Dictionary_Entry_Value_Type_Int:
+ copy = Dictionary_Entry_Value_FromInt( self->as.typeInt );
+ break;
+ case Dictionary_Entry_Value_Type_UnsignedLong:
+ copy = Dictionary_Entry_Value_FromUnsignedLong( self->as.typeUnsignedLong );
+ break;
+ case Dictionary_Entry_Value_Type_Bool:
+ copy = Dictionary_Entry_Value_FromBool( self->as.typeBool );
+ break;
+ case Dictionary_Entry_Value_Type_Struct:
+ copy = Dictionary_Entry_Value_NewStruct();
+ copy->as.typeStruct = self->as.typeStruct;
+ break;
+ default: {
+ Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
+ Journal_Firewall( False, errorStream, "In func %s: self->type '%d' is invalid.\n", __func__, self->type );
+ }
+ }
+
+ Dictionary_Entry_Value_SetNewList( self );
+ Dictionary_Entry_Value_AddElementWithSource( self, copy, source );
+ }
+
+ if (!self->as.typeList->first) {
+ self->as.typeList->first = element;
+ } else {
+ self->as.typeList->last->next = element;
+ }
+ self->as.typeList->last = element;
+ self->as.typeList->count++;
+}
+
+
void Dictionary_Entry_Value_Delete( Dictionary_Entry_Value* self ) {
Dictionary_Entry_Value_DeleteContents( self );
Memory_Free( self );
@@ -1006,3 +1061,27 @@
Journal_Firewall( False, errorStream, "In func %s: self->type '%d' is invalid.\n", __func__, self->type );
};
}
+
+
+void Dictionary_Entry_Value_SetMemberWithSource( Dictionary_Entry_Value* self,
+ Dictionary_Entry_Key name, Dictionary_Entry_Value* member, Dictionary_Entry_Source source ) {
+ Stream* errorStream = Journal_Register( Error_Type, "Dictionary_Entry_Value" );
+
+ switch( self->type ) {
+ case Dictionary_Entry_Value_Type_Struct:
+ self->as.typeStruct->setWithSource( self->as.typeStruct, name, member, source );
+ return;
+ case Dictionary_Entry_Value_Type_List:
+ case Dictionary_Entry_Value_Type_String:
+ case Dictionary_Entry_Value_Type_Bool:
+ case Dictionary_Entry_Value_Type_Double:
+ case Dictionary_Entry_Value_Type_UnsignedInt:
+ case Dictionary_Entry_Value_Type_Int:
+ case Dictionary_Entry_Value_Type_UnsignedLong:
+ /* should print a warning once journal set up */
+ Journal_Printf( errorStream, "Func %s does not support Dictionary_Entry_Values of type '%d'.\n", __func__, self->type );
+ return;
+ default:
+ Journal_Firewall( False, errorStream, "In func %s: self->type '%d' is invalid.\n", __func__, self->type );
+ };
+}
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.h 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/Dictionary_Entry_Value.h 2006-08-18 00:17:23 UTC (rev 4330)
@@ -138,13 +138,20 @@
void Dictionary_Entry_Value_InitNewList( Dictionary_Entry_Value* );
-
/** Add a member into a struct, with a given value associated with the given key. */
void Dictionary_Entry_Value_AddMember( Dictionary_Entry_Value*, Dictionary_Entry_Key, Dictionary_Entry_Value* );
+ /** Add a member into a struct, with a given value associated with the given key from a given source file. */
+ void Dictionary_Entry_Value_AddMemberWithSource( Dictionary_Entry_Value*, Dictionary_Entry_Key,
+ Dictionary_Entry_Value*, Dictionary_Entry_Source );
+
/** Add an element into a list, with a given value */
void Dictionary_Entry_Value_AddElement( Dictionary_Entry_Value* self, Dictionary_Entry_Value* element );
+ /** Add an element into a list, with a given value */
+ void Dictionary_Entry_Value_AddElementWithSource( Dictionary_Entry_Value* self, Dictionary_Entry_Value* element,
+ Dictionary_Entry_Source source );
+
/** Deletes a Dictionary_Entry_Value */
void Dictionary_Entry_Value_Delete( Dictionary_Entry_Value* self );
@@ -152,7 +159,6 @@
void Dictionary_Entry_Value_Print( Dictionary_Entry_Value* self, Stream* stream );
-
/** Set a dictionary entry value to the given type and value */
void Dictionary_Entry_Value_SetFrom( Dictionary_Entry_Value* self, void* value, char type );
@@ -229,8 +235,12 @@
/** Setting the value of a struct member */
- void Dictionary_Entry_Value_SetMember( Dictionary_Entry_Value* self,
- Dictionary_Entry_Key name, Dictionary_Entry_Value* member );
+ void Dictionary_Entry_Value_SetMember( Dictionary_Entry_Value* self, Dictionary_Entry_Key name,
+ Dictionary_Entry_Value* member );
+
+ /** Setting the value of a struct member from a source file */
+ void Dictionary_Entry_Value_SetMemberWithSource( Dictionary_Entry_Value* self, Dictionary_Entry_Key name,
+ Dictionary_Entry_Value* member, Dictionary_Entry_Source source );
/** Getting/accessing members out of a struct */
Dictionary_Entry_Value* Dictionary_Entry_Value_GetMember( Dictionary_Entry_Value* self, Dictionary_Entry_Key name );
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.c 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.c 2006-08-18 00:17:23 UTC (rev 4330)
@@ -58,6 +58,7 @@
Stg_Class_PrintFunction* _print,
Stg_Class_CopyFunction* _copy,
IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
+ IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
IO_Handler_WriteAllToFileFunction* _writeAllToFile )
{
@@ -71,6 +72,7 @@
/* Virtual functions */
self->_readAllFromFile = _readAllFromFile;
+ self->_readAllFromFileForceSource = _readAllFromFileForceSource;
self->_readAllFromBuffer = _readAllFromBuffer;
self->_writeAllToFile = _writeAllToFile;
@@ -114,6 +116,7 @@
/* Virtual info */
printf( "\t_readAllFromFile (func ptr): %p\n", (void*)self->_readAllFromFile );
+ printf( "\t_readAllFromFileForceSource (func ptr): %p\n", (void*)self->_readAllFromFileForceSource );
printf( "\t_writeAllToFile (func ptr): %p\n", (void*)self->_writeAllToFile );
/* IO_Handler */
@@ -152,6 +155,31 @@
return self->_readAllFromFile( self, filename, dictionary );
}
+/** Read a dictionary entry of a given name from file, include source files in dictionary_Entries. */
+Bool IO_Handler_ReadAllFromFileForceSource( void* io_handler, const char* filename, Dictionary* dictionary )
+{
+ IO_Handler* self = (IO_Handler*) io_handler;
+ Index chr_I;
+
+ for( chr_I = strlen(filename); chr_I > 0; chr_I--)
+ if( filename[chr_I - 1] == '/' )
+ {
+ self->currPath = Memory_Alloc_Array( char, (chr_I + 1), "IO_Handler->currPath" );
+ strncpy(self->currPath, filename, chr_I);
+ self->currPath[chr_I] = 0;
+ break;
+ }
+
+ if( chr_I == 0 )
+ {
+ self->currPath = Memory_Alloc_Array( char, 3, "IO_Handler->currPath" );
+ strcpy(self->currPath, "./");
+ self->currPath[2] = 0;
+ }
+
+ return self->_readAllFromFileForceSource( self, filename, dictionary );
+}
+
/** Read a dictionary entry of a given name from file */
Bool IO_Handler_ReadAllFromBuffer( void* io_handler, const char* buffer, Dictionary* dictionary )
{
@@ -246,6 +274,87 @@
return newDictVal;
} /* IO_Handler_SetAdd */
+/** Add a new dictionary value depending on the parent type, or replace the existing value if found.
+ * if parent is NULL, add as a plain entry. If parent is a list, add as an element to that
+ * list. If parent is a struct, add as a member of that struct. */
+Dictionary_Entry_Value* IO_Handler_DictSetAddValueWithSource(
+ void* io_handler,
+ Dictionary_Entry_Key name,
+ char* newValue,
+ char newDictValType,
+ Dictionary_Entry_Value* parent,
+ Dictionary_MergeType mergeType,
+ Dictionary_Entry_Source source )
+{
+ IO_Handler* self = (IO_Handler*) io_handler;
+ Dictionary_Entry_Value* newDictVal = NULL;
+ #if DEBUG
+ assert( self );
+ #endif
+
+ /* If parent == NULL... then this is being added to no list or struct, but the dictionary itself */
+ if ( NULL == parent ) {
+ if ( NULL == name ) {
+ fprintf( stdout, "Warning- while parsing file %s: entry that isn't a list element "
+ "given with no name. Not adding this parameter to the dictionary.\n",
+ self->resource );
+ return NULL;
+ }
+
+ newDictVal = Dictionary_Entry_Value_FromStringTo( newValue, newDictValType );
+ newDictVal = Dictionary_AddMergeWithSource(
+ self->currDictionary,
+ name,
+ newDictVal,
+ mergeType,
+ source );
+ }
+ else if( parent->type == Dictionary_Entry_Value_Type_List ) {
+ if ( NULL != name ) {
+ fprintf( stdout, "Warning - while parsing file %s: entry inside a list given with a name. Adding the "
+ "entry to the list, but ignoring the name.\n", self->resource );
+ }
+
+ newDictVal = Dictionary_Entry_Value_FromStringTo( newValue, newDictValType );
+ Dictionary_Entry_Value_AddElementWithSource( parent, newDictVal, source );
+ }
+ else if ( parent->type == Dictionary_Entry_Value_Type_Struct ) {
+ /* Dictionary_Entry_Value* member = NULL; */
+ newDictVal = Dictionary_Entry_Value_FromStringTo( newValue, newDictValType );
+
+ if ( NULL == name ) {
+ fprintf( stdout, "Warning - while parsing file %s: entry that isn't a list element given with no name. "
+ "Not adding it to the dictionary.\n", self->resource );
+ return NULL;
+ }
+
+ newDictVal = Dictionary_AddMergeWithSource(
+ parent->as.typeStruct,
+ name,
+ newDictVal,
+ mergeType,
+ source );
+
+ /*
+ ** This code overrides the merge code, disabling...
+ **
+ if ( (member = Dictionary_Entry_Value_GetMember( parent, name ) ) )
+ {
+ Dictionary_Entry_Value_SetMember( parent, name, newDictVal );
+ }
+ else {
+ Dictionary_Entry_Value_AddMember( parent, name, newDictVal );
+ }
+ */
+ }
+ else {
+ fprintf( stdout, "Warning - while parsing file %s: IO_Handler_SetAdd passed a parent not of list "
+ "or struct type. Ignoring.\n", self->resource );
+ }
+
+ return newDictVal;
+} /* IO_Handler_SetAddWithSource */
+
Index IO_Handler_ReadAllFilesFromCommandLine( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) {
IO_Handler* self = (IO_Handler*) ioHandler;
Stream* errorStream = Journal_Register( Error_Type, CURR_MODULE_NAME );
@@ -281,6 +390,41 @@
}
+Index IO_Handler_ReadAllFilesFromCommandLineForceSource( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) {
+ IO_Handler* self = (IO_Handler*) ioHandler;
+ Stream* errorStream = Journal_Register( Error_Type, CURR_MODULE_NAME );
+ Index arg_I;
+ char* filename;
+ char* extension;
+ Bool result;
+ Index filesRead = 0;
+
+ /* Loop over all the arguments from command line */
+ for ( arg_I = 1 ; arg_I < argc ; arg_I++ ) {
+ filename = argv[ arg_I ];
+
+ /* Find extension of potential filename by finding the pointer to the last dot in the string */
+ extension = strrchr( filename, '.' );
+
+ /* Check if there was a '.' in the filename at all - if not, then bail */
+ if ( extension == NULL )
+ continue;
+
+ /* Check if file has a ".xml" extension - if not, then bail */
+ if ( strcasecmp( extension, ".xml" ) != 0 )
+ continue;
+
+ /* Read file */
+ result = IO_Handler_ReadAllFromFileForceSource( self, filename, dictionary );
+ Journal_Firewall( result, errorStream,
+ "Error: %s could not read input file %s. Exiting.\n", argv[0], filename );
+ filesRead++;
+ }
+
+ return filesRead;
+}
+
+
Index IO_Handler_ReadAllFromCommandLine( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) {
Index filesRead = 0;
filesRead = IO_Handler_ReadAllFilesFromCommandLine( ioHandler, argc, argv, dictionary );
@@ -288,3 +432,12 @@
return filesRead;
}
+
+
+Index IO_Handler_ReadAllFromCommandLineForceSource( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) {
+ Index filesRead = 0;
+ filesRead = IO_Handler_ReadAllFilesFromCommandLineForceSource( ioHandler, argc, argv, dictionary );
+ Dictionary_ReadAllParamFromCommandLine( dictionary, argc, argv );
+
+ return filesRead;
+}
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.h 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/IO_Handler.h 2006-08-18 00:17:23 UTC (rev 4330)
@@ -45,6 +45,8 @@
typedef void (IO_Handler_DeleteFunction) (void* io_handler);
typedef void (IO_Handler_PrintFunction) (void* io_handler);
typedef Bool (IO_Handler_ReadAllFromFileFunction) (void* io_handler, const char* filename, Dictionary* dictionary );
+ typedef Bool (IO_Handler_ReadAllFromFileForceSourceFunction) (void* io_handler, const char* filename,
+ Dictionary* dictionary );
typedef Bool (IO_Handler_ReadAllFromBufferFunction) (void* io_handler, const char* buffer, Dictionary* dictionary );
typedef Bool (IO_Handler_WriteAllToFileFunction) (void* io_handler, const char* filename, Dictionary* dictionary );
typedef Bool (IO_Handler_DictSetAddValueFunction)
@@ -60,6 +62,7 @@
\
/* Virtual info */ \
IO_Handler_ReadAllFromFileFunction* _readAllFromFile; \
+ IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource; \
IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer; \
IO_Handler_WriteAllToFileFunction* _writeAllToFile; \
\
@@ -79,6 +82,7 @@
Stg_Class_PrintFunction* _print,
Stg_Class_CopyFunction* _copy,
IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
+ IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
IO_Handler_WriteAllToFileFunction* _writeAllToFile );
@@ -94,6 +98,9 @@
/** Read a dictionary entry of a given name from file */
extern Bool IO_Handler_ReadAllFromFile( void* io_handler, const char* filename, Dictionary* dictionary );
+ /** Read a dictionary entry of a given name from file, force it to include source file where applicable. */
+ extern Bool IO_Handler_ReadAllFromFileForceSource( void* io_handler, const char* filename, Dictionary* dictionary );
+
/** Read a dictionary entry of a given name from buffer */
extern Bool IO_Handler_ReadAllFromBuffer( void* io_handler, const char* buffer, Dictionary* dictionary );
@@ -110,12 +117,30 @@
Dictionary_Entry_Value* parent,
Dictionary_MergeType mergeType );
+ /** Set/add entry to dictionary given parent */
+ extern Dictionary_Entry_Value* IO_Handler_DictSetAddValueWithSource(
+ void* io_handler,
+ Dictionary_Entry_Key name,
+ char* newValue,
+ char newDictValType,
+ Dictionary_Entry_Value* parent,
+ Dictionary_MergeType mergeType,
+ Dictionary_Entry_Source source );
+
/** Finds all references to files in command line args with extension ".xml" and reads them with the IO
handler. Returns the number of files successfully read. */
Index IO_Handler_ReadAllFilesFromCommandLine( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) ;
+ /** Finds all references to files in command line args with extension ".xml" and reads them with the IO
+ handler. Forces the sourceFile to be included in Dictionary_Entry. Returns the number of files successfully read. */
+ Index IO_Handler_ReadAllFilesFromCommandLineForceSource( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) ;
+
/** Runs IO_Handler_ReadAllFilesFromCommandLine and Dictionary_ReadAllParamFromCommandLine.
Returns the number of files successfully read. */
Index IO_Handler_ReadAllFromCommandLine( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) ;
+ /** Runs IO_Handler_ReadAllFilesFromCommandLineForceSource and Dictionary_ReadAllParamFromCommandLine.
+ Returns the number of files successfully read. */
+ Index IO_Handler_ReadAllFromCommandLineForceSource( void* ioHandler, int argc, char* argv[], Dictionary* dictionary ) ;
+
#endif /* __Base_IO_IO_Handler_h__ */
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.c 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.c 2006-08-18 00:17:23 UTC (rev 4330)
@@ -52,6 +52,7 @@
/* keyword strings for nodes and lists */
static const xmlChar* INCLUDE_TAG = (const xmlChar*) "include";
static const xmlChar* NAME_ATTR = (const xmlChar*) "name";
+static const xmlChar* SOURCEFILE_ATTR = (const xmlChar*) "sourceFile";
static const xmlChar* MERGETYPE_ATTR = (const xmlChar*) "mergeType";
static const xmlChar* CHILDRENMERGETYPE_ATTR = (const xmlChar*) "childrenMergeType";
static const xmlChar* TYPE_ATTR = (const xmlChar*) "type";
@@ -90,34 +91,38 @@
static void _XML_IO_Handler_OpenFile( XML_IO_Handler*, const char* );
static void _XML_IO_Handler_OpenBuffer( XML_IO_Handler*, const char* );
static xmlNodePtr _XML_IO_Handler_Check( XML_IO_Handler* );
-static void _XML_IO_Handler_ParseNodes( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*, Dictionary_MergeType );
-static void _XML_IO_Handler_ParseList( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*, Dictionary_MergeType );
+static void _XML_IO_Handler_ParseNodes( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*,
+ Dictionary_MergeType, Dictionary_Entry_Source source );
+static void _XML_IO_Handler_ParseList( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*,
+ Dictionary_MergeType, Dictionary_Entry_Source );
static void _XML_IO_Handler_ParseAsciiData( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value* );
static void _XML_IO_Handler_ParseColumnDefinitions( XML_IO_Handler*, xmlNodePtr, ColumnInfo [MAX_COLUMNS], int* const );
static void _XML_IO_Handler_ParseAsciiValue( char* asciiValue, ColumnInfo* columnInfo, Dictionary_Entry_Value* toDictStruct );
static char* _XML_IO_Handler_GetNextAsciiToken( XML_IO_Handler*, xmlNodePtr );
-static void _XML_IO_Handler_ParseStruct( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*, Dictionary_MergeType );
-static void _XML_IO_Handler_ParseParameter( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*, Dictionary_MergeType );
+static void _XML_IO_Handler_ParseStruct( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*,
+ Dictionary_MergeType, Dictionary_Entry_Source );
+static void _XML_IO_Handler_ParseParameter( XML_IO_Handler*, xmlNodePtr, Dictionary_Entry_Value*,
+ Dictionary_MergeType, Dictionary_Entry_Source source );
static Dictionary_Entry_Value_Type _XML_IO_Handler_GetDictValueType( XML_IO_Handler* self, char* type );
static xmlChar* _XML_IO_Handler_StripLeadingTrailingWhiteSpace( XML_IO_Handler* self, const xmlChar* const );
static Bool _XML_IO_Handler_IsOnlyWhiteSpace( char* );
/* Writing Function prototypes */
static void _XML_IO_Handler_WriteDictionary( XML_IO_Handler*, Dictionary*, xmlNodePtr);
-static void _XML_IO_Handler_WriteNode( XML_IO_Handler*, char*, Dictionary_Entry_Value*, xmlNodePtr);
-static void _XML_IO_Handler_WriteList( XML_IO_Handler*, char*, Dictionary_Entry_Value*, xmlNodePtr);
+static void _XML_IO_Handler_WriteNode( XML_IO_Handler*, char*, Dictionary_Entry_Value*, char*, xmlNodePtr);
+static void _XML_IO_Handler_WriteList( XML_IO_Handler*, char*, Dictionary_Entry_Value*, char*, xmlNodePtr);
static void _XML_IO_Handler_WriteListElementsXML( XML_IO_Handler*, Dictionary_Entry_Value*, xmlNodePtr);
static Bool _XML_IO_Handler_CheckListCanBePrintedRaw( Dictionary_Entry_Value* );
static void _XML_IO_Handler_WriteListElementsRawASCII( XML_IO_Handler*, Dictionary_Entry_Value*, xmlNodePtr);
static unsigned int _XML_IO_Handler_GetWrittenElementSize( XML_IO_Handler*, Dictionary_Entry_Value* );
static void _XML_IO_Handler_WriteMemberAscii( XML_IO_Handler*, Dictionary_Entry_Value*, char* );
static void _XML_IO_Handler_WriteListElementsRawBinary( XML_IO_Handler*, Dictionary_Entry_Value*, xmlNodePtr);
-static void _XML_IO_Handler_WriteStruct( XML_IO_Handler*, char*, Dictionary_Entry_Value*, xmlNodePtr);
-static void _XML_IO_Handler_WriteParameter( XML_IO_Handler*, char*, Dictionary_Entry_Value*, xmlNodePtr);
+static void _XML_IO_Handler_WriteStruct( XML_IO_Handler*, char*, Dictionary_Entry_Value*, char*, xmlNodePtr);
+static void _XML_IO_Handler_WriteParameter( XML_IO_Handler*, char*, Dictionary_Entry_Value*, char*, xmlNodePtr);
XML_IO_Handler* XML_IO_Handler_New( void ) {
return _XML_IO_Handler_New( sizeof(XML_IO_Handler), XML_IO_Handler_Type, _XML_IO_Handler_Delete, _XML_IO_Handler_Print,
- NULL, _XML_IO_Handler_ReadAllFromFile, _XML_IO_Handler_ReadAllFromBuffer, _XML_IO_Handler_WriteAllToFile, _XML_IO_Handler_WriteEntryToFile,
+ NULL, _XML_IO_Handler_ReadAllFromFile, _XML_IO_Handler_ReadAllFromFileForceSource, _XML_IO_Handler_ReadAllFromBuffer, _XML_IO_Handler_WriteAllToFile, _XML_IO_Handler_WriteEntryToFile,
_XML_IO_Handler_SetListEncoding, _XML_IO_Handler_SetWritingPrecision, _XML_IO_Handler_SetWriteExplicitTypes );
}
@@ -149,6 +154,7 @@
Stg_Class_PrintFunction* _print,
Stg_Class_CopyFunction* _copy,
IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
+ IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
IO_Handler_WriteAllToFileFunction* _writeAllToFile,
XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile,
@@ -167,6 +173,7 @@
_print,
_copy,
_readAllFromFile,
+ _readAllFromFileForceSource,
_readAllFromBuffer,
_writeAllToFile );
@@ -464,7 +471,7 @@
}
/* call parse nodes, starting on the first child */
- _XML_IO_Handler_ParseNodes( self, cur, NULL, Dictionary_MergeType_Replace );
+ _XML_IO_Handler_ParseNodes( self, cur, NULL, Dictionary_MergeType_Replace, NULL );
/* free memory */
xmlFreeDoc( self->currDoc );
@@ -473,6 +480,42 @@
return True;
}
+/** Read all parameters from a file implementation. See IO_Handler_ReadAllFromFile(). It will first check if the file
+ * exists, and contains valid XML.
+ * FORCES the source file to be added to each Dictionary_Entry_Source (even if XML didn't have a source entry)*/
+Bool _XML_IO_Handler_ReadAllFromFileForceSource( void* xml_io_handler, const char* filename, Dictionary* dictionary ) {
+ XML_IO_Handler* self = (XML_IO_Handler*) xml_io_handler;
+ xmlNodePtr cur = NULL;
+
+ Journal_DPrintf( Journal_Register( Debug_Type, XML_IO_Handler_Type ), "XML_IO_Handler called to read file %s.\n", filename );
+
+ assert( self && filename && dictionary );
+
+ /* set the current dictionary to the one being read */
+ self->currDictionary = dictionary;
+
+ /* setup initial search path (currPath) */
+ if( self->currPath )
+ _XML_IO_Handler_AddSearchPath( self, self->currPath );
+ else
+ _XML_IO_Handler_AddSearchPath( self, "./" );
+
+ /* open the file and check syntax */
+ if ( !(cur = _XML_IO_Handler_OpenCheckFile( self, filename )) ) {
+ xmlCleanupParser();
+ return False;
+ }
+
+ /* call parse nodes, starting on the first child */
+ _XML_IO_Handler_ParseNodes( self, cur, NULL, Dictionary_MergeType_Replace, (char*) cur->doc->URL );
+
+ /* free memory */
+ xmlFreeDoc( self->currDoc );
+ xmlCleanupParser();
+
+ return True;
+}
+
Bool _XML_IO_Handler_ReadAllFromBuffer( void* xml_io_handler, const char* buffer, Dictionary* dictionary ) {
XML_IO_Handler* self = (XML_IO_Handler*) xml_io_handler;
xmlNodePtr cur = NULL;
@@ -489,7 +532,7 @@
}
/* call parse nodes, starting on the first child */
- _XML_IO_Handler_ParseNodes( self, cur, NULL, Dictionary_MergeType_Replace );
+ _XML_IO_Handler_ParseNodes( self, cur, NULL, Dictionary_MergeType_Replace, NULL );
/* free memory */
xmlFreeDoc( self->currDoc );
@@ -678,20 +721,20 @@
/** given a document node and the parent of that node, parses all the information on that node and any of its children
* into the Dictionary. */
-static void _XML_IO_Handler_ParseNodes( XML_IO_Handler* self, xmlNodePtr cur, Dictionary_Entry_Value* parent, Dictionary_MergeType mergeType )
+static void _XML_IO_Handler_ParseNodes( XML_IO_Handler* self, xmlNodePtr cur, Dictionary_Entry_Value* parent, Dictionary_MergeType mergeType, Dictionary_Entry_Source source )
{
/* Process each node at this depth. Allow any order, and warn on unknown nodes */
while (cur != NULL) {
/* if parameter */
if ( (0 == xmlStrcmp( cur->name, (const xmlChar *) PARAM_TAG ) ) && ( cur->ns == self->currNameSpace ) ) {
- _XML_IO_Handler_ParseParameter( self, cur, parent, mergeType );
+ _XML_IO_Handler_ParseParameter( self, cur, parent, mergeType, source );
}
else if ( (0 == xmlStrcmp( cur->name, (const xmlChar *) LIST_TAG ) ) && ( cur->ns == self->currNameSpace ) ) {
- _XML_IO_Handler_ParseList( self, cur , parent, mergeType );
+ _XML_IO_Handler_ParseList( self, cur , parent, mergeType, source );
}
else if ( (0 == xmlStrcmp( cur->name, (const xmlChar *) STRUCT_TAG ) ) &&
( cur->ns == self->currNameSpace ) ) {
- _XML_IO_Handler_ParseStruct( self, cur, parent, mergeType );
+ _XML_IO_Handler_ParseStruct( self, cur, parent, mergeType, source );
}
else if ( (0 == xmlStrcmp( cur->name, (const xmlChar *) SEARCH_PATH_TAG ) ) &&
( cur->ns == self->currNameSpace ) )
@@ -768,8 +811,15 @@
}
if(
- strlen( (char*)absolute ) == 0 ||
- False == IO_Handler_ReadAllFromFile( newHandler, (char*)absolute, self->currDictionary ) )
+ strlen( (char*)absolute ) == 0
+ || (source != NULL &&
+ False == IO_Handler_ReadAllFromFileForceSource( newHandler,
+ (char*)absolute,
+ self->currDictionary ) )
+ || (source == NULL &&
+ False == IO_Handler_ReadAllFromFile( newHandler,
+ (char*)absolute ,
+ self->currDictionary ) ) )
{
Journal_Printf(
Journal_Register( Info_Type, XML_IO_Handler_Type ),
@@ -798,12 +848,15 @@
/** parse list: given a node containing a list, parses the list into the ::Dictionary. (In future might want flags to
* say whether each element constrained to be same type?) */
-static void _XML_IO_Handler_ParseList( XML_IO_Handler* self, xmlNodePtr cur, Dictionary_Entry_Value* parent, Dictionary_MergeType defaultMergeType )
+static void _XML_IO_Handler_ParseList( XML_IO_Handler* self, xmlNodePtr cur, Dictionary_Entry_Value* parent,
+ Dictionary_MergeType defaultMergeType, Dictionary_Entry_Source source )
{
xmlChar* name = xmlGetProp( cur, NAME_ATTR );
+ xmlChar* sourceFile = xmlGetProp( cur, SOURCEFILE_ATTR );
xmlChar* mergeTypeStr = xmlGetProp( cur, MERGETYPE_ATTR );
xmlChar* childrenMergeTypeStr = xmlGetProp( cur, CHILDRENMERGETYPE_ATTR );
xmlChar* spaceStrippedName = NULL;
+ xmlChar* spaceStrippedSourceFile = NULL;
xmlChar* spaceStrippedMergeType = NULL;
xmlChar* spaceStrippedChildrenMergeType = NULL;
Dictionary_Entry_Value* newList = NULL;
@@ -813,6 +866,12 @@
if ( name ) {
spaceStrippedName = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, name );
}
+ if ( sourceFile ) {
+ spaceStrippedSourceFile = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, sourceFile );
+ }
+ else if (source) {
+ spaceStrippedSourceFile = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, (xmlChar*) source );
+ }
if( mergeTypeStr ) {
spaceStrippedMergeType = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, mergeTypeStr );
if( !xmlStrcmp( spaceStrippedMergeType, APPEND_TAG ) ) {
@@ -874,13 +933,14 @@
spaceStrippedMergeType );
/* set/add the list */
- newList = IO_Handler_DictSetAddValue(
+ newList = IO_Handler_DictSetAddValueWithSource(
self,
(char*)spaceStrippedName,
NULL,
Dictionary_Entry_Value_Type_List,
parent,
- mergeType );
+ mergeType,
+ (char*)spaceStrippedSourceFile );
if ( (NULL != newList) && cur->xmlChildrenNode ) {
/* check to see if values presented as columns of binary and ascii data */
@@ -892,7 +952,7 @@
}
else {
/* TODO: working out whether to make sure all elements conform to type of first */
- _XML_IO_Handler_ParseNodes( self, cur->xmlChildrenNode, newList, childrenMergeType );
+ _XML_IO_Handler_ParseNodes( self, cur->xmlChildrenNode, newList, childrenMergeType, source );
}
/* if global encoding flag set, change encoding */
@@ -915,6 +975,10 @@
if ( spaceStrippedName ) {
Memory_Free( spaceStrippedName );
}
+ xmlFree( sourceFile );
+ if ( spaceStrippedSourceFile ) {
+ Memory_Free( spaceStrippedSourceFile );
+ }
}
@@ -1093,12 +1157,15 @@
XML_IO_Handler* self,
xmlNodePtr cur,
Dictionary_Entry_Value* parent,
- Dictionary_MergeType defaultMergeType )
+ Dictionary_MergeType defaultMergeType,
+ Dictionary_Entry_Source source )
{
xmlChar* name = xmlGetProp( cur, NAME_ATTR );
+ xmlChar* sourceFile = xmlGetProp( cur, SOURCEFILE_ATTR );
xmlChar* mergeTypeStr = xmlGetProp( cur, MERGETYPE_ATTR );
xmlChar* childrenMergeTypeStr = xmlGetProp( cur, CHILDRENMERGETYPE_ATTR );
xmlChar* spaceStrippedName = NULL;
+ xmlChar* spaceStrippedSourceFile = NULL;
xmlChar* spaceStrippedMergeType = NULL;
xmlChar* spaceStrippedChildrenMergeType = NULL;
Dictionary_Entry_Value* newStruct = NULL;
@@ -1108,6 +1175,12 @@
if ( name ) {
spaceStrippedName = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, name );
}
+ if ( sourceFile ) {
+ spaceStrippedSourceFile = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, sourceFile );
+ }
+ else if (source) {
+ spaceStrippedSourceFile = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, (xmlChar*) source );
+ }
if( mergeTypeStr ) {
spaceStrippedMergeType = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, mergeTypeStr );
if( !xmlStrcmp( spaceStrippedMergeType, APPEND_TAG ) ) {
@@ -1164,22 +1237,27 @@
spaceStrippedName );
/* set/add the struct */
- newStruct = IO_Handler_DictSetAddValue(
+ newStruct = IO_Handler_DictSetAddValueWithSource(
self,
(char*)spaceStrippedName,
NULL,
Dictionary_Entry_Value_Type_Struct,
parent,
- mergeType );
+ mergeType,
+ (char*)spaceStrippedSourceFile );
if ( NULL != newStruct ) {
- _XML_IO_Handler_ParseNodes( self, cur->xmlChildrenNode, newStruct, childrenMergeType );
+ _XML_IO_Handler_ParseNodes( self, cur->xmlChildrenNode, newStruct, childrenMergeType, source );
}
xmlFree( name );
if ( spaceStrippedName ) {
Memory_Free( spaceStrippedName );
}
+ xmlFree( sourceFile );
+ if ( spaceStrippedSourceFile ) {
+ Memory_Free( spaceStrippedSourceFile );
+ }
}
@@ -1188,14 +1266,17 @@
XML_IO_Handler* self,
xmlNodePtr cur,
Dictionary_Entry_Value* parent,
- Dictionary_MergeType defaultMergeType )
+ Dictionary_MergeType defaultMergeType,
+ Dictionary_Entry_Source source )
{
xmlChar* value = xmlNodeListGetString( self->currDoc, cur->xmlChildrenNode, 1 );
xmlChar* name = xmlGetProp( cur, NAME_ATTR );
+ xmlChar* sourceFile = xmlGetProp( cur, SOURCEFILE_ATTR );
xmlChar* type = xmlGetProp( cur, TYPE_ATTR );
xmlChar* mergeTypeStr = xmlGetProp( cur, MERGETYPE_ATTR );
Dictionary_Entry_Value_Type dictValueType = _XML_IO_Handler_GetDictValueType( self, (char*) type );
xmlChar* spaceStrippedName = NULL;
+ xmlChar* spaceStrippedSourceFile = NULL;
xmlChar* spaceStrippedMergeType = NULL;
xmlChar* spaceStrippedType = NULL;
xmlChar* strippedVal = NULL;
@@ -1204,6 +1285,14 @@
if ( name ) {
spaceStrippedName = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, name );
}
+
+ if ( sourceFile ) {
+ spaceStrippedSourceFile = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, sourceFile );
+ }
+ else if (source) {
+ spaceStrippedSourceFile = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, (xmlChar*) source );
+ }
+
if( mergeTypeStr ) {
spaceStrippedMergeType = _XML_IO_Handler_StripLeadingTrailingWhiteSpace( self, mergeTypeStr );
if( !xmlStrcmp( spaceStrippedMergeType, APPEND_TAG ) ) {
@@ -1303,15 +1392,25 @@
}
}
- IO_Handler_DictSetAddValue( self, (char*)spaceStrippedName, (char*)strippedVal, dictValueType, parent, mergeType );
+ IO_Handler_DictSetAddValueWithSource(
+ self,
+ (char*)spaceStrippedName,
+ (char*)strippedVal,
+ dictValueType,
+ parent,
+ mergeType,
+ (char*)spaceStrippedSourceFile );
-
xmlFree( name );
if ( spaceStrippedName ) {
Memory_Free( spaceStrippedName );
}
xmlFree( value );
Memory_Free( strippedVal );
+ xmlFree( sourceFile );
+ if ( spaceStrippedSourceFile ) {
+ Memory_Free( spaceStrippedSourceFile );
+ }
if( type ) {
xmlFree( type );
@@ -1487,17 +1586,18 @@
/** write a single dictionary entry to a file. The dictionary entry needs to be supplied as a name and value.
* \return True on success, False otherwise. */
Bool XML_IO_Handler_WriteEntryToFile( void* xml_io_handler, const char* filename,
- Dictionary_Entry_Key name, Dictionary_Entry_Value* value )
+ Dictionary_Entry_Key name, Dictionary_Entry_Value* value, Dictionary_Entry_Source source )
{
XML_IO_Handler* self = (XML_IO_Handler*) xml_io_handler;
assert( self );
- return self->_writeEntryToFile( xml_io_handler, filename, name, value );
+ return self->_writeEntryToFile( xml_io_handler, filename, name, value, source );
}
-/** XML_IO_Handler_WriteEntryToFile() implementation. */
+
+
Bool _XML_IO_Handler_WriteEntryToFile( void* xml_io_handler, const char* filename,
- Dictionary_Entry_Key name, Dictionary_Entry_Value* value )
+ Dictionary_Entry_Key name, Dictionary_Entry_Value* value, Dictionary_Entry_Source source )
{
Stream* stream = Journal_Register (Info_Type, "myStream");
/* create/overwrite new document */
@@ -1513,6 +1613,7 @@
assert( filename );
assert( name );
assert( value );
+ //Do not assert source -> it may well be NULL.
#endif
Journal_Printf(stream, "_XML_IO_Handler_WriteEntryToFile called to write dictionary entry %s to file %s.\n", name, filename );
/* if overwrite/new */
@@ -1537,7 +1638,7 @@
xmlDocSetRootElement( self->currDoc, rootNode );
/* TODO else parse in filename as currDoc, if update set */
- _XML_IO_Handler_WriteNode( self, name, value, rootNode );
+ _XML_IO_Handler_WriteNode( self, name, value, source, rootNode );
/* write result to file */
if ( 0 < (fileSize = xmlSaveFormatFile( filename, self->currDoc, 1 )) ) {
@@ -1574,24 +1675,25 @@
for (index=0; index < dict->count; index++) {
Dictionary_Entry* currEntryPtr = dict->entryPtr[index];
- _XML_IO_Handler_WriteNode( self, currEntryPtr->key, currEntryPtr->value, parent );
+ _XML_IO_Handler_WriteNode( self, currEntryPtr->key, currEntryPtr->value, currEntryPtr->source, parent );
}
}
/** write a single node to file, and its children. */
-static void _XML_IO_Handler_WriteNode( XML_IO_Handler* self, char* name, Dictionary_Entry_Value* value,
- xmlNodePtr parent)
+static void _XML_IO_Handler_WriteNode( XML_IO_Handler* self, char* name, Dictionary_Entry_Value* value,
+ char* source, xmlNodePtr parent)
+
{
switch ( value->type ) {
case Dictionary_Entry_Value_Type_Struct:
- _XML_IO_Handler_WriteStruct( self, name, value, parent );
+ _XML_IO_Handler_WriteStruct( self, name, value, source, parent );
break;
case Dictionary_Entry_Value_Type_List:
- _XML_IO_Handler_WriteList( self, name, value, parent );
+ _XML_IO_Handler_WriteList( self, name, value, source, parent );
break;
default:
- _XML_IO_Handler_WriteParameter( self, name, value, parent );
+ _XML_IO_Handler_WriteParameter( self, name, value, source, parent );
}
}
@@ -1599,7 +1701,7 @@
/** write a list and its children to a file. Depending on the encoding set by either XML_IO_Handler_SetListEncoding(),
* or stored on the list dictionary entry value itself, will write out as XML, ascii or binary.*/
static void _XML_IO_Handler_WriteList( XML_IO_Handler* self, char* name, Dictionary_Entry_Value* list,
- xmlNodePtr parent)
+ char* source, xmlNodePtr parent)
{
xmlNodePtr newNode;
@@ -1610,6 +1712,9 @@
if ( NULL != name ) {
xmlNewProp( newNode, (xmlChar*) NAME_ATTR, (xmlChar*) name );
}
+ if ( NULL != source ) {
+ xmlNewProp( newNode, (xmlChar*) SOURCEFILE_ATTR, (xmlChar*) source );
+ }
/* write list elements*/
switch (self->listEncoding) {
@@ -1673,7 +1778,7 @@
Dictionary_Entry_Value* currChildValue = Dictionary_Entry_Value_GetFirstElement( list );
while ( NULL != currChildValue ) {
- _XML_IO_Handler_WriteNode( self, NULL, currChildValue, listNode );
+ _XML_IO_Handler_WriteNode( self, NULL, currChildValue, NULL, listNode );
currChildValue = currChildValue->next;
}
}
@@ -1864,8 +1969,8 @@
/** writes a struct dictionary entry to the file */
-static void _XML_IO_Handler_WriteStruct( XML_IO_Handler* self, char* name, Dictionary_Entry_Value* value,
- xmlNodePtr parent)
+static void _XML_IO_Handler_WriteStruct( XML_IO_Handler* self, char* name, Dictionary_Entry_Value* value,
+ char* source, xmlNodePtr parent)
{
xmlNodePtr newNode;
@@ -1878,6 +1983,9 @@
if ( NULL != name ) {
xmlNewProp( newNode, (xmlChar*) NAME_ATTR, (xmlChar*) name );
}
+ if ( NULL != source ) {
+ xmlNewProp( newNode, (xmlChar*) SOURCEFILE_ATTR, (xmlChar*) source );
+ }
_XML_IO_Handler_WriteDictionary( self, value->as.typeStruct, newNode );
}
@@ -1885,7 +1993,7 @@
/** writes a single dictionary parameter to file. */
static void _XML_IO_Handler_WriteParameter( XML_IO_Handler* self, char* name, Dictionary_Entry_Value* value,
- xmlNodePtr parent)
+ char* source, xmlNodePtr parent)
{
xmlNodePtr newNode;
@@ -1898,6 +2006,9 @@
if ( NULL != name ) {
xmlNewProp( newNode, (xmlChar*) NAME_ATTR, (xmlChar*) name );
}
+ if ( NULL != source ) {
+ xmlNewProp( newNode, (xmlChar*) SOURCEFILE_ATTR, (xmlChar*) source );
+ }
if ( True == self->writeExplicitTypes )
{
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.h 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/XML_IO_Handler.h 2006-08-18 00:17:23 UTC (rev 4330)
@@ -53,7 +53,7 @@
/* additional class function ptr typedefs */
typedef Bool (XML_IO_Handler_WriteEntryToFileFunction) ( void* xml_io_handler, const char* filename,
- Dictionary_Entry_Key name, Dictionary_Entry_Value* value );
+ Dictionary_Entry_Key name, Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
typedef void (XML_IO_Handler_SetListEncodingFunction) ( void* xml_io_handler, ListEncoding listEncoding );
typedef void (XML_IO_Handler_SetWritingPrecisionFunction) ( void* xml_io_handler, int dictionaryEntryType,
int value );
@@ -106,6 +106,7 @@
Stg_Class_PrintFunction* _print,
Stg_Class_CopyFunction* _copy,
IO_Handler_ReadAllFromFileFunction* _readAllFromFile,
+ IO_Handler_ReadAllFromFileForceSourceFunction* _readAllFromFileForceSource,
IO_Handler_ReadAllFromBufferFunction* _readAllFromBuffer,
IO_Handler_WriteAllToFileFunction* _writeAllToFile,
XML_IO_Handler_WriteEntryToFileFunction* _writeEntryToFile,
@@ -144,6 +145,10 @@
/** Read a dictionary entry of a given name from file */
extern Bool _XML_IO_Handler_ReadAllFromFile( void* xml_io_handler, const char* filename, Dictionary* dictionary );
+ /** Read a dictionary entry of a given name from file and force the source file info to be added to the
+ * Dictionary_Entry */
+ extern Bool _XML_IO_Handler_ReadAllFromFileForceSource(void* xml_io_handler, const char* filename, Dictionary* dictionary);
+
/** Read a dictionary entry of a given name from buffer */
extern Bool _XML_IO_Handler_ReadAllFromBuffer( void* xml_io_handler, const char* buffer, Dictionary* dictionary );
@@ -154,9 +159,9 @@
/* TODO: option to choose between overwrite / update ? */
extern Bool XML_IO_Handler_WriteEntryToFile( void* xml_io_handler, const char* filename, Dictionary_Entry_Key name,
- Dictionary_Entry_Value* value );
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
- extern Bool _XML_IO_Handler_WriteEntryToFile( void* xml_io_handler, const char* filename, Dictionary_Entry_Key name,
- Dictionary_Entry_Value* value );
+ extern Bool _XML_IO_Handler_WriteEntryToFile( void* xml_io_handler, const char* filename, Dictionary_Entry_Key name,
+ Dictionary_Entry_Value* value, Dictionary_Entry_Source source );
#endif /* __Base_IO_XML_IO_Handler_h__ */
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/src/types.h
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/src/types.h 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/src/types.h 2006-08-18 00:17:23 UTC (rev 4330)
@@ -43,6 +43,7 @@
/* Dicitonary internal types */
typedef char* Dictionary_Entry_Key;
+ typedef char* Dictionary_Entry_Source;
typedef enum {
Dictionary_Entry_Value_Type_String,
Dictionary_Entry_Value_Type_Double,
Modified: long/3D/Gale/trunk/src/StGermain/Base/IO/tests/testIO_Handler-normal.c
===================================================================
--- long/3D/Gale/trunk/src/StGermain/Base/IO/tests/testIO_Handler-normal.c 2006-08-18 00:17:20 UTC (rev 4329)
+++ long/3D/Gale/trunk/src/StGermain/Base/IO/tests/testIO_Handler-normal.c 2006-08-18 00:17:23 UTC (rev 4330)
@@ -88,7 +88,7 @@
IO_Handler_WriteAllToFile( io_handler, "data/newnormalexplicittypes.xml", dictionary );
printf( "\ntest of writing single entry:\n");
- XML_IO_Handler_WriteEntryToFile( io_handler, "data/newgeom.xml", "geom", Dictionary_Get( dictionary, "geom" ) );
+ XML_IO_Handler_WriteEntryToFile( io_handler, "data/newgeom.xml", "geom", Dictionary_Get( dictionary, "geom" ), Dictionary_GetSource( dictionary, "geom" ) );
Stg_Class_Delete( io_handler );
Stg_Class_Delete( dictionary );
More information about the cig-commits
mailing list