Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
xData.h File Reference
#include <expat.h>
#include "statusMessageReporting.h"

Go to the source code of this file.

Classes

struct  xData_2d_xindex_y_s
 
struct  xData_matrix_rowStartEnd_s
 
struct  xData_matrix_s
 
struct  xData_docInfo_s
 
struct  xData_attribute_s
 
struct  xData_attributionList_s
 
struct  xData_text_s
 
struct  xData_elementListItem_s
 
struct  xData_elementList_s
 
struct  xDataType_s
 
struct  xData_rootElement_s
 
struct  xData_element_s
 
struct  xData_smr_s
 
struct  xData_document_s
 
struct  xData_item_s
 

Macros

#define XMLCALL
 
#define XML_Char   char
 
#define XML_Size   long
 
#define xData_malloc2(smr, size, zero, forItem)   xData_malloc( smr, size, zero, forItem, __FILE__, __LINE__ )
 
#define xData_realloc2(smr, old, size, forItem)   xData_realloc( smr, old, size, forItem, __FILE__, __LINE__ )
 
#define xDataMisc_allocateCopyString2(smr, s, forItem)   xDataMisc_allocateCopyString( smr, s, forItem, __FILE__, __LINE__ )
 

Typedefs

typedef int xData_Int
 
typedef struct xData_docInfo_s xData_docInfo
 
typedef struct xData_attribute_s xData_attribute
 
typedef struct xData_attributionList_s xData_attributionList
 
typedef struct xData_rootElement_s xData_rootElement
 
typedef struct xData_element_s xData_element
 
typedef struct xData_text_s xData_text
 
typedef struct xDataType_s xDataType
 
typedef struct xData_smr_s xData_smr
 
typedef struct xData_document_s xData_document
 
typedef struct xData_item_s xData_item
 
typedef struct xData_2d_xindex_y_s xData_2d_xindex_y
 
typedef struct xData_matrix_s xData_matrix
 
typedef struct xData_matrix_rowStartEnd_s xData_matrix_rowStartEnd
 
typedef struct xData_elementListItem_s xData_elementListItem
 
typedef struct xData_elementList_s xData_elementList
 
typedef int(* xData_sortElementFunc) (const void *, const void *)
 
typedef int(* xData_xDataTypeOk) (char const *name, xData_document *doc, void *userData)
 
typedef int(* xDT_toDataFunction) (statusMessageReporting *smr, xDataType *, xData_attributionList *, const char *)
 
typedef char *(* xDT_toStringFunction) (statusMessageReporting *smr, xDataType *)
 
typedef int(* xDT_releaseFunction) (statusMessageReporting *smr, xDataType *)
 

Enumerations

enum  xData_status { xData_statusParsing = 1 , xData_statusCompleted , xData_statusError }
 
enum  xData_errorCodes { xData_errNone , xData_errXML_ParserCreate , xData_errFileError , xData_errXMLParser }
 
enum  xData_itemMode { xData_itemModeEnd = 0 , xData_itemModeElement , xData_itemModeText }
 
enum  xData_xDataType { xData_xDataType_Ok , xData_xDataType_ConvertingToData , xData_xDataType_ConvertingToString }
 

Functions

xData_documentxData_parseReadFile (statusMessageReporting *smr, const char *fileName, xData_xDataTypeOk func, void *userData)
 
xData_documentxData_parseString (statusMessageReporting *smr, const char *str, xData_xDataTypeOk func, void *userData)
 
xData_documentxData_parseMalloc (statusMessageReporting *smr, xData_xDataTypeOk func, void *userData)
 
int xData_parseInitialize (statusMessageReporting *smr, xData_document *xData_doc, xData_xDataTypeOk func, void *userData)
 
int xData_parseEndOfXML (statusMessageReporting *smr, xData_document *xData_doc)
 
void * xData_parseFree (statusMessageReporting *smr, xData_document *xData_doc)
 
int xData_parse (xData_document *xData_doc, const char *s)
 
int xData_parseIsError (xData_document *xData_doc)
 
xData_elementxData_getDocumentsElement (xData_document *xData_doc)
 
xData_elementxData_getFirstElement (xData_element *element)
 
xData_elementxData_getNextElement (xData_element *element)
 
enum xData_itemMode xData_getFirstItem (xData_element *element, xData_item *item)
 
enum xData_itemMode xData_getNextItem (xData_item *item)
 
char * xData_getAttributesValue (xData_attributionList *attributes, const char *name)
 
const char * xData_getAttributesValueInElement (xData_element *element, const char *name)
 
int xData_initializeAttributionList (statusMessageReporting *smr, xData_attributionList *attributes)
 
int xData_copyAttributionList (statusMessageReporting *smr, xData_attributionList *dest, xData_attributionList *src)
 
int xData_releaseAttributionList (statusMessageReporting *smr, xData_attributionList *attributes)
 
int xData_attributeListLength (xData_attributionList *attributes)
 
xData_attributexData_attributeByIndex (xData_attributionList *attributes, int index)
 
xData_elementxData_getElements_xDataElement (statusMessageReporting *smr, xData_element *element)
 
int xData_getCommonData (statusMessageReporting *smr, xData_element *element, xData_Int *index, xData_Int *start, xData_Int *end, xData_Int *length)
 
int xData_xDataTypeConvertAttributes (statusMessageReporting *smr, xData_element *element)
 
xData_Int xData_convertAttributeTo_xData_Int (statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
 
int xData_convertAttributeToDouble (statusMessageReporting *smr, xData_element *element, const char *name, double *d)
 
int xData_numberOfElementsByTagName (statusMessageReporting *smr, xData_element *element, const char *tagName)
 
xData_elementListxData_getElementsByTagName (statusMessageReporting *smr, xData_element *element, const char *tagName)
 
xData_elementListxData_getElementsByTagNameAndSort (statusMessageReporting *smr, xData_element *element, const char *tagName, const char *sortAttributeName, xData_sortElementFunc sortFunction)
 
xData_elementxData_getOneElementByTagName (statusMessageReporting *smr, xData_element *element, char *name, int required)
 
void xData_freeElementList (statusMessageReporting *smr, xData_elementList *list)
 
int xData_addToAccessed (statusMessageReporting *smr, xData_element *element, int increment)
 
int xData_getAccessed (statusMessageReporting *smr, xData_element *element)
 
int xData_init_1d_x (statusMessageReporting *smr, xData_element *element)
 
int xData_is_1d_x (statusMessageReporting *smr, xDataType *xDT, int setMsg)
 
int xData_isElement_1d_x (statusMessageReporting *smr, xData_element *element, int setMsg)
 
int xData_1d_x_copyData (statusMessageReporting *smr, xData_element *element, xData_Int nAllocatedBytes, double *d)
 
double * xData_1d_x_allocateCopyData (statusMessageReporting *smr, xData_element *element)
 
int xData_1d_x_free_copyData (statusMessageReporting *smr, void *data)
 
int xData_init_2d_xindex_y (statusMessageReporting *smr, xData_element *element)
 
int xData_is_2d_xindex_y (statusMessageReporting *smr, xDataType *xDT, int setMsg)
 
int xData_isElement_2d_xindex_y (statusMessageReporting *smr, xData_element *element, int setMsg)
 
xData_IntxData_2d_xindex_y_rawIndices (statusMessageReporting *smr, xData_element *element)
 
int xData_2d_xindex_y_free_rawIndices (statusMessageReporting *smr, void *data)
 
double * xData_2d_xindex_y_toXYs (statusMessageReporting *smr, xData_element *element, double *Xs)
 
double * xData_2d_xindex_y_toFilledYs (statusMessageReporting *smr, xData_element *element, double *Xs)
 
int xData_2d_xindex_y_free_toFilledYs (statusMessageReporting *smr, void *data)
 
double * xData_2d_xindex_y_toFilledXYs (statusMessageReporting *smr, xData_element *element, double *Xs)
 
int xData_init_2d_xy (statusMessageReporting *smr, xData_element *element)
 
int xData_is_2d_xy (statusMessageReporting *smr, xDataType *xDT, int setMsg)
 
int xData_isElement_2d_xy (statusMessageReporting *smr, xData_element *element, int setMsg)
 
double * xData_2d_xy_allocateCopyData (statusMessageReporting *smr, xData_element *element, xData_Int *length)
 
int xData_2d_xy_free_copyData (statusMessageReporting *smr, void *data)
 
int xData_init_2d_xShared_yHistogram (statusMessageReporting *smr, xData_element *element)
 
int xData_is_2d_xShared_yHistogram (statusMessageReporting *smr, xDataType *xDT, int setMsg)
 
int xData_isElement_2d_xShared_yHistogram (statusMessageReporting *smr, xData_element *element, int setMsg)
 
double * xData_2d_xShared_yHistogram_copyData (statusMessageReporting *smr, xData_element *element, xData_Int *n)
 
int xData_2d_xShared_yHistogram_free_copyData (statusMessageReporting *smr, void *data)
 
double * xData_2d_xShared_yHistogram_toFilledXYs (xDataType *xDT, xData_Int nXs, double *Xs)
 
int xData_init_matrix (statusMessageReporting *smr, xData_element *element)
 
int xData_is_matrix (statusMessageReporting *smr, xDataType *xDT, int setMsg)
 
int xData_isElement_matrix (statusMessageReporting *smr, xData_element *element, int setMsg)
 
xData_matrixxData_matrix_copyData (statusMessageReporting *smr, xData_element *element)
 
int xData_matrix_free_copyData (statusMessageReporting *smr, void *data)
 
int getRowStartEndAtIndex (statusMessageReporting *smr, xDataType *xDT, xData_Int index, xData_Int *row, xData_Int *start, xData_Int *end)
 
int xData_is_xDataType (statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
 
char constxData_getFileName (xData_document *doc)
 
int xData_setFileName (statusMessageReporting *smr, xData_document *doc, char const *fileName)
 
xData_documentxData_getElementsDocument (xData_element *element)
 
void * xData_get_smrUserInterfaceFromDocument (xData_document *doc)
 
void * xData_get_smrUserInterfaceFromElement (xData_element *element)
 
int xData_stringTo_xData_Int (statusMessageReporting *smr, void *smrUserInterface, char const *c, xData_Int *value, char const *endings, char **e)
 
int xData_stringTo_double (statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e)
 
void * xData_malloc (statusMessageReporting *smr, size_t size, int zero, const char *forItem, const char *file, int line)
 
void * xData_realloc (statusMessageReporting *smr, void *pOld, size_t size, const char *forItem, const char *routine, int line)
 
void * xData_free (statusMessageReporting *smr, void *p)
 
char * xDataMisc_allocateCopyString (statusMessageReporting *smr, const char *s, const char *forItem, const char *routine, int line)
 
char * xDataMisc_getAbsPath (statusMessageReporting *smr, const char *fileName)
 
int xData_setMessageError_ReturnInt (int value, statusMessageReporting *smr, void *userData, const char *file, int line, int code, const char *fmt,...)
 

Variables

char const *const xData_oned_x_ID = "1d.x"
 
char const *const xData_twod_xy_ID = "2d.xy"
 
char const *const xData_twod_xindex_y_ID = "2d.xindex_y"
 
char const *const xData_twod_xShared_yHistogram_ID = "2d_xShared_yHistogram"
 
char const *const xData_matrix_ID = "matrix"
 

Macro Definition Documentation

◆ xData_malloc2

#define xData_malloc2 (   smr,
  size,
  zero,
  forItem 
)    xData_malloc( smr, size, zero, forItem, __FILE__, __LINE__ )

Definition at line 313 of file xData.h.

◆ xData_realloc2

#define xData_realloc2 (   smr,
  old,
  size,
  forItem 
)    xData_realloc( smr, old, size, forItem, __FILE__, __LINE__ )

Definition at line 314 of file xData.h.

◆ xDataMisc_allocateCopyString2

#define xDataMisc_allocateCopyString2 (   smr,
  s,
  forItem 
)    xDataMisc_allocateCopyString( smr, s, forItem, __FILE__, __LINE__ )

Definition at line 315 of file xData.h.

◆ XML_Char

#define XML_Char   char

Definition at line 57 of file xData.h.

◆ XML_Size

#define XML_Size   long

Definition at line 61 of file xData.h.

◆ XMLCALL

#define XMLCALL

Definition at line 53 of file xData.h.

Typedef Documentation

◆ xData_2d_xindex_y

Definition at line 93 of file xData.h.

◆ xData_attribute

Definition at line 84 of file xData.h.

◆ xData_attributionList

Definition at line 85 of file xData.h.

◆ xData_docInfo

Definition at line 83 of file xData.h.

◆ xData_document

Definition at line 91 of file xData.h.

◆ xData_element

Definition at line 87 of file xData.h.

◆ xData_elementList

Definition at line 97 of file xData.h.

◆ xData_elementListItem

Definition at line 96 of file xData.h.

◆ xData_Int

typedef int xData_Int

Definition at line 50 of file xData.h.

◆ xData_item

typedef struct xData_item_s xData_item

Definition at line 92 of file xData.h.

◆ xData_matrix

typedef struct xData_matrix_s xData_matrix

Definition at line 94 of file xData.h.

◆ xData_matrix_rowStartEnd

Definition at line 95 of file xData.h.

◆ xData_rootElement

Definition at line 86 of file xData.h.

◆ xData_smr

typedef struct xData_smr_s xData_smr

Definition at line 90 of file xData.h.

◆ xData_sortElementFunc

typedef int(* xData_sortElementFunc) (const void *, const void *)

Definition at line 99 of file xData.h.

◆ xData_text

typedef struct xData_text_s xData_text

Definition at line 88 of file xData.h.

◆ xData_xDataTypeOk

typedef int(* xData_xDataTypeOk) (char const *name, xData_document *doc, void *userData)

Definition at line 139 of file xData.h.

◆ xDataType

typedef struct xDataType_s xDataType

Definition at line 89 of file xData.h.

◆ xDT_releaseFunction

typedef int(* xDT_releaseFunction) (statusMessageReporting *smr, xDataType *)

Definition at line 142 of file xData.h.

◆ xDT_toDataFunction

typedef int(* xDT_toDataFunction) (statusMessageReporting *smr, xDataType *, xData_attributionList *, const char *)

Definition at line 140 of file xData.h.

◆ xDT_toStringFunction

typedef char *(* xDT_toStringFunction) (statusMessageReporting *smr, xDataType *)

Definition at line 141 of file xData.h.

Enumeration Type Documentation

◆ xData_errorCodes

Enumerator
xData_errNone 
xData_errXML_ParserCreate 
xData_errFileError 
xData_errXMLParser 

Definition at line 78 of file xData.h.

@ xData_errXML_ParserCreate
Definition: xData.h:78
@ xData_errFileError
Definition: xData.h:78
@ xData_errXMLParser
Definition: xData.h:79
@ xData_errNone
Definition: xData.h:78

◆ xData_itemMode

Enumerator
xData_itemModeEnd 
xData_itemModeElement 
xData_itemModeText 

Definition at line 80 of file xData.h.

@ xData_itemModeText
Definition: xData.h:80
@ xData_itemModeEnd
Definition: xData.h:80
@ xData_itemModeElement
Definition: xData.h:80

◆ xData_status

Enumerator
xData_statusParsing 
xData_statusCompleted 
xData_statusError 

Definition at line 77 of file xData.h.

@ xData_statusError
Definition: xData.h:77
@ xData_statusCompleted
Definition: xData.h:77
@ xData_statusParsing
Definition: xData.h:77

◆ xData_xDataType

Enumerator
xData_xDataType_Ok 
xData_xDataType_ConvertingToData 
xData_xDataType_ConvertingToString 

Definition at line 81 of file xData.h.

@ xData_xDataType_Ok
Definition: xData.h:81
@ xData_xDataType_ConvertingToData
Definition: xData.h:81
@ xData_xDataType_ConvertingToString
Definition: xData.h:81

Function Documentation

◆ getRowStartEndAtIndex()

int getRowStartEndAtIndex ( statusMessageReporting smr,
xDataType xDT,
xData_Int  index,
xData_Int row,
xData_Int start,
xData_Int end 
)

Definition at line 231 of file xData_matrix.cc.

231 {
232
233 int status = 0;
234 xData_matrix *matrix = (xData_matrix *) xDT->data;
235
236 if( !xData_is_matrix( smr, xDT, 1 ) ) return( 1 );
237 if( ( index < 0 ) || ( index >= xDT->length ) ) {
238 smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( xDT->element ), __FILE__, __LINE__, 1,
239 "index = %lld out of range (valid range 0 <= index < %lld)", index, xDT->length );
240 status = 1; }
241 else {
242 *row = matrix->rowStartEnds[index].row;
243 *start = matrix->rowStartEnds[index].start;
244 *end = matrix->rowStartEnds[index].end;
245 }
246 return( status );
247}
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
xData_Int length
Definition: xData.h:162
xData_element * element
Definition: xData.h:157
void * data
Definition: xData.h:163
xData_matrix_rowStartEnd * rowStartEnds
Definition: xData.h:112
void * xData_get_smrUserInterfaceFromElement(xData_element *element)
Definition: xData.cc:952
int xData_is_matrix(statusMessageReporting *smr, xDataType *xDT, int setMsg)
Definition: xData_matrix.cc:71

◆ xData_1d_x_allocateCopyData()

double * xData_1d_x_allocateCopyData ( statusMessageReporting smr,
xData_element element 
)

Definition at line 105 of file xData_1d_x.cc.

105 {
106
107 xData_Int i, n;
108 xDataType *xDT = &(element->xDataTypeInfo);
109 double *p, *data;
110
111 if( !xData_isElement_1d_x( smr, element, 1 ) ) return( NULL );
112 n = xDT->end - xDT->start;
113 p = (double *) xDT->data;
114 //if( ( data = xData_malloc2( smr, n * sizeof( double ), 0, "data" ) ) == NULL ) return( NULL );
115 if( ( data = (double*) xData_malloc2( smr, n * sizeof( double ), 0, "data" ) ) == NULL ) return( NULL );
116 for( i = 0; i < n; i++, p++ ) data[i] = *p;
117 return( data );
118}
xData_Int end
Definition: xData.h:162
xData_Int start
Definition: xData.h:162
xDataType xDataTypeInfo
Definition: xData.h:187
#define xData_malloc2(smr, size, zero, forItem)
Definition: xData.h:313
int xData_Int
Definition: xData.h:50
int xData_isElement_1d_x(statusMessageReporting *smr, xData_element *element, int setMsg)
Definition: xData_1d_x.cc:77

◆ xData_1d_x_copyData()

int xData_1d_x_copyData ( statusMessageReporting smr,
xData_element element,
xData_Int  nAllocatedBytes,
double *  d 
)

Definition at line 84 of file xData_1d_x.cc.

84 {
85
86 xData_Int i, n;
87 xDataType *xDT = &(element->xDataTypeInfo);
88 double *p;
89
90 if( !xData_isElement_1d_x( smr, element, 1 ) ) return( 1 );
91 n = xDT->end - xDT->start;
92 //if( n * sizeof( double ) > nAllocatedBytes ) {
93 if( n * sizeof( double ) > (size_t) nAllocatedBytes ) {
94 void *smrUser = xData_get_smrUserInterfaceFromElement( element );
95 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1, "allocated memory = %lld to small, need %lld", nAllocatedBytes, n );
96 return( 1 );
97 }
98 p = (double *) xDT->data;
99 for( i = 0; i < n; i++, d++, p++ ) *d = *p;
100 return( 0 );
101}

Referenced by tpia_misc_getEqualProbableBins().

◆ xData_1d_x_free_copyData()

int xData_1d_x_free_copyData ( statusMessageReporting smr,
void *  data 
)

Definition at line 122 of file xData_1d_x.cc.

122 {
123
124 xData_free( smr, data );
125 return( 0 );
126}
void * xData_free(statusMessageReporting *smr, void *p)
Definition: xDataMisc.cc:89

◆ xData_2d_xindex_y_free_rawIndices()

int xData_2d_xindex_y_free_rawIndices ( statusMessageReporting smr,
void *  data 
)

Definition at line 170 of file xData_2d_xindex_y.cc.

170 {
171
172 xData_free( smr, data );
173 return( 0 );
174}

◆ xData_2d_xindex_y_free_toFilledYs()

int xData_2d_xindex_y_free_toFilledYs ( statusMessageReporting smr,
void *  data 
)

Definition at line 209 of file xData_2d_xindex_y.cc.

209 {
210
211 xData_free( smr, data );
212 return( 0 );
213}

◆ xData_2d_xindex_y_rawIndices()

xData_Int * xData_2d_xindex_y_rawIndices ( statusMessageReporting smr,
xData_element element 
)

Definition at line 150 of file xData_2d_xindex_y.cc.

150 {
151/*
152* Returns NULL if length is 0 or memory could not be allocated.
153*/
154 xDataType *xDT = &(element->xDataTypeInfo);
155 xData_Int i, index = xDT->start, *values;
157
158 if( xDT->length == 0 ) return( NULL );
159 //if( ( values = xData_malloc2( smr, xDT->length * sizeof( xData_Int ), 0, "values" ) ) == NULL ) return( NULL );
160 if( ( values = (xData_Int*) xData_malloc2( smr, xDT->length * sizeof( xData_Int ), 0, "values" ) ) == NULL ) return( NULL );
161 for( i = 0; i < xDT->length; i++ ) {
162 values[i] = index;
163 index += data[i].index;
164 }
165 return( values );
166}
xData_Int index
Definition: xData.h:102

◆ xData_2d_xindex_y_toFilledXYs()

double * xData_2d_xindex_y_toFilledXYs ( statusMessageReporting smr,
xData_element element,
double *  Xs 
)

Definition at line 217 of file xData_2d_xindex_y.cc.

217 {
218
219 return( xData_2d_xindex_y_toFilled( smr, element, Xs, 2 ) );
220}

◆ xData_2d_xindex_y_toFilledYs()

double * xData_2d_xindex_y_toFilledYs ( statusMessageReporting smr,
xData_element element,
double *  Xs 
)

Definition at line 202 of file xData_2d_xindex_y.cc.

202 {
203
204 return( xData_2d_xindex_y_toFilled( smr, element, Xs, 1 ) );
205}

Referenced by tpia_misc_get2dxindex_y_data().

◆ xData_2d_xindex_y_toXYs()

double * xData_2d_xindex_y_toXYs ( statusMessageReporting smr,
xData_element element,
double *  Xs 
)

Definition at line 178 of file xData_2d_xindex_y.cc.

178 {
179/*
180* Returns NULL if length is 0 or memory could not be allocated.
181*/
182 xDataType *xDT = &(element->xDataTypeInfo);
183 xData_Int i, index = xDT->start;
184 double *values = NULL, *p;
186
187 if( xDT->length == 0 ) return( NULL );
188 //if( ( values = xData_malloc2( smr, 2 * xDT->length * sizeof( double ), 0, "values" ) ) == NULL ) return( NULL );
189 if( ( values = (double*) xData_malloc2( smr, 2 * xDT->length * sizeof( double ), 0, "values" ) ) == NULL ) return( NULL );
190 p = values;
191 for( i = 0; i < xDT->length; i++, p++ ) {
192 index += data[i].index;
193 *p = Xs[index];
194 p++;
195 *p = data[i].value;
196 }
197 return( values );
198}

◆ xData_2d_xShared_yHistogram_copyData()

double * xData_2d_xShared_yHistogram_copyData ( statusMessageReporting smr,
xData_element element,
xData_Int n 
)

Definition at line 85 of file xData_2d_xshared_yhistogram.cc.

85 {
86
87 xDataType *xDT = &(element->xDataTypeInfo);
88 xData_Int i;
89 double *p, *values, *d = (double *) xDT->data;
90
91 *n = xDT->end - xDT->start;
92 if( xDT->length == 0 ) return( NULL );
93 if( *n == 0 ) return( NULL );
94 //if(( values = xData_malloc2( NULL, *n * sizeof( double ), 0, "values" ) )) {
95 if(( values = (double*) xData_malloc2( NULL, *n * sizeof( double ), 0, "values" ) )) {
96 p = values;
97 for( i = 0; i < *n; i++, p++, d++ ) *p = *d;
98 }
99 return( values );
100}

Referenced by tpia_misc_get2d_xShared_yHistogram_data().

◆ xData_2d_xShared_yHistogram_free_copyData()

int xData_2d_xShared_yHistogram_free_copyData ( statusMessageReporting smr,
void *  data 
)

Definition at line 104 of file xData_2d_xshared_yhistogram.cc.

104 {
105
106 xData_free( smr, data );
107 return( 0 );
108}

◆ xData_2d_xShared_yHistogram_toFilledXYs()

double * xData_2d_xShared_yHistogram_toFilledXYs ( xDataType xDT,
xData_Int  nXs,
double *  Xs 
)

Definition at line 164 of file xData_2d_xshared_yhistogram.cc.

164 {
165/*
166* Returns NULL if length is 0, memory could not be allocated, or nXs != xDT->length + 1.
167*/
168 xData_Int i;
169 //double *p, *values, *d = xDT->data;
170 double *p, *values, *d = (double*) xDT->data;
171
172 if( xDT->length == 0 ) return( NULL );
173 if( ( xDT->length + 1 ) != nXs ) return( NULL );
174 //if( ( values = xData_malloc2( NULL, 4 * xDT->length * sizeof( double ), 0, "values" ) ) == NULL ) return( NULL );
175 if( ( values = (double*) xData_malloc2( NULL, 4 * xDT->length * sizeof( double ), 0, "values" ) ) == NULL ) return( NULL );
176 p = values;
177 for( i = 0; i < xDT->length; i++ ) {
178 *(p++) = Xs[i];
179 *(p++) = 0.;
180 *(p++) = Xs[i+1];
181 *(p++) = 0.;
182 }
183 p = &(values[4 * xDT->start + 1]);
184 for( i = xDT->start; i < xDT->end; i++, d++, p += 2 ) {
185 *p = *d;
186 p += 2;
187 *p = *d;
188 }
189 return( values );
190}

◆ xData_2d_xy_allocateCopyData()

double * xData_2d_xy_allocateCopyData ( statusMessageReporting smr,
xData_element element,
xData_Int length 
)

Definition at line 84 of file xData_2d_xy.cc.

84 {
85
86 xData_Int i;
87 xDataType *xDT = &(element->xDataTypeInfo);
88 double *data;
89
90 if( !xData_isElement_2d_xy( smr, element, 1 ) ) return( NULL );
91 *length = xDT->length;
92 //if( ( data = xData_malloc2( smr, 2 * xDT->length * sizeof( double ), 0, "data" ) ) ) {
93 if( ( data = (double*)xData_malloc2( smr, 2 * xDT->length * sizeof( double ), 0, "data" ) ) ) {
94 for( i = 0; i < 2 * xDT->length; i++ ) data[i] = ((double *) xDT->data)[i];
95 }
96 return( data );
97}
int xData_isElement_2d_xy(statusMessageReporting *smr, xData_element *element, int setMsg)
Definition: xData_2d_xy.cc:77

Referenced by tpia_misc_get2dx_y_data().

◆ xData_2d_xy_free_copyData()

int xData_2d_xy_free_copyData ( statusMessageReporting smr,
void *  data 
)

Definition at line 101 of file xData_2d_xy.cc.

101 {
102
103 xData_free( smr, data );
104 return( 0 );
105}

◆ xData_addToAccessed()

◆ xData_attributeByIndex()

xData_attribute * xData_attributeByIndex ( xData_attributionList attributes,
int  index 
)

Definition at line 603 of file xData.cc.

603 {
604
605 if( index >= attributes->number ) return( NULL );
606 return( &(attributes->attributes[index]) );
607}
xData_attribute * attributes
Definition: xData.h:129

◆ xData_attributeListLength()

int xData_attributeListLength ( xData_attributionList attributes)

Definition at line 596 of file xData.cc.

596 {
597
598 return( attributes->number );
599}

◆ xData_convertAttributeTo_xData_Int()

xData_Int xData_convertAttributeTo_xData_Int ( statusMessageReporting smr,
xData_element element,
const char *  name,
xData_Int n 
)

Definition at line 710 of file xData.cc.

710 {
711/*
712* Returns 1 if no such attribute, -1 if error converting to xData_Int and 0 if successful.
713*/
714 const char *value;
715 char *e;
716
717 if( ( value = xData_getAttributesValueInElement( element, name ) ) == NULL ) return( 1 );
718 //*n = strtoll( value, &e, 10 );
719 *n = strtol( value, &e, 10 );
720 if( *e != 0 ) {
721 smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( element ), __FILE__, __LINE__, 1,
722 "could not convert attribute %s's value = %s to an integer", name, value );
723 return( -1 );
724 }
725 return( 0 );
726}
void * xData_get_smrUserInterfaceFromElement(xData_element *element)
Definition: xData.cc:952
const char * xData_getAttributesValueInElement(xData_element *element, const char *name)
Definition: xData.cc:546

Referenced by tpia_angularEnergy_getFromElement(), tpia_channel_getFromElement(), tpia_misc_getEqualProbableBin(), tpia_misc_getEqualProbableBins(), tpia_target_heated_read(), and xData_xDataTypeConvertAttributes().

◆ xData_convertAttributeToDouble()

int xData_convertAttributeToDouble ( statusMessageReporting smr,
xData_element element,
const char *  name,
double *  d 
)

Definition at line 730 of file xData.cc.

730 {
731/*
732* Returns 1 if no such attribute, -1 if error converting to double and 0 if successful.
733*/
734 const char *value;
735 char *e;
736
737 if( ( value = xData_getAttributesValueInElement( element, name ) ) == NULL ) return( 1 );
738 *d = strtod( value, &e );
739 if( *e != 0 ) {
740 smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( element) , __FILE__, __LINE__, 1,
741 "could not convert attribute %s's values = %s to a double", name, value );
742 return( -1 );
743 }
744 return( 0 );
745}

Referenced by tpia_angularEnergy_getFromElement(), tpia_misc_getEqualProbableBins(), and tpia_target_read().

◆ xData_copyAttributionList()

int xData_copyAttributionList ( statusMessageReporting smr,
xData_attributionList dest,
xData_attributionList src 
)

Definition at line 564 of file xData.cc.

564 {
565/*
566* The dest must not be active, else a memory leak will occur, as this routine does no free-ing.
567*/
568 int i;
569 size_t lens;
570 xData_attribute *d, *s;
571 char *p;
572
573 //if( ( dest->attributes = xData_malloc2( smr, src->size, 0, "attributes" ) ) == NULL ) return( 1 );
574 if( ( dest->attributes = (xData_attribute*) xData_malloc2( smr, src->size, 0, "attributes" ) ) == NULL ) return( 1 );
575 dest->number = src->number;
576 dest->size = src->size;
577 d = dest->attributes;
578 s = src->attributes;
579 p = (char *) &(dest->attributes[src->number]);
580 for( i = 0; i < src->number; i++, s++, d++ ) {
581 lens = strlen( s->name ) + 1;
582 d->name = p;
583 strcpy( p, s->name );
584 p += lens;
585 lens = strlen( s->value ) + 1;
586 d->value= p;
587 strcpy( p, s->value );
588 p += lens;
589 }
590
591 return( 0 );
592}
char * name
Definition: xData.h:122
char * value
Definition: xData.h:123

Referenced by tpia_channel_getFromElement(), tpia_product_getFromElement(), tpia_target_heated_read(), and tpia_target_read().

◆ xData_free()

◆ xData_freeElementList()

◆ xData_get_smrUserInterfaceFromDocument()

void * xData_get_smrUserInterfaceFromDocument ( xData_document doc)

Definition at line 944 of file xData.cc.

944 {
945
946 if( doc == NULL ) return( NULL );
947 return( &(doc->smrUserInterface ) );
948}
xData_smr smrUserInterface
Definition: xData.h:205

Referenced by xData_get_smrUserInterfaceFromElement(), and xData_parseEndOfXML().

◆ xData_get_smrUserInterfaceFromElement()

void * xData_get_smrUserInterfaceFromElement ( xData_element element)

Definition at line 952 of file xData.cc.

952 {
953
955}
xData_document * xData_getElementsDocument(xData_element *element)
Definition: xData.cc:934
void * xData_get_smrUserInterfaceFromDocument(xData_document *doc)
Definition: xData.cc:944

Referenced by getRowStartEndAtIndex(), xData_1d_x_copyData(), xData_convertAttributeTo_xData_Int(), xData_convertAttributeToDouble(), xData_getCommonData(), xData_getOneElementByTagName(), xData_is_xDataType(), and xData_xDataTypeConvertAttributes().

◆ xData_getAccessed()

int xData_getAccessed ( statusMessageReporting smr,
xData_element element 
)

Definition at line 1087 of file xData.cc.

1087 {
1088
1089 return( element->accessed );
1090}

◆ xData_getAttributesValue()

char * xData_getAttributesValue ( xData_attributionList attributes,
const char *  name 
)

Definition at line 530 of file xData.cc.

530 {
531
532 int i;
533 char *value = NULL;
534
535 for( i = 0; i < attributes->number; i++ ) {
536 if( !strcmp( attributes->attributes[i].name, name ) ) {
537 value = attributes->attributes[i].value;
538 break;
539 }
540 }
541 return( value );
542}

Referenced by tpia_misc_pointerToAttributeIfAllOk(), tpia_multiplicity_getTimeScaleFromElement(), tpia_target_getAttributesValue(), tpia_target_heated_read(), and xData_getAttributesValueInElement().

◆ xData_getAttributesValueInElement()

const char * xData_getAttributesValueInElement ( xData_element element,
const char *  name 
)

Definition at line 546 of file xData.cc.

546 {
547
548 return( (const char *) xData_getAttributesValue( &(element->attributes), name ) );
549}
xData_attributionList attributes
Definition: xData.h:186
char * xData_getAttributesValue(xData_attributionList *attributes, const char *name)
Definition: xData.cc:530

Referenced by tpia_frame_setFromElement(), tpia_map_readFile(), tpia_target_read(), xData_convertAttributeTo_xData_Int(), xData_convertAttributeToDouble(), and xData_getElementsByTagNameAndSort().

◆ xData_getCommonData()

int xData_getCommonData ( statusMessageReporting smr,
xData_element element,
xData_Int index,
xData_Int start,
xData_Int end,
xData_Int length 
)

Definition at line 652 of file xData.cc.

653 {
654
655 if( element->xDataTypeInfo.typeString == NULL ) {
656 smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( element ), __FILE__, __LINE__, 1, "element %s is not xData", element->fullName );
657 return( 1 );
658 }
659 *index = element->xDataTypeInfo.index;
660 *start = element->xDataTypeInfo.start;
661 *end = element->xDataTypeInfo.end;
662 *length = element->xDataTypeInfo.length;
663 return( 0 );
664}
xData_Int index
Definition: xData.h:162
const char * typeString
Definition: xData.h:156
char * fullName
Definition: xData.h:185

◆ xData_getDocumentsElement()

xData_element * xData_getDocumentsElement ( xData_document xData_doc)

Definition at line 476 of file xData.cc.

476{ return( doc->root.children ); }

Referenced by tpia_map_readFile(), tpia_target_heated_read(), and tpia_target_read().

◆ xData_getElements_xDataElement()

xData_element * xData_getElements_xDataElement ( statusMessageReporting smr,
xData_element element 
)

Definition at line 622 of file xData.cc.

622 {
623
624 //return( xData_getOneElementByTagName( smr, element, "xData", 1 ) );
625 return( xData_getOneElementByTagName( smr, element, (char*) "xData", 1 ) );
626}
xData_element * xData_getOneElementByTagName(statusMessageReporting *smr, xData_element *element, char *name, int required)
Definition: xData.cc:810

Referenced by tpia_misc_getEqualProbableBins().

◆ xData_getElementsByTagName()

xData_elementList * xData_getElementsByTagName ( statusMessageReporting smr,
xData_element element,
const char *  tagName 
)

Definition at line 761 of file xData.cc.

761 {
762
763 int n = xData_numberOfElementsByTagName( smr, element, tagName );
764 size_t size;
765 xData_element *child;
767 xData_elementList *list = NULL;
768
769
770 size = sizeof( xData_elementList ) + n * sizeof( xData_elementListItem );
771 //if( ( list = xData_malloc2( smr, size, 0, "list" ) ) != NULL ) {
772 if( ( list = (xData_elementList*) xData_malloc2( smr, size, 0, "list" ) ) != NULL ) {
773 list->n = n;
774 p = list->items = (xData_elementListItem *) &(list[1]);
775 for( child = xData_getFirstElement( element ); child != NULL; child = xData_getNextElement( child ) ) {
776 if( !strcmp( child->name, tagName ) ) {
777 p->element = child;
778 p->sortString = NULL;
779 p++;
780 }
781 }
782 }
783 return( list );
784}
xData_element * element
Definition: xData.h:145
const char * sortString
Definition: xData.h:146
xData_elementListItem * items
Definition: xData.h:151
char * name
Definition: xData.h:184
int xData_numberOfElementsByTagName(statusMessageReporting *, xData_element *element, const char *tagName)
Definition: xData.cc:750
xData_element * xData_getNextElement(xData_element *element)
Definition: xData.cc:478
xData_element * xData_getFirstElement(xData_element *element)
Definition: xData.cc:477
struct xData_elementList_s xData_elementList
Definition: xData.h:97

Referenced by tpia_product_getDecayChannelFromElement(), xData_getElementsByTagNameAndSort(), and xData_getOneElementByTagName().

◆ xData_getElementsByTagNameAndSort()

xData_elementList * xData_getElementsByTagNameAndSort ( statusMessageReporting smr,
xData_element element,
const char *  tagName,
const char *  sortAttributeName,
xData_sortElementFunc  sortFunction 
)

Definition at line 788 of file xData.cc.

789 {
790
791 int i;
792 xData_elementList *list = xData_getElementsByTagName( smr, element, tagName );
794
795 if( list != NULL ) {
796 if( sortFunction == NULL ) {
797 sortFunction = (xData_sortElementFunc) xData_elementList_defaultSorter;
798 if( sortAttributeName == NULL ) sortFunction = (xData_sortElementFunc) xData_elementList_indexSorter;
799 }
800 if( sortAttributeName == NULL ) sortAttributeName = "index";
801 for( i = 0, p = list->items; i < list->n; i++, p++ ) p->sortString = xData_getAttributesValueInElement( p->element, sortAttributeName );
802 qsort( list->items, list->n, sizeof( xData_elementListItem ), sortFunction );
803 }
804
805 return( list );
806}
xData_elementList * xData_getElementsByTagName(statusMessageReporting *smr, xData_element *element, const char *tagName)
Definition: xData.cc:761
int(* xData_sortElementFunc)(const void *, const void *)
Definition: xData.h:99

Referenced by tpia_angularEnergy_getFromElement(), tpia_Legendre_getFromElement(), and tpia_misc_getEqualProbableBins().

◆ xData_getElementsDocument()

xData_document * xData_getElementsDocument ( xData_element element)

Definition at line 934 of file xData.cc.

934 {
935
936 xData_rootElement* root = element->parentRoot;
937
938 while( root->parentRoot != NULL ) root = root->parentRoot;
939 return( root->xData_doc );
940}
xData_rootElement * parentRoot
Definition: xData.h:181
xData_document * xData_doc
Definition: xData.h:167
xData_rootElement * parentRoot
Definition: xData.h:169

Referenced by xData_get_smrUserInterfaceFromElement().

◆ xData_getFileName()

char const * xData_getFileName ( xData_document doc)

Definition at line 914 of file xData.cc.

914 {
915
916 return( doc->fileName );
917}
char * fileName
Definition: xData.h:202

◆ xData_getFirstElement()

xData_element * xData_getFirstElement ( xData_element element)

◆ xData_getFirstItem()

enum xData_itemMode xData_getFirstItem ( xData_element element,
xData_item item 
)

Definition at line 482 of file xData.cc.

482 {
483
484 item->parentElement = element;
485 item->element = xData_getFirstElement( element );
486 if( item->element == NULL ) {
487 item->mode = xData_itemModeText;
488 if( element->text.length == 0 ) item->mode = xData_itemModeEnd; }
489 else {
491 if( 0 < item->element->textOffset ) item->mode = xData_itemModeText;
492 }
493 item->textOffset = 0;
494 item->textLength = element->text.length;
495 if( item->element != NULL ) item->textLength = item->element->textOffset;
496 item->text = element->text.text;
497 return( item->mode );
498}
xData_text text
Definition: xData.h:189
size_t textOffset
Definition: xData.h:188
enum xData_itemMode mode
Definition: xData.h:215
char * text
Definition: xData.h:218
size_t textOffset
Definition: xData.h:216
xData_element * element
Definition: xData.h:214
size_t textLength
Definition: xData.h:217
xData_element * parentElement
Definition: xData.h:213
char * text
Definition: xData.h:136
size_t length
Definition: xData.h:135

◆ xData_getNextElement()

xData_element * xData_getNextElement ( xData_element element)

◆ xData_getNextItem()

enum xData_itemMode xData_getNextItem ( xData_item item)

Definition at line 502 of file xData.cc.

502 {
503
504 if( item->mode != xData_itemModeEnd ) {
505 if( item->mode == xData_itemModeText ) {
507 if( item->element == NULL ) item->mode = xData_itemModeEnd;
508 item->textOffset += item->textLength;
509 item->textLength = 0;
510 item->text = &(item->parentElement->text.text[item->textOffset]); }
511 else {
512 item->element = item->element->next;
513 item->mode = xData_itemModeText;
514 if( item->element == NULL ) {
515 if( item->textOffset < item->parentElement->text.length ) {
516 item->textLength = item->parentElement->text.length - item->textOffset; }
517 else {
518 item->mode = xData_itemModeEnd;
519 } }
520 else {
521 item->textLength = item->element->textOffset - item->textOffset;
522 }
523 }
524 }
525 return( item->mode );
526}

◆ xData_getOneElementByTagName()

xData_element * xData_getOneElementByTagName ( statusMessageReporting smr,
xData_element element,
char *  name,
int  required 
)

Definition at line 810 of file xData.cc.

810 {
811
812 xData_elementList *list;
813 xData_element *xData = NULL;
814
815 if( ( list = xData_getElementsByTagName( smr, element, name ) ) != NULL ) {
816 if( list->n == 0 ) {
817 if( required ) smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( element ), __FILE__, __LINE__,
818 1, "element %s does not have sub-element named %s", element->fullName, name ); }
819 else if( list->n > 1 ) {
820 smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( element ), __FILE__, __LINE__, 1,
821 "element %s contains more than one sub-element named %s", element->fullName, name ); }
822 else {
823 xData = list->items[0].element;
824 }
825 xData_freeElementList( smr, list );
826 }
827 return( xData );
828}
void xData_freeElementList(statusMessageReporting *smr, xData_elementList *list)
Definition: xData.cc:832

Referenced by tpia_angularEnergy_getFromElement(), tpia_channel_getFromElement(), tpia_misc_get2d_xShared_yHistogram_data(), tpia_misc_get2dx_y_data(), tpia_misc_get2dxindex_y_data(), tpia_misc_getEqualProbableBin(), tpia_target_heated_read(), and xData_getElements_xDataElement().

◆ xData_init_1d_x()

int xData_init_1d_x ( statusMessageReporting smr,
xData_element element 
)

Definition at line 54 of file xData_1d_x.cc.

54 {
55
56 xDataType *xDT = &(element->xDataTypeInfo);
57
60 xDT->element = element;
61 xDT->toData = toData;
62 xDT->toString = toString;
63 xDT->release = release;
64 xDT->data = NULL;
65 return( xData_xDataTypeConvertAttributes( smr, element ) );
66}
enum xData_xDataType status
Definition: xData.h:155
xDT_releaseFunction release
Definition: xData.h:160
xDT_toStringFunction toString
Definition: xData.h:159
xDT_toDataFunction toData
Definition: xData.h:158
int xData_xDataTypeConvertAttributes(statusMessageReporting *smr, xData_element *element)
Definition: xData.cc:668
char const *const xData_oned_x_ID
Definition: xData.h:71

◆ xData_init_2d_xindex_y()

int xData_init_2d_xindex_y ( statusMessageReporting smr,
xData_element element 
)

Definition at line 55 of file xData_2d_xindex_y.cc.

55 {
56
57 xDataType *xDT = &(element->xDataTypeInfo);
58
61 xDT->element = element;
62 xDT->toData = toData;
63 xDT->toString = toString;
64 xDT->release = release;
65 xDT->data = NULL;
66 return( xData_xDataTypeConvertAttributes( smr, element ) );
67}
char const *const xData_twod_xindex_y_ID
Definition: xData.h:73

◆ xData_init_2d_xShared_yHistogram()

int xData_init_2d_xShared_yHistogram ( statusMessageReporting smr,
xData_element element 
)

Definition at line 54 of file xData_2d_xshared_yhistogram.cc.

54 {
55
56 xDataType *xDT = &(element->xDataTypeInfo);
57
60 xDT->element = element;
61 xDT->toData = toData;
62 xDT->toString = toString;
63 xDT->release = release;
64 xDT->data = NULL;
65 return( xData_xDataTypeConvertAttributes( smr, element ) );
66}
char const *const xData_twod_xShared_yHistogram_ID
Definition: xData.h:74

◆ xData_init_2d_xy()

int xData_init_2d_xy ( statusMessageReporting smr,
xData_element element 
)

Definition at line 54 of file xData_2d_xy.cc.

54 {
55
56 xDataType *xDT = &(element->xDataTypeInfo);
57
60 xDT->element = element;
61 xDT->toData = toData;
62 xDT->toString = toString;
63 xDT->release = release;
64 xDT->data = NULL;
65 return( xData_xDataTypeConvertAttributes( smr, element ) );
66}
char const *const xData_twod_xy_ID
Definition: xData.h:72

◆ xData_init_matrix()

int xData_init_matrix ( statusMessageReporting smr,
xData_element element 
)

Definition at line 55 of file xData_matrix.cc.

55 {
56
57 xDataType *xDT = &(element->xDataTypeInfo);
58
61 xDT->element = element;
62 xDT->toData = toData;
63 xDT->toString = toString;
64 xDT->release = release;
65 xDT->data = NULL;
66 return( xData_xDataTypeConvertAttributes( smr, element ) );
67}
char const *const xData_matrix_ID
Definition: xData.h:75

◆ xData_initializeAttributionList()

int xData_initializeAttributionList ( statusMessageReporting smr,
xData_attributionList attributes 
)

Definition at line 554 of file xData.cc.

554 {
555
556 attributes->number = 0;
557 attributes->size = 0;
558 attributes->attributes = NULL;
559 return( 0 );
560}

◆ xData_is_1d_x()

int xData_is_1d_x ( statusMessageReporting smr,
xDataType xDT,
int  setMsg 
)

Definition at line 70 of file xData_1d_x.cc.

70 {
71
72 return( xData_is_xDataType( smr, xDT, xData_oned_x_ID, setMsg ) );
73}
int xData_is_xDataType(statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
Definition: xData.cc:900

Referenced by xData_isElement_1d_x().

◆ xData_is_2d_xindex_y()

int xData_is_2d_xindex_y ( statusMessageReporting smr,
xDataType xDT,
int  setMsg 
)

Definition at line 71 of file xData_2d_xindex_y.cc.

71 {
72
73 return( xData_is_xDataType( smr, xDT, xData_twod_xindex_y_ID, setMsg ) );
74}

Referenced by tpia_misc_get2dxindex_y_data(), and xData_isElement_2d_xindex_y().

◆ xData_is_2d_xShared_yHistogram()

int xData_is_2d_xShared_yHistogram ( statusMessageReporting smr,
xDataType xDT,
int  setMsg 
)

Definition at line 70 of file xData_2d_xshared_yhistogram.cc.

70 {
71
72 return( xData_is_xDataType( smr, xDT, xData_twod_xShared_yHistogram_ID, setMsg ) );
73}

Referenced by xData_isElement_2d_xShared_yHistogram().

◆ xData_is_2d_xy()

int xData_is_2d_xy ( statusMessageReporting smr,
xDataType xDT,
int  setMsg 
)

Definition at line 70 of file xData_2d_xy.cc.

70 {
71
72 return( xData_is_xDataType( smr, xDT, xData_twod_xy_ID, setMsg ) );
73}

Referenced by tpia_misc_get2dx_y_data(), and xData_isElement_2d_xy().

◆ xData_is_matrix()

int xData_is_matrix ( statusMessageReporting smr,
xDataType xDT,
int  setMsg 
)

Definition at line 71 of file xData_matrix.cc.

71 {
72
73 return( xData_is_xDataType( smr, xDT, xData_matrix_ID, setMsg ) );
74}

Referenced by getRowStartEndAtIndex(), and xData_isElement_matrix().

◆ xData_is_xDataType()

int xData_is_xDataType ( statusMessageReporting smr,
xDataType xDT,
char const *const  type,
int  setMsg 
)

Definition at line 900 of file xData.cc.

900 {
901
902 if( xDT->typeString == NULL ) {
903 if( setMsg ) smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( xDT->element ), __FILE__, __LINE__, 1,
904 "element %s not xData object", xDT->element->fullName ); }
905 else if( xDT->typeString != type ) {
906 if( setMsg ) smr_setMessageError( smr, xData_get_smrUserInterfaceFromElement( xDT->element ), __FILE__, __LINE__, 1,
907 "Element %s is not xData object of type %s", type );
908 }
909 return( xDT->typeString == type );
910}

Referenced by xData_is_1d_x(), xData_is_2d_xindex_y(), xData_is_2d_xShared_yHistogram(), xData_is_2d_xy(), and xData_is_matrix().

◆ xData_isElement_1d_x()

int xData_isElement_1d_x ( statusMessageReporting smr,
xData_element element,
int  setMsg 
)

Definition at line 77 of file xData_1d_x.cc.

77 {
78
79 return( xData_is_1d_x( smr, &(element->xDataTypeInfo), setMsg ) );
80}
int xData_is_1d_x(statusMessageReporting *smr, xDataType *xDT, int setMsg)
Definition: xData_1d_x.cc:70

Referenced by xData_1d_x_allocateCopyData(), and xData_1d_x_copyData().

◆ xData_isElement_2d_xindex_y()

int xData_isElement_2d_xindex_y ( statusMessageReporting smr,
xData_element element,
int  setMsg 
)

Definition at line 78 of file xData_2d_xindex_y.cc.

78 {
79
80 return( xData_is_2d_xindex_y( smr, &(element->xDataTypeInfo), setMsg ) );
81}
int xData_is_2d_xindex_y(statusMessageReporting *smr, xDataType *xDT, int setMsg)

◆ xData_isElement_2d_xShared_yHistogram()

int xData_isElement_2d_xShared_yHistogram ( statusMessageReporting smr,
xData_element element,
int  setMsg 
)

Definition at line 77 of file xData_2d_xshared_yhistogram.cc.

77 {
78
79 return( xData_is_2d_xShared_yHistogram( smr, &(element->xDataTypeInfo), setMsg ) );
80}
int xData_is_2d_xShared_yHistogram(statusMessageReporting *smr, xDataType *xDT, int setMsg)

◆ xData_isElement_2d_xy()

int xData_isElement_2d_xy ( statusMessageReporting smr,
xData_element element,
int  setMsg 
)

Definition at line 77 of file xData_2d_xy.cc.

77 {
78
79 return( xData_is_2d_xy( smr, &(element->xDataTypeInfo), setMsg ) );
80}
int xData_is_2d_xy(statusMessageReporting *smr, xDataType *xDT, int setMsg)
Definition: xData_2d_xy.cc:70

Referenced by xData_2d_xy_allocateCopyData().

◆ xData_isElement_matrix()

int xData_isElement_matrix ( statusMessageReporting smr,
xData_element element,
int  setMsg 
)

Definition at line 78 of file xData_matrix.cc.

78 {
79
80 return( xData_is_matrix( smr, &(element->xDataTypeInfo), setMsg ) );
81}

Referenced by xData_matrix_copyData().

◆ xData_malloc()

void * xData_malloc ( statusMessageReporting smr,
size_t  size,
int  zero,
const char *  forItem,
const char *  file,
int  line 
)

Definition at line 56 of file xDataMisc.cc.

56 {
57
58 void *p = xData_realloc( smr, NULL, size, forItem, file, line );
59 int i;
60 char *c;
61 long long *l;
62
63 if( ( p != NULL ) && zero ) {
64 //for( i = 0, l = (long long *) p; i < size / sizeof( long long ); i++, l++ ) *l = 0;
65 for( i = 0, l = (long long *) p; i < (int)( size / sizeof( long long ) ); i++, l++ ) *l = 0;
66 //for( i = sizeof( long long ) * i, c = (char *) l; i < size; i++, c++ ) *c = 0;
67 for( i = sizeof( long long ) * i, c = (char *) l; i < (int) size; i++, c++ ) *c = 0;
68 }
69
70 return( p );
71}
void * xData_realloc(statusMessageReporting *smr, void *pOld, size_t size, const char *forItem, const char *file, int line)
Definition: xDataMisc.cc:75

Referenced by xDataMisc_allocateCopyString().

◆ xData_matrix_copyData()

xData_matrix * xData_matrix_copyData ( statusMessageReporting smr,
xData_element element 
)

Definition at line 85 of file xData_matrix.cc.

85 {
86
87 xData_Int i, n;
88 xDataType *xDT = &(element->xDataTypeInfo);
89 xData_matrix *oldMatrix = (xData_matrix *) xDT->data, *newMatrix;
90 double *oldP, *newP;
91
92 if( !xData_isElement_matrix( smr, element, 1 ) ) return( NULL );
93 n = oldMatrix->rows * oldMatrix->columns;
94 if( ( newMatrix = (xData_matrix *) xData_malloc2( smr, sizeof( xData_matrix ) + xDT->length * sizeof( xData_matrix_rowStartEnd ) +
95 n * sizeof( double ), 0, "data" ) ) == NULL ) return( NULL );
96 newMatrix->rows = oldMatrix->rows;
97 newMatrix->columns = oldMatrix->columns;
98 newMatrix->rowStartEnds = (xData_matrix_rowStartEnd *) &(newMatrix[1]);
99 newMatrix->values = (double *) &(newMatrix->rowStartEnds[xDT->length]);
100 for( i = 0; i < xDT->length; i++ ) newMatrix->rowStartEnds[i] = oldMatrix->rowStartEnds[i];
101 for( i = 0, oldP = oldMatrix->values, newP = newMatrix->values; i < n; i++, oldP++, newP++ ) *newP = *oldP;
102 return( newMatrix );
103}
xData_Int columns
Definition: xData.h:111
double * values
Definition: xData.h:113
xData_Int rows
Definition: xData.h:111
int xData_isElement_matrix(statusMessageReporting *smr, xData_element *element, int setMsg)
Definition: xData_matrix.cc:78

◆ xData_matrix_free_copyData()

int xData_matrix_free_copyData ( statusMessageReporting smr,
void *  data 
)

Definition at line 107 of file xData_matrix.cc.

107 {
108
109 xData_free( smr, data );
110 return( 0 );
111}

◆ xData_numberOfElementsByTagName()

int xData_numberOfElementsByTagName ( statusMessageReporting smr,
xData_element element,
const char *  tagName 
)

Definition at line 750 of file xData.cc.

750 {
751
752 int n = 0;
753 xData_element *child;
754
755 for( child = xData_getFirstElement( element ); child != NULL; child = xData_getNextElement( child ) ) if( !strcmp( child->name, tagName ) ) n++;
756 return( n );
757}

Referenced by tpia_target_heated_read(), and xData_getElementsByTagName().

◆ xData_parse()

int xData_parse ( xData_document xData_doc,
const char *  s 
)

Definition at line 251 of file xData.cc.

251 {
252
253 if( doc->status != xData_statusParsing ) return( doc->status );
254 if( XML_Parse( doc->xmlParser, s, strlen( s ), 0 ) == XML_STATUS_ERROR ) return( -1 );
255 return( 0 );
256}
#define XML_STATUS_ERROR
Definition: include/expat.h:47
XML_Parse(XML_Parser parser, const char *s, int len, int isFinal)
Definition: xmlparse.cc:1430

Referenced by xData_parseReadFile(), and xData_parseString().

◆ xData_parseEndOfXML()

int xData_parseEndOfXML ( statusMessageReporting smr,
xData_document xData_doc 
)

Definition at line 187 of file xData.cc.

187 {
188
189 if( doc->xmlParser ) {
190 doc->err = XML_GetErrorCode( doc->xmlParser );
191 doc->err_line = XML_GetCurrentLineNumber( doc->xmlParser );
192 doc->err_column = XML_GetCurrentColumnNumber( doc->xmlParser );
193 if( smr_isOk( smr ) && ( XML_Parse( doc->xmlParser, NULL, 0, 1 ) == XML_STATUS_ERROR ) ) {
194 doc->status = xData_statusError;
196 "status = %d\nXML_Error code = %d\nXML_ErrorString = %s\nerror line, column = %d, %d", xData_errXMLParser,
197 doc->err, XML_ErrorString( doc->err ), doc->err_line, doc->err_column );
198 }
199 XML_ParserFree( doc->xmlParser );
200 doc->xmlParser = NULL;
201 if( doc->status != xData_statusError ) doc->status = xData_statusCompleted;
202 }
203 return( 0 );
204}
XML_GetErrorCode(XML_Parser parser)
Definition: xmlparse.cc:1755
XML_ParserFree(XML_Parser parser)
Definition: xmlparse.cc:1082
XML_ErrorString(enum XML_Error code)
Definition: xmlparse.cc:1848
int smr_isOk(statusMessageReporting *smr)
XML_Size XMLCALL XML_GetCurrentColumnNumber(XML_Parser parser)
Definition: xmlparse.cc:1800
XML_Size XMLCALL XML_GetCurrentLineNumber(XML_Parser parser)
Definition: xmlparse.cc:1790

Referenced by xData_parseFree(), xData_parseReadFile(), and xData_parseString().

◆ xData_parseFree()

void * xData_parseFree ( statusMessageReporting smr,
xData_document xData_doc 
)

Definition at line 208 of file xData.cc.

208 {
209
210 xData_parseEndOfXML( smr, doc );
211 //doc->root.children = xData_parseFreeElement( smr, doc->root.children );
212 doc->root.children = (xData_element*) xData_parseFreeElement( smr, doc->root.children );
213 //doc->fileName = xData_free( smr, doc->fileName );
214 doc->fileName = (char*) xData_free( smr, doc->fileName );
215 xData_smrUserInterfaceFree( doc );
216 xData_free( smr, doc );
217 return( NULL );
218}
int xData_parseEndOfXML(statusMessageReporting *smr, xData_document *doc)
Definition: xData.cc:187

Referenced by tpia_map_readFile(), tpia_target_heated_read(), tpia_target_read(), xData_parseMalloc(), xData_parseReadFile(), and xData_parseString().

◆ xData_parseInitialize()

int xData_parseInitialize ( statusMessageReporting smr,
xData_document xData_doc,
xData_xDataTypeOk  func,
void *  userData 
)

Definition at line 157 of file xData.cc.

157 {
158
159 XML_Parser xmlParser;
160
161 doc->status = xData_statusParsing;
162 doc->error = xData_errNone;
163 //doc->err = 0;
164 doc->err = (XML_Error) 0;
165 doc->err_line = 0;
166 doc->err_column = 0;
167 doc->fileName = NULL;
168 doc->xDataTypeOk_userFunction = func;
169 doc->xDataTypeOk_userData = userData;
170 xData_smrUserInterfaceInitialize( doc );
171 doc->smr= smr;
172 doc->xmlParser = xmlParser = XML_ParserCreate( NULL );
173 if( xmlParser == NULL ) {
174 smr_setMessageError( smr, NULL, __FILE__, __LINE__, xData_errXML_ParserCreate, "XML_ParserCreate failed" ); }
175 else {
176 XML_SetUserData( doc->xmlParser, doc );
177 xData_parseInitializeRootElement( doc, &(doc->root), NULL, 0 );
178 doc->currentRoot = &(doc->root);
179 XML_SetElementHandler( xmlParser, xData_parseStartElement, xData_parseEndElement );
180 XML_SetCharacterDataHandler( xmlParser, xData_parseCharacterData );
181 }
182 return( !smr_isOk( smr ) );
183}
XML_ParserCreate(const XML_Char *encoding)
Definition: xmlparse.cc:658
XML_SetUserData(XML_Parser parser, void *userData)
Definition: xmlparse.cc:1173
XML_SetElementHandler(XML_Parser parser, XML_StartElementHandler start, XML_EndElementHandler end)
Definition: xmlparse.cc:1214
XML_Error
Definition: include/expat.h:54
XML_SetCharacterDataHandler(XML_Parser parser, XML_CharacterDataHandler handler)
Definition: xmlparse.cc:1235
#define userData
Definition: xmlparse.cc:555

Referenced by xData_parseMalloc().

◆ xData_parseIsError()

int xData_parseIsError ( xData_document xData_doc)

Definition at line 469 of file xData.cc.

469 {
470
471 return( doc->status == xData_statusError );
472}

◆ xData_parseMalloc()

xData_document * xData_parseMalloc ( statusMessageReporting smr,
xData_xDataTypeOk  func,
void *  userData 
)

Definition at line 141 of file xData.cc.

141 {
142/*
143* Returns NULL is any error occurred.
144*/
145 xData_document *doc;
146
147 //if( ( doc = xData_malloc2( smr, sizeof( xData_document ), 1, "xData_document" ) ) != NULL ) {
148 if( ( doc = (xData_document*) xData_malloc2( smr, sizeof( xData_document ), 1, "xData_document" ) ) != NULL ) {
149 //if( xData_parseInitialize( smr, doc, func, userData ) ) doc = xData_parseFree( smr, doc );
150 if( xData_parseInitialize( smr, doc, func, userData ) ) doc = (xData_document*) xData_parseFree( smr, doc );
151 }
152 return( doc );
153}
int xData_parseInitialize(statusMessageReporting *smr, xData_document *doc, xData_xDataTypeOk func, void *userData)
Definition: xData.cc:157
void * xData_parseFree(statusMessageReporting *smr, xData_document *doc)
Definition: xData.cc:208

Referenced by xData_parseReadFile(), and xData_parseString().

◆ xData_parseReadFile()

xData_document * xData_parseReadFile ( statusMessageReporting smr,
const char *  fileName,
xData_xDataTypeOk  func,
void *  userData 
)

Definition at line 84 of file xData.cc.

84 {
85/*
86* Returns NULL is any error occurred. If an error occurs in an expat routine, xData_parseEndOfXML will set smr appropriately.
87*/
88 int f;
89 char buffer[10 * 1000];
90 ssize_t count, n = sizeof( buffer ) - 1;
91 ssize_t s = 0;
92 xData_document *doc = NULL;
93
94 if( ( doc = xData_parseMalloc( smr, func, userData ) ) != NULL ) {
95 if( xData_setFileName( smr, doc, fileName ) == 0 ) {
96 f = open( fileName, O_RDONLY );
97 if( f == -1 ) {
98 xData_parseEndOfXML( smr, doc );
99 smr_setMessageError( smr, NULL, __FILE__, __LINE__, xData_errFileError, "could not open file %s", fileName ); }
100 else {
101 while( ( count = read( f, buffer, n ) ) > 0 ) {
102 s += count;
103 buffer[count] = 0;
104 if( xData_parse( doc, buffer ) ) break;
105 if( !smr_isOk( doc->smr ) ) break;
106 }
107 close( f );
108 xData_parseEndOfXML( smr, doc );
109 if( count < 0 ) smr_setMessageError( smr, NULL, __FILE__, __LINE__, xData_errFileError,
110 "read failed with errno = %d for %s", errno, fileName );
111 }
112 }
113 if( ( doc != NULL ) && ( !smr_isOk( smr ) ) ) {
114 xData_parseFree( smr, doc );
115 doc = NULL;
116 }
117 }
118 return( doc );
119}
statusMessageReporting * smr
Definition: xData.h:206
int xData_parse(xData_document *doc, const char *s)
Definition: xData.cc:251
int xData_setFileName(statusMessageReporting *smr, xData_document *doc, char const *fileName)
Definition: xData.cc:921
xData_document * xData_parseMalloc(statusMessageReporting *smr, xData_xDataTypeOk func, void *userData)
Definition: xData.cc:141
#define buffer
Definition: xmlparse.cc:611

Referenced by tpia_map_readFile(), tpia_target_heated_read(), and tpia_target_read().

◆ xData_parseString()

xData_document * xData_parseString ( statusMessageReporting smr,
const char *  str,
xData_xDataTypeOk  func,
void *  userData 
)

Definition at line 123 of file xData.cc.

123 {
124/*
125* Returns NULL is any error occurred. If an error occurs in an expat routine, xData_parseEndOfXML will set smr appropriately.
126*/
127 xData_document *doc = NULL;
128 if( ( doc = xData_parseMalloc( smr, func, userData ) ) != NULL ) {
129 xData_parse( doc, str );
130 xData_parseEndOfXML( smr, doc );
131 if( !smr_isOk( smr ) ) {
132 xData_parseFree( smr, doc );
133 doc = NULL;
134 }
135 }
136 return( doc );
137}

◆ xData_realloc()

void * xData_realloc ( statusMessageReporting smr,
void *  pOld,
size_t  size,
const char *  forItem,
const char *  routine,
int  line 
)

Definition at line 75 of file xDataMisc.cc.

75 {
76
77 void *p = realloc( pOld, size );
78
79 if( ( p == NULL ) && ( smr != NULL ) ) {
80 smr_setMessageError( smr, NULL, file, line, -1, " xData_realloc: failed to realloc size = %llu for variable %s\n",
81 (unsigned long long) size, forItem );
82 }
83 return( p );
84}

Referenced by xData_malloc().

◆ xData_releaseAttributionList()

int xData_releaseAttributionList ( statusMessageReporting smr,
xData_attributionList attributes 
)

Definition at line 611 of file xData.cc.

611 {
612
613 attributes->number = 0;
614 attributes->size = 0;
615 //attributes->attributes = xData_free( smr, attributes->attributes );
616 attributes->attributes = (xData_attribute*) xData_free( smr, attributes->attributes );
617 return( 0 );
618}

Referenced by tpia_channel_release(), tpia_product_release(), tpia_target_heated_release(), and tpia_target_release().

◆ xData_setFileName()

int xData_setFileName ( statusMessageReporting smr,
xData_document doc,
char const fileName 
)

Definition at line 921 of file xData.cc.

921 {
922
923 doc->fileName = (char*) xData_free( smr, doc->fileName );
924 if( fileName != NULL ) {
925 //if( ( doc->fileName = xData_malloc2( smr, strlen( fileName ) + 1, 0, "doc->fileName" ) ) == NULL ) return( 1 );
926 if( ( doc->fileName = (char*) xData_malloc2( smr, strlen( fileName ) + 1, 0, "doc->fileName" ) ) == NULL ) return( 1 );
927 strcpy( doc->fileName, fileName );
928 }
929 return( 0 );
930}

Referenced by xData_parseReadFile().

◆ xData_setMessageError_ReturnInt()

int xData_setMessageError_ReturnInt ( int  value,
statusMessageReporting smr,
void *  userData,
const char *  file,
int  line,
int  code,
const char *  fmt,
  ... 
)

Definition at line 160 of file xDataMisc.cc.

161 {
162
163 va_list args;
164
165 va_start( args, fmt );
166 smr_setMessageError( smr, userInterface, packageName, lineNumber, code, fmt, args );
167 va_end( args );
168 return( value );
169}

◆ xData_stringTo_double()

int xData_stringTo_double ( statusMessageReporting smr,
void *  smrUserInterface,
char const c,
double *  value,
char const endings,
char **  e 
)

Definition at line 1044 of file xData.cc.

1044 {
1045
1046 char const *s;
1047 char tmp[64];
1048 int status = 1, n = sizeof( tmp );
1049
1050 for( s = c; *s != 0; s++ ) if( !isspace( *s ) ) break;
1051 *value = strtod( s, e );
1052 if( *e == s ) {
1053 smr_setMessageError(smr, smrUserInterface, __FILE__, __LINE__, 1, "could not convert \"%s\" to an double", xData_shortStringForMessage( n, tmp, c ));}
1054 else {
1055 if( *endings == 0 ) while( isspace( **e ) ) (*e)++;
1056 if( **e == 0 ) {
1057 status = 0; }
1058 else {
1059 if( *endings == 0 ) {
1060 smr_setMessageError( smr, smrUserInterface, __FILE__, __LINE__, 1, "double string \"%s\" does not end with a '\\0'",
1061 xData_shortStringForMessage( n, tmp, c ) ); }
1062 else {
1063 if( strchr( endings, **e ) == NULL ) {
1064 smr_setMessageError( smr, smrUserInterface, __FILE__, __LINE__, 1, "double string \"%s\" does not end with a white space or a '\\0\'",
1065 xData_shortStringForMessage( n, tmp, c ) ); }
1066 else {
1067 status = 0;
1068 }
1069 }
1070 }
1071 }
1072 return( status );
1073}

◆ xData_stringTo_xData_Int()

int xData_stringTo_xData_Int ( statusMessageReporting smr,
void *  smrUserInterface,
char const c,
xData_Int value,
char const endings,
char **  e 
)

Definition at line 1010 of file xData.cc.

1010 {
1011
1012 char const *s;
1013 char tmp[64];
1014 int status = 1, n = sizeof( tmp );
1015
1016 for( s = c; *s != 0; s++ ) if( !isspace( *s ) ) break;
1017 //*value = strtoll( s, e, 10 );
1018 *value = strtol( s, e, 10 );
1019 if( *e == s ) {
1020 smr_setMessageError(smr, smrUserInterface, __FILE__, __LINE__, 1, "could not convert \"%s\" to an integer", xData_shortStringForMessage( n, tmp, c ));}
1021 else {
1022 if( *endings == 0 ) while( isspace( **e ) ) (*e)++;
1023 if( **e == 0 ) {
1024 status = 0; }
1025 else {
1026 if( *endings == 0 ) {
1027 smr_setMessageError( smr, smrUserInterface, __FILE__, __LINE__, 1, "integer string \"%s\" does not end with a '\\0'",
1028 xData_shortStringForMessage( n, tmp, c ) ); }
1029 else {
1030 if( strchr( endings, **e ) == NULL ) {
1031 smr_setMessageError( smr, smrUserInterface, __FILE__, __LINE__, 1, "integer string \"%s\" does not end with a white space or a '\\0\'",
1032 xData_shortStringForMessage( n, tmp, c ) ); }
1033 else {
1034 status = 0;
1035 }
1036 }
1037 }
1038 }
1039 return( status );
1040}

◆ xData_xDataTypeConvertAttributes()

int xData_xDataTypeConvertAttributes ( statusMessageReporting smr,
xData_element element 
)

Definition at line 668 of file xData.cc.

668 {
669
670 xDataType *xDT = &(element->xDataTypeInfo);
671 void *smrUser = xData_get_smrUserInterfaceFromElement( element );
672
673 xDT->index = -1;
674 xDT->start = -1;
675 xDT->end = -1;
676 xDT->length = -1;
677 if( ( xDT->indexPresent = xData_convertAttributeTo_xData_Int( smr, element, "index", &(xDT->index) ) ) < 0 ) return( 1 );
678 if( ( xDT->startPresent = xData_convertAttributeTo_xData_Int( smr, element, "start", &(xDT->start) ) ) < 0 ) return( 1 );
679 if( ( xDT->endPresent = xData_convertAttributeTo_xData_Int( smr, element, "end", &(xDT->end) ) ) < 0 ) return( 1 );
680 if( ( xDT->lengthPresent = xData_convertAttributeTo_xData_Int( smr, element, "length", &(xDT->length) ) ) < 0 ) return( 1 );
681 if( ( xDT->endPresent > 0 ) ) {
682 if( xDT->lengthPresent > 0 ) {
683 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1, "missing length (or end) in xData" );
684 return( 1 );
685 }
686 xDT->end = xDT->length; }
687 else {
688 if( xDT->lengthPresent > 0 ) xDT->length = xDT->end;
689 }
690
691 if( xDT->startPresent > 0 ) xDT->start = 0;
692 if( xDT->start < 0 ) {
693 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1, "start = %d < 0", xDT->start );
694 return( 1 );
695 }
696 if( xDT->end < xDT->start ) {
697 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1, "start = %d >= end = %d", xDT->start, xDT->end );
698 return( 1 );
699 }
700 if( xDT->length < 0 ) {
701 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1, "length = %d < 0", xDT->length );
702 return( 1 );
703 }
704
705 return( 0 );
706}
signed char startPresent
Definition: xData.h:161
signed char lengthPresent
Definition: xData.h:161
signed char indexPresent
Definition: xData.h:161
signed char endPresent
Definition: xData.h:161
xData_Int xData_convertAttributeTo_xData_Int(statusMessageReporting *smr, xData_element *element, const char *name, xData_Int *n)
Definition: xData.cc:710

Referenced by xData_init_1d_x(), xData_init_2d_xindex_y(), xData_init_2d_xShared_yHistogram(), xData_init_2d_xy(), and xData_init_matrix().

◆ xDataMisc_allocateCopyString()

char * xDataMisc_allocateCopyString ( statusMessageReporting smr,
const char *  s,
const char *  forItem,
const char *  routine,
int  line 
)

Definition at line 97 of file xDataMisc.cc.

97 {
98/*
99* User must free returned string.
100*/
101 char *c;
102
103 //if( ( c = xData_malloc( smr, strlen( s ) + 1, 0, forItem, file, line ) ) != NULL ) {
104 if( ( c = (char*) xData_malloc( smr, strlen( s ) + 1, 0, forItem, file, line ) ) != NULL ) {
105 strcpy( c, s );
106 }
107 return( c );
108}
void * xData_malloc(statusMessageReporting *smr, size_t size, int zero, const char *forItem, const char *file, int line)
Definition: xDataMisc.cc:56

◆ xDataMisc_getAbsPath()

char * xDataMisc_getAbsPath ( statusMessageReporting smr,
const char *  fileName 
)

Definition at line 112 of file xDataMisc.cc.

112 {
113/*
114* User must free returned string.
115*/
116 int n = strlen( fileName ) + 1, nCwd = 0;
117 //char *absPath, cwd[4 * 1024] = "", *p, *needle;
118 char *absPath, cwd[4 * 1024 + 1] = "", *p, *needle;
119
120 if( fileName[0] != '/' ) {
121 //if( getcwd( cwd, sizeof( cwd ) + 1 ) == NULL ) {
122 if( getcwd( cwd, sizeof( cwd ) ) == NULL ) {
123 smr_setMessageError( smr, NULL, __FILE__, __LINE__, -1, "hardwired cwd too small" );
124 return( NULL );
125 }
126 nCwd = strlen( cwd );
127 n += nCwd + 1; /* cwd + '/'. */
128 }
129 //if( ( absPath = xData_malloc2( smr, n, 0, "absPath" ) ) == NULL ) return( NULL );
130 if( ( absPath = (char*) xData_malloc2( smr, n, 0, "absPath" ) ) == NULL ) return( NULL );
131 if( fileName[0] != '/' ) {
132 strcpy( absPath, cwd );
133 strcat( absPath, "/" );
134 strcat( absPath, fileName ); }
135 else {
136 strcpy( absPath, fileName );
137 }
138
139 while( 1 ) { /* Remove all ./ from path. */
140 if( ( needle = strstr( absPath, "/./" ) ) == NULL ) break;
141 p = needle;
142 for( needle += 2; *needle; p++, needle++ ) *p = *needle;
143 *p = 0;
144 }
145
146 while( 1 ) { /* Remove all ../ from path. */
147 if( ( needle = strstr( absPath, "/../" ) ) == NULL ) break;
148 p = needle - 1;
149 while( ( p > absPath ) && ( *p != '/' ) ) p--;
150 if( *p != '/' ) break; /* This should not happen if path is legit, I think, and I do not know what to do so will leave it. */
151 if( p == absPath ) break; /* Ditto. */
152 for( needle += 3; *needle; p++, needle++ ) *p = *needle;
153 *p = 0;
154 }
155 return( absPath );
156}

Referenced by tpia_target_heated_read(), and tpia_target_read().

Variable Documentation

◆ xData_matrix_ID

char const* const xData_matrix_ID = "matrix"

Definition at line 75 of file xData.h.

Referenced by xData_init_matrix(), and xData_is_matrix().

◆ xData_oned_x_ID

char const* const xData_oned_x_ID = "1d.x"

Definition at line 71 of file xData.h.

Referenced by xData_init_1d_x(), and xData_is_1d_x().

◆ xData_twod_xindex_y_ID

char const* const xData_twod_xindex_y_ID = "2d.xindex_y"

Definition at line 73 of file xData.h.

Referenced by xData_init_2d_xindex_y(), and xData_is_2d_xindex_y().

◆ xData_twod_xShared_yHistogram_ID

char const* const xData_twod_xShared_yHistogram_ID = "2d_xShared_yHistogram"

Definition at line 74 of file xData.h.

Referenced by xData_init_2d_xShared_yHistogram(), and xData_is_2d_xShared_yHistogram().

◆ xData_twod_xy_ID

char const* const xData_twod_xy_ID = "2d.xy"

Definition at line 72 of file xData.h.

Referenced by xData_init_2d_xy(), and xData_is_2d_xy().