Geant4 10.7.0
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.

◆ 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 925 of file xDataTOM_importXML.cc.

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

◆ xDataXML_attributeByIndex()

xDataXML_attribute * xDataXML_attributeByIndex ( xDataXML_attributionList attributes,
int  index 
)

Definition at line 512 of file xDataTOM_importXML.cc.

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

Referenced by MCGIDI_misc_copyXMLAttributesToTOM().

◆ xDataXML_attributeListLength()

int xDataXML_attributeListLength ( xDataXML_attributionList attributes)

Definition at line 505 of file xDataTOM_importXML.cc.

505 {
506
507 return( attributes->number );
508}

◆ 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 601 of file xDataTOM_importXML.cc.

601 {
602/*
603* Returns 1 if no such attribute, -1 if error converting to xDataTOM_Int and 0 if successful.
604*/
605 char const *value;
606 char *e;
607
608 if( ( value = xDataXML_getAttributesValueInElement( element, name ) ) == NULL ) {
610 "missing required attribute '%s'", name );
611 return( 1 );
612 }
613 *n = (xDataTOM_Int) strtoll( value, &e, 10 );
614 if( *e != 0 ) {
616 "could not convert attribute %s's value = %s to an integer", name, value );
617 return( -1 );
618 }
619 return( 0 );
620}
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 624 of file xDataTOM_importXML.cc.

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

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 188 of file xDataTOM_importXML.cc.

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

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 706 of file xDataTOM_importXML.cc.

706 {
707
708 smr_freeMemory( (void **) &list );
709}

Referenced by xDataXML_getOneElementByTagName().

◆ xDataXML_get_smrUserInterfaceFromDocument()

void * xDataXML_get_smrUserInterfaceFromDocument ( xDataXML_document doc)

Definition at line 808 of file xDataTOM_importXML.cc.

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

Referenced by xDataXML_get_smrUserInterfaceFromElement().

◆ xDataXML_get_smrUserInterfaceFromElement()

◆ xDataXML_getAccessed()

int xDataXML_getAccessed ( statusMessageReporting smr,
xDataXML_element element 
)

Definition at line 933 of file xDataTOM_importXML.cc.

933 {
934
935 return( element->accessed );
936}

◆ xDataXML_getAttributesValue()

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

Definition at line 486 of file xDataTOM_importXML.cc.

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

Referenced by xDataXML_getAttributesValueInElement().

◆ xDataXML_getAttributesValueInElement()

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

Definition at line 498 of file xDataTOM_importXML.cc.

498 {
499
500 return( (char const *) xDataXML_getAttributesValue( &(element->attributes), name ) );
501}
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 542 of file xDataTOM_importXML.cc.

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

◆ xDataXML_getDocumentsElement()

xDataXML_element * xDataXML_getDocumentsElement ( xDataXML_document doc)

Definition at line 413 of file xDataTOM_importXML.cc.

413{ 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 658 of file xDataTOM_importXML.cc.

658 {
659
660 int n = xDataXML_numberOfElementsByTagName( smr, element, tagName );
661 size_t size;
662 xDataXML_element *child;
664 xDataXML_elementList *list = NULL;
665
666
667 size = sizeof( xDataXML_elementList ) + n * sizeof( xDataXML_elementListItem );
668 if( ( list = (xDataXML_elementList *) smr_malloc2( smr, size, 0, "list" ) ) != NULL ) {
669 list->n = n;
670 p = list->items = (xDataXML_elementListItem *) &(list[1]);
671 for( child = xDataXML_getFirstElement( element ); child != NULL; child = xDataXML_getNextElement( child ) ) {
672 if( !strcmp( child->name, tagName ) ) {
673 p->element = child;
674 p->sortString = NULL;
675 p++;
676 }
677 }
678 }
679 return( list );
680}
#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 798 of file xDataTOM_importXML.cc.

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

Referenced by xDataXML_get_smrUserInterfaceFromElement().

◆ xDataXML_getFileName()

char const * xDataXML_getFileName ( xDataXML_document doc)

Definition at line 767 of file xDataTOM_importXML.cc.

767 {
768
769 return( doc->fileName );
770}

◆ xDataXML_getFirstElement()

◆ xDataXML_getFirstItem()

enum xDataXML_itemMode xDataXML_getFirstItem ( xDataXML_element element,
xDataXML_item item 
)

Definition at line 419 of file xDataTOM_importXML.cc.

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

◆ xDataXML_getNextElement()

◆ xDataXML_getNextItem()

enum xDataXML_itemMode xDataXML_getNextItem ( xDataXML_item item)

Definition at line 439 of file xDataTOM_importXML.cc.

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

◆ xDataXML_getOneElementByTagName()

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

Definition at line 684 of file xDataTOM_importXML.cc.

684 {
685
687 xDataXML_element *xData = NULL;
688
689 if( ( list = xDataXML_getElementsByTagName( smr, element, name ) ) != NULL ) {
690 if( list->n == 0 ) {
692 1, "element %s does not have sub-element named %s", element->fullName, name ); }
693 else if( list->n > 1 ) {
695 "element %s contains more than one sub-element named %s", element->fullName, name ); }
696 else {
697 xData = list->items[0].element;
698 }
699 xDataXML_freeElementList( smr, list );
700 }
701 return( xData );
702}
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 774 of file xDataTOM_importXML.cc.

774 {
775
776 return( doc->realFileName );
777}

◆ 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;
97 ssize_t s = 0;
99
100 if( ( doc = xDataXML_mallocDoc( smr ) ) == NULL ) return( NULL );
101 if( xDataXML_setFileName( smr, doc, fileName ) == 0 ) {
102 f = open( fileName, O_RDONLY );
103 if( f == -1 ) {
104 xDataXML_endXMLParsing( smr, doc );
105 smr_setReportError2( smr, xDataTOM_smrLibraryID, xDataXML_errFileError, "could not open XML file %s", fileName ); }
106 else {
107 while( ( count = read( f, buffer, n ) ) > 0 ) {
108 s += count;
109 buffer[count] = 0;
110 if( xDataXML_parse( doc, buffer ) ) break;
111 if( !smr_isOk( doc->smr ) ) break;
112 } // Loop checking, 11.06.2015, T. Koi
113 close( f );
114 xDataXML_endXMLParsing( smr, doc );
115 if( count < 0 ) smr_setReportError2( smr, xDataTOM_smrLibraryID, xDataXML_errFileError, "read failed with errno = %d for XML %s",
116 errno, fileName );
117 }
118 }
119 if( doc != NULL ) {
120 if( !smr_isOk( smr ) ) {
121 xDataXML_freeDoc( smr, doc );
122 doc = NULL;
123 }
124 }
125 return( doc );
126}
#define smr_setReportError2(smr, libraryID, code, fmt,...)
int smr_isOk(statusMessageReporting *smr)
statusMessageReporting * smr
#define buffer
Definition: xmlparse.cc:628

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 1009 of file xDataTOM_importXML.cc.

1009 {
1010
1011 xDataTOM_xDataInfo *xDI = &(TE->xDataInfo);
1012
1013 if( xData_initializeData( smr, TE, ID, size ) == NULL ) return( NULL );
1014 if( xDataXML_axesElememtToTOM( smr, XE, &(xDI->axes) ) != 0 ) smr_freeMemory( (void **) &(xDI->data) );
1015 return( xDI->data );
1016}
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 753 of file xDataTOM_importXML.cc.

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

◆ xDataXML_isAttributeInElement()

int xDataXML_isAttributeInElement ( xDataXML_element element,
char const *  name 
)

Definition at line 479 of file xDataTOM_importXML.cc.

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

◆ xDataXML_isAttributeInList()

int xDataXML_isAttributeInList ( xDataXML_attributionList attributes,
char const *  name 
)

Definition at line 467 of file xDataTOM_importXML.cc.

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

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 647 of file xDataTOM_importXML.cc.

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

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 406 of file xDataTOM_importXML.cc.

406 {
407
408 return( doc->status == xDataXML_statusError );
409}

◆ 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}
double * coefficients
Definition: xDataTOM.h:147
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 891 of file xDataTOM_importXML.cc.

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

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 858 of file xDataTOM_importXML.cc.

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

◆ 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 559 of file xDataTOM_importXML.cc.

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