Geant4 11.2.2
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xDataTOM_importXML_private.h File Reference
#include <expat.h>
#include <statusMessageReporting.h>
#include <xDataTOM_private.h>

Go to the source code of this file.

Classes

struct  xDataXML_docInfo_s
 
struct  xDataXML_attribute_s
 
struct  xDataXML_attributionList_s
 
struct  xDataXML_text_s
 
struct  xDataXML_elementListItem_s
 
struct  xDataXML_elementList_s
 
struct  xDataXMLType_s
 
struct  xDataXML_rootElement_s
 
struct  xDataXML_element_s
 
struct  xDataXML_smr_s
 
struct  xDataXML_document_s
 
struct  xDataXML_item_s
 

Macros

#define XMLCALL
 
#define XML_Char   char
 
#define XML_Size   long
 

Typedefs

typedef struct xDataXMLType_s xDataXMLType
 
typedef struct xDataTOM_importXMLTOM_s xDataTOM_importXMLTOM
 
typedef struct xDataXML_attribute_s xDataXML_attribute
 
typedef struct xDataXML_document_s xDataXML_document
 
typedef struct xDataXML_docInfo_s xDataXML_docInfo
 
typedef struct xDataXML_attributionList_s xDataXML_attributionList
 
typedef struct xDataXML_element_s xDataXML_element
 
typedef struct xDataXML_elementList_s xDataXML_elementList
 
typedef struct xDataXML_elementListItem_s xDataXML_elementListItem
 
typedef struct xDataXML_rootElement_s xDataXML_rootElement
 
typedef struct xDataXML_text_s xDataXML_text
 
typedef struct xDataXML_smr_s xDataXML_smr
 
typedef struct xDataXML_item_s xDataXML_item
 
typedef int(* xDTXML_toDataFunction) (statusMessageReporting *smr, xDataXMLType *, xDataXML_attributionList *, char const *)
 
typedef char *(* xDTXML_toStringFunction) (statusMessageReporting *smr, xDataXMLType *)
 
typedef int(* xDTXML_releaseFunction) (statusMessageReporting *smr, xDataXMLType *)
 

Enumerations

enum  xDataXML_status { xDataXML_statusParsing = 1 , xDataXML_statusCompleted , xDataXML_statusError }
 
enum  xDataXML_errorCodes { xDataXML_errNone , xDataXML_errXML_ParserCreate , xDataXML_errFileError , xDataXML_errXMLParser }
 
enum  xDataXML_itemMode { xDataXML_itemModeEnd = 0 , xDataXML_itemModeElement , xDataXML_itemModeText }
 
enum  xDataXML_xDataType { xDataXML_xDataType_Ok , xDataXML_xDataType_ConvertingToData , xDataXML_xDataType_ConvertingToString }
 

Functions

xDataTOM_TOMxDataXML_importFile (statusMessageReporting *smr, char const *fileName)
 
xDataXML_documentxDataXML_importFile2 (statusMessageReporting *smr, char const *fileName)
 
void * xDataXML_freeDoc (statusMessageReporting *smr, xDataXML_document *doc)
 
int xDataXML_parseIsError (xDataXML_document *doc)
 
xDataXML_elementxDataXML_getDocumentsElement (xDataXML_document *doc)
 
xDataXML_elementxDataXML_getFirstElement (xDataXML_element *element)
 
xDataXML_elementxDataXML_getNextElement (xDataXML_element *element)
 
enum xDataXML_itemMode xDataXML_getFirstItem (xDataXML_element *element, xDataXML_item *item)
 
enum xDataXML_itemMode xDataXML_getNextItem (xDataXML_item *item)
 
int xDataXML_isAttributeInList (xDataXML_attributionList *attributes, char const *name)
 
int xDataXML_isAttributeInElement (xDataXML_element *element, char const *name)
 
char * xDataXML_getAttributesValue (xDataXML_attributionList *attributes, char const *name)
 
char const * xDataXML_getAttributesValueInElement (xDataXML_element *element, char const *name)
 
int xDataXML_attributeListLength (xDataXML_attributionList *attributes)
 
xDataXML_attributexDataXML_attributeByIndex (xDataXML_attributionList *attributes, int index)
 
int xDataXML_getCommonData (statusMessageReporting *smr, xDataXML_element *element, xDataTOM_Int *index, xDataTOM_Int *start, xDataTOM_Int *end, xDataTOM_Int *length)
 
int xDataXML_xDataTypeConvertAttributes (statusMessageReporting *smr, xDataXML_element *element)
 
xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int (statusMessageReporting *smr, xDataXML_element *element, char const *name, xDataTOM_Int *n, int required)
 
int xDataXML_convertAttributeToDouble (statusMessageReporting *smr, xDataXML_element *element, char const *name, double *d, int required)
 
int xDataXML_numberOfElementsByTagName (statusMessageReporting *smr, xDataXML_element *element, char const *tagName)
 
xDataXML_elementListxDataXML_getElementsByTagName (statusMessageReporting *smr, xDataXML_element *element, char const *tagName)
 
xDataXML_elementxDataXML_getOneElementByTagName (statusMessageReporting *smr, xDataXML_element *element, char *name, int required)
 
void xDataXML_freeElementList (statusMessageReporting *smr, xDataXML_elementList *list)
 
int xDataXML_is_xDataType (statusMessageReporting *smr, xDataXMLType *xDT, char const *const type, int setMsg)
 
char const * xDataXML_getFileName (xDataXML_document *doc)
 
char const * xDataXML_getRealFileName (xDataXML_document *doc)
 
xDataXML_documentxDataXML_getElementsDocument (xDataXML_element *element)
 
void * xDataXML_get_smrUserInterfaceFromDocument (xDataXML_document *doc)
 
void * xDataXML_get_smrUserInterfaceFromElement (xDataXML_element *element)
 
int xDataXML_stringTo_xDataTOM_Int (statusMessageReporting *smr, void *smrUserInterface, char const *c, xDataTOM_Int *value, char const *endings, char **e)
 
int xDataXML_stringTo_double (statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e)
 
int xDataXML_addToAccessed (statusMessageReporting *smr, xDataXML_element *element, int increment)
 
int xDataXML_getAccessed (statusMessageReporting *smr, xDataXML_element *element)
 
void * xDataXML_initializeData (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE, char const *ID, size_t size)
 
int xDataXML_axesElememtToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes)
 
int xDataXML_axesToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes)
 
int xDataXML_XYsToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_XYsDataToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_XYs *XYs, int index, int length, double value, double accuracy, enum xDataTOM_subAxesType subAxesType, int axesOffest, xDataTOM_axes *axes, xDataTOM_interpolation *interpolation)
 
int xDataXML_stringToDoubles (statusMessageReporting *smr, xDataXML_element *XE, char const *s, int length, double *d)
 
int xDataXML_regionsXYsToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_W_XYsToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_W_XYsDataToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_W_XYs *W_XYs, int index, double value, xDataTOM_axes *axes, int axesOffset)
 
int xDataXML_V_W_XYsToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_W_XYs_LegendreSeriesToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_LegendreSeries *LegendreSeries)
 
int xDataXML_regionsW_XYs_LegendreSeriesToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_V_W_XYs_LegendreSeriesToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_polynomialToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 
int xDataXML_KalbachMannToTOM (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE)
 

Macro Definition Documentation

◆ XML_Char

#define XML_Char   char

Definition at line 22 of file xDataTOM_importXML_private.h.

Referenced by XML_GetFeatureList().

◆ XML_Size

#define XML_Size   long

Definition at line 26 of file xDataTOM_importXML_private.h.

◆ XMLCALL

#define XMLCALL

Definition at line 18 of file xDataTOM_importXML_private.h.

Typedef Documentation

◆ xDataTOM_importXMLTOM

typedef struct xDataTOM_importXMLTOM_s xDataTOM_importXMLTOM

Definition at line 36 of file xDataTOM_importXML_private.h.

◆ xDataXML_attribute

Definition at line 37 of file xDataTOM_importXML_private.h.

◆ xDataXML_attributionList

◆ xDataXML_docInfo

Definition at line 39 of file xDataTOM_importXML_private.h.

◆ xDataXML_document

Definition at line 38 of file xDataTOM_importXML_private.h.

◆ xDataXML_element

Definition at line 41 of file xDataTOM_importXML_private.h.

◆ xDataXML_elementList

Definition at line 42 of file xDataTOM_importXML_private.h.

◆ xDataXML_elementListItem

◆ xDataXML_item

Definition at line 47 of file xDataTOM_importXML_private.h.

◆ xDataXML_rootElement

Definition at line 44 of file xDataTOM_importXML_private.h.

◆ xDataXML_smr

typedef struct xDataXML_smr_s xDataXML_smr

Definition at line 46 of file xDataTOM_importXML_private.h.

◆ xDataXML_text

Definition at line 45 of file xDataTOM_importXML_private.h.

◆ xDataXMLType

typedef struct xDataXMLType_s xDataXMLType

Definition at line 29 of file xDataTOM_importXML_private.h.

◆ xDTXML_releaseFunction

typedef int(* xDTXML_releaseFunction) (statusMessageReporting *smr, xDataXMLType *)

Definition at line 74 of file xDataTOM_importXML_private.h.

◆ xDTXML_toDataFunction

typedef int(* xDTXML_toDataFunction) (statusMessageReporting *smr, xDataXMLType *, xDataXML_attributionList *, char const *)

Definition at line 72 of file xDataTOM_importXML_private.h.

◆ xDTXML_toStringFunction

typedef char *(* xDTXML_toStringFunction) (statusMessageReporting *smr, xDataXMLType *)

Definition at line 73 of file xDataTOM_importXML_private.h.

Enumeration Type Documentation

◆ xDataXML_errorCodes

Enumerator
xDataXML_errNone 
xDataXML_errXML_ParserCreate 
xDataXML_errFileError 
xDataXML_errXMLParser 

Definition at line 32 of file xDataTOM_importXML_private.h.

◆ xDataXML_itemMode

Enumerator
xDataXML_itemModeEnd 
xDataXML_itemModeElement 
xDataXML_itemModeText 

Definition at line 33 of file xDataTOM_importXML_private.h.

◆ xDataXML_status

Enumerator
xDataXML_statusParsing 
xDataXML_statusCompleted 
xDataXML_statusError 

Definition at line 31 of file xDataTOM_importXML_private.h.

◆ xDataXML_xDataType

Enumerator
xDataXML_xDataType_Ok 
xDataXML_xDataType_ConvertingToData 
xDataXML_xDataType_ConvertingToString 

Definition at line 34 of file xDataTOM_importXML_private.h.

Function Documentation

◆ xDataXML_addToAccessed()

int xDataXML_addToAccessed ( statusMessageReporting * smr,
xDataXML_element * element,
int increment )

Definition at line 923 of file xDataTOM_importXML.cc.

923 {
924
925 element->accessed += increment;
926 return( element->accessed );
927}

◆ xDataXML_attributeByIndex()

xDataXML_attribute * xDataXML_attributeByIndex ( xDataXML_attributionList * attributes,
int index )

Definition at line 510 of file xDataTOM_importXML.cc.

510 {
511
512 if( index >= attributes->number ) return( NULL );
513 return( &(attributes->attributes[index]) );
514}

Referenced by MCGIDI_misc_copyXMLAttributesToTOM().

◆ xDataXML_attributeListLength()

int xDataXML_attributeListLength ( xDataXML_attributionList * attributes)

Definition at line 503 of file xDataTOM_importXML.cc.

503 {
504
505 return( attributes->number );
506}

◆ xDataXML_axesElememtToTOM()

int xDataXML_axesElememtToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_axes * axes )

Definition at line 20 of file xDataTOM_importXML_axes.cc.

20 {
21
22 int axesProcessed = 0;
23 xDataXML_element *XMLChild;
24
25 for( XMLChild = xDataXML_getFirstElement( XE ); XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
26 if( strcmp( "axes", XMLChild->name ) == 0 ) {
27 if( axesProcessed ) {
28 smr_setReportError3p( smr, xDataXML_get_smrUserInterfaceFromElement( XE ), xDataTOM_smrLibraryID, -1, "multiple 'axes' elements found" );
29 return( 1 );
30 }
31 axesProcessed = 1;
32 if( xDataXML_axesToTOM( smr, XMLChild, axes ) != 0 ) return( 1 );
33 }
34 }
35 if( axesProcessed == 0 ) {
37 return( 1 );
38 }
39
40 return( 0 );
41}
#define smr_setReportError3p(smr, userInterface, libraryID, code, fmt)
int xDataXML_axesToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes)
void * xDataXML_get_smrUserInterfaceFromElement(xDataXML_element *element)
xDataXML_element * xDataXML_getNextElement(xDataXML_element *element)
xDataXML_element * xDataXML_getFirstElement(xDataXML_element *element)
int xDataTOM_smrLibraryID
Definition xDataTOM.cc:34

Referenced by xDataXML_initializeData(), and xDataXML_XYsToTOM().

◆ xDataXML_axesToTOM()

int xDataXML_axesToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_axes * axes )

Definition at line 45 of file xDataTOM_importXML_axes.cc.

45 {
46
47 int i = 0, n = 0, index;
48 xDataXML_element *XMLChild;
49 char const *label, *unit, *sInterpolation, *attribute;
50 xDataTOM_interpolation interpolation;
51
52 for( XMLChild = xDataXML_getFirstElement( XE ); XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
53 if( strcmp( "axis", XMLChild->name ) != 0 ) {
55 "non axis element found: name = %s", XMLChild->name );
56 return( 1 );
57 }
58 n++;
59 }
60 if( xDataTOM_axes_initialize( smr, axes, n ) != 0 ) return( 1 );
61
62 for( XMLChild = xDataXML_getFirstElement( XE ), i = 0; XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ), i++ ) {
63 attribute = "index";
64 if( xDataXML_convertAttributeTo_xDataTOM_Int( smr, XMLChild, attribute, &index, 1 ) != 0 ) goto errA;
65 attribute = "label";
66 if( ( label = xDataXML_getAttributesValueInElement( XMLChild, attribute ) ) == NULL ) goto errA;
67 attribute = "unit";
68 if( ( unit = xDataXML_getAttributesValueInElement( XMLChild, attribute ) ) == NULL ) goto errA;
69 if( i < ( n - 1 ) ) {
70 attribute = "interpolation";
71 if( ( sInterpolation = xDataXML_getAttributesValueInElement( XMLChild, attribute ) ) == NULL ) goto errA;
72 if( xDataTOM_interpolation_setFromString( smr, &interpolation, sInterpolation ) != 0 ) goto err; }
73 else {
74 sInterpolation = "";
77 }
78 xDataTOM_axis_initialize( smr, &(axes->axis[i]), index, label, unit, &interpolation );
79 }
80 return( 0 );
81
82errA:
83 smr_setReportError3( smr, xDataXML_get_smrUserInterfaceFromElement( XE ), xDataTOM_smrLibraryID, -1, "axis missing attribute '%s'", attribute );
84err:
85 n = i;
86 for( i = 0; i < n; i++ ) xDataTOM_axis_release( smr, &(axes->axis[i]) );
87 smr_freeMemory( (void **) &(axes->axis) );
88 return( 1 );
89}
#define smr_setReportError3(smr, userInterface, libraryID, code, fmt,...)
void * smr_freeMemory(void **p)
xDataTOM_axis * axis
Definition xDataTOM.h:70
int xDataTOM_interpolation_setFromString(statusMessageReporting *smr, xDataTOM_interpolation *interpolation, char const *str)
xDataTOM_axis * xDataTOM_axis_release(statusMessageReporting *smr, xDataTOM_axis *axis)
int xDataTOM_axis_initialize(statusMessageReporting *smr, xDataTOM_axis *axis, int index, char const *label, char const *unit, xDataTOM_interpolation *interpolation)
@ xDataTOM_interpolationFlag_linear
Definition xDataTOM.h:19
int xDataTOM_axes_initialize(statusMessageReporting *smr, xDataTOM_axes *axes, int numberOfAxes)
int xDataTOM_interpolation_set(statusMessageReporting *smr, xDataTOM_interpolation *interpolation, enum xDataTOM_interpolationFlag independent, enum xDataTOM_interpolationFlag dependent, enum xDataTOM_interpolationQualifier qualifier)
@ xDataTOM_interpolationQualifier_dependent
Definition xDataTOM.h:21
xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int(statusMessageReporting *smr, xDataXML_element *element, char const *name, xDataTOM_Int *n, int required)
char const * xDataXML_getAttributesValueInElement(xDataXML_element *element, char const *name)

Referenced by xDataXML_axesElememtToTOM().

◆ xDataXML_convertAttributeTo_xDataTOM_Int()

xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int ( statusMessageReporting * smr,
xDataXML_element * element,
char const * name,
xDataTOM_Int * n,
int required )

Definition at line 599 of file xDataTOM_importXML.cc.

599 {
600/*
601* Returns 1 if no such attribute, -1 if error converting to xDataTOM_Int and 0 if successful.
602*/
603 char const *value;
604 char *e;
605
606 if( ( value = xDataXML_getAttributesValueInElement( element, name ) ) == NULL ) {
608 "missing required attribute '%s'", name );
609 return( 1 );
610 }
611 *n = (xDataTOM_Int) strtoll( value, &e, 10 );
612 if( *e != 0 ) {
614 "could not convert attribute %s's value = %s to an integer", name, value );
615 return( -1 );
616 }
617 return( 0 );
618}
int xDataTOM_Int
Definition xDataTOM.h:16
void * xDataXML_get_smrUserInterfaceFromElement(xDataXML_element *element)
char const * xDataXML_getAttributesValueInElement(xDataXML_element *element, char const *name)

Referenced by xDataXML_axesToTOM(), xDataXML_polynomialToTOM(), xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM(), xDataXML_xDataTypeConvertAttributes(), and xDataXML_XYsToTOM().

◆ xDataXML_convertAttributeToDouble()

int xDataXML_convertAttributeToDouble ( statusMessageReporting * smr,
xDataXML_element * element,
char const * name,
double * d,
int required )

Definition at line 622 of file xDataTOM_importXML.cc.

622 {
623/*
624* Returns 1 if no such attribute, -1 if error converting to double and 0 if successful.
625*/
626 char const *value;
627 char *e;
628
629 if( ( value = xDataXML_getAttributesValueInElement( element, name ) ) == NULL ) {
631 "missing required attribute '%s'", name );
632 return( 1 );
633 }
634 *d = strtod( value, &e );
635 if( *e != 0 ) {
637 "could not convert attribute %s's values = %s to a double", name, value );
638 return( -1 );
639 }
640 return( 0 );
641}

Referenced by MCGIDI_target_read(), xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM(), and xDataXML_XYsToTOM().

◆ xDataXML_freeDoc()

void * xDataXML_freeDoc ( statusMessageReporting * smr,
xDataXML_document * doc )

Definition at line 186 of file xDataTOM_importXML.cc.

186 {
187
188 xDataXML_endXMLParsing( smr, doc );
189 doc->root.children = (xDataXML_element *) xDataXML_freeElement( smr, doc->root.children );
190 smr_freeMemory( (void **) &(doc->fileName) );
191 smr_freeMemory( (void **) &(doc->realFileName) );
192 xDataXML_smrUserInterfaceFree( doc );
193 smr_freeMemory( (void **) &doc );
194 return( NULL );
195}

Referenced by MCGIDI_map_readFile(), MCGIDI_target_read(), xDataXML_importFile(), and xDataXML_importFile2().

◆ xDataXML_freeElementList()

void xDataXML_freeElementList ( statusMessageReporting * smr,
xDataXML_elementList * list )

Definition at line 704 of file xDataTOM_importXML.cc.

704 {
705
706 smr_freeMemory( (void **) &list );
707}

Referenced by xDataXML_getOneElementByTagName().

◆ xDataXML_get_smrUserInterfaceFromDocument()

void * xDataXML_get_smrUserInterfaceFromDocument ( xDataXML_document * doc)

Definition at line 806 of file xDataTOM_importXML.cc.

806 {
807
808 if( doc == NULL ) return( NULL );
809 return( &(doc->smrUserInterface ) );
810}

Referenced by xDataXML_get_smrUserInterfaceFromElement().

◆ xDataXML_get_smrUserInterfaceFromElement()

◆ xDataXML_getAccessed()

int xDataXML_getAccessed ( statusMessageReporting * smr,
xDataXML_element * element )

Definition at line 931 of file xDataTOM_importXML.cc.

931 {
932
933 return( element->accessed );
934}

◆ xDataXML_getAttributesValue()

char * xDataXML_getAttributesValue ( xDataXML_attributionList * attributes,
char const * name )

Definition at line 484 of file xDataTOM_importXML.cc.

484 {
485
486 int i;
487
488 for( i = 0; i < attributes->number; i++ ) {
489 if( !strcmp( attributes->attributes[i].name, name ) ) return( attributes->attributes[i].value );
490 }
491 return( NULL );
492}

Referenced by xDataXML_getAttributesValueInElement().

◆ xDataXML_getAttributesValueInElement()

char const * xDataXML_getAttributesValueInElement ( xDataXML_element * element,
char const * name )

Definition at line 496 of file xDataTOM_importXML.cc.

496 {
497
498 return( (char const *) xDataXML_getAttributesValue( &(element->attributes), name ) );
499}
xDataXML_attributionList attributes
char * xDataXML_getAttributesValue(xDataXML_attributionList *attributes, char const *name)

Referenced by MCGIDI_map_readFile(), MCGIDI_target_read(), xDataXML_axesToTOM(), xDataXML_convertAttributeTo_xDataTOM_Int(), xDataXML_convertAttributeToDouble(), and xDataXML_KalbachMannToTOM().

◆ xDataXML_getCommonData()

int xDataXML_getCommonData ( statusMessageReporting * smr,
xDataXML_element * element,
xDataTOM_Int * index,
xDataTOM_Int * start,
xDataTOM_Int * end,
xDataTOM_Int * length )

Definition at line 540 of file xDataTOM_importXML.cc.

541 {
542
543 if( element->xDataTypeInfo.ID == NULL ) {
545 "element %s is not xData", element->fullName );
546 return( 1 );
547 }
548 *index = element->xDataTypeInfo.index;
549 *start = element->xDataTypeInfo.start;
550 *end = element->xDataTypeInfo.end;
551 *length = element->xDataTypeInfo.length;
552 return( 0 );
553}

◆ xDataXML_getDocumentsElement()

xDataXML_element * xDataXML_getDocumentsElement ( xDataXML_document * doc)

Definition at line 411 of file xDataTOM_importXML.cc.

411{ return( doc->root.children ); }

Referenced by MCGIDI_map_readFile(), MCGIDI_target_read(), and xDataXML_importFile().

◆ xDataXML_getElementsByTagName()

xDataXML_elementList * xDataXML_getElementsByTagName ( statusMessageReporting * smr,
xDataXML_element * element,
char const * tagName )

Definition at line 656 of file xDataTOM_importXML.cc.

656 {
657
658 int n = xDataXML_numberOfElementsByTagName( smr, element, tagName );
659 size_t size;
660 xDataXML_element *child;
662 xDataXML_elementList *list = NULL;
663
664
665 size = sizeof( xDataXML_elementList ) + n * sizeof( xDataXML_elementListItem );
666 if( ( list = (xDataXML_elementList *) smr_malloc2( smr, size, 0, "list" ) ) != NULL ) {
667 list->n = n;
668 p = list->items = (xDataXML_elementListItem *) &(list[1]);
669 for( child = xDataXML_getFirstElement( element ); child != NULL; child = xDataXML_getNextElement( child ) ) {
670 if( !strcmp( child->name, tagName ) ) {
671 p->element = child;
672 p->sortString = NULL;
673 p++;
674 }
675 }
676 }
677 return( list );
678}
#define smr_malloc2(smr, size, zero, forItem)
xDataXML_elementListItem * items
xDataXML_element * xDataXML_getNextElement(xDataXML_element *element)
int xDataXML_numberOfElementsByTagName(statusMessageReporting *, xDataXML_element *element, char const *tagName)
xDataXML_element * xDataXML_getFirstElement(xDataXML_element *element)
struct xDataXML_elementList_s xDataXML_elementList

Referenced by xDataXML_getOneElementByTagName().

◆ xDataXML_getElementsDocument()

xDataXML_document * xDataXML_getElementsDocument ( xDataXML_element * element)

Definition at line 796 of file xDataTOM_importXML.cc.

796 {
797
798 xDataXML_rootElement* root = element->parentRoot;
799
800 while( root->parentRoot != NULL ) root = root->parentRoot; // Loop checking, 11.06.2015, T. Koi
801 return( root->xData_doc );
802}
xDataXML_rootElement * parentRoot
xDataXML_rootElement * parentRoot

Referenced by xDataXML_get_smrUserInterfaceFromElement().

◆ xDataXML_getFileName()

char const * xDataXML_getFileName ( xDataXML_document * doc)

Definition at line 765 of file xDataTOM_importXML.cc.

765 {
766
767 return( doc->fileName );
768}

◆ xDataXML_getFirstElement()

◆ xDataXML_getFirstItem()

enum xDataXML_itemMode xDataXML_getFirstItem ( xDataXML_element * element,
xDataXML_item * item )

Definition at line 417 of file xDataTOM_importXML.cc.

417 {
418
419 item->parentElement = element;
420 item->element = xDataXML_getFirstElement( element );
421 if( item->element == NULL ) {
423 if( element->text.length == 0 ) item->mode = xDataXML_itemModeEnd; }
424 else {
426 if( 0 < item->element->textOffset ) item->mode = xDataXML_itemModeText;
427 }
428 item->textOffset = 0;
429 item->textLength = element->text.length;
430 if( item->element != NULL ) item->textLength = item->element->textOffset;
431 item->text = element->text.text;
432 return( item->mode );
433}
enum xDataXML_itemMode mode
xDataXML_element * parentElement

◆ xDataXML_getNextElement()

◆ xDataXML_getNextItem()

enum xDataXML_itemMode xDataXML_getNextItem ( xDataXML_item * item)

Definition at line 437 of file xDataTOM_importXML.cc.

437 {
438
439 if( item->mode != xDataXML_itemModeEnd ) {
440 if( item->mode == xDataXML_itemModeText ) {
442 if( item->element == NULL ) item->mode = xDataXML_itemModeEnd;
443 item->textOffset += item->textLength;
444 item->textLength = 0;
445 item->text = &(item->parentElement->text.text[item->textOffset]); }
446 else {
447 item->element = item->element->next;
449 if( item->element == NULL ) {
450 if( item->textOffset < item->parentElement->text.length ) {
451 item->textLength = item->parentElement->text.length - item->textOffset; }
452 else {
454 } }
455 else {
456 item->textLength = item->element->textOffset - item->textOffset;
457 }
458 }
459 }
460 return( item->mode );
461}

◆ xDataXML_getOneElementByTagName()

xDataXML_element * xDataXML_getOneElementByTagName ( statusMessageReporting * smr,
xDataXML_element * element,
char * name,
int required )

Definition at line 682 of file xDataTOM_importXML.cc.

682 {
683
685 xDataXML_element *xData = NULL;
686
687 if( ( list = xDataXML_getElementsByTagName( smr, element, name ) ) != NULL ) {
688 if( list->n == 0 ) {
690 1, "element %s does not have sub-element named %s", element->fullName, name ); }
691 else if( list->n > 1 ) {
693 "element %s contains more than one sub-element named %s", element->fullName, name ); }
694 else {
695 xData = list->items[0].element;
696 }
697 xDataXML_freeElementList( smr, list );
698 }
699 return( xData );
700}
xDataXML_elementList * xDataXML_getElementsByTagName(statusMessageReporting *smr, xDataXML_element *element, char const *tagName)
void xDataXML_freeElementList(statusMessageReporting *, xDataXML_elementList *list)

◆ xDataXML_getRealFileName()

char const * xDataXML_getRealFileName ( xDataXML_document * doc)

Definition at line 772 of file xDataTOM_importXML.cc.

772 {
773
774 return( doc->realFileName );
775}

◆ xDataXML_importFile()

xDataTOM_TOM * xDataXML_importFile ( statusMessageReporting * smr,
char const * fileName )

Definition at line 63 of file xDataTOM_importXML.cc.

63 {
64/*
65* Returns NULL is any error occurred. If an error occurs in an expat routine, xDataXML_endXMLParsing will set smr appropriately.
66*/
67 xDataTOM_TOM *TOM = NULL;
68 xDataXML_document *XML = NULL;
69 xDataXML_element *element;
70
71 if( ( XML = xDataXML_importFile2( smr, fileName ) ) == NULL ) return( NULL );
72
73 if( ( TOM = xDataTOM_mallocTOM( smr ) ) == NULL ) goto Err;
74 if( xDataTOM_setFileNameTOM( smr, TOM, fileName ) != 0 ) goto Err;
75
76 element = xDataXML_getDocumentsElement( XML );
77 if( xDataXML_constructTOM( smr, (&TOM->root), element ) != 0 ) goto Err;
78
79 xDataXML_freeDoc( smr, XML );
80 return( TOM );
81
82Err:
83 if( XML != NULL ) xDataXML_freeDoc( smr, XML );
84 if( TOM != NULL ) xDataTOM_freeTOM( smr, &TOM );
85 return( NULL );
86}
xDataTOM_element root
Definition xDataTOM.h:193
xDataTOM_TOM * xDataTOM_mallocTOM(statusMessageReporting *smr)
Definition xDataTOM.cc:54
int xDataTOM_setFileNameTOM(statusMessageReporting *smr, xDataTOM_TOM *doc, const char *fileName)
Definition xDataTOM.cc:94
void * xDataTOM_freeTOM(statusMessageReporting *smr, xDataTOM_TOM **TOM)
Definition xDataTOM.cc:78
void * xDataXML_freeDoc(statusMessageReporting *smr, xDataXML_document *doc)
xDataXML_element * xDataXML_getDocumentsElement(xDataXML_document *doc)
xDataXML_document * xDataXML_importFile2(statusMessageReporting *smr, char const *fileName)

Referenced by xDataTOM_importFile().

◆ xDataXML_importFile2()

xDataXML_document * xDataXML_importFile2 ( statusMessageReporting * smr,
char const * fileName )

Definition at line 90 of file xDataTOM_importXML.cc.

90 {
91/*
92* Returns NULL is any error occurred. If an error occurs in an expat routine, xDataXML_endXMLParsing will set smr appropriately.
93*/
94 int f;
95 char buffer[10 * 1000];
96 ssize_t count, n = sizeof( buffer ) - 1;
98
99 if( ( doc = xDataXML_mallocDoc( smr ) ) == NULL ) return( NULL );
100 if( xDataXML_setFileName( smr, doc, fileName ) == 0 ) {
101 f = open( fileName, O_RDONLY );
102 if( f == -1 ) {
103 xDataXML_endXMLParsing( smr, doc );
104 smr_setReportError2( smr, xDataTOM_smrLibraryID, xDataXML_errFileError, "could not open XML file %s", fileName ); }
105 else {
106 while( ( count = read( f, buffer, n ) ) > 0 ) {
107 buffer[count] = 0;
108 if( xDataXML_parse( doc, buffer ) ) break;
109 if( !smr_isOk( doc->smr ) ) break;
110 } // Loop checking, 11.06.2015, T. Koi
111 close( f );
112 xDataXML_endXMLParsing( smr, doc );
113 if( count < 0 ) smr_setReportError2( smr, xDataTOM_smrLibraryID, xDataXML_errFileError, "read failed with errno = %d for XML %s",
114 errno, fileName );
115 }
116 }
117 if( doc != NULL ) {
118 if( !smr_isOk( smr ) ) {
119 xDataXML_freeDoc( smr, doc );
120 doc = NULL;
121 }
122 }
123 return( doc );
124}
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int smr_isOk(statusMessageReporting *smr)
statusMessageReporting * smr

Referenced by MCGIDI_map_readFile(), MCGIDI_target_read(), and xDataXML_importFile().

◆ xDataXML_initializeData()

void * xDataXML_initializeData ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE,
char const * ID,
size_t size )

Definition at line 1007 of file xDataTOM_importXML.cc.

1007 {
1008
1009 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
1010
1011 if( xData_initializeData( smr, TE, ID, size ) == NULL ) return( NULL );
1012 if( xDataXML_axesElememtToTOM( smr, XE, &(xDI->axes) ) != 0 ) smr_freeMemory( (void **) &(xDI->data) );
1013 return( xDI->data );
1014}
xDataTOM_xDataInfo xDataInfo
Definition xDataTOM.h:187
xDataTOM_axes axes
Definition xDataTOM.h:153
void * xData_initializeData(statusMessageReporting *smr, xDataTOM_element *TE, char const *ID, size_t size)
Definition xDataTOM.cc:479
int xDataXML_axesElememtToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes)

Referenced by xDataXML_KalbachMannToTOM(), xDataXML_polynomialToTOM(), xDataXML_regionsW_XYs_LegendreSeriesToTOM(), xDataXML_regionsXYsToTOM(), xDataXML_V_W_XYs_LegendreSeriesToTOM(), xDataXML_V_W_XYsToTOM(), xDataXML_W_XYs_LegendreSeriesToTOM(), and xDataXML_W_XYsToTOM().

◆ xDataXML_is_xDataType()

int xDataXML_is_xDataType ( statusMessageReporting * smr,
xDataXMLType * xDT,
char const *const type,
int setMsg )

Definition at line 751 of file xDataTOM_importXML.cc.

751 {
752
753 if( xDT->ID == NULL ) {
755 "element %s not xData object", xDT->element->fullName ); }
756 else if( xDT->ID != ID ) {
758 "Element %s is not xData object of ID %s but %s", xDT->element->fullName, ID, xDT->ID );
759 }
760 return( xDT->ID == ID );
761}
xDataXML_element * element

◆ xDataXML_isAttributeInElement()

int xDataXML_isAttributeInElement ( xDataXML_element * element,
char const * name )

Definition at line 477 of file xDataTOM_importXML.cc.

477 {
478
479 return( xDataXML_isAttributeInList( &(element->attributes), name ) );
480}
int xDataXML_isAttributeInList(xDataXML_attributionList *attributes, char const *name)

◆ xDataXML_isAttributeInList()

int xDataXML_isAttributeInList ( xDataXML_attributionList * attributes,
char const * name )

Definition at line 465 of file xDataTOM_importXML.cc.

465 {
466
467 int i;
468
469 for( i = 0; i < attributes->number; i++ ) {
470 if( !strcmp( attributes->attributes[i].name, name ) ) return( 1 );
471 }
472 return( 0 );
473}

Referenced by xDataXML_isAttributeInElement().

◆ xDataXML_KalbachMannToTOM()

int xDataXML_KalbachMannToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 21 of file xDataTOM_importXML_KalbachMann.cc.

21 {
22
23 int length;
24 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
25 xDataTOM_KalbachMann *KalbachMann;
26 char const *wLabel, *form;
27 xDataXML_element *XMLChild;
28 xDataTOM_axes *axes = &(xDI->axes);
29
30/* Need to release KalbachMann if an error occurs later. */
31 if( ( xDI->data = xDataXML_initializeData( smr, XE, TE, xDataTOM_KalbachMann_ID, sizeof( xDataTOM_KalbachMann ) ) ) == NULL ) return( 1 );
32 KalbachMann = (xDataTOM_KalbachMann *) xDI->data;
33
34 if( ( form = xDataXML_getAttributesValueInElement( XE, "form" ) ) == NULL ) goto err;
35 if( strcmp( form, "fr" ) == 0 ) {
36 KalbachMann->type = xDataTOM_KalbachMannType_fr; }
37 else if( strcmp( form, "fra" ) == 0 ) {
38 KalbachMann->type = xDataTOM_KalbachMannType_fra; }
39 else {
41 "invalid KalbachMann type - '%s'", form );
42 goto err;
43 }
44 if( ( wLabel = xDataTOM_axes_getLabel( smr, axes, 0 ) ) == NULL ) goto err;
45 length = xDataXML_numberOfElementsByTagName( smr, XE, wLabel );
46 if( xDataTOM_KalbachMann_initialize( smr, KalbachMann, length, axes ) != 0 ) return( 1 );
47
48 for( XMLChild = xDataXML_getFirstElement( XE ); XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
49 if( strcmp( "axes", XMLChild->name ) == 0 ) {
50 continue; }
51 else if( strcmp( wLabel, XMLChild->name ) == 0 ) {
52 if( xDataXML_KalbachMannCoefficientsToTOM( smr, XMLChild, &(KalbachMann->coefficients[KalbachMann->numberOfEnergies]) ) != 0 ) goto err;
53 KalbachMann->numberOfEnergies++; }
54 else {
56 "invalid element '%s' in xData = 'KalbachMann'", XMLChild->name );
57 goto err;
58 }
59 }
60
61 return( 0 );
62
63err:
64 smr_freeMemory( (void **) &(xDI->data) );
65 return( 1 );
66}
enum xDataTOM_KalbachMannType type
Definition xDataTOM.h:138
xDataTOM_KalbachMannCoefficients * coefficients
Definition xDataTOM.h:141
char const * xDataTOM_axes_getLabel(statusMessageReporting *smr, xDataTOM_axes *axes, int index)
int xDataTOM_KalbachMann_initialize(statusMessageReporting *smr, xDataTOM_KalbachMann *KalbachMann, int length, xDataTOM_axes *axes)
@ xDataTOM_KalbachMannType_fra
Definition xDataTOM.h:25
@ xDataTOM_KalbachMannType_fr
Definition xDataTOM.h:25
void * xDataXML_initializeData(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE, char const *ID, size_t size)
int xDataXML_numberOfElementsByTagName(statusMessageReporting *smr, xDataXML_element *element, char const *tagName)
char const * xDataTOM_KalbachMann_ID

◆ xDataXML_numberOfElementsByTagName()

int xDataXML_numberOfElementsByTagName ( statusMessageReporting * smr,
xDataXML_element * element,
char const * tagName )

Definition at line 645 of file xDataTOM_importXML.cc.

645 {
646
647 int n = 0;
648 xDataXML_element *child;
649
650 for( child = xDataXML_getFirstElement( element ); child != NULL; child = xDataXML_getNextElement( child ) ) if( !strcmp( child->name, tagName ) ) n++;
651 return( n );
652}

Referenced by xDataXML_getElementsByTagName(), xDataXML_KalbachMannToTOM(), xDataXML_regionsW_XYs_LegendreSeriesToTOM(), xDataXML_regionsXYsToTOM(), xDataXML_V_W_XYs_LegendreSeriesToTOM(), xDataXML_V_W_XYsToTOM(), xDataXML_W_XYs_LegendreSeriesToTOM(), and xDataXML_W_XYsDataToTOM().

◆ xDataXML_parseIsError()

int xDataXML_parseIsError ( xDataXML_document * doc)

Definition at line 404 of file xDataTOM_importXML.cc.

404 {
405
406 return( doc->status == xDataXML_statusError );
407}

◆ xDataXML_polynomialToTOM()

int xDataXML_polynomialToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 20 of file xDataTOM_importXML_polynomial.cc.

20 {
21
22 int length, dataProcessed = 0;
23 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
24 xDataTOM_polynomial *polynomial = NULL;
25 xDataXML_element *XMLChild;
26
27 if( xDataXML_convertAttributeTo_xDataTOM_Int( smr, XE, "length", &length, 1 ) != 0 ) return( 1 );
28 if( ( xDI->data = xDataXML_initializeData( smr, XE, TE, xDataTOM_polynomial_ID, sizeof( xDataTOM_polynomial ) ) ) == NULL ) return( 1 );
29 if( xDataTOM_polynomial_initialize( smr, (xDataTOM_polynomial *) xDI->data, length, &(xDI->axes) ) != 0 ) goto err;
30 polynomial = (xDataTOM_polynomial *) xDI->data;
31
32 for( XMLChild = xDataXML_getFirstElement( XE ); XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
33 if( strcmp( "axes", XMLChild->name ) == 0 ) {
34 continue; }
35 else if( strcmp( "data", XMLChild->name ) == 0 ) {
36 if( dataProcessed ) {
37 smr_setReportError3p( smr, xDataXML_get_smrUserInterfaceFromElement( XE ), xDataTOM_smrLibraryID, -1, "multiple 'data' elements found" );
38 goto err;
39 }
40 dataProcessed = 1;
41 if( xDataXML_stringToDoubles( smr, XE, XMLChild->text.text, length, (double *) polynomial->coefficients ) != 0 ) goto err;
42 }
43 }
44 if( dataProcessed == 0 ) {
46 goto err;
47 }
48 return( 0 );
49
50err:
51 if( polynomial != NULL ) xDataTOM_polynomial_release( polynomial );
52 smr_freeMemory( (void **) &(xDI->data) );
53 return( 1 );
54}
int xDataTOM_polynomial_initialize(statusMessageReporting *smr, xDataTOM_polynomial *polynomial, int length, xDataTOM_axes *axes)
int xDataTOM_polynomial_release(xDataTOM_polynomial *polynomial)
int xDataXML_stringToDoubles(statusMessageReporting *smr, xDataXML_element *XE, char const *s, int length, double *d)
char const * xDataTOM_polynomial_ID

◆ xDataXML_regionsW_XYs_LegendreSeriesToTOM()

int xDataXML_regionsW_XYs_LegendreSeriesToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 22 of file xDataTOM_importXML_regionsW_XYs_LegendreSeries.cc.

22 {
23
24 int index, length;
25 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
26 xDataXML_element *XMLChild;
27 char const *wLabel;
28 xDataTOM_regionsW_XYs_LegendreSeries *regionsW_XYs_LegendreSeries;
29
31 == NULL ) return( 1 );
32 regionsW_XYs_LegendreSeries = (xDataTOM_regionsW_XYs_LegendreSeries *) xDI->data;
33 length = xDataXML_numberOfElementsByTagName( smr, XE, "region" );
34 if( xDataTOM_regionsW_XYs_LegendreSeries_initialize( smr, regionsW_XYs_LegendreSeries, length, &(xDI->axes) ) != 0 ) goto err;
35 if( ( wLabel = xDataTOM_axes_getLabel( smr, &(xDI->axes), 0 ) ) == NULL ) goto err;
36
37 for( XMLChild = xDataXML_getFirstElement( XE ), index = 0; XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
38 if( strcmp( "axes", XMLChild->name ) == 0 ) {
39 continue; }
40 else if( strcmp( "region", XMLChild->name ) == 0 ) {
41 if( xDataXML_regionsW_XYs_LegendreSeries_regionToTOM( smr, XMLChild, &(regionsW_XYs_LegendreSeries->W_XYs_LegendreSeries[index]),
42 wLabel, regionsW_XYs_LegendreSeries->axes ) != 0 ) goto err;
43 index++; }
44 else {
46 "invalid element '%s' in xData 'regionsW_XYs_LegendreSeries'", XMLChild->name );
47 goto err;
48 }
49 }
50
51 return( 0 );
52
53err:
54/* Need to free things here?????????.*/
55 return( 1 );
56}
xDataTOM_W_XYs_LegendreSeries * W_XYs_LegendreSeries
Definition xDataTOM.h:122
int xDataTOM_regionsW_XYs_LegendreSeries_initialize(statusMessageReporting *smr, xDataTOM_regionsW_XYs_LegendreSeries *regionsW_XYs_LegendreSeries, int length, xDataTOM_axes *axes)
char const * xDataTOM_regionsW_XYs_LegendreSeries_ID

◆ xDataXML_regionsXYsToTOM()

int xDataXML_regionsXYsToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 23 of file xDataTOM_importXML_regionsXYs.cc.

23 {
24
25 int index;
26 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
27 xDataXML_element *XMLChild;
28 xDataTOM_regionsXYs *regionsXYs;
29
30 if( ( xDI->data = xDataXML_initializeData( smr, XE, TE, xDataTOM_regionsXYs_ID, sizeof( xDataTOM_regionsXYs ) ) ) == NULL ) return( 1 );
31 regionsXYs = (xDataTOM_regionsXYs *) xDI->data;
32 regionsXYs->axes = &(xDI->axes);
33 regionsXYs->length = xDataXML_numberOfElementsByTagName( smr, XE, "region" );
34 if( ( regionsXYs->XYs = (xDataTOM_XYs *) smr_malloc2( smr, regionsXYs->length * sizeof( xDataTOM_XYs ), 1, "regionsXYs->XYs" ) ) == NULL ) goto err;
35
36
37 for( XMLChild = xDataXML_getFirstElement( XE ), index = 0; XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
38 if( strcmp( "axes", XMLChild->name ) == 0 ) {
39 continue; }
40 else if( strcmp( "region", XMLChild->name ) == 0 ) {
41 if( xDataXML_regionsXYs_regionToTOM( smr, XMLChild, &(regionsXYs->XYs[index]), regionsXYs->axes ) != 0 ) goto err;
42 index++; }
43 else {
45 "invalid element '%s' in xData 'regionsXYs'", XMLChild->name );
46 goto err;
47 }
48 }
49
50 return( 0 );
51
52err:
53/* Need to free things here?????????.*/
54 return( 1 );
55}
xDataTOM_XYs * XYs
Definition xDataTOM.h:90
xDataTOM_axes * axes
Definition xDataTOM.h:89
char const * xDataTOM_regionsXYs_ID

◆ xDataXML_stringTo_double()

int xDataXML_stringTo_double ( statusMessageReporting * smr,
void * smrUserInterface,
char const * c,
double * value,
char const * endings,
char ** e )

Definition at line 889 of file xDataTOM_importXML.cc.

889 {
890
891 char const *s;
892 char tmp[64];
893 int status = 1, n = sizeof( tmp );
894
895 for( s = c; *s != 0; s++ ) if( !isspace( *s ) ) break;
896 *value = strtod( s, e );
897 if( *e == s ) {
898 smr_setReportError3( smr, smrUserInterface, xDataTOM_smrLibraryID, 1, "could not convert \"%s\" to an double",
899 xDataXML_shortStringForMessage( n, tmp, c ));}
900 else {
901 if( *endings == 0 ) while( isspace( **e ) ) (*e)++; // Loop checking, 11.06.2015, T. Koi
902 if( **e == 0 ) {
903 status = 0; }
904 else {
905 if( *endings == 0 ) {
906 smr_setReportError3( smr, smrUserInterface, xDataTOM_smrLibraryID, 1, "double string \"%s\" does not end with a '\\0'",
907 xDataXML_shortStringForMessage( n, tmp, c ) ); }
908 else {
909 if( strchr( endings, **e ) == NULL ) {
910 smr_setReportError3( smr, smrUserInterface, xDataTOM_smrLibraryID, 1, "double string \"%s\" does not end with a white space or a '\\0\'",
911 xDataXML_shortStringForMessage( n, tmp, c ) ); }
912 else {
913 status = 0;
914 }
915 }
916 }
917 }
918 return( status );
919}

Referenced by xDataXML_stringToDoubles().

◆ xDataXML_stringTo_xDataTOM_Int()

int xDataXML_stringTo_xDataTOM_Int ( statusMessageReporting * smr,
void * smrUserInterface,
char const * c,
xDataTOM_Int * value,
char const * endings,
char ** e )

Definition at line 856 of file xDataTOM_importXML.cc.

856 {
857
858 char const *s;
859 char tmp[64];
860 int status = 1, n = sizeof( tmp );
861
862 for( s = c; *s != 0; s++ ) if( !isspace( *s ) ) break;
863 *value = (xDataTOM_Int) strtoll( s, e, 10 );
864 if( *e == s ) {
865 smr_setReportError3(smr, smrUserInterface, xDataTOM_smrLibraryID, 1, "could not convert \"%s\" to an integer", xDataXML_shortStringForMessage( n, tmp, c ));}
866 else {
867 if( *endings == 0 ) while( isspace( **e ) ) (*e)++; // Loop checking, 11.06.2015, T. Koi
868 if( **e == 0 ) {
869 status = 0; }
870 else {
871 if( *endings == 0 ) {
872 smr_setReportError3( smr, smrUserInterface, xDataTOM_smrLibraryID, 1, "integer string \"%s\" does not end with a '\\0'",
873 xDataXML_shortStringForMessage( n, tmp, c ) ); }
874 else {
875 if( strchr( endings, **e ) == NULL ) {
876 smr_setReportError3( smr, smrUserInterface, xDataTOM_smrLibraryID, 1, "integer string \"%s\" does not end with a white space or a '\\0\'",
877 xDataXML_shortStringForMessage( n, tmp, c ) ); }
878 else {
879 status = 0;
880 }
881 }
882 }
883 }
884 return( status );
885}

◆ xDataXML_stringToDoubles()

int xDataXML_stringToDoubles ( statusMessageReporting * smr,
xDataXML_element * XE,
char const * s,
int length,
double * d )

Definition at line 96 of file xDataTOM_importXML_XYs.cc.

96 {
97
98 char *e1 = (char *) s1;
99 int i1;
100
101 for( i1 = 0; i1 < length; i1++, d1++, s1 = e1 ) {
102 if( xDataXML_stringTo_double( smr, xDataXML_get_smrUserInterfaceFromElement( XE ), s1, d1, " \n", &e1 ) ) return( 1 );
103 }
104 while( isspace( *e1 ) ) e1++; /* There should be nothing but white spaces left in the string. */ // Loop checking, 11.06.2015, T. Koi
105 if( *e1 != 0 ) {
106 smr_setReportError3( smr, xDataXML_get_smrUserInterfaceFromElement( XE ), xDataTOM_smrLibraryID, -1, "text contains extra data = %s", e1 );
107 return( 1 );
108 }
109 return( 0 );
110}
int xDataXML_stringTo_double(statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e)

Referenced by xDataXML_polynomialToTOM(), and xDataXML_XYsDataToTOM().

◆ xDataXML_V_W_XYs_LegendreSeriesToTOM()

int xDataXML_V_W_XYs_LegendreSeriesToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 22 of file xDataTOM_importXML_V_W_XYs_LegendreSeries.cc.

22 {
23
24 int index, length;
25 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
26 xDataXML_element *XMLChild;
27 char const *wLabel;
28 xDataTOM_V_W_XYs_LegendreSeries *V_W_XYs_LegendreSeries;
29
31 return( 1 );
32 V_W_XYs_LegendreSeries = (xDataTOM_V_W_XYs_LegendreSeries *) xDI->data;
33 if( ( wLabel = xDataTOM_axes_getLabel( smr, &(xDI->axes), 0 ) ) == NULL ) goto err;
34 length = (int) xDataXML_numberOfElementsByTagName( smr, XE, wLabel );
35 if( xDataTOM_V_W_XYs_LegendreSeries_initialize( smr, V_W_XYs_LegendreSeries, length, &(xDI->axes) ) != 0 ) goto err;
36
37 for( XMLChild = xDataXML_getFirstElement( XE ), index = 0; XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
38 if( strcmp( "axes", XMLChild->name ) == 0 ) {
39 continue; }
40 else if( strcmp( wLabel, XMLChild->name ) == 0 ) {
41 if( xDataXML_V_W_XYs_LegendreSeries_W_XYs_LegendreSeriesToTOM( smr, XMLChild, &(V_W_XYs_LegendreSeries->W_XYs_LegendreSeries[index]),
42 &(xDI->axes) ) != 0 ) goto err;
43 index++; }
44 else {
46 "invalid element '%s' in xData = 'V_W_XYs_LegendreSeries'", XMLChild->name );
47 goto err;
48 }
49 }
50
51 return( 0 );
52
53err:
54 return( 1 );
55}
xDataTOM_W_XYs_LegendreSeries * W_XYs_LegendreSeries
Definition xDataTOM.h:128
int xDataTOM_V_W_XYs_LegendreSeries_initialize(statusMessageReporting *smr, xDataTOM_V_W_XYs_LegendreSeries *V_W_XYs_LegendreSeries, int length, xDataTOM_axes *axes)
char const * xDataTOM_V_W_XYs_LegendreSeries_ID

◆ xDataXML_V_W_XYsToTOM()

int xDataXML_V_W_XYsToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 21 of file xDataTOM_importXML_V_W_XYs.cc.

21 {
22
23 int index, length;
24 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
25 xDataXML_element *XMLChild;
26 char const *wLabel;
27 xDataTOM_V_W_XYs *V_W_XYs;
28
29/* Need to release V_W_XYs if an error occurs later. */
30 if( ( xDI->data = xDataXML_initializeData( smr, XE, TE, xDataTOM_V_W_XYs_ID, sizeof( xDataTOM_V_W_XYs ) ) ) == NULL ) return( 1 );
31 V_W_XYs = (xDataTOM_V_W_XYs *) xDI->data;
32 if( ( wLabel = xDataTOM_axes_getLabel( smr, &(xDI->axes), 0 ) ) == NULL ) goto err;
33 length = xDataXML_numberOfElementsByTagName( smr, XE, wLabel );
34 if( xDataTOM_V_W_XYs_initialize( smr, V_W_XYs, length, &(xDI->axes) ) != 0 ) return( 1 );
35
36 for( XMLChild = xDataXML_getFirstElement( XE ), index = 0; XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
37 if( strcmp( "axes", XMLChild->name ) == 0 ) {
38 continue; }
39 else if( strcmp( wLabel, XMLChild->name ) == 0 ) {
40 if( xDataXML_V_W_XYs_W_XYsToTOM( smr, XMLChild, &(V_W_XYs->W_XYs[index]), &(xDI->axes) ) != 0 ) goto err;
41 index++; }
42 else {
44 "invalid element '%s' in xData = 'V_W_XYs'", XMLChild->name );
45 goto err;
46 }
47 }
48
49 return( 0 );
50
51err:
52 smr_freeMemory( (void **) &(xDI->data) );
53 return( 1 );
54}
xDataTOM_W_XYs * W_XYs
Definition xDataTOM.h:103
int xDataTOM_V_W_XYs_initialize(statusMessageReporting *smr, xDataTOM_V_W_XYs *V_W_XYs, int length, xDataTOM_axes *axes)
char const * xDataTOM_V_W_XYs_ID

◆ xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM()

int xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_LegendreSeries * LegendreSeries )

Definition at line 58 of file xDataTOM_importXML_W_XYs_LegendreSeries.cc.

58 {
59
60 int index, length;
61 double value;
62
63 if( xDataXML_convertAttributeTo_xDataTOM_Int( smr, XE, "index", &index, 1 ) != 0 ) return( 1 );
64 if( xDataXML_convertAttributeTo_xDataTOM_Int( smr, XE, "length", &length, 1 ) != 0 ) return( 1 );
65 if( xDataXML_convertAttributeToDouble( smr, XE, "value", &value, 1 ) != 0 ) return( 1 );
66 return( xDataXML_LegendreSeriesDataToTOM( smr, XE, LegendreSeries, index, length, value ) );
67}
int xDataXML_convertAttributeToDouble(statusMessageReporting *smr, xDataXML_element *element, char const *name, double *d, int required)

Referenced by xDataXML_W_XYs_LegendreSeriesToTOM().

◆ xDataXML_W_XYs_LegendreSeriesToTOM()

int xDataXML_W_XYs_LegendreSeriesToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 22 of file xDataTOM_importXML_W_XYs_LegendreSeries.cc.

22 {
23
24 int index, length;
25 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
26 xDataXML_element *XMLChild;
27 char const *wLabel;
28 xDataTOM_W_XYs_LegendreSeries *W_XYs_LegendreSeries = NULL;
29
30 if( ( xDI->data = xDataXML_initializeData( smr, XE, TE, xDataTOM_W_XYs_LegendreSeries_ID, sizeof( xDataTOM_W_XYs_LegendreSeries ) ) ) == NULL )
31 return( 1 );
32 W_XYs_LegendreSeries = (xDataTOM_W_XYs_LegendreSeries *) xDI->data;
33 if( ( wLabel = xDataTOM_axes_getLabel( smr, &(xDI->axes), 0 ) ) == NULL ) goto err;
34 length = xDataXML_numberOfElementsByTagName( smr, XE, wLabel );
35 if( xDataTOM_W_XYs_LegendreSeries_initialize( smr, W_XYs_LegendreSeries, 0, length, 0., xDataTOM_subAxesType_proxy, &(xDI->axes), NULL ) != 0 ) goto err;
36
37 for( XMLChild = xDataXML_getFirstElement( XE ), index = 0; XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
38 if( strcmp( "axes", XMLChild->name ) == 0 ) {
39 continue; }
40 else if( strcmp( wLabel, XMLChild->name ) == 0 ) {
41 if( xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM( smr, XMLChild, &(W_XYs_LegendreSeries->LegendreSeries[index]) ) != 0 ) goto err;
42 index++; }
43 else {
45 "invalid element '%s' in xData = 'W_XYs_LegendreSeries'", XMLChild->name );
46 goto err;
47 }
48 }
49
50 return( 0 );
51
52err:
53 return( 1 );
54}
xDataTOM_LegendreSeries * LegendreSeries
Definition xDataTOM.h:116
@ xDataTOM_subAxesType_proxy
Definition xDataTOM.h:24
int xDataTOM_W_XYs_LegendreSeries_initialize(statusMessageReporting *smr, xDataTOM_W_XYs_LegendreSeries *W_XYs_LegendreSeries, int index, int length, double value, enum xDataTOM_subAxesType subAxesType, xDataTOM_axes *axes, xDataTOM_interpolation *interpolation)
int xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_LegendreSeries *LegendreSeries)
char const * xDataTOM_W_XYs_LegendreSeries_ID

◆ xDataXML_W_XYsDataToTOM()

int xDataXML_W_XYsDataToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_W_XYs * W_XYs,
int index,
double value,
xDataTOM_axes * axes,
int axesOffset )

Definition at line 41 of file xDataTOM_importXML_W_XYs.cc.

42 {
43
44 int length;
45 char const *wLabel;
46 xDataXML_element *XMLChild;
47
48 if( ( wLabel = xDataTOM_axes_getLabel( smr, axes, axesOffset ) ) == NULL ) goto err;
49 length = xDataXML_numberOfElementsByTagName( smr, XE, wLabel );
50 if( xDataTOM_W_XYs_initialize( smr, W_XYs, index, length, value, axes, axesOffset ) != 0 ) return( 1 );
51
52 for( XMLChild = xDataXML_getFirstElement( XE ), index = 0; XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
53 if( strcmp( "axes", XMLChild->name ) == 0 ) {
54 continue; }
55 else if( strcmp( wLabel, XMLChild->name ) == 0 ) {
56 if( xDataXML_W_XYs_XYsToTOM( smr, XMLChild, &(W_XYs->XYs[index]), axes, axesOffset + 1 ) != 0 ) goto err;
57 index++; }
58 else {
60 "invalid element '%s' in xData = 'W_XYs'", XMLChild->name );
61 goto err;
62 }
63 }
64
65 return( 0 );
66
67err:
68 return( 1 );
69}
xDataTOM_XYs * XYs
Definition xDataTOM.h:97
int xDataTOM_W_XYs_initialize(statusMessageReporting *smr, xDataTOM_W_XYs *W_XYs, int index, int length, double value, xDataTOM_axes *axes, int axesOffset)

Referenced by xDataXML_W_XYsToTOM().

◆ xDataXML_W_XYsToTOM()

int xDataXML_W_XYsToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 22 of file xDataTOM_importXML_W_XYs.cc.

22 {
23
24 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
25 xDataTOM_W_XYs *W_XYs;
26
27/* Need to release W_XYs if an error occurs later. */
28 if( ( xDI->data = xDataXML_initializeData( smr, XE, TE, xDataTOM_W_XYs_ID, sizeof( xDataTOM_W_XYs ) ) ) == NULL ) return( 1 );
29 W_XYs = (xDataTOM_W_XYs *) xDI->data;
30
31 if( xDataXML_W_XYsDataToTOM( smr, XE, W_XYs, 0, 0., &(xDI->axes), 0 ) != 0 ) goto err;
32 return( 0 );
33
34err:
35 smr_freeMemory( (void **) &(xDI->data) );
36 return( 1 );
37}
int xDataXML_W_XYsDataToTOM(statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_W_XYs *W_XYs, int index, double value, xDataTOM_axes *axes, int axesOffset)
char const * xDataTOM_W_XYs_ID

◆ xDataXML_xDataTypeConvertAttributes()

int xDataXML_xDataTypeConvertAttributes ( statusMessageReporting * smr,
xDataXML_element * element )

Definition at line 557 of file xDataTOM_importXML.cc.

557 {
558
559 xDataXMLType *xDT = &(element->xDataTypeInfo);
560 void *smrUser = xDataXML_get_smrUserInterfaceFromElement( element );
561
562 xDT->index = -1;
563 xDT->start = -1;
564 xDT->end = -1;
565 xDT->length = -1;
566 if( ( xDT->indexPresent = xDataXML_convertAttributeTo_xDataTOM_Int( smr, element, "index", &(xDT->index), 0 ) ) < 0 ) return( 1 );
567 if( ( xDT->startPresent = xDataXML_convertAttributeTo_xDataTOM_Int( smr, element, "start", &(xDT->start), 0 ) ) < 0 ) return( 1 );
568 if( ( xDT->endPresent = xDataXML_convertAttributeTo_xDataTOM_Int( smr, element, "end", &(xDT->end), 0 ) ) < 0 ) return( 1 );
569 if( ( xDT->lengthPresent = xDataXML_convertAttributeTo_xDataTOM_Int( smr, element, "length", &(xDT->length), 0 ) ) < 0 ) return( 1 );
570 if( ( xDT->endPresent > 0 ) ) {
571 if( xDT->lengthPresent > 0 ) {
572 smr_setReportError3p( smr, smrUser, xDataTOM_smrLibraryID, 1, "missing length (or end) in xData" );
573 return( 1 );
574 }
575 xDT->end = xDT->length; }
576 else {
577 if( xDT->lengthPresent > 0 ) xDT->length = xDT->end;
578 }
579
580 if( xDT->startPresent > 0 ) xDT->start = 0;
581 if( xDT->start < 0 ) {
582 smr_setReportError3( smr, smrUser, xDataTOM_smrLibraryID, 1, "start = %d < 0", xDT->start );
583 return( 1 );
584 }
585 if( xDT->end < xDT->start ) {
586 smr_setReportError3( smr, smrUser, xDataTOM_smrLibraryID, 1, "start = %d >= end = %d", xDT->start, xDT->end );
587 return( 1 );
588 }
589 if( xDT->length < 0 ) {
590 smr_setReportError3( smr, smrUser, xDataTOM_smrLibraryID, 1, "length = %d < 0", xDT->length );
591 return( 1 );
592 }
593
594 return( 0 );
595}
xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int(statusMessageReporting *smr, xDataXML_element *element, char const *name, xDataTOM_Int *n, int required)

◆ xDataXML_XYsDataToTOM()

int xDataXML_XYsDataToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_XYs * XYs,
int index,
int length,
double value,
double accuracy,
enum xDataTOM_subAxesType subAxesType,
int axesOffest,
xDataTOM_axes * axes,
xDataTOM_interpolation * interpolation )

Definition at line 76 of file xDataTOM_importXML_XYs.cc.

77 {
78
79 XYs->index = index;
80 XYs->length = length;
81 XYs->value = value;
82 XYs->accuracy = accuracy;
83 if( xDataTOM_subAxes_initialize( smr, &(XYs->subAxes), subAxesType, axesOffest, axes, interpolation ) != 0 ) return( 1 );
84 if( ( XYs->data = (double *) smr_malloc2( smr, 2 * length * sizeof( double ), 0, "XYs->data" ) ) == NULL ) goto err;
85
86 if( xDataXML_stringToDoubles( smr, XE, XE->text.text, 2 * length, (double *) XYs->data ) != 0 ) goto err;
87 return( 0 );
88
89err:
90 smr_freeMemory( (void **) &(XYs->data) );
91 return( 1 );
92}
double value
Definition xDataTOM.h:82
xDataTOM_subAxes subAxes
Definition xDataTOM.h:83
double accuracy
Definition xDataTOM.h:82
double * data
Definition xDataTOM.h:84
int xDataTOM_subAxes_initialize(statusMessageReporting *smr, xDataTOM_subAxes *subAxes, enum xDataTOM_subAxesType type, int offset, xDataTOM_axes *axes, xDataTOM_interpolation *interpolation)
int xDataXML_stringToDoubles(statusMessageReporting *smr, xDataXML_element *XE, char const *s1, int length, double *d1)

◆ xDataXML_XYsToTOM()

int xDataXML_XYsToTOM ( statusMessageReporting * smr,
xDataXML_element * XE,
xDataTOM_element * TE )

Definition at line 22 of file xDataTOM_importXML_XYs.cc.

22 {
23
24 int dataProcessed = 0, length;
25 double accuracy;
26 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
27 xDataXML_element *XMLChild;
28
29 xDI->element = TE;
30 if( xDataXML_convertAttributeTo_xDataTOM_Int( smr, XE, "length", &length, 1 ) != 0 ) return( 1 );
31 if( xDataXML_convertAttributeToDouble( smr, XE, "accuracy", &accuracy, 1 ) != 0 ) return( 1 );
32 if( xDataXML_axesElememtToTOM( smr, XE, &(xDI->axes) ) != 0 ) return( 1 );
33 for( XMLChild = xDataXML_getFirstElement( XE ); XMLChild != NULL; XMLChild = xDataXML_getNextElement( XMLChild ) ) {
34 if( strcmp( "axes", XMLChild->name ) == 0 ) {
35 continue; }
36 else if( strcmp( "data", XMLChild->name ) == 0 ) {
37 if( dataProcessed ) {
38 smr_setReportError3p( smr, xDataXML_get_smrUserInterfaceFromElement( XE ), xDataTOM_smrLibraryID, -1, "multiple 'data' elements found" );
39 goto err;
40 }
41 dataProcessed = 1;
42 if( xDataXML_XYsDataToTOM2( smr, XMLChild, xDI, -1, length, 0., accuracy ) != 0 ) goto err;
43 }
44 }
45 if( dataProcessed == 0 ) {
47 goto err;
48 }
49 return( 0 );
50
51err:
52 return( 1 );
53}
xDataTOM_element * element
Definition xDataTOM.h:152