Geant4 11.1.1
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xDataTOM_importXML.cc File Reference
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <errno.h>
#include <unistd.h>
#include "xDataTOM_importXML_private.h"

Go to the source code of this file.

Macros

#define PATH_MAX   4096
 

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 *, 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 *, xDataXML_elementList *list)
 
int xDataXML_is_xDataType (statusMessageReporting *smr, xDataXMLType *xDT, char const *const ID, 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 *, xDataXML_element *element, int increment)
 
int xDataXML_getAccessed (statusMessageReporting *, xDataXML_element *element)
 
void * xDataXML_initializeData (statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE, char const *ID, size_t size)
 

Macro Definition Documentation

◆ PATH_MAX

#define PATH_MAX   4096

Definition at line 33 of file xDataTOM_importXML.cc.

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_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}
#define smr_setReportError3(smr, userInterface, libraryID, code, fmt,...)
int xDataTOM_Int
Definition: xDataTOM.h:16
void * xDataXML_get_smrUserInterfaceFromElement(xDataXML_element *element)
char const * xDataXML_getAttributesValueInElement(xDataXML_element *element, char const *name)
int xDataTOM_smrLibraryID
Definition: xDataTOM.cc:34

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}
void * smr_freeMemory(void **p)

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}
xDataXML_element * element
enum xDataXML_itemMode mode
xDataXML_element * parentElement
@ xDataXML_itemModeText
@ xDataXML_itemModeElement
@ xDataXML_itemModeEnd

◆ 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
@ xDataXML_errFileError

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  ID,
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_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_statusError

◆ 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_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}
#define smr_setReportError3p(smr, userInterface, libraryID, code, fmt)
xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int(statusMessageReporting *smr, xDataXML_element *element, char const *name, xDataTOM_Int *n, int required)