Geant4 10.7.0
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 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_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}
#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 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}
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 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_itemModeText
@ xDataXML_itemModeElement
@ xDataXML_itemModeEnd

◆ 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
@ xDataXML_errFileError
#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  ID,
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_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_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 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_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}
#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)