Geant4 Cross Reference |
1 /* 2 # <<BEGIN-copyright>> 3 # <<END-copyright>> 4 */ 5 #ifndef xDataTOM_importXML_private_h_included 6 #define xDataTOM_importXML_private_h_included 7 8 #include <expat.h> 9 #include <statusMessageReporting.h> 10 #include <xDataTOM_private.h> 11 12 #if defined __cplusplus 13 extern "C" { 14 namespace GIDI { 15 #endif 16 17 #ifndef XMLCALL 18 #define XMLCALL 19 #endif 20 21 #ifndef XML_Char 22 #define XML_Char char 23 #endif 24 25 #ifndef XML_Size 26 #define XML_Size long 27 #endif 28 29 typedef struct xDataXMLType_s xDataXMLType; 30 31 enum xDataXML_status { xDataXML_statusParsing = 1, xDataXML_statusCompleted, xDataXML_statusError }; 32 enum xDataXML_errorCodes { xDataXML_errNone, xDataXML_errXML_ParserCreate, xDataXML_errFileError, xDataXML_errXMLParser }; 33 enum xDataXML_itemMode { xDataXML_itemModeEnd = 0, xDataXML_itemModeElement, xDataXML_itemModeText }; 34 enum xDataXML_xDataType { xDataXML_xDataType_Ok, xDataXML_xDataType_ConvertingToData, xDataXML_xDataType_ConvertingToString }; 35 36 typedef struct xDataTOM_importXMLTOM_s xDataTOM_importXMLTOM; 37 typedef struct xDataXML_attribute_s xDataXML_attribute; 38 typedef struct xDataXML_document_s xDataXML_document; 39 typedef struct xDataXML_docInfo_s xDataXML_docInfo; 40 typedef struct xDataXML_attributionList_s xDataXML_attributionList; 41 typedef struct xDataXML_element_s xDataXML_element; 42 typedef struct xDataXML_elementList_s xDataXML_elementList; 43 typedef struct xDataXML_elementListItem_s xDataXML_elementListItem; 44 typedef struct xDataXML_rootElement_s xDataXML_rootElement; 45 typedef struct xDataXML_text_s xDataXML_text; 46 typedef struct xDataXML_smr_s xDataXML_smr; 47 typedef struct xDataXML_item_s xDataXML_item; 48 49 struct xDataXML_docInfo_s { 50 size_t line; 51 size_t column; 52 }; 53 54 struct xDataXML_attribute_s { 55 char *name; 56 char *value; 57 }; 58 59 struct xDataXML_attributionList_s { 60 int number; 61 size_t size; 62 xDataXML_attribute *attributes; 63 }; 64 65 struct xDataXML_text_s { 66 xDataXML_docInfo docInfo; 67 size_t allocated; 68 size_t length; 69 char *text; 70 }; 71 72 typedef int (*xDTXML_toDataFunction)( statusMessageReporting *smr, xDataXMLType *, xDataXML_attributionList *, char const * ); 73 typedef char *(*xDTXML_toStringFunction)( statusMessageReporting *smr, xDataXMLType * ); 74 typedef int (*xDTXML_releaseFunction)( statusMessageReporting *smr, xDataXMLType * ); 75 76 struct xDataXML_elementListItem_s { 77 xDataXML_element *element; 78 const char *sortString; 79 }; 80 81 struct xDataXML_elementList_s { 82 int n; 83 xDataXML_elementListItem *items; 84 }; 85 86 struct xDataXMLType_s { 87 enum xDataXML_xDataType status; 88 const char *ID; 89 xDataXML_element *element; 90 xDTXML_toDataFunction toData; 91 xDTXML_toStringFunction toString; 92 xDTXML_releaseFunction release; 93 int indexPresent, startPresent, endPresent, lengthPresent; 94 xDataTOM_Int index, start, end, length; 95 void *data; 96 }; 97 98 struct xDataXML_rootElement_s { 99 xDataXML_document *xData_doc; 100 xDataXML_element *parentElement; 101 xDataXML_rootElement *parentRoot; 102 int depth; 103 int numberOfElements; 104 xDataXML_element *children; 105 xDataXML_element *currentChild; 106 }; 107 108 struct xDataXML_element_s { 109 xDataXML_docInfo docInfo; 110 int ordinal; /* Counting from 0. */ 111 int index; /* Value from "index" attribute if present or -1 */ 112 int accessed; /* For the convenience of the users, not used internally. */ 113 xDataXML_rootElement *parentRoot; 114 xDataXML_rootElement childrenRoot; 115 xDataXML_element *next; 116 char *name; /* Allocated in xData_parseAddElementToRoot. */ 117 char *fullName; /* Allocated in xData_parseAddElementToRoot. */ 118 xDataXML_attributionList attributes; /* attributes->abbributes is allocated in xData_parseAddElementToRoot. */ 119 xDataXMLType xDataTypeInfo; 120 size_t textOffset; 121 xDataXML_text text; 122 }; 123 124 struct xDataXML_smr_s { 125 smr_userInterface smrUserInterface; 126 xDataXML_document *doc; 127 }; 128 129 struct xDataXML_document_s { 130 enum xDataXML_status status; 131 enum xDataXML_errorCodes error; 132 enum XML_Error err; 133 XML_Size err_line, err_column; 134 char *fileName; 135 char *realFileName; 136 xDataXML_smr smrUserInterface; 137 statusMessageReporting *smr; 138 XML_Parser xmlParser; 139 xDataXML_rootElement root; 140 xDataXML_rootElement *currentRoot; 141 }; 142 143 struct xDataXML_item_s { 144 xDataXML_element *parentElement; 145 xDataXML_element *element; 146 enum xDataXML_itemMode mode; 147 size_t textOffset; 148 size_t textLength; 149 char *text; 150 }; 151 152 xDataTOM_TOM *xDataXML_importFile( statusMessageReporting *smr, char const *fileName ); 153 xDataXML_document *xDataXML_importFile2( statusMessageReporting *smr, char const *fileName ); 154 void *xDataXML_freeDoc( statusMessageReporting *smr, xDataXML_document *doc ); 155 int xDataXML_parseIsError( xDataXML_document *doc ); 156 xDataXML_element *xDataXML_getDocumentsElement( xDataXML_document *doc ); 157 xDataXML_element *xDataXML_getFirstElement( xDataXML_element *element ); 158 xDataXML_element *xDataXML_getNextElement( xDataXML_element *element ); 159 enum xDataXML_itemMode xDataXML_getFirstItem( xDataXML_element *element, xDataXML_item *item ); 160 enum xDataXML_itemMode xDataXML_getNextItem( xDataXML_item *item ); 161 int xDataXML_isAttributeInList( xDataXML_attributionList *attributes, char const *name ); 162 int xDataXML_isAttributeInElement( xDataXML_element *element, char const *name ); 163 char *xDataXML_getAttributesValue( xDataXML_attributionList *attributes, char const *name ); 164 char const *xDataXML_getAttributesValueInElement( xDataXML_element *element, char const *name ); 165 int xDataXML_attributeListLength( xDataXML_attributionList *attributes ); 166 xDataXML_attribute *xDataXML_attributeByIndex( xDataXML_attributionList *attributes, int index ); 167 int xDataXML_getCommonData( statusMessageReporting *smr, xDataXML_element *element, xDataTOM_Int *index, xDataTOM_Int *start, xDataTOM_Int *end, 168 xDataTOM_Int *length ); 169 int xDataXML_xDataTypeConvertAttributes( statusMessageReporting *smr, xDataXML_element *element ); 170 xDataTOM_Int xDataXML_convertAttributeTo_xDataTOM_Int( statusMessageReporting *smr, xDataXML_element *element, char const *name, xDataTOM_Int *n, int required ); 171 int xDataXML_convertAttributeToDouble( statusMessageReporting *smr, xDataXML_element *element, char const *name, double *d, int required ); 172 int xDataXML_numberOfElementsByTagName( statusMessageReporting *smr, xDataXML_element *element, char const *tagName ); 173 xDataXML_elementList *xDataXML_getElementsByTagName( statusMessageReporting *smr, xDataXML_element *element, char const *tagName ); 174 xDataXML_element *xDataXML_getOneElementByTagName( statusMessageReporting *smr, xDataXML_element *element, char *name, int required ); 175 void xDataXML_freeElementList( statusMessageReporting *smr, xDataXML_elementList *list ); 176 int xDataXML_is_xDataType( statusMessageReporting *smr, xDataXMLType *xDT, char const * const type, int setMsg ); 177 char const *xDataXML_getFileName( xDataXML_document *doc ); 178 char const *xDataXML_getRealFileName( xDataXML_document *doc ); 179 xDataXML_document *xDataXML_getElementsDocument( xDataXML_element *element ); 180 void *xDataXML_get_smrUserInterfaceFromDocument( xDataXML_document *doc ); 181 void *xDataXML_get_smrUserInterfaceFromElement( xDataXML_element *element ); 182 int xDataXML_stringTo_xDataTOM_Int( statusMessageReporting *smr, void *smrUserInterface, char const *c, xDataTOM_Int *value, char const *endings, char **e ); 183 int xDataXML_stringTo_double( statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e ); 184 int xDataXML_addToAccessed( statusMessageReporting *smr, xDataXML_element *element, int increment ); 185 int xDataXML_getAccessed( statusMessageReporting *smr, xDataXML_element *element ); 186 void *xDataXML_initializeData( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE, char const *ID, size_t size ); 187 188 /* 189 c Stuff in xDataTOM_importXML_axes.c 190 */ 191 int xDataXML_axesElememtToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes ); 192 int xDataXML_axesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_axes *axes ); 193 194 /* 195 c Stuff in xDataTOM_importXML_XYs.c 196 */ 197 int xDataXML_XYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 198 int xDataXML_XYsDataToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_XYs *XYs, int index, int length, double value, double accuracy, 199 enum xDataTOM_subAxesType subAxesType, int axesOffest, xDataTOM_axes *axes, xDataTOM_interpolation *interpolation ); 200 int xDataXML_stringToDoubles( statusMessageReporting *smr, xDataXML_element *XE, char const *s, int length, double *d ); 201 202 /* 203 c Stuff in xDataTOM_importXML_regionsXYs.c 204 */ 205 int xDataXML_regionsXYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 206 207 /* 208 c Stuff in xDataTOM_importXML_W_XYs.c 209 */ 210 int xDataXML_W_XYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 211 int xDataXML_W_XYsDataToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_W_XYs *W_XYs, int index, double value, xDataTOM_axes *axes, 212 int axesOffset ); 213 214 /* 215 c Stuff in xDataTOM_importXML_V_W_XYs.c 216 */ 217 int xDataXML_V_W_XYsToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 218 219 /* 220 c Stuff in xDataTOM_importXML_W_XYs_LegendreSeries.c 221 */ 222 int xDataXML_W_XYs_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 223 int xDataXML_W_XYs_LegendreSeries_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_LegendreSeries *LegendreSeries ); 224 225 /* 226 c Stuff in xDataTOM_importXML_regionsW_XYs_LegendreSeries.c 227 */ 228 int xDataXML_regionsW_XYs_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 229 230 /* 231 c Stuff in xDataTOM_importXML_V_W_XYs_LegendreSeries.c 232 */ 233 int xDataXML_V_W_XYs_LegendreSeriesToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 234 235 /* 236 c Stuff in xDataTOM_importXML_polynomial.c 237 */ 238 int xDataXML_polynomialToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 239 240 /* 241 c Stuff in xDataTOM_importXML_KalbachMann.c 242 */ 243 int xDataXML_KalbachMannToTOM( statusMessageReporting *smr, xDataXML_element *XE, xDataTOM_element *TE ); 244 245 #if defined __cplusplus 246 } 247 } 248 #endif 249 250 #endif /* End of xDataTOM_importXML_private_h_included. */ 251