19#include "match_string.h"
39 SDDS_SetError(
"Unable to transfer column definition--NULL or blank name passed (SDDS_TransferColumnDefinition)");
45 SDDS_SetError(
"Unable to transfer column definition--unknown column named (SDDS_TransferColumnDefinition)");
49 SDDS_SetError(
"Unable to transfer column definition--column already present (SDDS_TransferColumnDefinition)");
52 if (
SDDS_DefineColumn(target, newName, coldef->symbol, coldef->units, coldef->description, coldef->format_string, coldef->type, coldef->field_length) < 0) {
54 SDDS_SetError(
"Unable to transfer column definition--call to define column failed (SDDS_TransferColumnDefinition)");
77 SDDS_SetError(
"Unable to transfer parameter definition--NULL or blank name passed (SDDS_TransferParameterDefinition)");
83 SDDS_SetError(
"Unable to transfer parameter definition--unknown parameter named (SDDS_TransferParameterDefinition)");
87 SDDS_SetError(
"Unable to transfer parameter definition--parameter already present (SDDS_TransferParameterDefinition)");
90 if (
SDDS_DefineParameter(target, newName, pardef->symbol, pardef->units, pardef->description, pardef->format_string, pardef->type, NULL) < 0) {
92 SDDS_SetError(
"Unable to transfer parameter definition--call to define parameter failed (SDDS_TransferParameterDefinition)");
115 SDDS_SetError(
"Unable to transfer array definition--NULL or blank name passed (SDDS_TransferArrayDefinition)");
121 SDDS_SetError(
"Unable to transfer array definition--unknown array named (SDDS_TransferArrayDefinition)");
125 SDDS_SetError(
"Unable to transfer array definition--array already present (SDDS_TransferArrayDefinition)");
128 if (
SDDS_DefineArray(target, newName, ardef->symbol, ardef->units, ardef->description, ardef->format_string, ardef->type, ardef->field_length, ardef->dimensions, ardef->group_name) < 0) {
130 SDDS_SetError(
"Unable to transfer array definition--call to define array failed (SDDS_TransferArrayDefinition)");
153 SDDS_SetError(
"Unable to transfer associate definition--NULL or blank name passed (SDDS_TransferAssociateDefinition)");
160 SDDS_SetError(
"Unable to transfer associate definition--associate already present (SDDS_TransferAssociateDefinition)");
164 SDDS_SetError(
"Unable to transfer associate definition--unknown associate named (SDDS_TransferAssociateDefinition)");
167 if (
SDDS_DefineAssociate(target, newName, asdef->filename, asdef->path, asdef->description, asdef->contents, asdef->sdds) < 0) {
169 SDDS_SetError(
"Unable to transfer associate definition--call to define associate failed (SDDS_TransferAssociateDefinition)");
192 SDDS_SetError(
"Unable to define parameter--NULL or blank name passed (SDDS_DefineParameterLikeColumn)");
198 SDDS_SetError(
"Unable to define parameter--unknown column named (SDDS_DefineParameterLikeColumn)");
202 SDDS_SetError(
"Unable to define parameter--already exists (SDDS_DefineParameterLikeColumn)");
205 if (
SDDS_DefineParameter(target, newName, coldef->symbol, coldef->units, coldef->description, coldef->format_string, coldef->type, NULL) < 0) {
207 SDDS_SetError(
"Unable to define parameter--call to define parameter failed (SDDS_DefineParameterLikeColumn)");
230 SDDS_SetError(
"Unable to define parameter--NULL or blank name passed (SDDS_DefineParameterLikeArray)");
236 SDDS_SetError(
"Unable to define parameter--unknown array named (SDDS_DefineParameterLikeArray)");
240 SDDS_SetError(
"Unable to define parameter--already exists (SDDS_DefineParameterLikeArray)");
243 if (
SDDS_DefineParameter(target, newName, arrayDef->symbol, arrayDef->units, arrayDef->description, arrayDef->format_string, arrayDef->type, NULL) < 0) {
245 SDDS_SetError(
"Unable to define parameter--call to define parameter failed (SDDS_DefineParameterLikeArray)");
268 SDDS_SetError(
"Unable to define column--NULL or blank name passed (SDDS_DefineColumnLikeParameter)");
274 SDDS_SetError(
"Unable to define column--unknown parameter named (SDDS_DefineColumnLikeParameter)");
278 SDDS_SetError(
"Unable to define column--already exists (SDDS_DefineColumnLikeParameter)");
281 if (
SDDS_DefineColumn(target, newName, pardef->symbol, pardef->units, pardef->description, pardef->format_string, pardef->type, 0) < 0) {
283 SDDS_SetError(
"Unable to define column--call to define column failed (SDDS_DefineColumnLikeParameter)");
306 SDDS_SetError(
"Unable to define column--NULL or blank name passed (SDDS_DefineColumnLikeArray)");
312 SDDS_SetError(
"Unable to define column--unknown array named (SDDS_DefineColumnLikeArray)");
316 SDDS_SetError(
"Unable to define column--already exists (SDDS_DefineColumnLikeArray)");
319 if (
SDDS_DefineColumn(target, newName, arrayDef->symbol, arrayDef->units, arrayDef->description, arrayDef->format_string, arrayDef->type, 0) < 0) {
321 SDDS_SetError(
"Unable to define column--call to define column failed (SDDS_DefineColumnLikeArray)");
346 char messBuffer[1024];
352 if (mode & SDDS_TRANSFER_KEEPOLD && mode & SDDS_TRANSFER_OVERWRITE) {
353 SDDS_SetError(
"Inconsistent mode flags (SDDS_TransferAllParameterDefinitions)");
356 target = &SDDS_target->layout;
357 source = &SDDS_source->layout;
359 for (i = 0; i < source->n_parameters; i++) {
362 if (mode & SDDS_TRANSFER_KEEPOLD)
364 if (!(mode & SDDS_TRANSFER_OVERWRITE)) {
365 sprintf(messBuffer,
"Unable to define parameter %s---already exists (SDDS_TransferAllParameterDefinitions)", source->parameter_definition[i].name);
371 &source->parameter_definition[i].symbol,
372 SDDS_BY_INDEX, index) ||
374 &source->parameter_definition[i].units,
375 SDDS_BY_INDEX, index) ||
377 &source->parameter_definition[i].description,
378 SDDS_BY_INDEX, index) ||
380 &source->parameter_definition[i].format_string,
381 SDDS_BY_INDEX, index) ||
383 &source->parameter_definition[i].type, SDDS_BY_INDEX, index) ||
384 (source->parameter_definition[i].fixed_value != NULL && !
SDDS_ChangeParameterInformation(SDDS_target,
"fixed_value", &source->parameter_definition[i].fixed_value, SDDS_BY_INDEX, index))) {
385 SDDS_SetError(
"Unable to define parameter---problem with overwrite (SDDS_TransferAllParameterDefinitions)");
389 if (source->parameter_definition[i].fixed_value == NULL)
390 target->parameter_definition[index].fixed_value = NULL;
391 target->parameter_definition[index].definition_mode = source->parameter_definition[index].definition_mode;
392 if (target->parameter_definition[index].type ==
SDDS_STRING)
393 target->parameter_definition[index].memory_number =
SDDS_CreateRpnMemory(source->parameter_definition[i].name, 1);
395 target->parameter_definition[index].memory_number =
SDDS_CreateRpnMemory(source->parameter_definition[i].name, 0);
398 source->parameter_definition[i].symbol, source->parameter_definition[i].units, source->parameter_definition[i].description, source->parameter_definition[i].format_string, source->parameter_definition[i].type, source->parameter_definition[i].fixed_value) < 0) {
399 SDDS_SetError(
"Unable to define parameter (SDDS_TransferAllParameterDefinitions)");
427 char messBuffer[1024];
433 if (mode & SDDS_TRANSFER_KEEPOLD && mode & SDDS_TRANSFER_OVERWRITE) {
434 SDDS_SetError(
"Inconsistent mode flags (SDDS_TransferAllColumnDefinitions)");
437 target = &SDDS_target->layout;
438 source = &SDDS_source->layout;
440 for (i = 0; i < source->n_columns; i++)
443 if (mode & SDDS_TRANSFER_KEEPOLD)
445 if (!(mode & SDDS_TRANSFER_OVERWRITE)) {
446 sprintf(messBuffer,
"Unable to define column %s---already exists (SDDS_TransferAllColumnDefinitions)", source->column_definition[i].name);
451 if (source->column_definition[i].type != target->column_definition[index].type && SDDS_target->n_rows_allocated) {
452 sprintf(messBuffer,
"Unable to define column %s---type mismatch and table already allocated (SDDS_TransferAllColumnDefinitions)", source->column_definition[i].name);
458 &source->column_definition[i].symbol,
459 SDDS_BY_INDEX, index) ||
461 &source->column_definition[i].units,
462 SDDS_BY_INDEX, index) ||
464 &source->column_definition[i].description,
465 SDDS_BY_INDEX, index) ||
467 &source->column_definition[i].format_string,
468 SDDS_BY_INDEX, index) ||
470 SDDS_SetError(
"Unable to define column---problem with overwrite (SDDS_TransferAllColumnDefinitions)");
474 target->column_definition[index].definition_mode = source->column_definition[index].definition_mode;
475 if (target->column_definition[index].type ==
SDDS_STRING)
476 target->column_definition[index].memory_number =
SDDS_CreateRpnMemory(source->column_definition[i].name, 1);
478 target->column_definition[index].memory_number =
SDDS_CreateRpnMemory(source->column_definition[i].name, 0);
480 if (
SDDS_DefineColumn(SDDS_target, source->column_definition[i].name, source->column_definition[i].symbol,
481 source->column_definition[i].units, source->column_definition[i].description, source->column_definition[i].format_string, source->column_definition[i].type, source->column_definition[i].field_length) < 0) {
482 SDDS_SetError(
"Unable to define column (SDDS_TransferAllColumnDefinitions)");
516 SDDS_SetError(
"Nonzero mode not supported for arrays (SDDS_TransferAllArrayDefinitions)");
519 source = &SDDS_source->layout;
521 for (i = 0; i < source->n_arrays; i++)
522 if (
SDDS_DefineArray(SDDS_target, source->array_definition[i].name, source->array_definition[i].symbol,
523 source->array_definition[i].units, source->array_definition[i].description,
524 source->array_definition[i].format_string, source->array_definition[i].type, source->array_definition[i].field_length, source->array_definition[i].dimensions, source->array_definition[i].group_name) < 0) {
525 SDDS_SetError(
"Unable to define array (SDDS_TransferAllArrayDefinitions)");
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
void SDDS_DeferSavingLayout(SDDS_DATASET *SDDS_dataset, int32_t mode)
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_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.
Internal definitions and function declarations for SDDS with LZMA support.
int32_t SDDS_DefineAssociate(SDDS_DATASET *SDDS_dataset, const char *name, const char *filename, const char *path, const char *description, const char *contents, int32_t sdds)
Defines an associate for the SDDS dataset.
int32_t SDDS_DefineArray(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length, int32_t dimensions, const char *group_name)
Defines a data array within the SDDS dataset.
int32_t SDDS_DefineColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, int32_t field_length)
Defines a data column within the SDDS dataset.
int32_t SDDS_DefineParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, char *fixed_value)
Defines a data parameter with a fixed string value.
int64_t SDDS_CreateRpnMemory(const char *name, short is_string)
Stub function for creating RPN memory when RPN_SUPPORT is not enabled.
int32_t SDDS_TransferColumnDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a column definition from a source dataset to a target dataset.
int32_t SDDS_TransferAllArrayDefinitions(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Transfers all array definitions from a source dataset to a target dataset.
int32_t SDDS_TransferAllParameterDefinitions(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Transfers all parameter definitions from a source dataset to a target dataset.
int32_t SDDS_DefineParameterLikeColumn(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Defines a parameter in the target dataset based on a column definition from the source dataset.
int32_t SDDS_TransferArrayDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers an array definition from a source dataset to a target dataset.
int32_t SDDS_TransferAssociateDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers an associate definition from a source dataset to a target dataset.
int32_t SDDS_DefineColumnLikeArray(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Defines a column in the target dataset based on an array definition from the source dataset.
int32_t SDDS_DefineParameterLikeArray(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Defines a parameter in the target dataset based on an array definition from the source dataset.
int32_t SDDS_DefineColumnLikeParameter(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Defines a column in the target dataset based on a parameter definition from the source dataset.
int32_t SDDS_TransferParameterDefinition(SDDS_DATASET *target, SDDS_DATASET *source, char *name, char *newName)
Transfers a parameter definition from a source dataset to a target dataset.
int32_t SDDS_TransferAllColumnDefinitions(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Transfers all column definitions from a source dataset to a target dataset.
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
ASSOCIATE_DEFINITION * SDDS_GetAssociateDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified associate from the SDDS dataset.
ARRAY_DEFINITION * SDDS_GetArrayDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified array from the SDDS dataset.
int32_t SDDS_FreeArrayDefinition(ARRAY_DEFINITION *source)
Frees memory allocated for an array definition.
int32_t SDDS_GetArrayIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named array in the SDDS dataset.
PARAMETER_DEFINITION * SDDS_GetParameterDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified parameter from the SDDS dataset.
int32_t SDDS_FreeParameterDefinition(PARAMETER_DEFINITION *source)
Frees memory allocated for a parameter definition.
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.
int32_t SDDS_CheckDataset(SDDS_DATASET *SDDS_dataset, const char *caller)
Validates the SDDS dataset pointer.
int32_t SDDS_StringIsBlank(char *s)
Checks if a string is blank (contains only whitespace characters).
int32_t SDDS_FreeAssociateDefinition(ASSOCIATE_DEFINITION *source)
Frees memory allocated for an associate definition.
int32_t SDDS_FreeColumnDefinition(COLUMN_DEFINITION *source)
Frees memory allocated for a column definition.
COLUMN_DEFINITION * SDDS_GetColumnDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified column from the SDDS dataset.
#define SDDS_STRING
Identifier for the string data type.