19#include "match_string.h"
42 int32_t field_index, type;
53 SDDS_SetError(
"NULL field name passed. (SDDS_GetColumnInformation)");
57 va_start(argptr, mode);
59 if (mode & SDDS_GET_BY_INDEX) {
60 if ((column_index = va_arg(argptr, int32_t)) < 0 || column_index >= SDDS_dataset->layout.n_columns) {
61 SDDS_SetError(
"Invalid column index passed. (SDDS_GetColumnInformation)");
65 if (!(column_name = va_arg(argptr,
char *))) {
66 SDDS_SetError(
"NULL column name passed. (SDDS_GetColumnInformation)");
70 SDDS_SetError(
"Unknown column name given (SDDS_GetColumnInformation)");
74 columndef = SDDS_dataset->layout.column_definition + column_index;
79 for (field_index = 0; field_index < SDDS_COLUMN_FIELDS; field_index++)
82 if (field_index == SDDS_COLUMN_FIELDS) {
83 SDDS_SetError(
"Unknown field name given (SDDS_GetColumnInformation)");
91 SDDS_SetError(
"Unable to copy field data (SDDS_GetColumnInformation)");
118 int32_t field_index, type, parameter_index;
120 char *parameter_name;
128 SDDS_SetError(
"NULL field name passed. (SDDS_GetParameterInformation)");
132 va_start(argptr, mode);
134 if (mode & SDDS_GET_BY_INDEX) {
135 if ((parameter_index = va_arg(argptr, int32_t)) < 0 || parameter_index >= SDDS_dataset->layout.n_parameters) {
136 SDDS_SetError(
"Invalid parameter index passed. (SDDS_GetParameterInformation)");
140 if (!(parameter_name = va_arg(argptr,
char *))) {
141 SDDS_SetError(
"NULL parameter name passed. (SDDS_GetParameterInformation)");
145 SDDS_SetError(
"Unknown parameter name given (SDDS_GetParameterInformation)");
149 parameterdef = SDDS_dataset->layout.parameter_definition + parameter_index;
154 for (field_index = 0; field_index < SDDS_PARAMETER_FIELDS; field_index++)
157 if (field_index == SDDS_PARAMETER_FIELDS) {
158 SDDS_SetError(
"Unknown field name given (SDDS_GetParameterInformation)");
166 SDDS_SetError(
"Unable to copy field data (SDDS_GetParameterInformation)");
193 int32_t field_index, type, array_index;
203 SDDS_SetError(
"NULL field name passed. (SDDS_GetArrayInformation)");
207 va_start(argptr, mode);
209 if (mode & SDDS_GET_BY_INDEX) {
210 if ((array_index = va_arg(argptr, int32_t)) < 0 || array_index >= SDDS_dataset->layout.n_arrays) {
211 SDDS_SetError(
"Invalid array index passed. (SDDS_GetArrayInformation)");
215 if (!(array_name = va_arg(argptr,
char *))) {
216 SDDS_SetError(
"NULL array name passed. (SDDS_GetArrayInformation)");
220 SDDS_SetError(
"Unknown array name given (SDDS_GetArrayInformation)");
224 arraydef = SDDS_dataset->layout.array_definition + array_index;
229 for (field_index = 0; field_index < SDDS_ARRAY_FIELDS; field_index++)
232 if (field_index == SDDS_ARRAY_FIELDS) {
233 SDDS_SetError(
"Unknown field name given (SDDS_GetArrayInformation)");
241 SDDS_SetError(
"Unable to copy field data (SDDS_GetArrayInformation)");
268 int32_t field_index, type, associate_index;
270 char *associate_name;
278 SDDS_SetError(
"NULL field name passed. (SDDS_GetAssociateInformation)");
282 va_start(argptr, mode);
284 if (mode & SDDS_GET_BY_INDEX) {
285 if ((associate_index = va_arg(argptr, int32_t)) < 0 || associate_index >= SDDS_dataset->layout.n_associates) {
286 SDDS_SetError(
"Invalid associate index passed. (SDDS_GetAssociateInformation)");
290 if (!(associate_name = va_arg(argptr,
char *))) {
291 SDDS_SetError(
"NULL associate name passed. (SDDS_GetAssociateInformation)");
295 SDDS_SetError(
"Unknown associate name given (SDDS_GetAssociateInformation)");
299 associatedef = SDDS_dataset->layout.associate_definition + associate_index;
304 for (field_index = 0; field_index < SDDS_ASSOCIATE_FIELDS; field_index++)
307 if (field_index == SDDS_ASSOCIATE_FIELDS) {
308 SDDS_SetError(
"Unknown field name given (SDDS_GetAssociateInformation)");
316 SDDS_SetError(
"Unable to copy field data (SDDS_GetAssociateInformation)");
365 int32_t field_index, type, givenType;
366 int32_t i, column_index;
377 SDDS_SetError(
"NULL field name passed. (SDDS_ChangeColumnInformation)");
381 va_start(argptr, mode);
383 if (mode & SDDS_SET_BY_INDEX) {
384 if ((column_index = va_arg(argptr, int32_t)) < 0 || column_index >= SDDS_dataset->layout.n_columns) {
385 SDDS_SetError(
"Invalid column index passed. (SDDS_ChangeColumnInformation)");
389 if (!(column_name = va_arg(argptr,
char *))) {
390 SDDS_SetError(
"NULL column name passed. (SDDS_ChangeColumnInformation)");
394 SDDS_SetError(
"Unknown column name given (SDDS_ChangeColumnInformation)");
398 columndef = SDDS_dataset->layout.column_definition + column_index;
403 for (field_index = 0; field_index < SDDS_COLUMN_FIELDS; field_index++)
406 if (field_index == SDDS_COLUMN_FIELDS) {
407 SDDS_SetError(
"Unknown field name given (SDDS_ChangeColumnInformation)");
415 SDDS_SetError(
"Unable to copy field data (SDDS_ChangeColumnInformation)");
418 if (strcmp(field_name,
"name") == 0) {
419 for (i = 0; i < SDDS_dataset->layout.n_columns; i++)
420 if (column_index == SDDS_dataset->layout.column_index[i]->index)
422 if (i == SDDS_dataset->layout.n_columns) {
423 SDDS_SetError(
"Unable to copy field data--column indexing problem (SDDS_ChangeColumnInformation)");
426 SDDS_dataset->layout.column_index[i]->name = SDDS_dataset->layout.column_definition[column_index].name;
427 qsort((
char *)SDDS_dataset->layout.column_index, SDDS_dataset->layout.n_columns,
sizeof(*SDDS_dataset->layout.column_index),
SDDS_CompareIndexedNamesPtr);
430 if (mode & SDDS_PASS_BY_STRING) {
431 if (strcmp(field_name,
"type") == 0 && (givenType =
SDDS_IdentifyType((
char *)memory)) > 0)
433 memcpy((
char *)buffer, (
char *)&givenType,
sizeof(givenType));
434 else if (!
SDDS_ScanData((
char *)memory, type, 0, (
void *)buffer, 0, 0)) {
435 SDDS_SetError(
"Unable to scan string data (SDDS_ChangeColumnInformation)");
486 int32_t field_index, type, parameter_index, givenType;
488 char *parameter_name;
497 SDDS_SetError(
"NULL field name passed. (SDDS_ChangeParameterInformation)");
501 va_start(argptr, mode);
503 if (mode & SDDS_SET_BY_INDEX) {
504 if ((parameter_index = va_arg(argptr, int32_t)) < 0 || parameter_index >= SDDS_dataset->layout.n_parameters) {
505 SDDS_SetError(
"Invalid parameter index passed. (SDDS_ChangeParameterInformation)");
509 if (!(parameter_name = va_arg(argptr,
char *))) {
510 SDDS_SetError(
"NULL parameter name passed. (SDDS_ChangeParameterInformation)");
514 SDDS_SetError(
"Unknown parameter name given (SDDS_ChangeParameterInformation)");
518 parameterdef = SDDS_dataset->layout.parameter_definition + parameter_index;
523 for (field_index = 0; field_index < SDDS_PARAMETER_FIELDS; field_index++)
526 if (field_index == SDDS_PARAMETER_FIELDS) {
527 SDDS_SetError(
"Unknown field name given (SDDS_ChangeParameterInformation)");
535 SDDS_SetError(
"Unable to copy field data (SDDS_ChangeParameterInformation)");
538 if (strcmp(field_name,
"name") == 0)
539 qsort((
char *)SDDS_dataset->layout.parameter_index, SDDS_dataset->layout.n_parameters,
sizeof(*SDDS_dataset->layout.parameter_index),
SDDS_CompareIndexedNamesPtr);
541 if (mode & SDDS_PASS_BY_STRING) {
542 if (strcmp(field_name,
"type") == 0 && (givenType =
SDDS_IdentifyType((
char *)memory)) > 0)
544 memcpy((
char *)buffer, (
char *)&givenType,
sizeof(givenType));
545 else if (!
SDDS_ScanData((
char *)memory, type, 0, (
void *)buffer, 0, 0)) {
546 SDDS_SetError(
"Unable to scan string data (SDDS_ChangeParameterInformation)");
598 int32_t field_index, type, array_index, givenType;
609 SDDS_SetError(
"NULL field name passed. (SDDS_ChangeArrayInformation)");
613 va_start(argptr, mode);
615 if (mode & SDDS_SET_BY_INDEX) {
616 if ((array_index = va_arg(argptr, int32_t)) < 0 || array_index >= SDDS_dataset->layout.n_arrays) {
617 SDDS_SetError(
"Invalid array index passed. (SDDS_ChangeArrayInformation)");
621 if (!(array_name = va_arg(argptr,
char *))) {
622 SDDS_SetError(
"NULL array name passed. (SDDS_ChangeArrayInformation)");
626 SDDS_SetError(
"Unknown array name given (SDDS_ChangeArrayInformation)");
630 arraydef = SDDS_dataset->layout.array_definition + array_index;
635 for (field_index = 0; field_index < SDDS_ARRAY_FIELDS; field_index++)
638 if (field_index == SDDS_ARRAY_FIELDS) {
639 SDDS_SetError(
"Unknown field name given (SDDS_ChangeArrayInformation)");
647 SDDS_SetError(
"Unable to copy field data (SDDS_ChangeArrayInformation)");
650 if (strcmp(field_name,
"name") == 0)
651 qsort((
char *)SDDS_dataset->layout.array_index, SDDS_dataset->layout.n_arrays,
sizeof(*SDDS_dataset->layout.array_index),
SDDS_CompareIndexedNamesPtr);
653 if (mode & SDDS_PASS_BY_STRING) {
654 if (strcmp(field_name,
"type") == 0 && (givenType =
SDDS_IdentifyType((
char *)memory)) > 0)
656 memcpy((
char *)buffer, (
char *)&givenType,
sizeof(givenType));
657 else if (!
SDDS_ScanData((
char *)memory, type, 0, (
void *)buffer, 0, 0)) {
658 SDDS_SetError(
"Unable to scan string data (SDDS_ChangeArrayInformation)");
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_ScanData(char *string, int32_t type, int32_t field_length, void *data, int64_t index, int32_t is_parameter)
Scans a string and saves the parsed value into a data pointer according to the specified data type.
SDDS_FIELD_INFORMATION SDDS_AssociateFieldInformation[SDDS_ASSOCIATE_FIELDS]
Field information for associate definitions.
SDDS_FIELD_INFORMATION SDDS_ArrayFieldInformation[SDDS_ARRAY_FIELDS]
Field information for array definitions.
SDDS_FIELD_INFORMATION SDDS_ColumnFieldInformation[SDDS_COLUMN_FIELDS]
Field information for column definitions.
int32_t SDDS_type_size[SDDS_NUM_TYPES]
Array of sizes for each supported data type.
SDDS_FIELD_INFORMATION SDDS_ParameterFieldInformation[SDDS_PARAMETER_FIELDS]
Field information for parameter definitions.
int32_t SDDS_GetArrayInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified array in the SDDS dataset.
int32_t SDDS_ChangeParameterInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Modifies a specific field in a parameter definition within the SDDS dataset.
int32_t SDDS_GetParameterInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified parameter in the SDDS dataset.
int32_t SDDS_ChangeArrayInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Modifies a specific field in an array definition within the SDDS dataset.
int32_t SDDS_GetAssociateInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified associate in the SDDS dataset.
int32_t SDDS_ChangeColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Modifies a specific field in a column definition within the SDDS dataset.
int32_t SDDS_GetColumnInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified column in the SDDS dataset.
Internal definitions and function declarations for SDDS with LZMA support.
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
int32_t SDDS_GetArrayIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named array in the SDDS dataset.
int32_t SDDS_GetParameterIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named parameter in the SDDS dataset.
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
int SDDS_CompareIndexedNamesPtr(const void *s1, const void *s2)
Compares two pointers to SORTED_INDEX structures by their name fields.
int32_t SDDS_CheckDataset(SDDS_DATASET *SDDS_dataset, const char *caller)
Validates the SDDS dataset pointer.
int32_t SDDS_IdentifyType(char *typeName)
Identifies the SDDS data type based on its string name.
int32_t SDDS_GetAssociateIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named associate in the SDDS dataset.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
#define SDDS_STRING
Identifier for the string data type.