Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
xData.h
Go to the documentation of this file.
1 /*
2 # <<BEGIN-copyright>>
3 # Copyright (c) 2010, Lawrence Livermore National Security, LLC.
4 # Produced at the Lawrence Livermore National Laboratory
5 # Written by Bret R. Beck, beck6@llnl.gov.
6 # CODE-461393
7 # All rights reserved.
8 #
9 # This file is part of GIDI. For details, see nuclear.llnl.gov.
10 # Please also read the "Additional BSD Notice" at nuclear.llnl.gov.
11 #
12 # Redistribution and use in source and binary forms, with or without modification,
13 # are permitted provided that the following conditions are met:
14 #
15 # 1) Redistributions of source code must retain the above copyright notice,
16 # this list of conditions and the disclaimer below.
17 # 2) Redistributions in binary form must reproduce the above copyright notice,
18 # this list of conditions and the disclaimer (as noted below) in the
19 # documentation and/or other materials provided with the distribution.
20 # 3) Neither the name of the LLNS/LLNL nor the names of its contributors may be
21 # used to endorse or promote products derived from this software without
22 # specific prior written permission.
23 #
24 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
25 # EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26 # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
27 # SHALL LAWRENCE LIVERMORE NATIONAL SECURITY, LLC, THE U.S. DEPARTMENT OF ENERGY OR
28 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29 # CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
31 # AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
33 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 # <<END-copyright>>
35 */
36 #ifndef xData_h_included
37 #define xData_h_included
38 
39 #if defined __cplusplus
40  extern "C" {
41 #endif
42 
43 #include <expat.h>
44 #include "statusMessageReporting.h"
45 
46 #if defined __cplusplus
47  namespace GIDI {
48 #endif
49 
50 typedef int xData_Int;
51 
52 #ifndef XMLCALL
53 #define XMLCALL
54 #endif
55 
56 #ifndef XML_Char
57 #define XML_Char char
58 #endif
59 
60 #ifndef XML_Size
61 #define XML_Size long
62 #endif
63 
64 //TK move follwoing reference from source
65 //extern char const * const xData_oned_x_ID;
66 //extern char const * const xData_twod_xy_ID;
67 //extern char const * const xData_twod_xindex_y_ID;
68 //extern char const * const xData_twod_xShared_yHistogram_ID;
69 //extern char const * const xData_matrix_ID;
70 
71 char const * const xData_oned_x_ID = "1d.x";
72 char const * const xData_twod_xy_ID = "2d.xy";
73 char const * const xData_twod_xindex_y_ID = "2d.xindex_y";
74 char const * const xData_twod_xShared_yHistogram_ID = "2d_xShared_yHistogram";
75 char const * const xData_matrix_ID = "matrix";
76 
82 
88 typedef struct xData_text_s xData_text;
89 typedef struct xDataType_s xDataType;
90 typedef struct xData_smr_s xData_smr;
92 typedef struct xData_item_s xData_item;
98 
99 typedef int (*xData_sortElementFunc)( const void *, const void * );
100 
103  double value;
104 };
105 
107  xData_Int row, start, end;
108 };
109 
111  xData_Int rows, columns;
113  double *values;
114 };
115 
117  size_t line;
118  size_t column;
119 };
120 
122  char *name;
123  char *value;
124 };
125 
127  int number;
128  size_t size;
130 };
131 
132 struct xData_text_s {
134  size_t allocated;
135  size_t length;
136  char *text;
137 };
138 
139 typedef int (*xData_xDataTypeOk)( char const *name, xData_document *doc, void *userData );
141 typedef char *(*xDT_toStringFunction)( statusMessageReporting *smr, xDataType * );
143 
146  const char *sortString;
147 };
148 
150  int n;
152 };
153 
154 struct xDataType_s {
155  enum xData_xDataType status;
156  const char *typeString;
161  signed char indexPresent, startPresent, endPresent, lengthPresent;
162  xData_Int index, start, end, length;
163  void *data;
164 };
165 
170  int depth;
174 };
175 
178  int ordinal; /* Counting from 0. */
179  int index; /* Value from "index" attribute if present or -1 */
180  int accessed; /* For the convenience of the users, not used internally. */
184  char *name; /* Allocated in xData_parseAddElementToRoot. */
185  char *fullName; /* Allocated in xData_parseAddElementToRoot. */
186  xData_attributionList attributes; /* attributes->abbributes is allocated in xData_parseAddElementToRoot. */
188  size_t textOffset;
190 };
191 
192 struct xData_smr_s {
195 };
196 
198  enum xData_status status;
199  enum xData_errorCodes error;
200  enum XML_Error err;
201  XML_Size err_line, err_column;
202  char *fileName;
210 };
211 
212 struct xData_item_s {
215  enum xData_itemMode mode;
216  size_t textOffset;
217  size_t textLength;
218  char *text;
219 };
220 
221 xData_document *xData_parseReadFile( statusMessageReporting *smr, const char *fileName, xData_xDataTypeOk func, void *userData );
226 void *xData_parseFree( statusMessageReporting *smr, xData_document *xData_doc );
227 int xData_parse( xData_document *xData_doc, const char *s );
228 int xData_parseIsError( xData_document *xData_doc );
234 char *xData_getAttributesValue( xData_attributionList *attributes, const char *name );
235 const char *xData_getAttributesValueInElement( xData_element *element, const char *name );
243  xData_Int *length );
246 int xData_convertAttributeToDouble( statusMessageReporting *smr, xData_element *element, const char *name, double *d );
247 int xData_numberOfElementsByTagName( statusMessageReporting *smr, xData_element *element, const char *tagName );
250  const char *sortAttributeName, xData_sortElementFunc sortFunction );
253 int xData_addToAccessed( statusMessageReporting *smr, xData_element *element, int increment );
255 
257 int xData_is_1d_x( statusMessageReporting *smr, xDataType *xDT, int setMsg );
258 int xData_isElement_1d_x( statusMessageReporting *smr, xData_element *element, int setMsg );
259 int xData_1d_x_copyData( statusMessageReporting *smr, xData_element *element, xData_Int nAllocatedBytes, double *d );
262 
264 int xData_is_2d_xindex_y( statusMessageReporting *smr, xDataType *xDT, int setMsg );
265 int xData_isElement_2d_xindex_y( statusMessageReporting *smr, xData_element *element, int setMsg );
268 double *xData_2d_xindex_y_toXYs( statusMessageReporting *smr, xData_element *element, double *Xs );
269 double *xData_2d_xindex_y_toFilledYs( statusMessageReporting *smr, xData_element *element, double *Xs );
271 double *xData_2d_xindex_y_toFilledXYs( statusMessageReporting *smr, xData_element *element, double *Xs );
272 
274 int xData_is_2d_xy( statusMessageReporting *smr, xDataType *xDT, int setMsg );
275 int xData_isElement_2d_xy( statusMessageReporting *smr, xData_element *element, int setMsg );
278 
284 double *xData_2d_xShared_yHistogram_toFilledXYs( xDataType *xDT, xData_Int nXs, double *Xs );
285 
287 int xData_is_matrix( statusMessageReporting *smr, xDataType *xDT, int setMsg );
288 int xData_isElement_matrix( statusMessageReporting *smr, xData_element *element, int setMsg );
292 
293 int xData_is_xDataType( statusMessageReporting *smr, xDataType *xDT, char const * const type, int setMsg );
294 char const *xData_getFileName( xData_document *doc );
295 int xData_setFileName( statusMessageReporting *smr, xData_document *doc, char const *fileName );
299 
300 int xData_stringTo_xData_Int( statusMessageReporting *smr, void *smrUserInterface, char const *c, xData_Int *value, char const *endings, char **e );
301 int xData_stringTo_double( statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e );
302 
303 /*
304 * Stuff in xDataMisc.c
305 */
306 void *xData_malloc( statusMessageReporting *smr, size_t size, int zero, const char *forItem, const char *file, int line );
307 void *xData_realloc( statusMessageReporting *smr, void *pOld, size_t size, const char *forItem, const char *routine, int line );
308 void *xData_free( statusMessageReporting *smr, void *p );
309 char *xDataMisc_allocateCopyString( statusMessageReporting *smr, const char *s, const char *forItem, const char *routine, int line );
310 char *xDataMisc_getAbsPath( statusMessageReporting *smr, const char *fileName );
311 int xData_setMessageError_ReturnInt( int value, statusMessageReporting *smr, void *userData, const char *file, int line, int code, const char *fmt, ... );
312 
313 #define xData_malloc2( smr, size, zero, forItem ) xData_malloc( smr, size, zero, forItem, __FILE__, __LINE__ )
314 #define xData_realloc2( smr, old, size, forItem ) xData_realloc( smr, old, size, forItem, __FILE__, __LINE__ )
315 #define xDataMisc_allocateCopyString2( smr, s, forItem ) xDataMisc_allocateCopyString( smr, s, forItem, __FILE__, __LINE__ )
316 
317 #if defined __cplusplus
318  }
319  }
320 #endif
321 
322 #endif /* End of xData_h_included. */