SDDSlib
Loading...
Searching...
No Matches
SDDS_transfer.c File Reference

This file provides functions for transferring definitions from one SDDS dataset to another. More...

#include "mdb.h"
#include "match_string.h"
#include "SDDS.h"
#include "SDDS_internal.h"

Go to the source code of this file.

Functions

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_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_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_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_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_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_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_TransferAllColumnDefinitions (SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
 Transfers all column definitions 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.
 

Detailed Description

This file provides functions for transferring definitions from one SDDS dataset to another.

This file provides functions for transferring definitions from one SDDS dataset to another.

License
This file is distributed under the terms of the Software License Agreement found in the file LICENSE included with this distribution.
Author
M. Borland, C. Saunders, R. Soliday. H. Shang

Definition in file SDDS_transfer.c.

Function Documentation

◆ SDDS_DefineColumnLikeArray()

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.

This function creates a column in the target SDDS dataset with properties matching those of a specified array in the source dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the array in the source dataset whose definition is to be used.
newNameThe name of the column in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 302 of file SDDS_transfer.c.

302 {
303 ARRAY_DEFINITION *arrayDef;
304
305 if (!name || SDDS_StringIsBlank(name)) {
306 SDDS_SetError("Unable to define column--NULL or blank name passed (SDDS_DefineColumnLikeArray)");
307 return 0;
308 }
309 if (!newName)
310 newName = name;
311 if (!(arrayDef = SDDS_GetArrayDefinition(source, name))) {
312 SDDS_SetError("Unable to define column--unknown array named (SDDS_DefineColumnLikeArray)");
313 return 0;
314 }
315 if (SDDS_GetColumnIndex(target, newName) >= 0) {
316 SDDS_SetError("Unable to define column--already exists (SDDS_DefineColumnLikeArray)");
317 return 0;
318 }
319 if (SDDS_DefineColumn(target, newName, arrayDef->symbol, arrayDef->units, arrayDef->description, arrayDef->format_string, arrayDef->type, 0) < 0) {
320 SDDS_FreeArrayDefinition(arrayDef);
321 SDDS_SetError("Unable to define column--call to define column failed (SDDS_DefineColumnLikeArray)");
322 return 0;
323 }
324 SDDS_FreeArrayDefinition(arrayDef);
325 return 1;
326}
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.
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
Definition SDDS_utils.c:379
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_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
int32_t SDDS_StringIsBlank(char *s)
Checks if a string is blank (contains only whitespace characters).

◆ SDDS_DefineColumnLikeParameter()

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.

This function creates a column in the target SDDS dataset with properties matching those of a specified parameter in the source dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the parameter in the source dataset whose definition is to be used.
newNameThe name of the column in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 264 of file SDDS_transfer.c.

264 {
265 PARAMETER_DEFINITION *pardef;
266
267 if (!name || SDDS_StringIsBlank(name)) {
268 SDDS_SetError("Unable to define column--NULL or blank name passed (SDDS_DefineColumnLikeParameter)");
269 return 0;
270 }
271 if (!newName)
272 newName = name;
273 if (!(pardef = SDDS_GetParameterDefinition(source, name))) {
274 SDDS_SetError("Unable to define column--unknown parameter named (SDDS_DefineColumnLikeParameter)");
275 return 0;
276 }
277 if (SDDS_GetColumnIndex(target, newName) >= 0) {
278 SDDS_SetError("Unable to define column--already exists (SDDS_DefineColumnLikeParameter)");
279 return 0;
280 }
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)");
284 return 0;
285 }
287 return 1;
288}
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.

◆ SDDS_DefineParameterLikeArray()

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.

This function creates a parameter in the target SDDS dataset with properties matching those of a specified array in the source dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the array in the source dataset whose definition is to be used.
newNameThe name of the parameter in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 226 of file SDDS_transfer.c.

226 {
227 ARRAY_DEFINITION *arrayDef;
228
229 if (!name || SDDS_StringIsBlank(name)) {
230 SDDS_SetError("Unable to define parameter--NULL or blank name passed (SDDS_DefineParameterLikeArray)");
231 return 0;
232 }
233 if (!newName)
234 newName = name;
235 if (!(arrayDef = SDDS_GetArrayDefinition(source, name))) {
236 SDDS_SetError("Unable to define parameter--unknown array named (SDDS_DefineParameterLikeArray)");
237 return 0;
238 }
239 if (SDDS_GetParameterIndex(target, newName) >= 0) {
240 SDDS_SetError("Unable to define parameter--already exists (SDDS_DefineParameterLikeArray)");
241 return 0;
242 }
243 if (SDDS_DefineParameter(target, newName, arrayDef->symbol, arrayDef->units, arrayDef->description, arrayDef->format_string, arrayDef->type, NULL) < 0) {
244 SDDS_FreeArrayDefinition(arrayDef);
245 SDDS_SetError("Unable to define parameter--call to define parameter failed (SDDS_DefineParameterLikeArray)");
246 return 0;
247 }
248 SDDS_FreeArrayDefinition(arrayDef);
249 return 1;
250}
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.
int32_t SDDS_GetParameterIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named parameter in the SDDS dataset.

◆ SDDS_DefineParameterLikeColumn()

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.

This function creates a parameter in the target SDDS dataset with properties matching those of a specified column in the source dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the column in the source dataset whose definition is to be used.
newNameThe name of the parameter in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 188 of file SDDS_transfer.c.

188 {
189 COLUMN_DEFINITION *coldef;
190
191 if (!name || SDDS_StringIsBlank(name)) {
192 SDDS_SetError("Unable to define parameter--NULL or blank name passed (SDDS_DefineParameterLikeColumn)");
193 return 0;
194 }
195 if (!newName)
196 newName = name;
197 if (!(coldef = SDDS_GetColumnDefinition(source, name))) {
198 SDDS_SetError("Unable to define parameter--unknown column named (SDDS_DefineParameterLikeColumn)");
199 return 0;
200 }
201 if (SDDS_GetParameterIndex(target, newName) >= 0) {
202 SDDS_SetError("Unable to define parameter--already exists (SDDS_DefineParameterLikeColumn)");
203 return 0;
204 }
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)");
208 return 0;
209 }
211 return 1;
212}
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.
Definition SDDS_utils.c:978

◆ SDDS_TransferAllArrayDefinitions()

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.

This function defines all arrays in the target SDDS dataset to match the array definitions in the source SDDS dataset. Currently, only mode 0 is supported, which results in an error if any array already exists in the target dataset.

Parameters
SDDS_targetPointer to the SDDS_DATASET structure representing the target dataset.
SDDS_sourcePointer to the SDDS_DATASET structure representing the source dataset.
modeFlags that determine how to handle existing arrays. Valid value:
  • 0: Error if an array already exists in the target dataset.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.
Note
Non-zero mode flags are not supported for array definitions.

Definition at line 506 of file SDDS_transfer.c.

506 {
507 SDDS_LAYOUT *source;
508 int32_t i;
509
510 if (!SDDS_CheckDataset(SDDS_target, "SDDS_TransferAllArrayDefinitions"))
511 return (0);
512 if (!SDDS_CheckDataset(SDDS_source, "SDDS_TransferAllArrayDefinitions"))
513 return (0);
514 if (mode) {
515 /* haven't done this one yet */
516 SDDS_SetError("Nonzero mode not supported for arrays (SDDS_TransferAllArrayDefinitions)");
517 return 0;
518 }
519 source = &SDDS_source->layout;
520 SDDS_DeferSavingLayout(SDDS_target, 1);
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)");
526 SDDS_DeferSavingLayout(SDDS_target, 0);
527 return 0;
528 }
529 SDDS_DeferSavingLayout(SDDS_target, 0);
530 return 1;
531}
void SDDS_DeferSavingLayout(SDDS_DATASET *SDDS_dataset, int32_t mode)
Definition SDDS_copy.c:603
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_CheckDataset(SDDS_DATASET *SDDS_dataset, const char *caller)
Validates the SDDS dataset pointer.
Definition SDDS_utils.c:552

◆ SDDS_TransferAllColumnDefinitions()

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.

This function defines all columns in the target SDDS dataset to match the column definitions in the source SDDS dataset. It handles existing columns based on the specified mode.

Parameters
SDDS_targetPointer to the SDDS_DATASET structure representing the target dataset.
SDDS_sourcePointer to the SDDS_DATASET structure representing the source dataset.
modeFlags that determine how to handle existing columns. Valid flags include:
  • 0: Error if a column already exists in the target dataset.
  • SDDS_TRANSFER_KEEPOLD: Retain existing columns in the target dataset and skip transferring conflicting columns.
  • SDDS_TRANSFER_OVERWRITE: Overwrite existing columns in the target dataset with definitions from the source dataset.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 424 of file SDDS_transfer.c.

424 {
425 SDDS_LAYOUT *target, *source;
426 int32_t i, index;
427 char messBuffer[1024];
428
429 if (!SDDS_CheckDataset(SDDS_target, "SDDS_TransferAllColumnDefinitions"))
430 return (0);
431 if (!SDDS_CheckDataset(SDDS_source, "SDDS_TransferAllColumnDefinitions"))
432 return (0);
433 if (mode & SDDS_TRANSFER_KEEPOLD && mode & SDDS_TRANSFER_OVERWRITE) {
434 SDDS_SetError("Inconsistent mode flags (SDDS_TransferAllColumnDefinitions)");
435 return 0;
436 }
437 target = &SDDS_target->layout;
438 source = &SDDS_source->layout;
439 SDDS_DeferSavingLayout(SDDS_target, 1);
440 for (i = 0; i < source->n_columns; i++)
441 if ((index = SDDS_GetColumnIndex(SDDS_target, source->column_definition[i].name)) >= 0) {
442 /* already exists */
443 if (mode & SDDS_TRANSFER_KEEPOLD)
444 continue;
445 if (!(mode & SDDS_TRANSFER_OVERWRITE)) {
446 sprintf(messBuffer, "Unable to define column %s---already exists (SDDS_TransferAllColumnDefinitions)", source->column_definition[i].name);
447 SDDS_SetError(messBuffer);
448 SDDS_DeferSavingLayout(SDDS_target, 0);
449 return 0;
450 }
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);
453 SDDS_SetError(messBuffer);
454 SDDS_DeferSavingLayout(SDDS_target, 0);
455 return 0;
456 }
457 if (!SDDS_ChangeColumnInformation(SDDS_target, "symbol",
458 &source->column_definition[i].symbol,
459 SDDS_BY_INDEX, index) ||
460 !SDDS_ChangeColumnInformation(SDDS_target, "units",
461 &source->column_definition[i].units,
462 SDDS_BY_INDEX, index) ||
463 !SDDS_ChangeColumnInformation(SDDS_target, "description",
464 &source->column_definition[i].description,
465 SDDS_BY_INDEX, index) ||
466 !SDDS_ChangeColumnInformation(SDDS_target, "format_string",
467 &source->column_definition[i].format_string,
468 SDDS_BY_INDEX, index) ||
469 !SDDS_ChangeColumnInformation(SDDS_target, "type", &source->column_definition[i].type, SDDS_BY_INDEX, index) || !SDDS_ChangeColumnInformation(SDDS_target, "field_length", &source->column_definition[i].field_length, SDDS_BY_INDEX, index)) {
470 SDDS_SetError("Unable to define column---problem with overwrite (SDDS_TransferAllColumnDefinitions)");
471 SDDS_DeferSavingLayout(SDDS_target, 0);
472 return 0;
473 }
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);
477 else
478 target->column_definition[index].memory_number = SDDS_CreateRpnMemory(source->column_definition[i].name, 0);
479 } else {
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)");
483 SDDS_DeferSavingLayout(SDDS_target, 0);
484 return 0;
485 }
486 }
487 SDDS_DeferSavingLayout(SDDS_target, 0);
488 return 1;
489}
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.
Definition SDDS_info.c:364
int64_t SDDS_CreateRpnMemory(const char *name, short is_string)
Stub function for creating RPN memory when RPN_SUPPORT is not enabled.
Definition SDDS_rpn.c:785
#define SDDS_STRING
Identifier for the string data type.
Definition SDDStypes.h:85

◆ SDDS_TransferAllParameterDefinitions()

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.

This function defines all parameters in the target SDDS dataset to match the parameter definitions in the source SDDS dataset. It handles existing parameters based on the specified mode.

Parameters
SDDS_targetPointer to the SDDS_DATASET structure representing the target dataset.
SDDS_sourcePointer to the SDDS_DATASET structure representing the source dataset.
modeFlags that determine how to handle existing parameters. Valid flags include:
  • 0: Error if a parameter already exists in the target dataset.
  • SDDS_TRANSFER_KEEPOLD: Retain existing parameters in the target dataset and skip transferring conflicting parameters.
  • SDDS_TRANSFER_OVERWRITE: Overwrite existing parameters in the target dataset with definitions from the source dataset.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 343 of file SDDS_transfer.c.

343 {
344 SDDS_LAYOUT *target, *source;
345 int32_t i, index;
346 char messBuffer[1024];
347
348 if (!SDDS_CheckDataset(SDDS_target, "SDDS_TransferAllParameterDefinitions"))
349 return (0);
350 if (!SDDS_CheckDataset(SDDS_source, "SDDS_TransferAllParameterDefinitions"))
351 return (0);
352 if (mode & SDDS_TRANSFER_KEEPOLD && mode & SDDS_TRANSFER_OVERWRITE) {
353 SDDS_SetError("Inconsistent mode flags (SDDS_TransferAllParameterDefinitions)");
354 return 0;
355 }
356 target = &SDDS_target->layout;
357 source = &SDDS_source->layout;
358 SDDS_DeferSavingLayout(SDDS_target, 1);
359 for (i = 0; i < source->n_parameters; i++) {
360 if ((index = SDDS_GetParameterIndex(SDDS_target, source->parameter_definition[i].name)) >= 0) {
361 /* already exists */
362 if (mode & SDDS_TRANSFER_KEEPOLD)
363 continue;
364 if (!(mode & SDDS_TRANSFER_OVERWRITE)) {
365 sprintf(messBuffer, "Unable to define parameter %s---already exists (SDDS_TransferAllParameterDefinitions)", source->parameter_definition[i].name);
366 SDDS_SetError(messBuffer);
367 SDDS_DeferSavingLayout(SDDS_target, 0);
368 return 0;
369 }
370 if (!SDDS_ChangeParameterInformation(SDDS_target, "symbol",
371 &source->parameter_definition[i].symbol,
372 SDDS_BY_INDEX, index) ||
373 !SDDS_ChangeParameterInformation(SDDS_target, "units",
374 &source->parameter_definition[i].units,
375 SDDS_BY_INDEX, index) ||
376 !SDDS_ChangeParameterInformation(SDDS_target, "description",
377 &source->parameter_definition[i].description,
378 SDDS_BY_INDEX, index) ||
379 !SDDS_ChangeParameterInformation(SDDS_target, "format_string",
380 &source->parameter_definition[i].format_string,
381 SDDS_BY_INDEX, index) ||
382 !SDDS_ChangeParameterInformation(SDDS_target, "type",
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)");
386 SDDS_DeferSavingLayout(SDDS_target, 0);
387 return 0;
388 }
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);
394 else
395 target->parameter_definition[index].memory_number = SDDS_CreateRpnMemory(source->parameter_definition[i].name, 0);
396 } else {
397 if (SDDS_DefineParameter(SDDS_target, source->parameter_definition[i].name,
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)");
400 SDDS_DeferSavingLayout(SDDS_target, 0);
401 return 0;
402 }
403 }
404 }
405 SDDS_DeferSavingLayout(SDDS_target, 0);
406 return 1;
407}
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.
Definition SDDS_info.c:485

◆ SDDS_TransferArrayDefinition()

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.

This function defines an array in the target SDDS dataset to match the definition of an array in the source SDDS dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the array in the source dataset to be transferred.
newNameThe name of the array in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 111 of file SDDS_transfer.c.

111 {
112 ARRAY_DEFINITION *ardef;
113
114 if (!name || SDDS_StringIsBlank(name)) {
115 SDDS_SetError("Unable to transfer array definition--NULL or blank name passed (SDDS_TransferArrayDefinition)");
116 return 0;
117 }
118 if (!newName)
119 newName = name;
120 if (!(ardef = SDDS_GetArrayDefinition(source, name))) {
121 SDDS_SetError("Unable to transfer array definition--unknown array named (SDDS_TransferArrayDefinition)");
122 return 0;
123 }
124 if (SDDS_GetArrayIndex(target, newName) >= 0) {
125 SDDS_SetError("Unable to transfer array definition--array already present (SDDS_TransferArrayDefinition)");
126 return 0;
127 }
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)");
131 return 0;
132 }
134 return 1;
135}
int32_t SDDS_GetArrayIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named array in the SDDS dataset.

◆ SDDS_TransferAssociateDefinition()

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.

This function defines an associate in the target SDDS dataset to match the definition of an associate in the source SDDS dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the associate in the source dataset to be transferred.
newNameThe name of the associate in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 149 of file SDDS_transfer.c.

149 {
151
152 if (!name || SDDS_StringIsBlank(name)) {
153 SDDS_SetError("Unable to transfer associate definition--NULL or blank name passed (SDDS_TransferAssociateDefinition)");
154 return 0;
155 }
156 if (!newName)
157 newName = name;
158 if ((asdef = SDDS_GetAssociateDefinition(target, name))) {
160 SDDS_SetError("Unable to transfer associate definition--associate already present (SDDS_TransferAssociateDefinition)");
161 return 0;
162 }
163 if (!(asdef = SDDS_GetAssociateDefinition(source, newName))) {
164 SDDS_SetError("Unable to transfer associate definition--unknown associate named (SDDS_TransferAssociateDefinition)");
165 return 0;
166 }
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)");
170 return 0;
171 }
173 return 1;
174}
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.
ASSOCIATE_DEFINITION * SDDS_GetAssociateDefinition(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the definition of a specified associate from the SDDS dataset.
Definition SDDS_utils.c:883
int32_t SDDS_FreeAssociateDefinition(ASSOCIATE_DEFINITION *source)
Frees memory allocated for an associate definition.
Definition SDDS_utils.c:944

◆ SDDS_TransferColumnDefinition()

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.

This function defines a column in the target SDDS dataset to match the definition of a column in the source SDDS dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the column in the source dataset to be transferred.
newNameThe name of the column in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 35 of file SDDS_transfer.c.

35 {
36 COLUMN_DEFINITION *coldef;
37
38 if (!name || SDDS_StringIsBlank(name)) {
39 SDDS_SetError("Unable to transfer column definition--NULL or blank name passed (SDDS_TransferColumnDefinition)");
40 return 0;
41 }
42 if (!newName)
43 newName = name;
44 if (!(coldef = SDDS_GetColumnDefinition(source, name))) {
45 SDDS_SetError("Unable to transfer column definition--unknown column named (SDDS_TransferColumnDefinition)");
46 return 0;
47 }
48 if (SDDS_GetColumnIndex(target, newName) >= 0) {
49 SDDS_SetError("Unable to transfer column definition--column already present (SDDS_TransferColumnDefinition)");
50 return 0;
51 }
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)");
55 return 0;
56 }
58 return 1;
59}

◆ SDDS_TransferParameterDefinition()

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.

This function defines a parameter in the target SDDS dataset to match the definition of a parameter in the source SDDS dataset.

Parameters
targetPointer to the SDDS_DATASET structure representing the target dataset.
sourcePointer to the SDDS_DATASET structure representing the source dataset.
nameThe name of the parameter in the source dataset to be transferred.
newNameThe name of the parameter in the target dataset. If NULL, the original name is used.
Returns
1 on success; 0 on failure. On failure, an error message is recorded.

Definition at line 73 of file SDDS_transfer.c.

73 {
75
76 if (!name || SDDS_StringIsBlank(name)) {
77 SDDS_SetError("Unable to transfer parameter definition--NULL or blank name passed (SDDS_TransferParameterDefinition)");
78 return 0;
79 }
80 if (!newName)
81 newName = name;
82 if (!(pardef = SDDS_GetParameterDefinition(source, name))) {
83 SDDS_SetError("Unable to transfer parameter definition--unknown parameter named (SDDS_TransferParameterDefinition)");
84 return 0;
85 }
86 if (SDDS_GetParameterIndex(target, newName) >= 0) {
87 SDDS_SetError("Unable to transfer parameter definition--parameter already present (SDDS_TransferParameterDefinition)");
88 return 0;
89 }
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)");
93 return 0;
94 }
96 return 1;
97}