41 #if defined __cplusplus
48 static int toData( statusMessageReporting *smr, xDataType *xDT, xData_attributionList *attributes,
const char *text );
49 static char *
toString( statusMessageReporting *smr, xDataType *xDT );
50 static int release( statusMessageReporting *smr, xDataType *xDT );
56 xDataType *xDT = &(element->xDataTypeInfo);
58 xDT->status = xData_xDataType_Ok;
59 xDT->typeString = xData_oned_x_ID;
60 xDT->element = element;
70 int xData_is_1d_x( statusMessageReporting *smr, xDataType *xDT,
int setMsg ) {
79 return(
xData_is_1d_x( smr, &(element->xDataTypeInfo), setMsg ) );
84 int xData_1d_x_copyData( statusMessageReporting *smr, xData_element *element, xData_Int nAllocatedBytes,
double *d ) {
87 xDataType *xDT = &(element->xDataTypeInfo);
91 n = xDT->end - xDT->start;
93 if( n *
sizeof(
double ) > (size_t) nAllocatedBytes ) {
95 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"allocated memory = %lld to small, need %lld", nAllocatedBytes, n );
98 p = (
double *) xDT->data;
99 for( i = 0; i < n; i++, d++, p++ ) *d = *p;
108 xDataType *xDT = &(element->xDataTypeInfo);
112 n = xDT->end - xDT->start;
113 p = (
double *) xDT->data;
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;
131 static int toData( statusMessageReporting *smr, xDataType *xDT, xData_attributionList *,
const char *text ) {
133 xData_Int i,
n, status = 0;
142 n = xDT->end - xDT->start;
143 if( ( xDT->data = xData_malloc2( smr, n *
sizeof(
double ), 0,
"1d.x-toData" ) ) == NULL )
return( 1 );
144 for( i = 0, s = text, p = (
double *) xDT->data; i < n; i++, p++, s = e ) {
148 while( isspace( *e ) ) e++;
150 smr_setMessageError( smr, smrUser, __FILE__, __LINE__, 1,
"xData.1d.x contains extra data = %s", e );
154 if( status != 0 )
release( smr, xDT );
161 static char *
toString( statusMessageReporting *, xDataType *xDT ) {
165 double *data = (
double *) xDT->data;
167 n = xDT->end - xDT->start;
169 if( ( str = (
char *)
malloc( ( n + 1 ) * 17 ) ) == NULL )
return( NULL );
170 for( i = 0, p = str; i <
n; i++, p += 17, data++ ) {
171 sprintf( p,
" %15.7e\n", *data );
179 static int release( statusMessageReporting *smr, xDataType *xDT ) {
181 if( xDT->data != NULL ) xDT->data =
xData_free( smr, xDT->data );
182 return( xDT->status = xData_xDataType_Ok );
185 #if defined __cplusplus
static int release(statusMessageReporting *smr, xDataType *xDT)
int xData_xDataTypeConvertAttributes(statusMessageReporting *smr, xData_element *element)
int smr_setMessageError(statusMessageReporting *smr, void *userInterface, const char *file, int line, int code, const char *fmt,...)
double * xData_1d_x_allocateCopyData(statusMessageReporting *smr, xData_element *element)
int xData_isElement_1d_x(statusMessageReporting *smr, xData_element *element, int setMsg)
static char * toString(statusMessageReporting *smr, xDataType *xDT)
int xData_1d_x_free_copyData(statusMessageReporting *smr, void *data)
int xData_is_1d_x(statusMessageReporting *smr, xDataType *xDT, int setMsg)
int xData_1d_x_copyData(statusMessageReporting *smr, xData_element *element, xData_Int nAllocatedBytes, double *d)
int xData_is_xDataType(statusMessageReporting *smr, xDataType *xDT, char const *const type, int setMsg)
void * xData_free(statusMessageReporting *, void *p)
int xData_init_1d_x(statusMessageReporting *smr, xData_element *element)
int xData_stringTo_double(statusMessageReporting *smr, void *smrUserInterface, char const *c, double *value, char const *endings, char **e)
void * xData_get_smrUserInterfaceFromElement(xData_element *element)
void * malloc(size_t __size)
int xData_setMessageError_ReturnInt(int value, statusMessageReporting *smr, void *userInterface, const char *packageName, int lineNumber, int code, const char *fmt,...)
static int toData(statusMessageReporting *smr, xDataType *xDT, xData_attributionList *attributes, const char *text)