SDDSlib
Loading...
Searching...
No Matches
sddsdatamodule.c
Go to the documentation of this file.
1/**
2 * @file sddsdatamodule.c
3 * @brief Python C extension module (sddsdata) for interfacing with the C language SDDS library.
4 *
5 * This file provides a set of Python bindings to the SDDS library for handling
6 * scientific data in the Self-Describing Data Sets (SDDS) format.
7 */
8#include <Python.h>
9#include "SDDS.h"
10
11#if PY_MAJOR_VERSION >= 3
12#define IS_PY3K
13#define PyString_Check PyUnicode_Check
14#define PyString_AsString PyUnicode_AsUTF8
15#define PyString_FromString PyUnicode_FromString
16#define PyInt_Check PyLong_Check
17#define PyInt_AsLong PyLong_AsLong
18#define PyInt_AsUnsignedLong PyLong_AsUnsignedLong
19#define PyInt_AsLongLong PyLong_AsLongLong
20#define PyInt_AsUnsignedLongLong PyLong_AsUnsignedLongLong
21#define PyExc_StandardError PyExc_Exception
22#endif
23#if PY_MAJOR_VERSION < 3
24#define PyInt_AsUnsignedLongLong PyInt_AsUnsignedLongLongMask
25#define PyInt_AsUnsignedLong PyInt_AsUnsignedLongMask
26#define PyInt_AsLongLong PyInt_AsLong
27#endif
28
29/**
30 * @brief Array of SDDS dataset structures.
31 *
32 * This array maintains a collection of SDDS_DATASET structures
33 * that correspond to files being managed by the SDDS library.
34 */
36
37/**
38 * @brief Initializes an SDDS dataset for input from a file.
39 *
40 * @param self Unused pointer to the module object.
41 * @param args Python tuple containing:
42 * - fileIndex (long): Index of the dataset in the array.
43 * - filename (char*): Name of the input file.
44 *
45 * @return PyObject*
46 * - 1 on success.
47 * - 0 on error.
48 */
49static PyObject* sddsdata_InitializeInput( PyObject* self, PyObject* args )
50{
51 long fileIndex;
52 char *filename;
53 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &filename)) {
54 return NULL;
55 }
56 return PyLong_FromLong(SDDS_InitializeInput(&dataset_f[fileIndex], filename));
57}
58
59/**
60 * @brief Initializes an SDDS dataset for appending data to a file.
61 *
62 * @param self Unused pointer to the module object.
63 * @param args Python tuple containing:
64 * - fileIndex (long): Index of the dataset in the array.
65 * - filename (char*): Name of the file to append to.
66 *
67 * @return PyObject*
68 * - 1 on success.
69 * - 0 on error.
70 */
71static PyObject* sddsdata_InitializeAppend( PyObject* self, PyObject* args )
72{
73 long fileIndex;
74 char *filename;
75 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &filename)) {
76 return NULL;
77 }
78 return PyLong_FromLong(SDDS_InitializeAppend(&dataset_f[fileIndex], filename));
79}
80
81/**
82 * @brief Initializes appending data to an existing SDDS page in a file.
83 *
84 * @param self Unused pointer to the module object.
85 * @param args Python tuple containing:
86 * - fileIndex (long): Index of the dataset in the array.
87 * - filename (char*): Name of the file to append to.
88 * - updateInterval (long): Interval at which data should be updated.
89 *
90 * @return PyObject*
91 * - Number of rows in the page on success.
92 * - NULL on error.
93 */
94static PyObject* sddsdata_InitializeAppendToPage( PyObject* self, PyObject* args )
95{
96 long fileIndex;
97 char *filename;
98 long updateInterval, result;
99 int64_t rowsPresent;
100 if (!PyArg_ParseTuple(args, "lsl", &fileIndex, &filename, &updateInterval)) {
101 return NULL;
102 }
103 result = SDDS_InitializeAppendToPage(&dataset_f[fileIndex], filename, updateInterval, &rowsPresent);
104 if (result != 1)
105 return NULL;
106 return PyLong_FromLongLong((long long)rowsPresent);
107}
108
109/**
110 * @brief Initializes an SDDS dataset for output to a file.
111 *
112 * @param self Unused pointer to the module object.
113 * @param args Python tuple containing:
114 * - fileIndex (long): Index of the dataset in the array.
115 * - data_mode (long): Data mode (e.g., SDDS_BINARY or SDDS_ASCII).
116 * - lines_per_row (long): Number of lines per row in the output file.
117 * - description (char*): Description of the dataset.
118 * - contents (char*): Contents of the dataset.
119 * - filename (char*): Name of the output file.
120 *
121 * @return PyObject*
122 * - 1 on success.
123 * - 0 on error.
124 */
125static PyObject* sddsdata_InitializeOutput( PyObject* self, PyObject* args )
126{
127 long fileIndex;
128 long data_mode;
129 long lines_per_row;
130 char *description;
131 char *contents;
132 char *filename;
133 if (!PyArg_ParseTuple(args, "lllsss", &fileIndex, &data_mode, &lines_per_row, &description, &contents, &filename)) {
134 return NULL;
135 }
136 if (description)
137 if (strlen(description) == 0)
138 description = NULL;
139 if (contents)
140 if (strlen(contents) == 0)
141 contents = NULL;
142 return PyLong_FromLong(SDDS_InitializeOutput(&dataset_f[fileIndex], data_mode, lines_per_row, description, contents, filename));
143}
144
145/**
146 * @brief Sets the data order for the SDDS dataset to column-major.
147 *
148 * @param self Unused pointer to the module object.
149 * @param args Python tuple containing:
150 * - fileIndex (long): Index of the dataset in the array.
151 *
152 * @return PyObject*
153 * - Py_None (NULL return value in Python).
154 */
155static PyObject* sddsdata_SetColumnMajorOrder( PyObject* self, PyObject* args )
156{
157 long fileIndex;
158 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
159 return NULL;
160 }
161 dataset_f[fileIndex].layout.data_mode.column_major = 1;
162 return Py_None;
163}
164
165/**
166 * @brief Sets the row count mode for an SDDS dataset to fixed row count mode.
167 *
168 * @param self Unused pointer to the module object.
169 * @param args Python tuple containing:
170 * - fileIndex (long): Index of the dataset in the array.
171 *
172 * @return PyObject*
173 * - Py_None (Python's None).
174 */
175static PyObject* sddsdata_SetFixedRowCountMode( PyObject* self, PyObject* args )
176{
177 long fileIndex;
178 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
179 return NULL;
180 }
181 SDDS_SetRowCountMode(&dataset_f[fileIndex], SDDS_FIXEDROWCOUNT);
182 return Py_None;
183}
184
185/**
186 * @brief Sets the data order for the SDDS dataset to row-major.
187 *
188 * @param self Unused pointer to the module object.
189 * @param args Python tuple containing:
190 * - fileIndex (long): Index of the dataset in the array.
191 *
192 * @return PyObject*
193 * - Py_None (Python's None).
194 */
195static PyObject* sddsdata_SetRowMajorOrder( PyObject* self, PyObject* args )
196{
197 long fileIndex;
198 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
199 return NULL;
200 }
201 dataset_f[fileIndex].layout.data_mode.column_major = 0;
202 return Py_None;
203}
204
205/**
206 * @brief Enables filesystem synchronization (fsync) for an SDDS dataset.
207 *
208 * @param self Unused pointer to the module object.
209 * @param args Python tuple containing:
210 * - fileIndex (long): Index of the dataset in the array.
211 *
212 * @return PyObject*
213 * - Py_None (Python's None).
214 */
215static PyObject* sddsdata_EnableFSync( PyObject* self, PyObject* args )
216{
217 long fileIndex;
218 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
219 return NULL;
220 }
221 dataset_f[fileIndex].layout.data_mode.fsync_data = 1;
222 return Py_None;
223}
224
225/**
226 * @brief Disables filesystem synchronization (fsync) for an SDDS dataset.
227 *
228 * @param self Unused pointer to the module object.
229 * @param args Python tuple containing:
230 * - fileIndex (long): Index of the dataset in the array.
231 *
232 * @return PyObject*
233 * - Py_None (Python's None).
234 */
235static PyObject* sddsdata_DisableFSync( PyObject* self, PyObject* args )
236{
237 long fileIndex;
238 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
239 return NULL;
240 }
241 dataset_f[fileIndex].layout.data_mode.fsync_data = 0;
242 return Py_None;
243}
244
245/**
246 * @brief Terminates an SDDS dataset, releasing any associated resources.
247 *
248 * @param self Unused pointer to the module object.
249 * @param args Python tuple containing:
250 * - fileIndex (long): Index of the dataset in the array.
251 *
252 * @return PyObject*
253 * - 1 on success.
254 * - 0 on error.
255 */
256static PyObject* sddsdata_Terminate( PyObject* self, PyObject* args )
257{
258 long fileIndex;
259 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
260 return NULL;
261 }
262 return PyLong_FromLong(SDDS_Terminate(&dataset_f[fileIndex]));
263}
264
265/**
266 * @brief Sets the termination mode for SDDS to avoid freeing strings in arrays and tables.
267 *
268 * Sets the termination mode to `TERMINATE_DONT_FREE_ARRAY_STRINGS` and
269 * `TERMINATE_DONT_FREE_TABLE_STRINGS`.
270 *
271 * @param self Unused pointer to the module object.
272 * @param args Unused.
273 *
274 * @return PyObject*
275 * - Py_None (Python's None).
276 */
277static PyObject* sddsdata_SetTerminateMode( PyObject* self, PyObject* args )
278{
279 SDDS_SetTerminateMode(TERMINATE_DONT_FREE_TABLE_STRINGS+TERMINATE_DONT_FREE_ARRAY_STRINGS);
280 Py_INCREF(Py_None);
281 return Py_None;
282}
283
284/**
285 * @brief Defines a parameter in an SDDS dataset.
286 *
287 * @param self Unused pointer to the module object.
288 * @param args Python tuple containing:
289 * - fileIndex (long): Index of the dataset in the array.
290 * - name (char*): Name of the parameter.
291 * - symbol (char*): Symbol for the parameter (optional).
292 * - units (char*): Units of the parameter (optional).
293 * - description (char*): Description of the parameter (optional).
294 * - format_string (char*): Format string for displaying the parameter (optional).
295 * - type (long): Data type of the parameter (e.g., SDDS_LONG, SDDS_DOUBLE).
296 * - fixed_value (PyObject*): Fixed value for the parameter.
297 *
298 * @return PyObject*
299 * - Index of the defined parameter on success.
300 * - -1 on error.
301 */
302static PyObject* sddsdata_DefineParameter( PyObject* self, PyObject* args )
303{
304 long fileIndex;
305 char *name;
306 char *symbol;
307 char *units;
308 char *description;
309 char *format_string;
310 long type;
311 PyObject *fixed_value;
312 char *fixedStringValue;
313 int32_t fixedLongValue;
314 double fixedDoubleValue;
315 char buffer[SDDS_MAXLINE];
316 if (!PyArg_ParseTuple(args, "lssssslO", &fileIndex, &name , &symbol , &units , &description , &format_string , &type , &fixed_value)) {
317 return NULL;
318 }
319 if (symbol)
320 if (strlen(symbol) == 0)
321 symbol = NULL;
322 if (units)
323 if (strlen(units) == 0)
324 units = NULL;
325 if (description)
326 if (strlen(description) == 0)
327 description = NULL;
328 if (format_string)
329 if (strlen(format_string) == 0)
330 format_string = NULL;
331
332 if (PyString_Check(fixed_value)) {
333 fixedStringValue = PyString_AsString(fixed_value);
334 if (fixedStringValue)
335 if (strlen(fixedStringValue) == 0)
336 fixedStringValue = NULL;
337 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
338 name, symbol, units,
339 description, format_string,
340 type, fixedStringValue));
341 } else {
342 if (PyNumber_Check(fixed_value)) {
343 if (PyLong_Check(fixed_value)) {
344 fixedLongValue = (int32_t)PyLong_AsLong(fixed_value);
345 SDDS_SprintTypedValue(&fixedLongValue, 0, SDDS_LONG , format_string, buffer, 0);
346 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
347 name, symbol, units,
348 description, format_string,
349 type, buffer));
350 } else if (PyInt_Check(fixed_value)) {
351 fixedLongValue = (int32_t)PyInt_AsLong(fixed_value);
352 SDDS_SprintTypedValue(&fixedLongValue, 0, SDDS_LONG , format_string, buffer, 0);
353 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
354 name, symbol, units,
355 description, format_string,
356 type, buffer));
357 } else if (PyFloat_Check(fixed_value)) {
358 fixedDoubleValue = PyFloat_AsDouble(fixed_value);
359 SDDS_SprintTypedValue(&fixedDoubleValue, 0, SDDS_DOUBLE , format_string, buffer, 0);
360 return PyLong_FromLong(SDDS_DefineParameter(&dataset_f[fileIndex],
361 name, symbol, units,
362 description, format_string,
363 type, buffer));
364 }
365 }
366 return PyLong_FromLong(SDDS_DefineParameter1(&dataset_f[fileIndex],
367 name, symbol, units,
368 description, format_string,
369 type, NULL));
370 }
371}
372
373/**
374 * @brief Defines an array in an SDDS dataset.
375 *
376 * @param self Unused.
377 * @param args A tuple containing:
378 * - fileIndex (long): Index of the dataset.
379 * - name (char*): Name of the array.
380 * - symbol (char*): Symbol for the array.
381 * - units (char*): Units of the array.
382 * - description (char*): Description of the array.
383 * - format_string (char*): Format string for the array.
384 * - type (long): Data type of the array.
385 * - field_length (long): Length of the fields in the array.
386 * - dimensions (long): Number of dimensions in the array.
387 * - group_name (char*): Name of the group to which the array belongs.
388 *
389 * @return PyObject* A Python integer representing the index of the array on success or -1 on error.
390 */
391static PyObject* sddsdata_DefineArray( PyObject* self, PyObject* args )
392{
393 long fileIndex;
394 char *name;
395 char *symbol;
396 char *units;
397 char *description;
398 char *format_string;
399 long type;
400 long field_length;
401 long dimensions;
402 char *group_name;
403 if (!PyArg_ParseTuple(args, "lsssssslll", &fileIndex, &name , &symbol, &units, &description, &format_string, &group_name, &type, &field_length, &dimensions)) {
404 return NULL;
405 }
406 if (symbol)
407 if (strlen(symbol) == 0)
408 symbol = NULL;
409 if (units)
410 if (strlen(units) == 0)
411 units = NULL;
412 if (description)
413 if (strlen(description) == 0)
414 description = NULL;
415 if (format_string)
416 if (strlen(format_string) == 0)
417 format_string = NULL;
418 if (group_name)
419 if (strlen(group_name) == 0)
420 group_name = NULL;
421 return PyLong_FromLong(SDDS_DefineArray(&dataset_f[fileIndex], name, symbol, units, description, format_string, type, field_length, dimensions, group_name));
422}
423
424/**
425 * @brief Defines a column in an SDDS dataset.
426 *
427 * @param self Unused.
428 * @param args A tuple containing:
429 * - fileIndex (long): Index of the dataset.
430 * - name (char*): Name of the column.
431 * - symbol (char*): Symbol for the column.
432 * - units (char*): Units of the column.
433 * - description (char*): Description of the column.
434 * - format_string (char*): Format string for the column.
435 * - type (long): Data type of the column.
436 * - field_length (long): Length of the fields in the column.
437 *
438 * @return PyObject* A Python integer representing the index of the column on success or -1 on error.
439 */
440static PyObject* sddsdata_DefineColumn( PyObject* self, PyObject* args )
441{
442 long fileIndex;
443 char *name;
444 char *symbol;
445 char *units;
446 char *description;
447 char *format_string;
448 long type;
449 long field_length;
450 if (!PyArg_ParseTuple(args, "lsssssll", &fileIndex, &name , &symbol, &units, &description, &format_string, &type, &field_length)) {
451 return NULL;
452 }
453 if (symbol)
454 if (strlen(symbol) == 0)
455 symbol = NULL;
456 if (units)
457 if (strlen(units) == 0)
458 units = NULL;
459 if (description)
460 if (strlen(description) == 0)
461 description = NULL;
462 if (format_string)
463 if (strlen(format_string) == 0)
464 format_string = NULL;
465 return PyLong_FromLong(SDDS_DefineColumn(&dataset_f[fileIndex], name, symbol, units, description, format_string, type, field_length));
466}
467
468/**
469 * @brief Validates a name for SDDS compatibility.
470 *
471 * @param self Unused.
472 * @param args A tuple containing:
473 * - name (char*): The name to validate.
474 *
475 * @return PyObject* A Python integer (1 if valid, 0 if invalid).
476 */
477static PyObject* sddsdata_IsValidName( PyObject* self, PyObject* args )
478{
479 char *name;
480 if (!PyArg_ParseTuple(args, "s", &name)) {
481 return NULL;
482 }
483 return PyLong_FromLong(SDDS_IsValidName(name, NULL));
484}
485
486/**
487 * @brief Sets name validity flags to allow any name.
488 *
489 * @param self Unused.
490 * @param args Unused.
491 *
492 * @return PyObject* A Python integer representing the previous value of nameValidityFlags.
493 */
494static PyObject* sddsdata_SetNameValidityFlags( PyObject* self, PyObject* args )
495{
496 return PyLong_FromLong(SDDS_SetNameValidityFlags(SDDS_ALLOW_ANY_NAME));
497}
498
499/**
500 * @brief Defines a simple column in an SDDS dataset.
501 *
502 * @param self Unused.
503 * @param args A tuple containing:
504 * - fileIndex (long): Index of the dataset.
505 * - name (char*): Name of the column.
506 * - units (char*): Units of the column.
507 * - type (long): Data type of the column.
508 *
509 * @return PyObject* A Python integer (1 on success, 0 on error).
510 */
511static PyObject* sddsdata_DefineSimpleColumn( PyObject* self, PyObject* args )
512{
513 long fileIndex;
514 char *name;
515 char *units;
516 long type;
517 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
518 return NULL;
519 }
520 if (units)
521 if (strlen(units) == 0)
522 units = NULL;
523 return PyLong_FromLong(SDDS_DefineSimpleColumn(&dataset_f[fileIndex], name, units, type));
524}
525
526/**
527 * @brief Defines a simple array in an SDDS dataset.
528 *
529 * @param self Unused.
530 * @param args A tuple containing:
531 * - fileIndex (long): Index of the dataset.
532 * - name (char*): Name of the array.
533 * - units (char*): Units of the array.
534 * - type (long): Data type of the array.
535 * - dimensions (long): Number of dimensions in the array.
536 *
537 * @return PyObject* A Python integer (1 on success, 0 on error).
538 */
539static PyObject* sddsdata_DefineSimpleArray( PyObject* self, PyObject* args )
540{
541 long fileIndex;
542 char *name;
543 char *units;
544 long type;
545 long dimensions;
546 long results;
547 if (!PyArg_ParseTuple(args, "lssll", &fileIndex, &name, &units, &type, &dimensions)) {
548 return NULL;
549 }
550 if (units)
551 if (strlen(units) == 0)
552 units = NULL;
553 results = SDDS_DefineArray(&dataset_f[fileIndex], name, NULL, units, NULL, NULL, type, 0, dimensions, NULL);
554 if (results == -1) {
555 results = 0;
556 } else {
557 results = 1;
558 }
559 return PyLong_FromLong(results);
560}
561
562/**
563 * @brief Defines a simple parameter in an SDDS dataset.
564 *
565 * @param self Unused.
566 * @param args A tuple containing:
567 * - fileIndex (long): Index of the dataset.
568 * - name (char*): Name of the parameter.
569 * - units (char*): Units of the parameter.
570 * - type (long): Data type of the parameter.
571 *
572 * @return PyObject* A Python integer (1 on success, 0 on error).
573 */
574static PyObject* sddsdata_DefineSimpleParameter( PyObject* self, PyObject* args )
575{
576 long fileIndex;
577 char *name;
578 char *units;
579 long type;
580 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
581 return NULL;
582 }
583 if (units)
584 if (strlen(units) == 0)
585 units = NULL;
586 return PyLong_FromLong(SDDS_DefineSimpleParameter(&dataset_f[fileIndex], name, units, type));
587}
588
589/**
590 * @brief Writes the layout of an SDDS dataset.
591 *
592 * @param self Unused.
593 * @param args A tuple containing:
594 * - fileIndex (long): Index of the dataset.
595 *
596 * @return PyObject* A Python integer (1 on success, 0 on error).
597 */
598static PyObject* sddsdata_WriteLayout( PyObject* self, PyObject* args )
599{
600 long fileIndex;
601 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
602 return NULL;
603 }
604 return PyLong_FromLong(SDDS_WriteLayout(&dataset_f[fileIndex]));
605}
606
607/**
608 * @brief Erases data from an SDDS dataset.
609 *
610 * @param self Unused.
611 * @param args A tuple containing:
612 * - fileIndex (long): Index of the dataset.
613 *
614 * @return PyObject* A Python integer (1 on success, 0 on error).
615 */
616static PyObject* sddsdata_EraseData( PyObject* self, PyObject* args )
617{
618 long fileIndex;
619 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
620 return NULL;
621 }
622 return PyLong_FromLong(SDDS_EraseData(&dataset_f[fileIndex]));
623}
624
625
626/**
627 * @brief Processes a column definition string.
628 *
629 * @param self Unused.
630 * @param args A tuple containing:
631 * - fileIndex (long): Index of the dataset.
632 * - string (char*): Column definition string.
633 * - mode (long): Mode for processing (0 for SDDS_NORMAL_DEFINITION, 1 for SDDS_WRITEONLY_DEFINITION).
634 *
635 * @return PyObject* A Python integer (1 on success, 0 on error).
636 */
637static PyObject* sddsdata_ProcessColumnString( PyObject* self, PyObject* args )
638{
639 long fileIndex;
640 char *string;
641 long mode;
642 if (!PyArg_ParseTuple(args, "lsl", &fileIndex, &string, &mode)) {
643 return NULL;
644 }
645 return PyLong_FromLong(SDDS_ProcessColumnString(&dataset_f[fileIndex], string, mode));
646}
647
648/**
649 * @brief Processes an array definition string.
650 *
651 * @param self Unused.
652 * @param args A tuple containing:
653 * - fileIndex (long): Index of the dataset.
654 * - string (char*): Array definition string.
655 *
656 * @return PyObject* A Python integer (1 on success, 0 on error).
657 */
658static PyObject* sddsdata_ProcessArrayString( PyObject* self, PyObject* args )
659{
660 long fileIndex;
661 char *string;
662 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &string)) {
663 return NULL;
664 }
665 return PyLong_FromLong(SDDS_ProcessArrayString(&dataset_f[fileIndex], string));
666}
667
668/**
669 * @brief Processes a parameter definition string.
670 *
671 * @param self Unused.
672 * @param args A tuple containing:
673 * - fileIndex (long): Index of the dataset.
674 * - string (char*): Parameter definition string.
675 * - mode (long): Mode for processing (0 for SDDS_NORMAL_DEFINITION, 1 for SDDS_WRITEONLY_DEFINITION).
676 *
677 * @return PyObject* A Python integer (1 on success, 0 on error).
678 */
679static PyObject* sddsdata_ProcessParameterString( PyObject* self, PyObject* args )
680{
681 long fileIndex;
682 char *string;
683 long mode;
684 if (!PyArg_ParseTuple(args, "lsl", &fileIndex, &string, &mode)) {
685 return NULL;
686 }
687 return PyLong_FromLong(SDDS_ProcessParameterString(&dataset_f[fileIndex], string, mode));
688}
689
690/**
691 * @brief Initializes a copy from one SDDS dataset to another.
692 *
693 * @param self Unused.
694 * @param args A tuple containing:
695 * - fileIndexTarget (long): Index of the target dataset.
696 * - fileIndexSource (long): Index of the source dataset.
697 * - filename (char*): Name of the target file (can be NULL).
698 * - filemode (char*): File mode for the target file ("r", "w", "rb", "wb", "m").
699 *
700 * @return PyObject* A Python integer (1 on success, 0 on error).
701 */
702static PyObject* sddsdata_InitializeCopy( PyObject* self, PyObject* args )
703{
704 long fileIndexTarget;
705 long fileIndexSource;
706 char *filename;
707 char *filemode;
708 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &filename, &filemode)) {
709 return NULL;
710 }
711 if (filename)
712 if (strlen(filename) == 0)
713 filename = NULL;
714 return PyLong_FromLong(SDDS_InitializeCopy(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], filename, filemode));
715}
716
717/**
718 * @brief Copies the layout from one SDDS dataset to another.
719 *
720 * @param self Unused.
721 * @param args A tuple containing:
722 * - fileIndexTarget (long): Index of the target dataset.
723 * - fileIndexSource (long): Index of the source dataset.
724 *
725 * @return PyObject* A Python integer (1 on success, 0 on error).
726 */
727static PyObject* sddsdata_CopyLayout( PyObject* self, PyObject* args )
728{
729 long fileIndexTarget;
730 long fileIndexSource;
731 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
732 return NULL;
733 }
734 return PyLong_FromLong(SDDS_CopyLayout(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
735}
736
737/**
738 * @brief Appends the layout of one SDDS dataset to another.
739 *
740 * @param self Unused.
741 * @param args A tuple containing:
742 * - fileIndexTarget (long): Index of the target dataset.
743 * - fileIndexSource (long): Index of the source dataset.
744 *
745 * @return PyObject* A Python integer (1 on success, 0 on error).
746 */
747static PyObject* sddsdata_AppendLayout( PyObject* self, PyObject* args )
748{
749 long fileIndexTarget;
750 long fileIndexSource;
751 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
752 return NULL;
753 }
754 return PyLong_FromLong(SDDS_AppendLayout(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], 0));
755}
756
757/**
758 * @brief Copies a page from one SDDS dataset to another.
759 *
760 * @param self Unused.
761 * @param args A tuple containing:
762 * - fileIndexTarget (long): Index of the target dataset.
763 * - fileIndexSource (long): Index of the source dataset.
764 *
765 * @return PyObject* A Python integer (1 on success, 0 on error).
766 */
767static PyObject* sddsdata_CopyPage( PyObject* self, PyObject* args )
768{
769 long fileIndexTarget;
770 long fileIndexSource;
771 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
772 return NULL;
773 }
774 return PyLong_FromLong(SDDS_CopyPage(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
775}
776
777/**
778 * @brief Copies parameters from one SDDS dataset to another.
779 *
780 * @param self Unused.
781 * @param args A tuple containing:
782 * - fileIndexTarget (long): Index of the target dataset.
783 * - fileIndexSource (long): Index of the source dataset.
784 *
785 * @return PyObject* A Python integer (1 on success, 0 on error).
786 */
787static PyObject* sddsdata_CopyParameters( PyObject* self, PyObject* args )
788{
789 long fileIndexTarget;
790 long fileIndexSource;
791 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
792 return NULL;
793 }
794 return PyLong_FromLong(SDDS_CopyParameters(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
795}
796
797/**
798 * @brief Copies arrays from one SDDS dataset to another.
799 *
800 * @param self Unused.
801 * @param args A tuple containing:
802 * - fileIndexTarget (long): Index of the target dataset.
803 * - fileIndexSource (long): Index of the source dataset.
804 *
805 * @return PyObject* A Python integer (1 on success, 0 on error).
806 */
807static PyObject* sddsdata_CopyArrays( PyObject* self, PyObject* args )
808{
809 long fileIndexTarget;
810 long fileIndexSource;
811 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
812 return NULL;
813 }
814 return PyLong_FromLong(SDDS_CopyArrays(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
815}
816
817/**
818 * @brief Copies columns from one SDDS dataset to another.
819 *
820 * @param self Unused.
821 * @param args A tuple containing:
822 * - fileIndexTarget (long): Index of the target dataset.
823 * - fileIndexSource (long): Index of the source dataset.
824 *
825 * @return PyObject* A Python integer (1 on success, 0 on error).
826 */
827static PyObject* sddsdata_CopyColumns( PyObject* self, PyObject* args )
828{
829 long fileIndexTarget;
830 long fileIndexSource;
831 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
832 return NULL;
833 }
834 return PyLong_FromLong(SDDS_CopyColumns(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
835}
836
837/**
838 * @brief Copies a row from one SDDS dataset to another.
839 *
840 * @param self Unused.
841 * @param args A tuple containing:
842 * - fileIndexTarget (long): Index of the target dataset.
843 * - target_row (long): Row number in the target dataset.
844 * - fileIndexSource (long): Index of the source dataset.
845 * - source_row (long): Row number in the source dataset.
846 *
847 * @return PyObject* A Python integer (1 on success, 0 on error).
848 */
849static PyObject* sddsdata_CopyRow( PyObject* self, PyObject* args )
850{
851 long fileIndexTarget;
852 long target_row;
853 long fileIndexSource;
854 long source_row;
855 if (!PyArg_ParseTuple(args, "llll", &fileIndexTarget, &target_row, &fileIndexSource, &source_row)) {
856 return NULL;
857 }
858 return PyLong_FromLong(SDDS_CopyRow(&dataset_f[fileIndexTarget], target_row, &dataset_f[fileIndexSource], source_row));
859}
860
861/**
862 * @brief Directly copies a row from one SDDS dataset to another.
863 *
864 * @param self Unused.
865 * @param args A tuple containing:
866 * - fileIndexTarget (long): Index of the target dataset.
867 * - target_row (long): Row number in the target dataset.
868 * - fileIndexSource (long): Index of the source dataset.
869 * - source_row (long): Row number in the source dataset.
870 *
871 * @return PyObject* A Python integer (1 on success, 0 on error).
872 */
873static PyObject* sddsdata_CopyRowDirect( PyObject* self, PyObject* args )
874{
875 long fileIndexTarget;
876 long target_row;
877 long fileIndexSource;
878 long source_row;
879 if (!PyArg_ParseTuple(args, "llll", &fileIndexTarget, &target_row, &fileIndexSource, &source_row)) {
880 return NULL;
881 }
882 return PyLong_FromLong(SDDS_CopyRowDirect(&dataset_f[fileIndexTarget], target_row, &dataset_f[fileIndexSource], source_row));
883}
884
885/**
886 * @brief Copies additional rows from one SDDS dataset to another.
887 *
888 * @param self Unused.
889 * @param args A tuple containing:
890 * - fileIndexTarget (long): Index of the target dataset.
891 * - fileIndexSource (long): Index of the source dataset.
892 *
893 * @return PyObject* A Python integer (1 on success, 0 on error).
894 */
895static PyObject* sddsdata_CopyAdditionalRows( PyObject* self, PyObject* args )
896{
897 long fileIndexTarget;
898 long fileIndexSource;
899 if (!PyArg_ParseTuple(args, "ll", &fileIndexTarget, &fileIndexSource)) {
900 return NULL;
901 }
902 return PyLong_FromLong(SDDS_CopyAdditionalRows(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource]));
903}
904
905/**
906 * @brief Defers saving the layout of an SDDS dataset.
907 *
908 * @param self Unused.
909 * @param args A tuple containing:
910 * - fileIndex (long): Index of the dataset.
911 * - mode (long): Mode for deferring (0 for False, 1 for True).
912 *
913 * @return PyObject* None.
914 */
915static PyObject* sddsdata_DeferSavingLayout( PyObject* self, PyObject* args )
916{
917 long fileIndex, mode;
918 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &mode)) {
919 return NULL;
920 }
921 SDDS_DeferSavingLayout(&dataset_f[fileIndex],mode);
922 Py_INCREF(Py_None);
923 return Py_None;
924}
925
926/**
927 * @brief Saves the layout of an SDDS dataset.
928 *
929 * @param self Unused.
930 * @param args A tuple containing:
931 * - fileIndex (long): Index of the dataset.
932 *
933 * @return PyObject* A Python integer (1 on success, 0 on error).
934 */
935static PyObject* sddsdata_SaveLayout( PyObject* self, PyObject* args )
936{
937 long fileIndex;
938 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
939 return NULL;
940 }
941 return PyLong_FromLong(SDDS_SaveLayout(&dataset_f[fileIndex]));
942}
943
944/**
945 * @brief Restores the layout of an SDDS dataset.
946 *
947 * @param self Unused.
948 * @param args A tuple containing:
949 * - fileIndex (long): Index of the dataset.
950 *
951 * @return PyObject* A Python integer (1 on success, 0 on error).
952 */
953static PyObject* sddsdata_RestoreLayout( PyObject* self, PyObject* args )
954{
955 long fileIndex;
956 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
957 return NULL;
958 }
959 return PyLong_FromLong(SDDS_RestoreLayout(&dataset_f[fileIndex]));
960}
961
962/**
963 * @brief Starts a page in an SDDS dataset.
964 *
965 * @param self Unused.
966 * @param args A tuple containing:
967 * - fileIndex (long): Index of the dataset.
968 * - expected_n_rows (long): Expected number of rows on the page.
969 *
970 * @return PyObject* A Python integer (1 on success, 0 on error).
971 */
972static PyObject* sddsdata_StartPage( PyObject* self, PyObject* args )
973{
974 long fileIndex;
975 long expected_n_rows;
976 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &expected_n_rows)) {
977 return NULL;
978 }
979 return PyLong_FromLong(SDDS_StartPage(&dataset_f[fileIndex], expected_n_rows));
980}
981
982/**
983 * @brief Clears the current page in an SDDS dataset.
984 *
985 * @param self Unused.
986 * @param args A tuple containing:
987 * - fileIndex (long): Index of the dataset.
988 *
989 * @return PyObject* A Python integer (1 on success, 0 on error).
990 */
991static PyObject* sddsdata_ClearPage( PyObject* self, PyObject* args )
992{
993 long fileIndex;
994 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
995 return NULL;
996 }
997 return PyLong_FromLong(SDDS_ClearPage(&dataset_f[fileIndex]));
998}
999
1000/**
1001 * @brief Lengthens the table by adding additional rows.
1002 *
1003 * @param self Pointer to the Python self object.
1004 * @param args Tuple containing:
1005 * - fileIndex (long): Index of the file dataset.
1006 * - n_additional_rows (long): Number of rows to add.
1007 * @return PyObject*:
1008 * - 0 on error.
1009 * - 1 on success.
1010 */
1011static PyObject* sddsdata_LengthenTable( PyObject* self, PyObject* args )
1012{
1013 long fileIndex;
1014 long n_additional_rows;
1015 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &n_additional_rows)) {
1016 return NULL;
1017 }
1018 return PyLong_FromLong(SDDS_LengthenTable(&dataset_f[fileIndex], n_additional_rows));
1019}
1020
1021/**
1022 * @brief Writes the current page of the dataset to the file.
1023 *
1024 * @param self Pointer to the Python self object.
1025 * @param args Tuple containing:
1026 * - fileIndex (long): Index of the file dataset.
1027 * @return PyObject*:
1028 * - 0 on error.
1029 * - 1 on success.
1030 */
1031static PyObject* sddsdata_WritePage( PyObject* self, PyObject* args )
1032{
1033 long fileIndex;
1034 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1035 return NULL;
1036 }
1037 return PyLong_FromLong(SDDS_WritePage(&dataset_f[fileIndex]));
1038}
1039
1040/**
1041 * @brief Updates the page based on the specified mode.
1042 *
1043 * @param self Pointer to the Python self object.
1044 * @param args Tuple containing:
1045 * - fileIndex (long): Index of the file dataset.
1046 * - mode (long): Update mode.
1047 * @return PyObject*:
1048 * - 0 on error.
1049 * - 1 on success.
1050 */
1051static PyObject* sddsdata_UpdatePage( PyObject* self, PyObject* args )
1052{
1053 long fileIndex, mode;
1054 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &mode)) {
1055 return NULL;
1056 }
1057 return PyLong_FromLong(SDDS_UpdatePage(&dataset_f[fileIndex], mode));
1058}
1059
1060/**
1061 * @brief Initializes a headerless input for a dataset file.
1062 *
1063 * @param self Pointer to the Python self object.
1064 * @param args Tuple containing:
1065 * - fileIndex (long): Index of the file dataset.
1066 * - filename (char*): Name of the file to initialize.
1067 * @return PyObject*:
1068 * - 0 on error.
1069 * - 1 on success.
1070 */
1071static PyObject* sddsdata_InitHeaderlessInput( PyObject* self, PyObject* args )
1072{
1073 long fileIndex;
1074 char *filename;
1075 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &filename)) {
1076 return NULL;
1077 }
1078 return PyLong_FromLong(SDDS_InitializeHeaderlessInput(&dataset_f[fileIndex], filename));
1079}
1080
1081/**
1082 * @brief Reads the current page from the dataset file.
1083 *
1084 * @param self Pointer to the Python self object.
1085 * @param args Tuple containing:
1086 * - fileIndex (long): Index of the file dataset.
1087 * @return PyObject*:
1088 * - 0 on error.
1089 * - -1 on EOF.
1090 * - Page number on success.
1091 */
1092static PyObject* sddsdata_ReadPage( PyObject* self, PyObject* args )
1093{
1094 long fileIndex;
1095 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1096 return NULL;
1097 }
1098 return PyLong_FromLong(SDDS_ReadPage(&dataset_f[fileIndex]));
1099}
1100
1101/**
1102 * @brief Reads a sparse page from the dataset file.
1103 *
1104 * @param self Pointer to the Python self object.
1105 * @param args Tuple containing:
1106 * - fileIndex (long): Index of the file dataset.
1107 * - sparse_interval (long): Interval for sparse reading.
1108 * - sparse_offset (long): Offset for sparse reading.
1109 * @return PyObject*:
1110 * - 0 on error.
1111 * - -1 on EOF.
1112 * - Page number on success.
1113 */
1114static PyObject* sddsdata_ReadPageSparse( PyObject* self, PyObject* args )
1115{
1116 long fileIndex;
1117 long sparse_interval;
1118 long sparse_offset;
1119 if (!PyArg_ParseTuple(args, "lll", &fileIndex, &sparse_interval, &sparse_offset)) {
1120 return NULL;
1121 }
1122 return PyLong_FromLong(SDDS_ReadPageSparse(&dataset_f[fileIndex], 0, sparse_interval, sparse_offset, 0));
1123}
1124
1125/**
1126 * @brief Reads the last rows of the current page from the dataset file.
1127 *
1128 * @param self Pointer to the Python self object.
1129 * @param args Tuple containing:
1130 * - fileIndex (long): Index of the file dataset.
1131 * - last_rows (long): Number of last rows to read.
1132 * @return PyObject*:
1133 * - 0 on error.
1134 * - -1 on EOF.
1135 * - Page number on success.
1136 */
1137static PyObject* sddsdata_ReadPageLastRows( PyObject* self, PyObject* args )
1138{
1139 long fileIndex;
1140 long last_rows;
1141 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &last_rows)) {
1142 return NULL;
1143 }
1144 return PyLong_FromLong(SDDS_ReadPageLastRows(&dataset_f[fileIndex], last_rows));
1145}
1146
1147/**
1148 * @brief Gets the number of rows in the dataset.
1149 *
1150 * @param self Pointer to the Python self object.
1151 * @param args Tuple containing:
1152 * - fileIndex (long): Index of the file dataset.
1153 * @return PyObject*:
1154 * - Number of rows in the dataset.
1155 */
1156static PyObject* sddsdata_RowCount( PyObject* self, PyObject* args )
1157{
1158 long fileIndex;
1159 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1160 return NULL;
1161 }
1162 return PyLong_FromLongLong((long long)SDDS_RowCount(&dataset_f[fileIndex]));
1163}
1164
1165/**
1166 * @brief Sets the column flags for the dataset.
1167 *
1168 * @param self Pointer to the Python self object.
1169 * @param args Tuple containing:
1170 * - fileIndex (long): Index of the file dataset.
1171 * - column_flag_value (long): Flag value (valid values: 0, 1).
1172 * @return PyObject*:
1173 * - 0 on error.
1174 * - 1 on success.
1175 */
1176static PyObject* sddsdata_SetColumnFlags( PyObject* self, PyObject* args )
1177{
1178 long fileIndex;
1179 long column_flag_value;
1180 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &column_flag_value)) {
1181 return NULL;
1182 }
1183 return PyLong_FromLong(SDDS_SetColumnFlags(&dataset_f[fileIndex], column_flag_value));
1184}
1185
1186/**
1187 * @brief Sets the row flags for the dataset.
1188 *
1189 * @param self Pointer to the Python self object.
1190 * @param args Tuple containing:
1191 * - fileIndex (long): Index of the file dataset.
1192 * - row_flag_value (long): Flag value (valid values: 0, 1).
1193 * @return PyObject*:
1194 * - 0 on error.
1195 * - 1 on success.
1196 */
1197static PyObject* sddsdata_SetRowFlags( PyObject* self, PyObject* args )
1198{
1199 long fileIndex;
1200 long row_flag_value;
1201 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &row_flag_value)) {
1202 return NULL;
1203 }
1204 return PyLong_FromLong(SDDS_SetRowFlags(&dataset_f[fileIndex], row_flag_value));
1205}
1206
1207/**
1208 * @brief Gets the flag value for a specific row in the dataset.
1209 *
1210 * @param self Pointer to the Python self object.
1211 * @param args Tuple containing:
1212 * - fileIndex (long): Index of the file dataset.
1213 * - row (long): Row number for which the flag is retrieved.
1214 * @return PyObject*:
1215 * - -1 on error.
1216 * - Row flag on success.
1217 */
1218static PyObject* sddsdata_GetRowFlag( PyObject* self, PyObject* args )
1219{
1220 long fileIndex;
1221 long row;
1222 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &row)) {
1223 return NULL;
1224 }
1225 return PyLong_FromLong(SDDS_GetRowFlag(&dataset_f[fileIndex], row));
1226}
1227
1228/**
1229 * @brief Deletes a column from the dataset.
1230 * @param self Python object (unused).
1231 * @param args Python arguments tuple containing:
1232 * - fileIndex (long): Index of the dataset file.
1233 * - column_name (char*): Name of the column to delete.
1234 * @return PyObject*:
1235 * - PyLong(0) on error.
1236 * - PyLong(1) on success.
1237 */
1238static PyObject* sddsdata_DeleteColumn( PyObject* self, PyObject* args )
1239{
1240 long fileIndex;
1241 char *column_name;
1242 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &column_name)) {
1243 return NULL;
1244 }
1245 return PyLong_FromLong(SDDS_DeleteColumn(&dataset_f[fileIndex], column_name));
1246}
1247
1248/**
1249 * @brief Deletes a parameter from the dataset.
1250 * @param self Python object (unused).
1251 * @param args Python arguments tuple containing:
1252 * - fileIndex (long): Index of the dataset file.
1253 * - parameter_name (char*): Name of the parameter to delete.
1254 * @return PyObject*:
1255 * - PyLong(0) on error.
1256 * - PyLong(1) on success.
1257 */
1258static PyObject* sddsdata_DeleteParameter( PyObject* self, PyObject* args )
1259{
1260 long fileIndex;
1261 char *parameter_name;
1262 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &parameter_name)) {
1263 return NULL;
1264 }
1265 return PyLong_FromLong(SDDS_DeleteParameter(&dataset_f[fileIndex], parameter_name));
1266}
1267
1268/**
1269 * @brief Deletes all unset columns in the dataset.
1270 * @param self Python object (unused).
1271 * @param args Python arguments tuple containing:
1272 * - fileIndex (long): Index of the dataset file.
1273 * @return PyObject*:
1274 * - PyLong(0) on error.
1275 * - PyLong(1) on success.
1276 */
1277static PyObject* sddsdata_DeleteUnsetColumns( PyObject* self, PyObject* args )
1278{
1279 long fileIndex;
1280 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1281 return NULL;
1282 }
1283 return PyLong_FromLong(SDDS_DeleteUnsetColumns(&dataset_f[fileIndex]));
1284}
1285
1286/**
1287 * @brief Deletes all unset rows in the dataset.
1288 * @param self Python object (unused).
1289 * @param args Python arguments tuple containing:
1290 * - fileIndex (long): Index of the dataset file.
1291 * @return PyObject*:
1292 * - PyLong(0) on error.
1293 * - PyLong(1) on success.
1294 */
1295static PyObject* sddsdata_DeleteUnsetRows( PyObject* self, PyObject* args )
1296{
1297 long fileIndex;
1298 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1299 return NULL;
1300 }
1301 return PyLong_FromLong(SDDS_DeleteUnsetRows(&dataset_f[fileIndex]));
1302}
1303
1304/**
1305 * @brief Gets the count of columns in the dataset.
1306 * @param self Python object (unused).
1307 * @param args Python arguments tuple containing:
1308 * - fileIndex (long): Index of the dataset file.
1309 * @return PyObject*: Number of columns as PyLong.
1310 */
1311static PyObject* sddsdata_ColumnCount( PyObject* self, PyObject* args )
1312{
1313 long fileIndex;
1314 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1315 return NULL;
1316 }
1317 return PyLong_FromLong(SDDS_ColumnCount(&dataset_f[fileIndex]));
1318}
1319
1320/**
1321 * @brief Gets the count of arrays in the dataset.
1322 * @param self Python object (unused).
1323 * @param args Python arguments tuple containing:
1324 * - fileIndex (long): Index of the dataset file.
1325 * @return PyObject*: Number of arrays as PyLong.
1326 */
1327static PyObject* sddsdata_ArrayCount( PyObject* self, PyObject* args )
1328{
1329 long fileIndex;
1330 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1331 return NULL;
1332 }
1333 return PyLong_FromLong(SDDS_ArrayCount(&dataset_f[fileIndex]));
1334}
1335
1336/**
1337 * @brief Gets the count of parameters in the dataset.
1338 * @param self Python object (unused).
1339 * @param args Python arguments tuple containing:
1340 * - fileIndex (long): Index of the dataset file.
1341 * @return PyObject*: Number of parameters as PyLong.
1342 */
1343static PyObject* sddsdata_ParameterCount( PyObject* self, PyObject* args )
1344{
1345 long fileIndex;
1346 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1347 return NULL;
1348 }
1349 return PyLong_FromLong(SDDS_ParameterCount(&dataset_f[fileIndex]));
1350}
1351
1352/**
1353 * @brief Gets the description (text and contents) of the dataset.
1354 * @param self Python object (unused).
1355 * @param args Python arguments tuple containing:
1356 * - fileIndex (long): Index of the dataset file.
1357 * @return PyObject*:
1358 * - PyList of [text, contents] on success.
1359 * - NULL on error.
1360 */
1361static PyObject* sddsdata_GetDescription( PyObject* self, PyObject* args )
1362{
1363 long fileIndex;
1364 char *text;
1365 char *contents;
1366 PyObject *v;
1367 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1368 return NULL;
1369 }
1370 if (SDDS_GetDescription(&dataset_f[fileIndex], &text, &contents) == 0) {
1371 return NULL;
1372 }
1373 if (!(v = PyList_New(2)))
1374 return NULL;
1375 if (text) {
1376 PyList_SetItem(v, 0, PyString_FromString(text));
1377 free(text);
1378 } else {
1379 PyList_SetItem(v, 0, PyString_FromString(""));
1380 }
1381 if (contents) {
1382 PyList_SetItem(v, 1, PyString_FromString(contents));
1383 free(contents);
1384 } else {
1385 PyList_SetItem(v, 1, PyString_FromString(""));
1386 }
1387 return v;
1388}
1389
1390/**
1391 * @brief Retrieves the description text for a dataset.
1392 *
1393 * @param self Python object (unused).
1394 * @param args Python tuple containing:
1395 * - `fileIndex` (long): Index of the dataset file.
1396 * @return Python string containing the description text, or NULL on error.
1397 */
1398static PyObject* sddsdata_GetDescriptionText( PyObject* self, PyObject* args )
1399{
1400 long fileIndex;
1401 char *text;
1402 char *contents;
1403 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1404 return NULL;
1405 }
1406 if (SDDS_GetDescription(&dataset_f[fileIndex], &text, &contents) == 0) {
1407 return NULL;
1408 }
1409 if (text)
1410 return PyString_FromString(text);
1411 return PyString_FromString("");
1412}
1413
1414/**
1415 * @brief Retrieves the description contents for a dataset.
1416 *
1417 * @param self Python object (unused).
1418 * @param args Python tuple containing:
1419 * - `fileIndex` (long): Index of the dataset file.
1420 * @return Python string containing the description contents, or NULL on error.
1421 */
1422static PyObject* sddsdata_GetDescriptionContents( PyObject* self, PyObject* args )
1423{
1424 long fileIndex;
1425 char *text;
1426 char *contents;
1427 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
1428 return NULL;
1429 }
1430 if (SDDS_GetDescription(&dataset_f[fileIndex], &text, &contents) == 0) {
1431 return NULL;
1432 }
1433 if (contents)
1434 return PyString_FromString(contents);
1435 return PyString_FromString("");
1436}
1437
1438/**
1439 * @brief Returns the number of errors recorded.
1440 *
1441 * @param self Python object (unused).
1442 * @param args Python tuple (unused).
1443 * @return Python integer representing the number of errors.
1444 */
1445static PyObject* sddsdata_NumberOfErrors( PyObject* self, PyObject* args )
1446{
1447 return PyLong_FromLong(SDDS_NumberOfErrors());
1448}
1449
1450/**
1451 * @brief Clears all recorded errors.
1452 *
1453 * @param self Python object (unused).
1454 * @param args Python tuple (unused).
1455 * @return Python None.
1456 */
1457static PyObject* sddsdata_ClearErrors( PyObject* self, PyObject* args )
1458{
1460 Py_INCREF(Py_None);
1461 return Py_None;
1462}
1463
1464/**
1465 * @brief Sets an error description.
1466 *
1467 * @param self Python object (unused).
1468 * @param args Python tuple containing:
1469 * - `error_text` (char*): Description of the error.
1470 * @return Python None, or NULL on error.
1471 */
1472static PyObject* sddsdata_SetError( PyObject* self, PyObject* args )
1473{
1474 char *error_text;
1475 if (!PyArg_ParseTuple(args, "s", &error_text)) {
1476 return NULL;
1477 }
1478 SDDS_SetError(error_text);
1479 Py_INCREF(Py_None);
1480 return Py_None;
1481}
1482
1483/**
1484 * @brief Displays a message on stderr and exits the program.
1485 *
1486 * @param self Python object (unused).
1487 * @param args Python tuple containing:
1488 * - `message` (char*): Message to display.
1489 * @return Python None, or NULL on error.
1490 */
1491static PyObject* sddsdata_Bomb( PyObject* self, PyObject* args )
1492{
1493 char *message;
1494 if (!PyArg_ParseTuple(args, "s", &message)) {
1495 return NULL;
1496 }
1497 SDDS_Bomb(message);
1498 Py_INCREF(Py_None);
1499 return Py_None;
1500}
1501
1502/**
1503 * @brief Displays a warning message on stderr.
1504 *
1505 * @param self Python object (unused).
1506 * @param args Python tuple containing:
1507 * - `message` (char*): Warning message to display.
1508 * @return Python None, or NULL on error.
1509 */
1510static PyObject* sddsdata_Warning( PyObject* self, PyObject* args )
1511{
1512 char *message;
1513 if (!PyArg_ParseTuple(args, "s", &message)) {
1514 return NULL;
1515 }
1516 SDDS_Warning(message);
1517 Py_INCREF(Py_None);
1518 return Py_None;
1519}
1520
1521/**
1522 * @brief Registers a program name for use in error messages.
1523 *
1524 * @param self Python object (unused).
1525 * @param args Python tuple containing:
1526 * - `name` (char*): Name of the program.
1527 * @return Python None, or NULL on error.
1528 */
1529static PyObject* sddsdata_RegisterProgramName( PyObject* self, PyObject* args )
1530{
1531 char *name;
1532 if (!PyArg_ParseTuple(args, "s", &name)) {
1533 return NULL;
1534 }
1536 Py_INCREF(Py_None);
1537 return Py_None;
1538}
1539
1540/**
1541 * @brief Prints error messages based on the provided mode.
1542 *
1543 * @param self Python object (unused).
1544 * @param args Python tuple containing:
1545 * - `mode` (long): Error print mode. Valid values: 0, 1, 2, 3.
1546 * @return Python None, or NULL on error.
1547 */
1548static PyObject* sddsdata_PrintErrors( PyObject* self, PyObject* args )
1549{
1550 long mode;
1551 if (!PyArg_ParseTuple(args, "l", &mode)) {
1552 return NULL;
1553 }
1554 SDDS_PrintErrors(stderr, mode);
1555 Py_INCREF(Py_None);
1556 return Py_None;
1557}
1558
1559/**
1560 * @brief Transfers a column definition from one dataset to another.
1561 *
1562 * @param self Python object (unused).
1563 * @param args Python tuple containing:
1564 * - `fileIndexTarget` (long): Target dataset index.
1565 * - `fileIndexSource` (long): Source dataset index.
1566 * - `name` (char*): Name of the column to transfer.
1567 * - `newName` (char*): New name for the column (optional).
1568 * @return Python integer (1 on success, 0 on error).
1569 */
1570static PyObject* sddsdata_TransferColumnDefinition( PyObject* self, PyObject* args )
1571{
1572 long fileIndexTarget;
1573 long fileIndexSource;
1574 char *name;
1575 char *newName;
1576 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1577 return NULL;
1578 }
1579 return PyLong_FromLong(SDDS_TransferColumnDefinition(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1580}
1581
1582/**
1583 * @brief Transfers an array definition from one dataset to another.
1584 *
1585 * @param self Python object (unused).
1586 * @param args Python tuple containing:
1587 * - `fileIndexTarget` (long): Target dataset index.
1588 * - `fileIndexSource` (long): Source dataset index.
1589 * - `name` (char*): Name of the array to transfer.
1590 * - `newName` (char*): New name for the array (optional).
1591 * @return Python integer (1 on success, 0 on error).
1592 */
1593static PyObject* sddsdata_TransferArrayDefinition( PyObject* self, PyObject* args )
1594{
1595 long fileIndexTarget;
1596 long fileIndexSource;
1597 char *name;
1598 char *newName;
1599 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1600 return NULL;
1601 }
1602 return PyLong_FromLong(SDDS_TransferArrayDefinition(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1603}
1604
1605/**
1606 * @brief Transfers a parameter definition from one dataset to another.
1607 *
1608 * @param self Python object (unused).
1609 * @param args Python tuple containing:
1610 * - `fileIndexTarget` (long): Target dataset index.
1611 * - `fileIndexSource` (long): Source dataset index.
1612 * - `name` (char*): Name of the parameter to transfer.
1613 * - `newName` (char*): New name for the parameter (optional).
1614 * @return Python integer (1 on success, 0 on error).
1615 */
1616static PyObject* sddsdata_TransferParameterDefinition( PyObject* self, PyObject* args )
1617{
1618 long fileIndexTarget;
1619 long fileIndexSource;
1620 char *name;
1621 char *newName;
1622 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1623 return NULL;
1624 }
1625 return PyLong_FromLong(SDDS_TransferParameterDefinition(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1626}
1627
1628/**
1629 * @brief Defines a column in one dataset based on a parameter in another dataset.
1630 *
1631 * @param self Python object (unused).
1632 * @param args Python tuple containing:
1633 * - `fileIndexTarget` (long): Target dataset index.
1634 * - `fileIndexSource` (long): Source dataset index.
1635 * - `name` (char*): Name of the parameter to base the column on.
1636 * - `newName` (char*): New name for the column (optional).
1637 * @return Python integer (1 on success, 0 on error).
1638 */
1639static PyObject* sddsdata_DefineColumnLikeParameter( PyObject* self, PyObject* args )
1640{
1641 long fileIndexTarget;
1642 long fileIndexSource;
1643 char *name;
1644 char *newName;
1645 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1646 return NULL;
1647 }
1648 return PyLong_FromLong(SDDS_DefineColumnLikeParameter(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1649}
1650
1651/**
1652 * @brief Defines a parameter in one dataset based on a column in another dataset.
1653 *
1654 * @param self Python object (unused).
1655 * @param args Python tuple containing:
1656 * - `fileIndexTarget` (long): Target dataset index.
1657 * - `fileIndexSource` (long): Source dataset index.
1658 * - `name` (char*): Name of the column to base the parameter on.
1659 * - `newName` (char*): New name for the parameter (optional).
1660 * @return Python integer (1 on success, 0 on error).
1661 */
1662static PyObject* sddsdata_DefineParameterLikeColumn( PyObject* self, PyObject* args )
1663{
1664 long fileIndexTarget;
1665 long fileIndexSource;
1666 char *name;
1667 char *newName;
1668 if (!PyArg_ParseTuple(args, "llss", &fileIndexTarget, &fileIndexSource, &name, &newName)) {
1669 return NULL;
1670 }
1671 return PyLong_FromLong(SDDS_DefineParameterLikeColumn(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], name, newName));
1672}
1673
1674/**
1675 * @brief Transfers all column definitions from one dataset to another.
1676 *
1677 * @param self Python object (unused).
1678 * @param args Python tuple containing:
1679 * - `fileIndexTarget` (long): Target dataset index.
1680 * - `fileIndexSource` (long): Source dataset index.
1681 * - `mode` (long): Transfer mode. Valid values: 0, 1, 2, 3.
1682 * @return Python integer (1 on success, 0 on error).
1683 */
1684static PyObject* sddsdata_TransferAllColumnDefinitions( PyObject* self, PyObject* args )
1685{
1686 long fileIndexTarget;
1687 long fileIndexSource;
1688 long mode;
1689 if (!PyArg_ParseTuple(args, "lll", &fileIndexTarget, &fileIndexSource, &mode)) {
1690 return NULL;
1691 }
1692 return PyLong_FromLong(SDDS_TransferAllColumnDefinitions(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], mode));
1693}
1694
1695/**
1696 * @brief Transfers all array definitions from one dataset to another.
1697 *
1698 * @param self Python object (unused).
1699 * @param args Python tuple containing:
1700 * - `fileIndexTarget` (long): Target dataset index.
1701 * - `fileIndexSource` (long): Source dataset index.
1702 * - `mode` (long): Transfer mode. Valid values: 0, 1, 2, 3.
1703 * @return Python integer (1 on success, 0 on error).
1704 */
1705static PyObject* sddsdata_TransferAllArrayDefinitions( PyObject* self, PyObject* args )
1706{
1707 long fileIndexTarget;
1708 long fileIndexSource;
1709 long mode;
1710 if (!PyArg_ParseTuple(args, "lll", &fileIndexTarget, &fileIndexSource, &mode)) {
1711 return NULL;
1712 }
1713 return PyLong_FromLong(SDDS_TransferAllArrayDefinitions(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], mode));
1714}
1715
1716/**
1717 * @brief Transfers all parameter definitions from one dataset to another.
1718 *
1719 * @param self Python object (unused).
1720 * @param args Python tuple containing:
1721 * - `fileIndexTarget` (long): Target dataset index.
1722 * - `fileIndexSource` (long): Source dataset index.
1723 * - `mode` (long): Transfer mode. Valid values: 0, 1, 2, 3.
1724 * @return Python integer (1 on success, 0 on error).
1725 */
1726static PyObject* sddsdata_TransferAllParameterDefinitions( PyObject* self, PyObject* args )
1727{
1728 long fileIndexTarget;
1729 long fileIndexSource;
1730 long mode;
1731 if (!PyArg_ParseTuple(args, "lll", &fileIndexTarget, &fileIndexSource, &mode)) {
1732 return NULL;
1733 }
1734 return PyLong_FromLong(SDDS_TransferAllParameterDefinitions(&dataset_f[fileIndexTarget], &dataset_f[fileIndexSource], mode));
1735}
1736
1737/**
1738 * @brief Retrieves the index of a column in a dataset.
1739 *
1740 * @param self Python object (unused).
1741 * @param args Python tuple containing:
1742 * - `fileIndex` (long): Dataset index.
1743 * - `name` (char*): Name of the column.
1744 * @return Python integer (index on success, -1 on error).
1745 */
1746static PyObject* sddsdata_GetColumnIndex( PyObject* self, PyObject* args )
1747{
1748 long fileIndex;
1749 char *name;
1750 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1751 return NULL;
1752 }
1753 return PyLong_FromLong(SDDS_GetColumnIndex(&dataset_f[fileIndex], name));
1754}
1755
1756/**
1757 * @brief Retrieves the index of an array in a dataset.
1758 *
1759 * @param self Python object (unused).
1760 * @param args Python tuple containing:
1761 * - `fileIndex` (long): Dataset index.
1762 * - `name` (char*): Name of the array.
1763 * @return Python integer (index on success, -1 on error).
1764 */
1765static PyObject* sddsdata_GetArrayIndex( PyObject* self, PyObject* args )
1766{
1767 long fileIndex;
1768 char *name;
1769 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1770 return NULL;
1771 }
1772 return PyLong_FromLong(SDDS_GetArrayIndex(&dataset_f[fileIndex], name));
1773}
1774
1775/**
1776 * @brief Retrieves the index of a parameter in a dataset.
1777 *
1778 * @param self Python object (unused).
1779 * @param args Python tuple containing:
1780 * - `fileIndex` (long): Dataset index.
1781 * - `name` (char*): Name of the parameter.
1782 * @return Python integer (index on success, -1 on error).
1783 */
1784static PyObject* sddsdata_GetParameterIndex( PyObject* self, PyObject* args )
1785{
1786 long fileIndex;
1787 char *name;
1788 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1789 return NULL;
1790 }
1791 return PyLong_FromLong(SDDS_GetParameterIndex(&dataset_f[fileIndex], name));
1792}
1793
1794/**
1795 * @brief Retrieves the type of a column in a dataset.
1796 *
1797 * @param self Python object (unused).
1798 * @param args Python tuple containing:
1799 * - `fileIndex` (long): Dataset index.
1800 * - `index` (long): Column index.
1801 * @return Python integer (type on success, 0 on error).
1802 */
1803static PyObject* sddsdata_GetColumnType( PyObject* self, PyObject* args )
1804{
1805 long fileIndex;
1806 long index;
1807 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
1808 return NULL;
1809 }
1810 return PyLong_FromLong(SDDS_GetColumnType(&dataset_f[fileIndex], index));
1811}
1812
1813/**
1814 * @brief Retrieves the type of an array in a dataset.
1815 *
1816 * @param self Python object (unused).
1817 * @param args Python tuple containing:
1818 * - `fileIndex` (long): Dataset index.
1819 * - `index` (long): Array index.
1820 * @return Python integer (type on success, 0 on error).
1821 */
1822static PyObject* sddsdata_GetArrayType( PyObject* self, PyObject* args )
1823{
1824 long fileIndex;
1825 long index;
1826 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
1827 return NULL;
1828 }
1829 return PyLong_FromLong(SDDS_GetArrayType(&dataset_f[fileIndex], index));
1830}
1831
1832/**
1833 * @brief Retrieves the type of a column by name in a dataset.
1834 *
1835 * @param self Python object (unused).
1836 * @param args Python tuple containing:
1837 * - `fileIndex` (long): Dataset index.
1838 * - `name` (char*): Name of the column.
1839 * @return Python integer (type on success, 0 on error).
1840 */
1841static PyObject* sddsdata_GetNamedColumnType( PyObject* self, PyObject* args )
1842{
1843 long fileIndex;
1844 char *name;
1845 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1846 return NULL;
1847 }
1848 return PyLong_FromLong(SDDS_GetNamedColumnType(&dataset_f[fileIndex], name));
1849}
1850
1851/**
1852 * @brief Retrieves the type of an array by name in a dataset.
1853 *
1854 * @param self Python object (unused).
1855 * @param args Python tuple containing:
1856 * - `fileIndex` (long): Dataset index.
1857 * - `name` (char*): Name of the array.
1858 * @return Python integer (type on success, 0 on error).
1859 */
1860static PyObject* sddsdata_GetNamedArrayType( PyObject* self, PyObject* args )
1861{
1862 long fileIndex;
1863 char *name;
1864 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1865 return NULL;
1866 }
1867 return PyLong_FromLong(SDDS_GetNamedArrayType(&dataset_f[fileIndex], name));
1868}
1869
1870/**
1871 * @brief Retrieves the definition of a column in a dataset.
1872 *
1873 * @param self Python object (unused).
1874 * @param args Python tuple containing:
1875 * - `fileIndex` (long): Dataset index.
1876 * - `name` (char*): Name of the column.
1877 * @return Python list containing column attributes on success, NULL on error.
1878 */
1879static PyObject* sddsdata_GetColumnDefinition( PyObject* self, PyObject* args )
1880{
1881 long fileIndex;
1882 char *name;
1883 COLUMN_DEFINITION *pardef;
1884 PyObject *v;
1885 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1886 return NULL;
1887 }
1888 if ((pardef = SDDS_GetColumnDefinition(&dataset_f[fileIndex], name)) == NULL)
1889 return NULL;
1890 if (!(v = PyList_New(6)))
1891 return NULL;
1892
1893 if (pardef->symbol)
1894 PyList_SetItem(v, 0, PyString_FromString(pardef->symbol));
1895 else
1896 PyList_SetItem(v, 0, PyString_FromString(""));
1897 if (pardef->units)
1898 PyList_SetItem(v, 1, PyString_FromString(pardef->units));
1899 else
1900 PyList_SetItem(v, 1, PyString_FromString(""));
1901 if (pardef->description)
1902 PyList_SetItem(v, 2, PyString_FromString(pardef->description));
1903 else
1904 PyList_SetItem(v, 2, PyString_FromString(""));
1905 if (pardef->format_string)
1906 PyList_SetItem(v, 3, PyString_FromString(pardef->format_string));
1907 else
1908 PyList_SetItem(v, 3, PyString_FromString(""));
1909 PyList_SetItem(v, 4, PyLong_FromLong(pardef->type));
1910 PyList_SetItem(v, 5, PyLong_FromLong(pardef->field_length));
1911
1913
1914 return v;
1915}
1916
1917/**
1918 * @brief Retrieves the definition of an array in a dataset.
1919 *
1920 * @param self Python object (unused).
1921 * @param args Python tuple containing:
1922 * - `fileIndex` (long): Dataset index.
1923 * - `name` (char*): Name of the array.
1924 * @return Python list containing array attributes on success, NULL on error.
1925 */
1926static PyObject* sddsdata_GetArrayDefinition( PyObject* self, PyObject* args )
1927{
1928 long fileIndex;
1929 char *name;
1930 ARRAY_DEFINITION *pardef;
1931 PyObject *v;
1932 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
1933 return NULL;
1934 }
1935 if ((pardef = SDDS_GetArrayDefinition(&dataset_f[fileIndex], name)) == NULL)
1936 return NULL;
1937 if (!(v = PyList_New(8)))
1938 return NULL;
1939
1940 if (pardef->symbol)
1941 PyList_SetItem(v, 0, PyString_FromString(pardef->symbol));
1942 else
1943 PyList_SetItem(v, 0, PyString_FromString(""));
1944 if (pardef->units)
1945 PyList_SetItem(v, 1, PyString_FromString(pardef->units));
1946 else
1947 PyList_SetItem(v, 1, PyString_FromString(""));
1948 if (pardef->description)
1949 PyList_SetItem(v, 2, PyString_FromString(pardef->description));
1950 else
1951 PyList_SetItem(v, 2, PyString_FromString(""));
1952 if (pardef->format_string)
1953 PyList_SetItem(v, 3, PyString_FromString(pardef->format_string));
1954 else
1955 PyList_SetItem(v, 3, PyString_FromString(""));
1956 if (pardef->group_name)
1957 PyList_SetItem(v, 4, PyString_FromString(pardef->group_name));
1958 else
1959 PyList_SetItem(v, 4, PyString_FromString(""));
1960 PyList_SetItem(v, 5, PyLong_FromLong(pardef->type));
1961 PyList_SetItem(v, 6, PyLong_FromLong(pardef->field_length));
1962 PyList_SetItem(v, 7, PyLong_FromLong(pardef->dimensions));
1963
1965
1966 return v;
1967}
1968
1969/**
1970 * @brief Retrieves the type of a parameter in a dataset.
1971 *
1972 * @param self Python object (unused).
1973 * @param args Python tuple containing:
1974 * - `fileIndex` (long): Dataset index.
1975 * - `index` (long): Parameter index.
1976 * @return Python integer (type on success, 0 on error).
1977 */
1978static PyObject* sddsdata_GetParameterType( PyObject* self, PyObject* args )
1979{
1980 long fileIndex;
1981 long index;
1982 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
1983 return NULL;
1984 }
1985 return PyLong_FromLong(SDDS_GetParameterType(&dataset_f[fileIndex], index));
1986}
1987
1988/**
1989 * @brief Retrieves the type of a parameter by name in a dataset.
1990 *
1991 * @param self Python object (unused).
1992 * @param args Python tuple containing:
1993 * - `fileIndex` (long): Dataset index.
1994 * - `name` (char*): Name of the parameter.
1995 * @return Python integer (type on success, 0 on error).
1996 */
1997static PyObject* sddsdata_GetNamedParameterType( PyObject* self, PyObject* args )
1998{
1999 long fileIndex;
2000 char *name;
2001 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
2002 return NULL;
2003 }
2004 return PyLong_FromLong(SDDS_GetNamedParameterType(&dataset_f[fileIndex], name));
2005}
2006
2007/**
2008 * @brief Retrieves the definition of a parameter in a dataset.
2009 *
2010 * @param self Python object (unused).
2011 * @param args Python tuple containing:
2012 * - `fileIndex` (long): Dataset index.
2013 * - `name` (char*): Name of the parameter.
2014 * @return Python list containing parameter attributes on success, NULL on error.
2015 */
2016static PyObject* sddsdata_GetParameterDefinition( PyObject* self, PyObject* args )
2017{
2018 long fileIndex;
2019 char *name;
2020 PARAMETER_DEFINITION *pardef;
2021 PyObject *v;
2022 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &name)) {
2023 return NULL;
2024 }
2025 if ((pardef = SDDS_GetParameterDefinition(&dataset_f[fileIndex], name)) == NULL)
2026 return NULL;
2027 if (!(v = PyList_New(6)))
2028 return NULL;
2029
2030 if (pardef->symbol)
2031 PyList_SetItem(v, 0, PyString_FromString(pardef->symbol));
2032 else
2033 PyList_SetItem(v, 0, PyString_FromString(""));
2034 if (pardef->units)
2035 PyList_SetItem(v, 1, PyString_FromString(pardef->units));
2036 else
2037 PyList_SetItem(v, 1, PyString_FromString(""));
2038 if (pardef->description)
2039 PyList_SetItem(v, 2, PyString_FromString(pardef->description));
2040 else
2041 PyList_SetItem(v, 2, PyString_FromString(""));
2042 if (pardef->format_string)
2043 PyList_SetItem(v, 3, PyString_FromString(pardef->format_string));
2044 else
2045 PyList_SetItem(v, 3, PyString_FromString(""));
2046 PyList_SetItem(v, 4, PyLong_FromLong(pardef->type));
2047 if (pardef->fixed_value)
2048 PyList_SetItem(v, 5, PyString_FromString(pardef->fixed_value));
2049 else
2050 PyList_SetItem(v, 5, PyString_FromString(""));
2051
2053
2054 return v;
2055}
2056
2057/**
2058 * @brief Retrieves the size of a given SDDS data type.
2059 *
2060 * @param self Python object (unused).
2061 * @param args Python tuple containing:
2062 * - `type` (long): SDDS data type.
2063 * @return Python integer (size on success, -1 on error).
2064 */
2065static PyObject* sddsdata_GetTypeSize( PyObject* self, PyObject* args )
2066{
2067 long type;
2068 if (!PyArg_ParseTuple(args, "l", &type)) {
2069 return NULL;
2070 }
2071 return PyLong_FromLong(SDDS_GetTypeSize(type));
2072}
2073
2074/**
2075 * @brief Retrieves the name of a given SDDS data type.
2076 *
2077 * @param self Python object (unused).
2078 * @param args Python tuple containing:
2079 * - `type` (long): SDDS data type.
2080 * @return Python string (type name on success, NULL on error).
2081 */
2082static PyObject* sddsdata_GetTypeName( PyObject* self, PyObject* args )
2083{
2084 long type;
2085 char *name;
2086 char msgbuf[256];
2087 if (!PyArg_ParseTuple(args, "l", &type)) {
2088 return NULL;
2089 }
2090 name = SDDS_GetTypeName(type);
2091 if (name)
2092 return PyString_FromString(name);
2093 sprintf(msgbuf, "sdds.GetTypeName: %ld is an invalid SDDS data type", type);
2094 PyErr_SetString(PyExc_StandardError, msgbuf);
2095 return NULL;
2096}
2097
2098/**
2099 * @brief Identifies the SDDS data type for a given type name.
2100 *
2101 * @param self Python object (unused).
2102 * @param args Python tuple containing:
2103 * - `typeName` (char*): Name of the data type (e.g., double, float).
2104 * @return Python integer (type on success, 0 on error).
2105 */
2106static PyObject* sddsdata_IdentifyType( PyObject* self, PyObject* args )
2107{
2108 char *typeName;
2109 if (!PyArg_ParseTuple(args, "s", &typeName)) {
2110 return NULL;
2111 }
2112 return PyLong_FromLong(SDDS_IdentifyType(typeName));
2113}
2114
2115/**
2116 * @brief Verifies the existence and type of a column in a dataset.
2117 *
2118 * @param self Python object (unused).
2119 * @param args Python tuple containing:
2120 * - `fileIndex` (long): Dataset index.
2121 * - `name` (char*): Column name.
2122 * - `units` (char*): Expected units.
2123 * - `type` (long): Expected type.
2124 * @return Python integer indicating the check status.
2125 */
2126static PyObject* sddsdata_CheckColumn( PyObject* self, PyObject* args )
2127{
2128 long fileIndex;
2129 char *name;
2130 char *units;
2131 long type;
2132 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
2133 return NULL;
2134 }
2135 return PyLong_FromLong(SDDS_CheckColumn(&dataset_f[fileIndex], name, units, type, stderr));
2136}
2137
2138/**
2139 * @brief Verifies the existence and type of an array in a dataset.
2140 *
2141 * @param self Python object (unused).
2142 * @param args Python tuple containing:
2143 * - `fileIndex` (long): Dataset index.
2144 * - `name` (char*): Array name.
2145 * - `units` (char*): Expected units.
2146 * - `type` (long): Expected type.
2147 * @return Python integer indicating the check status.
2148 */
2149static PyObject* sddsdata_CheckArray( PyObject* self, PyObject* args )
2150{
2151 long fileIndex;
2152 char *name;
2153 char *units;
2154 long type;
2155 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
2156 return NULL;
2157 }
2158 return PyLong_FromLong(SDDS_CheckArray(&dataset_f[fileIndex], name, units, type, stderr));
2159}
2160
2161/**
2162 * @brief Verifies the existence and type of a parameter in a dataset.
2163 *
2164 * @param self Python object (unused).
2165 * @param args Python tuple containing:
2166 * - `fileIndex` (long): Dataset index.
2167 * - `name` (char*): Parameter name.
2168 * - `units` (char*): Expected units.
2169 * - `type` (long): Expected type.
2170 * @return Python integer indicating the check status.
2171 */
2172static PyObject* sddsdata_CheckParameter( PyObject* self, PyObject* args )
2173{
2174 long fileIndex;
2175 char *name;
2176 char *units;
2177 long type;
2178 if (!PyArg_ParseTuple(args, "lssl", &fileIndex, &name, &units, &type)) {
2179 return NULL;
2180 }
2181 return PyLong_FromLong(SDDS_CheckParameter(&dataset_f[fileIndex], name, units, type, stderr));
2182}
2183
2184/**
2185 * @brief Determines if a string contains whitespace.
2186 *
2187 * @param self Python object (unused).
2188 * @param args Python tuple containing:
2189 * - `string` (char*): String to check.
2190 * @return Python integer (1 if true, 0 otherwise).
2191 */
2192static PyObject* sddsdata_HasWhitespace( PyObject* self, PyObject* args )
2193{
2194 char *string;
2195 if (!PyArg_ParseTuple(args, "s", &string)) {
2196 return NULL;
2197 }
2198 return PyLong_FromLong(SDDS_HasWhitespace(string));
2199}
2200
2201/**
2202 * @brief Checks if a string is blank.
2203 *
2204 * @param self Python object (unused).
2205 * @param args Python tuple containing:
2206 * - `s` (char*): String to check.
2207 * @return Python integer (1 if true, 0 otherwise).
2208 */
2209static PyObject* sddsdata_StringIsBlank( PyObject* self, PyObject* args )
2210{
2211 char *s;
2212 if (!PyArg_ParseTuple(args, "s", &s)) {
2213 return NULL;
2214 }
2215 return PyLong_FromLong(SDDS_StringIsBlank(s));
2216}
2217
2218/**
2219 * @brief Applies a scaling factor to a parameter in a dataset.
2220 *
2221 * @param self Python object (unused).
2222 * @param args Python tuple containing:
2223 * - `fileIndex` (long): Dataset index.
2224 * - `name` (char*): Parameter name.
2225 * - `factor` (double): Scaling factor.
2226 * @return Python integer (1 on success, 0 on error).
2227 */
2228static PyObject* sddsdata_ApplyFactorToParameter( PyObject* self, PyObject* args )
2229{
2230 long fileIndex;
2231 char *name;
2232 double factor;
2233 if (!PyArg_ParseTuple(args, "lsd", &fileIndex, &name, &factor)) {
2234 return NULL;
2235 }
2236 return PyLong_FromLong(SDDS_ApplyFactorToParameter(&dataset_f[fileIndex], name, factor));
2237}
2238
2239/**
2240 * @brief Applies a scaling factor to a column in a dataset.
2241 *
2242 * @param self Python object (unused).
2243 * @param args Python tuple containing:
2244 * - `fileIndex` (long): Dataset index.
2245 * - `name` (char*): Column name.
2246 * - `factor` (double): Scaling factor.
2247 * @return Python integer (1 on success, 0 on error).
2248 */
2249static PyObject* sddsdata_ApplyFactorToColumn( PyObject* self, PyObject* args )
2250{
2251 long fileIndex;
2252 char *name;
2253 double factor;
2254 if (!PyArg_ParseTuple(args, "lsd", &fileIndex, &name, &factor)) {
2255 return NULL;
2256 }
2257 return PyLong_FromLong(SDDS_ApplyFactorToColumn(&dataset_f[fileIndex], name, factor));
2258}
2259
2260/**
2261 * @brief Deletes fixed parameter values for a given dataset.
2262 *
2263 * @param self Python object (unused).
2264 * @param args Python tuple containing:
2265 * - fileIndex: Index of the dataset file.
2266 *
2267 * @return PyObject*:
2268 * - 0 on error.
2269 * - 1 on success.
2270 */
2271static PyObject* sddsdata_DeleteParameterFixedValues( PyObject* self, PyObject* args )
2272{
2273 long fileIndex;
2274 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2275 return NULL;
2276 }
2277 return PyLong_FromLong(SDDS_DeleteParameterFixedValues(&dataset_f[fileIndex]));
2278}
2279
2280/**
2281 * @brief Sets the data mode for a given dataset.
2282 *
2283 * @param self Python object (unused).
2284 * @param args Python tuple containing:
2285 * - fileIndex: Index of the dataset file.
2286 * - newmode: New data mode to be set.
2287 *
2288 * @return PyObject*:
2289 * - 0 on error.
2290 * - 1 on success.
2291 */
2292static PyObject* sddsdata_SetDataMode( PyObject* self, PyObject* args )
2293{
2294 long fileIndex;
2295 long newmode;
2296 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &newmode)) {
2297 return NULL;
2298 }
2299 return PyLong_FromLong(SDDS_SetDataMode(&dataset_f[fileIndex], newmode));
2300}
2301
2302/**
2303 * @brief Checks the validity of a dataset.
2304 *
2305 * @param self Python object (unused).
2306 * @param args Python tuple containing:
2307 * - fileIndex: Index of the dataset file.
2308 * - caller: Caller information string.
2309 *
2310 * @return PyObject*:
2311 * - 0 on error.
2312 * - 1 on success.
2313 */
2314static PyObject* sddsdata_CheckDataset( PyObject* self, PyObject* args )
2315{
2316 long fileIndex;
2317 char *caller;
2318 if (!PyArg_ParseTuple(args, "ls", &fileIndex, &caller)) {
2319 return NULL;
2320 }
2321 return PyLong_FromLong(SDDS_CheckDataset(&dataset_f[fileIndex], caller));
2322}
2323
2324/**
2325 * @brief Sets the auto-check mode for datasets.
2326 *
2327 * @param self Python object (unused).
2328 * @param args Python tuple containing:
2329 * - newMode: New auto-check mode (0 or 1).
2330 *
2331 * @return PyObject*: Previous mode.
2332 */
2333static PyObject* sddsdata_SetAutoCheckMode( PyObject* self, PyObject* args )
2334{
2335 long newMode;
2336 if (!PyArg_ParseTuple(args, "l", &newMode)) {
2337 return NULL;
2338 }
2339 return PyLong_FromLong(SDDS_SetAutoCheckMode(newMode));
2340}
2341
2342/**
2343 * @brief Retrieves a column name by its index from a dataset.
2344 *
2345 * @param self Python object (unused).
2346 * @param args Python tuple containing:
2347 * - fileIndex: Index of the dataset file.
2348 * - index: Index of the column.
2349 *
2350 * @return PyObject*:
2351 * - NULL on error.
2352 * - Column name string on success.
2353 */
2354static PyObject* sddsdata_GetColumnNameFromIndex( PyObject* self, PyObject* args )
2355{
2356 long fileIndex;
2357 long index;
2358 char **data;
2359 int32_t number;
2360 PyObject *v;
2361 long i;
2362 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
2363 return NULL;
2364 }
2365 data = SDDS_GetColumnNames(&dataset_f[fileIndex], &number);
2366 if (!(data))
2367 return NULL;
2368 if ((index >= 0) && (index < number)) {
2369 v = PyString_FromString(data[index]);
2370 for (i=0;i<number;i++)
2371 free(data[i]);
2372 free(data);
2373 return v;
2374 }
2375 for (i=0;i<number;i++)
2376 free(data[i]);
2377 free(data);
2378 return NULL;
2379}
2380
2381/**
2382 * @brief Retrieves all column names from a dataset.
2383 *
2384 * @param self Python object (unused).
2385 * @param args Python tuple containing:
2386 * - fileIndex: Index of the dataset file.
2387 *
2388 * @return PyObject*:
2389 * - NULL on error.
2390 * - List of column names on success.
2391 */
2392static PyObject* sddsdata_GetColumnNames( PyObject* self, PyObject* args )
2393{
2394 long fileIndex;
2395 long index;
2396 char **data;
2397 int32_t number;
2398 PyObject *v;
2399 long i;
2400 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2401 return NULL;
2402 }
2403 data = SDDS_GetColumnNames(&dataset_f[fileIndex], &number);
2404 if (!(data))
2405 return NULL;
2406 if (!(v = PyList_New(number)))
2407 return NULL;
2408 for (index = 0; index < number; index++)
2409 PyList_SetItem(v, index, PyString_FromString(data[index]));
2410 for (i=0;i<number;i++)
2411 free(data[i]);
2412 free(data);
2413 return v;
2414}
2415
2416/**
2417 * @brief Retrieves an array name by its index from a dataset.
2418 *
2419 * @param self Python object (unused).
2420 * @param args Python tuple containing:
2421 * - fileIndex: Index of the dataset file.
2422 * - index: Index of the array.
2423 *
2424 * @return PyObject*:
2425 * - NULL on error.
2426 * - Array name string on success.
2427 */
2428static PyObject* sddsdata_GetArrayNameFromIndex( PyObject* self, PyObject* args )
2429{
2430 long fileIndex;
2431 long index;
2432 char **data;
2433 int32_t number;
2434 PyObject *v;
2435 long i;
2436 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
2437 return NULL;
2438 }
2439 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
2440 if (!(data))
2441 return NULL;
2442 if ((index >= 0) && (index < number)) {
2443 v = PyString_FromString(data[index]);
2444 for (i=0;i<number;i++)
2445 free(data[i]);
2446 free(data);
2447 return v;
2448 }
2449 for (i=0;i<number;i++)
2450 free(data[i]);
2451 free(data);
2452 return NULL;
2453}
2454
2455/**
2456 * @brief Retrieves all array names from a dataset.
2457 *
2458 * @param self Python object (unused).
2459 * @param args Python tuple containing:
2460 * - fileIndex: Index of the dataset file.
2461 *
2462 * @return PyObject*:
2463 * - NULL on error.
2464 * - List of array names on success.
2465 */
2466static PyObject* sddsdata_GetArrayNames( PyObject* self, PyObject* args )
2467{
2468 long fileIndex;
2469 long index;
2470 char **data;
2471 int32_t number;
2472 PyObject *v;
2473 long i;
2474 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2475 return NULL;
2476 }
2477 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
2478 if (!(data))
2479 return NULL;
2480 if (!(v = PyList_New(number)))
2481 return NULL;
2482 for (index = 0; index < number; index++)
2483 PyList_SetItem(v, index, PyString_FromString(data[index]));
2484 for (i=0;i<number;i++)
2485 free(data[i]);
2486 free(data);
2487 return v;
2488}
2489
2490/**
2491 * @brief Retrieves a parameter name by its index from a dataset.
2492 *
2493 * @param self Python object (unused).
2494 * @param args Python tuple containing:
2495 * - fileIndex: Index of the dataset file.
2496 * - index: Index of the parameter.
2497 *
2498 * @return PyObject*:
2499 * - NULL on error.
2500 * - Parameter name string on success.
2501 */
2502static PyObject* sddsdata_GetParameterNameFromIndex( PyObject* self, PyObject* args )
2503{
2504 long fileIndex;
2505 long index;
2506 char **data;
2507 int32_t number;
2508 PyObject *v;
2509 long i;
2510 if (!PyArg_ParseTuple(args, "ll", &fileIndex, &index)) {
2511 return NULL;
2512 }
2513 data = SDDS_GetParameterNames(&dataset_f[fileIndex], &number);
2514 if (!(data))
2515 return NULL;
2516 if ((index >= 0) && (index < number)) {
2517 v = PyString_FromString(data[index]);
2518 for (i=0;i<number;i++)
2519 free(data[i]);
2520 free(data);
2521 return v;
2522 }
2523 for (i=0;i<number;i++)
2524 free(data[i]);
2525 free(data);
2526 return NULL;
2527}
2528
2529/**
2530 * @brief Retrieves all parameter names from a dataset.
2531 *
2532 * @param self Python object (unused).
2533 * @param args Python tuple containing:
2534 * - fileIndex: Index of the dataset file.
2535 *
2536 * @return PyObject*:
2537 * - NULL on error.
2538 * - List of parameter names on success.
2539 */
2540static PyObject* sddsdata_GetParameterNames( PyObject* self, PyObject* args )
2541{
2542 long fileIndex;
2543 long index;
2544 char **data;
2545 int32_t number;
2546 PyObject *v;
2547 long i;
2548 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
2549 return NULL;
2550 }
2551 data = SDDS_GetParameterNames(&dataset_f[fileIndex], &number);
2552 if (!(data))
2553 return NULL;
2554 if (!(v = PyList_New(number)))
2555 return NULL;
2556 for (index = 0; index < number; index++)
2557 PyList_SetItem(v, index, PyString_FromString(data[index]));
2558 for (i=0;i<number;i++)
2559 free(data[i]);
2560 free(data);
2561 return v;
2562}
2563
2564/**
2565 * @brief Sets a parameter value in a dataset by index or name.
2566 *
2567 * @param self Python object (unused).
2568 * @param args Python tuple containing:
2569 * - fileIndex: Index of the dataset file.
2570 * - indexOrName: Index or name of the parameter.
2571 * - v: Value to set.
2572 *
2573 * @return PyObject*:
2574 * - 0 on error.
2575 * - 1 on success.
2576 */
2577static PyObject* sddsdata_SetParameter( PyObject* self, PyObject* args )
2578{
2579 long fileIndex;
2580 PyObject *indexOrName;
2581 PyObject *v;
2582 long index;
2583 long type;
2584 if (!PyArg_ParseTuple(args, "lOO", &fileIndex, &indexOrName, &v)) {
2585 return NULL;
2586 }
2587 if (PyString_Check(indexOrName)) {
2588 index = SDDS_GetParameterIndex(&dataset_f[fileIndex], PyString_AsString(indexOrName));
2589 } else if (PyNumber_Check(indexOrName)) {
2590 if (PyInt_Check(indexOrName))
2591 index = PyInt_AsLong(indexOrName);
2592 else if (PyLong_Check(indexOrName))
2593 index = PyLong_AsLong(indexOrName);
2594 else
2595 return NULL;
2596 } else
2597 return NULL;
2598 if ((type = SDDS_GetParameterType(&dataset_f[fileIndex], index)) == 0)
2599 return NULL;
2600 switch (type) {
2601 case SDDS_SHORT:
2602 case SDDS_USHORT:
2603 case SDDS_LONG:
2604 if (PyLong_Check(v)) {
2605 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsLong(v),-1));
2606 } else {
2607 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsLong(v),-1));
2608 }
2609 case SDDS_ULONG:
2610 if (PyLong_Check(v)) {
2611 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsUnsignedLong(v),-1));
2612 } else {
2613 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsUnsignedLong(v),-1));
2614 }
2615 case SDDS_LONG64:
2616 if (PyLong_Check(v)) {
2617 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsLongLong(v),-1));
2618 } else {
2619 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsLongLong(v),-1));
2620 }
2621 case SDDS_ULONG64:
2622 if (PyLong_Check(v)) {
2623 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyLong_AsUnsignedLongLong(v),-1));
2624 } else {
2625 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyInt_AsUnsignedLongLong(v),-1));
2626 }
2627 case SDDS_FLOAT:
2628 case SDDS_DOUBLE:
2629 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyFloat_AsDouble(v),-1));
2630 case SDDS_CHARACTER:
2631 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,(char)(PyString_AsString(v)[0]),-1));
2632 case SDDS_STRING:
2633 return PyLong_FromLong(SDDS_SetParameters(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,index,PyString_AsString(v),-1));
2634 }
2635 return PyLong_FromLong(0);
2636}
2637
2638/**
2639 * @brief Sets an array value in a dataset.
2640 *
2641 * @param self Python object (unused).
2642 * @param args Python tuple containing:
2643 * - fileIndex: Index of the dataset file.
2644 * - indexOrName: Index or name of the array.
2645 * - v: Array values.
2646 * - dim: Array dimensions.
2647 *
2648 * @return PyObject*:
2649 * - 0 on error.
2650 * - 1 on success.
2651 */
2652static PyObject* sddsdata_SetArray( PyObject* self, PyObject* args )
2653{
2654 long fileIndex;
2655 long elements;
2656 PyObject *indexOrName;
2657 PyObject *v;
2658 PyObject *dim;
2659 long type;
2660 long i;
2661 void *data = NULL;
2662 long index;
2663 long result=0;
2664 PyObject *temp;
2665 ARRAY_DEFINITION *arraydef;
2666 char **names=NULL;
2667 int32_t number;
2668 int32_t dimensions;
2669 int32_t *dimension=NULL;
2670
2671 if (!PyArg_ParseTuple(args, "lOOO", &fileIndex, &indexOrName, &v, &dim)) {
2672 return NULL;
2673 }
2674 if (PyString_Check(indexOrName)) {
2675 index = SDDS_GetArrayIndex(&dataset_f[fileIndex], PyString_AsString(indexOrName));
2676 if ((arraydef = SDDS_GetArrayDefinition(&dataset_f[fileIndex], PyString_AsString(indexOrName))) == NULL)
2677 return NULL;
2678 } else if (PyNumber_Check(indexOrName)) {
2679 if (PyInt_Check(indexOrName))
2680 index = PyInt_AsLong(indexOrName);
2681 else if (PyLong_Check(indexOrName))
2682 index = PyLong_AsLong(indexOrName);
2683 else
2684 return NULL;
2685 names = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
2686 if (!(names))
2687 return NULL;
2688 if (number <= index)
2689 return NULL;
2690 if ((arraydef = SDDS_GetArrayDefinition(&dataset_f[fileIndex], names[index])) == NULL)
2691 return NULL;
2692 } else
2693 return NULL;
2694 type = arraydef->type;
2695 dimensions = arraydef->dimensions;
2696
2697 if (dimensions != PyList_Size(dim))
2698 return NULL;
2699 dimension = malloc(sizeof(int32_t)*dimensions);
2700
2701 for (i=0;i<dimensions;i++) {
2702 temp = PyList_GetItem(dim, i);
2703 if (PyInt_Check(temp))
2704 dimension[i] = PyInt_AsLong(temp);
2705 else if (PyLong_Check(temp))
2706 dimension[i] = PyLong_AsLong(temp);
2707 else
2708 return NULL;
2709 }
2710
2711 elements = (long)PyList_Size(v);
2712 switch (type) {
2713 case SDDS_SHORT:
2714 data = malloc(sizeof(short)*elements);
2715 for (i=0;i<elements;i++) {
2716 temp = PyList_GetItem(v, i);
2717 if (PyLong_Check(temp))
2718 ((short*)data)[i] = (short)PyLong_AsLong(temp);
2719 else
2720 ((short*)data)[i] = (short)PyInt_AsLong(temp);
2721 }
2722 break;
2723 case SDDS_USHORT:
2724 data = malloc(sizeof(unsigned short)*elements);
2725 for (i=0;i<elements;i++) {
2726 temp = PyList_GetItem(v, i);
2727 if (PyLong_Check(temp))
2728 ((unsigned short*)data)[i] = (unsigned short)PyLong_AsLong(temp);
2729 else
2730 ((unsigned short*)data)[i] = (unsigned short)PyInt_AsLong(temp);
2731 }
2732 break;
2733 case SDDS_LONG:
2734 data = malloc(sizeof(int32_t)*elements);
2735 for (i=0;i<elements;i++) {
2736 temp = PyList_GetItem(v, i);
2737 if (PyLong_Check(temp))
2738 ((int32_t*)data)[i] = (int32_t)PyLong_AsLong(temp);
2739 else
2740 ((int32_t*)data)[i] = (int32_t)PyInt_AsLong(temp);
2741 }
2742 break;
2743 case SDDS_ULONG:
2744 data = malloc(sizeof(uint32_t)*elements);
2745 for (i=0;i<elements;i++) {
2746 temp = PyList_GetItem(v, i);
2747 if (PyLong_Check(temp))
2748 ((uint32_t*)data)[i] = (uint32_t)PyLong_AsUnsignedLong(temp);
2749 else
2750 ((uint32_t*)data)[i] = (uint32_t)PyInt_AsUnsignedLong(temp);
2751 }
2752 break;
2753 case SDDS_LONG64:
2754 data = malloc(sizeof(int64_t)*elements);
2755 for (i=0;i<elements;i++) {
2756 temp = PyList_GetItem(v, i);
2757 if (PyLong_Check(temp))
2758 ((int64_t*)data)[i] = (int64_t)PyLong_AsLongLong(temp);
2759 else
2760 ((int64_t*)data)[i] = (int64_t)PyInt_AsLongLong(temp);
2761 }
2762 break;
2763 case SDDS_ULONG64:
2764 data = malloc(sizeof(uint64_t)*elements);
2765 for (i=0;i<elements;i++) {
2766 temp = PyList_GetItem(v, i);
2767 if (PyLong_Check(temp))
2768 ((uint64_t*)data)[i] = (uint64_t)PyLong_AsUnsignedLongLong(temp);
2769 else
2770 ((uint64_t*)data)[i] = (uint64_t)PyInt_AsUnsignedLongLong(temp);
2771 }
2772 break;
2773 case SDDS_FLOAT:
2774 data = malloc(sizeof(float)*elements);
2775 for (i=0;i<elements;i++)
2776 ((float*)data)[i] = (float)PyFloat_AsDouble(PyList_GetItem(v, i));
2777 break;
2778 case SDDS_DOUBLE:
2779 data = malloc(sizeof(double)*elements);
2780 for (i=0;i<elements;i++)
2781 ((double*)data)[i] = (double)PyFloat_AsDouble(PyList_GetItem(v, i));
2782 break;
2783 case SDDS_CHARACTER:
2784 data = malloc(sizeof(char)*elements);
2785 for (i=0;i<elements;i++)
2786 ((char*)data)[i] = (char)(PyString_AsString(PyList_GetItem(v, i))[0]);
2787 break;
2788 case SDDS_STRING:
2789 data = malloc(sizeof(char*)*elements);
2790 for (i=0;i<elements;i++)
2791 SDDS_CopyString(((char**)data)+i, PyString_AsString(PyList_GetItem(v, i)));
2792 break;
2793 }
2794 if (PyString_Check(indexOrName)) {
2795 result = SDDS_SetArray(&dataset_f[fileIndex],PyString_AsString(indexOrName),SDDS_CONTIGUOUS_DATA,data,dimension);
2796 } else {
2797 result = SDDS_SetArray(&dataset_f[fileIndex],names[index],SDDS_CONTIGUOUS_DATA,data,dimension);
2798 for (i=0;i<number;i++)
2799 free(names[i]);
2800 free(names);
2801 }
2802 switch (type) {
2803 case SDDS_SHORT:
2804 free((short*)data);
2805 break;
2806 case SDDS_USHORT:
2807 free((unsigned short*)data);
2808 break;
2809 case SDDS_LONG:
2810 free((int32_t*)data);
2811 break;
2812 case SDDS_ULONG:
2813 free((uint32_t*)data);
2814 break;
2815 case SDDS_LONG64:
2816 free((int64_t*)data);
2817 break;
2818 case SDDS_ULONG64:
2819 free((uint64_t*)data);
2820 break;
2821 case SDDS_FLOAT:
2822 free((float*)data);
2823 break;
2824 case SDDS_DOUBLE:
2825 free((double*)data);
2826 break;
2827 case SDDS_CHARACTER:
2828 free((char*)data);
2829 break;
2830 case SDDS_STRING:
2831 for (i=0;i<elements;i++)
2832 free(((char**)data)[i]);
2833 free((char**)data);
2834 break;
2835 }
2836 if (dimension) free(dimension);
2837 return PyLong_FromLong(result);
2838}
2839
2840/**
2841 * @brief Sets a column value in a dataset.
2842 *
2843 * @param self Python object (unused).
2844 * @param args Python tuple containing:
2845 * - fileIndex: Index of the dataset file.
2846 * - indexOrName: Index or name of the column.
2847 * - v: List of values to set for the column.
2848 *
2849 * @return PyObject*:
2850 * - 0 on error.
2851 * - 1 on success.
2852 */
2853static PyObject* sddsdata_SetColumn( PyObject* self, PyObject* args )
2854{
2855 long fileIndex;
2856 long rows;
2857 PyObject *indexOrName;
2858 PyObject *v;
2859 long type;
2860 long i;
2861 void *data = NULL;
2862 long index;
2863 long result=0;
2864 PyObject *temp;
2865 if (!PyArg_ParseTuple(args, "lOO", &fileIndex, &indexOrName, &v)) {
2866 return NULL;
2867 }
2868 if (PyString_Check(indexOrName)) {
2869 index = SDDS_GetColumnIndex(&dataset_f[fileIndex], PyString_AsString(indexOrName));
2870 } else if (PyNumber_Check(indexOrName)) {
2871 if (PyInt_Check(indexOrName))
2872 index = PyInt_AsLong(indexOrName);
2873 else if (PyLong_Check(indexOrName))
2874 index = PyLong_AsLong(indexOrName);
2875 else
2876 return NULL;
2877 } else
2878 return NULL;
2879 if ((type = SDDS_GetColumnType(&dataset_f[fileIndex], index)) == 0)
2880 return NULL;
2881 rows = (long)PyList_Size(v);
2882 switch (type) {
2883 case SDDS_SHORT:
2884 data = malloc(sizeof(short)*rows);
2885 for (i=0;i<rows;i++) {
2886 temp = PyList_GetItem(v, i);
2887 if (PyLong_Check(temp))
2888 ((short*)data)[i] = (short)PyLong_AsLong(temp);
2889 else
2890 ((short*)data)[i] = (short)PyInt_AsLong(temp);
2891 }
2892 break;
2893 case SDDS_USHORT:
2894 data = malloc(sizeof(unsigned short)*rows);
2895 for (i=0;i<rows;i++) {
2896 temp = PyList_GetItem(v, i);
2897 if (PyLong_Check(temp))
2898 ((unsigned short*)data)[i] = (unsigned short)PyLong_AsLong(temp);
2899 else
2900 ((unsigned short*)data)[i] = (unsigned short)PyInt_AsLong(temp);
2901 }
2902 break;
2903 case SDDS_LONG:
2904 data = malloc(sizeof(int32_t)*rows);
2905 for (i=0;i<rows;i++) {
2906 temp = PyList_GetItem(v, i);
2907 if (PyLong_Check(temp))
2908 ((int32_t*)data)[i] = (int32_t)PyLong_AsLong(temp);
2909 else
2910 ((int32_t*)data)[i] = (int32_t)PyInt_AsLong(temp);
2911 }
2912 break;
2913 case SDDS_ULONG:
2914 data = malloc(sizeof(uint32_t)*rows);
2915 for (i=0;i<rows;i++) {
2916 temp = PyList_GetItem(v, i);
2917 if (PyLong_Check(temp))
2918 ((uint32_t*)data)[i] = (uint32_t)PyLong_AsUnsignedLong(temp);
2919 else
2920 ((uint32_t*)data)[i] = (uint32_t)PyInt_AsUnsignedLong(temp);
2921 }
2922 break;
2923 case SDDS_LONG64:
2924 data = malloc(sizeof(int64_t)*rows);
2925 for (i=0;i<rows;i++) {
2926 temp = PyList_GetItem(v, i);
2927 if (PyLong_Check(temp))
2928 ((int64_t*)data)[i] = (int64_t)PyLong_AsLongLong(temp);
2929 else
2930 ((int64_t*)data)[i] = (int64_t)PyInt_AsLongLong(temp);
2931 }
2932 break;
2933 case SDDS_ULONG64:
2934 data = malloc(sizeof(uint64_t)*rows);
2935 for (i=0;i<rows;i++) {
2936 temp = PyList_GetItem(v, i);
2937 if (PyLong_Check(temp))
2938 ((uint64_t*)data)[i] = (uint64_t)PyLong_AsUnsignedLongLong(temp);
2939 else
2940 ((uint64_t*)data)[i] = (uint64_t)PyInt_AsUnsignedLongLong(temp);
2941 }
2942 break;
2943 case SDDS_FLOAT:
2944 data = malloc(sizeof(float)*rows);
2945 for (i=0;i<rows;i++)
2946 ((float*)data)[i] = (float)PyFloat_AsDouble(PyList_GetItem(v, i));
2947 break;
2948 case SDDS_DOUBLE:
2949 data = malloc(sizeof(double)*rows);
2950 for (i=0;i<rows;i++)
2951 ((double*)data)[i] = (double)PyFloat_AsDouble(PyList_GetItem(v, i));
2952 break;
2953 case SDDS_CHARACTER:
2954 data = malloc(sizeof(char)*rows);
2955 for (i=0;i<rows;i++)
2956 ((char*)data)[i] = (char)(PyString_AsString(PyList_GetItem(v, i))[0]);
2957 break;
2958 case SDDS_STRING:
2959 data = malloc(sizeof(char*)*rows);
2960 for (i=0;i<rows;i++)
2961 SDDS_CopyString(((char**)data)+i, PyString_AsString(PyList_GetItem(v, i)));
2962 break;
2963 }
2964 result = SDDS_SetColumn(&dataset_f[fileIndex],SDDS_SET_BY_INDEX,data,rows,index,NULL);
2965 switch (type) {
2966 case SDDS_SHORT:
2967 free((short*)data);
2968 break;
2969 case SDDS_USHORT:
2970 free((unsigned short*)data);
2971 break;
2972 case SDDS_LONG:
2973 free((int32_t*)data);
2974 break;
2975 case SDDS_ULONG:
2976 free((uint32_t*)data);
2977 break;
2978 case SDDS_LONG64:
2979 free((int64_t*)data);
2980 break;
2981 case SDDS_ULONG64:
2982 free((uint64_t*)data);
2983 break;
2984 case SDDS_FLOAT:
2985 free((float*)data);
2986 break;
2987 case SDDS_DOUBLE:
2988 free((double*)data);
2989 break;
2990 case SDDS_CHARACTER:
2991 free((char*)data);
2992 break;
2993 case SDDS_STRING:
2994 for (i=0;i<rows;i++)
2995 free(((char**)data)[i]);
2996 free((char**)data);
2997 break;
2998 }
2999 return PyLong_FromLong(result);
3000}
3001
3002/**
3003 * @brief Sets values for a specific row in a dataset.
3004 *
3005 * @param self Python object (unused).
3006 * @param args Python tuple containing:
3007 * - fileIndex: Index of the dataset file.
3008 * - row: Row number to set values for.
3009 * - v: List of column-value pairs (alternating column name and value).
3010 *
3011 * @return PyObject*:
3012 * - 0 on error.
3013 * - 1 on success.
3014 */
3015static PyObject* sddsdata_SetRowValues( PyObject* self, PyObject* args )
3016{
3017 long fileIndex;
3018 long row, elements;
3019 PyObject *v;
3020 long type;
3021 long i;
3022 long index;
3023 PyObject *temp;
3024 if (!PyArg_ParseTuple(args, "llO", &fileIndex, &row, &v)) {
3025 return NULL;
3026 }
3027 elements = (long)PyList_Size(v);
3028 for (i=0; i<elements; i=i+2) {
3029 index = SDDS_GetColumnIndex(&dataset_f[fileIndex], PyString_AsString(PyList_GetItem(v, i)));
3030 temp = PyList_GetItem(v, i+1);
3031 if ((type = SDDS_GetColumnType(&dataset_f[fileIndex], index)) == 0)
3032 return NULL;
3033 switch (type) {
3034 case SDDS_SHORT:
3035 case SDDS_USHORT:
3036 case SDDS_LONG:
3037 if (PyLong_Check(temp)) {
3038 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsLong(temp),-1) == 0)
3039 return NULL;
3040 } else {
3041 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsLong(temp),-1) == 0)
3042 return NULL;
3043 }
3044 break;
3045 case SDDS_ULONG:
3046 if (PyLong_Check(temp)) {
3047 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsUnsignedLong(temp),-1) == 0)
3048 return NULL;
3049 } else {
3050 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsUnsignedLong(temp),-1) == 0)
3051 return NULL;
3052 }
3053 break;
3054 case SDDS_LONG64:
3055 if (PyLong_Check(temp)) {
3056 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsLongLong(temp),-1) == 0)
3057 return NULL;
3058 } else {
3059 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsLongLong(temp),-1) == 0)
3060 return NULL;
3061 }
3062 break;
3063 case SDDS_ULONG64:
3064 if (PyLong_Check(temp)) {
3065 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyLong_AsUnsignedLongLong(temp),-1) == 0)
3066 return NULL;
3067 } else {
3068 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyInt_AsUnsignedLongLong(temp),-1) == 0)
3069 return NULL;
3070 }
3071 break;
3072 case SDDS_FLOAT:
3073 case SDDS_DOUBLE:
3074 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyFloat_AsDouble(temp),-1) == 0)
3075 return NULL;
3076 break;
3077 case SDDS_CHARACTER:
3078 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,(char)(PyString_AsString(temp)[0]),-1) == 0)
3079 return NULL;
3080 break;
3081 case SDDS_STRING:
3082 if (SDDS_SetRowValues(&dataset_f[fileIndex],SDDS_SET_BY_INDEX|SDDS_PASS_BY_VALUE,row,index,PyString_AsString(temp),-1) == 0)
3083 return NULL;
3084 break;
3085 }
3086 }
3087 return PyLong_FromLong(1);
3088}
3089
3090/**
3091 * @brief Retrieves a column's data from a dataset.
3092 *
3093 * @param self Python object (unused).
3094 * @param args Python tuple containing:
3095 * - fileIndex: Index of the dataset file.
3096 * - indexOrName: Index or name of the column to retrieve.
3097 *
3098 * @return PyObject*:
3099 * - NULL on error.
3100 * - List of values from the column on success.
3101 */
3102static PyObject* sddsdata_GetColumn( PyObject* self, PyObject* args )
3103{
3104 long fileIndex;
3105 PyObject *indexOrName;
3106 long originalType;
3107 int64_t rows, i;
3108 void *columnValue;
3109 char *name;
3110 char **data;
3111 int32_t number;
3112 char buffer[40];
3113 long index;
3114 PyObject *v;
3115 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3116 return NULL;
3117 }
3118 if (PyString_Check(indexOrName)) {
3119 index = SDDS_GetColumnIndex(&dataset_f[fileIndex], PyString_AsString(indexOrName));
3120 } else if (PyNumber_Check(indexOrName)) {
3121 if (PyInt_Check(indexOrName))
3122 index = PyInt_AsLong(indexOrName);
3123 else if (PyLong_Check(indexOrName))
3124 index = PyLong_AsLong(indexOrName);
3125 else
3126 return NULL;
3127 } else
3128 return NULL;
3129
3130 data = SDDS_GetColumnNames(&dataset_f[fileIndex], &number);
3131 if (!(data))
3132 return NULL;
3133 if ((index >= 0) && (index < number)) {
3134 name = data[index];
3135 } else {
3136 return NULL;
3137 }
3138
3139 rows = SDDS_RowCount(&(dataset_f[fileIndex]));
3140 if (rows < 0) {
3141 Py_INCREF(Py_None);
3142 return Py_None;
3143 }
3144
3145 originalType = SDDS_GetColumnType(&(dataset_f[fileIndex]), index);
3146
3147 columnValue = SDDS_GetColumn(&(dataset_f[fileIndex]), name);
3148
3149 for (i=0;i<number;i++)
3150 free(data[i]);
3151 free(data);
3152
3153 if (!(columnValue))
3154 return NULL;
3155
3156 if (!(v = PyList_New(rows)))
3157 return NULL;
3158
3159 switch (originalType) {
3160 case SDDS_SHORT:
3161 for (i=0;i < rows;i++) {
3162 PyList_SetItem(v, i, PyLong_FromLong((long)(((short*)columnValue)[i])));
3163 }
3164 free((short*)columnValue);
3165 break;
3166 case SDDS_USHORT:
3167 for (i=0;i < rows;i++) {
3168 PyList_SetItem(v, i, PyLong_FromLong((long)(((unsigned short*)columnValue)[i])));
3169 }
3170 free((unsigned short*)columnValue);
3171 break;
3172 case SDDS_LONG:
3173 for (i=0;i < rows;i++) {
3174 PyList_SetItem(v, i, PyLong_FromLong((long)(((int32_t*)columnValue)[i])));
3175 }
3176 free((int32_t*)columnValue);
3177 break;
3178 case SDDS_ULONG:
3179 for (i=0;i < rows;i++) {
3180 PyList_SetItem(v, i, PyLong_FromUnsignedLong((unsigned long)(((uint32_t*)columnValue)[i])));
3181 }
3182 free((uint32_t*)columnValue);
3183 break;
3184 case SDDS_LONG64:
3185 for (i=0;i < rows;i++) {
3186 PyList_SetItem(v, i, PyLong_FromLongLong((long long)(((int64_t*)columnValue)[i])));
3187 }
3188 free((int64_t*)columnValue);
3189 break;
3190 case SDDS_ULONG64:
3191 for (i=0;i < rows;i++) {
3192 PyList_SetItem(v, i, PyLong_FromUnsignedLongLong((unsigned long long)(((uint64_t*)columnValue)[i])));
3193 }
3194 free((uint64_t*)columnValue);
3195 break;
3196 case SDDS_FLOAT:
3197 for (i=0;i < rows;i++) {
3198 sprintf(buffer, "%.6E", ((float*)columnValue)[i]);
3199 PyList_SetItem(v, i, PyFloat_FromDouble(atof(buffer)));
3200 }
3201 free((float*)columnValue);
3202 break;
3203 case SDDS_DOUBLE:
3204 for (i=0;i < rows;i++) {
3205 PyList_SetItem(v, i, PyFloat_FromDouble(((double*)columnValue)[i]));
3206 }
3207 free((double*)columnValue);
3208 break;
3209 case SDDS_CHARACTER:
3210 for (i=0;i < rows;i++) {
3211 sprintf(buffer, "%c", ((char*)columnValue)[i]);
3212 PyList_SetItem(v, i, PyString_FromString(buffer));
3213 }
3214 free((char*)columnValue);
3215 break;
3216 case SDDS_STRING:
3217 for (i=0;i < rows;i++) {
3218 PyList_SetItem(v, i, PyString_FromString(((char**)columnValue)[i]));
3219 }
3220 for (i=0;i < rows;i++)
3221 free(((char**)columnValue)[i]);
3222 free((char**)columnValue);
3223 break;
3224 default:
3225 return NULL;
3226 }
3227 return v;
3228}
3229
3230/**
3231 * @brief Retrieves an array's data from a dataset.
3232 *
3233 * @param self Python object (unused).
3234 * @param args Python tuple containing:
3235 * - fileIndex: Index of the dataset file.
3236 * - indexOrName: Index or name of the array to retrieve.
3237 *
3238 * @return PyObject*:
3239 * - NULL on error.
3240 * - List of values from the array on success.
3241 */
3242static PyObject* sddsdata_GetArray( PyObject* self, PyObject* args )
3243{
3244 long fileIndex;
3245 PyObject *indexOrName;
3246 long originalType, i, elements;
3247 SDDS_ARRAY *arrayValue=NULL;
3248 char *name;
3249 char **data;
3250 int32_t number;
3251 char buffer[40];
3252 long index;
3253 PyObject *v;
3254 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3255 return NULL;
3256 }
3257 if (PyString_Check(indexOrName)) {
3258 index = SDDS_GetArrayIndex(&dataset_f[fileIndex], PyString_AsString(indexOrName));
3259 } else if (PyNumber_Check(indexOrName)) {
3260 if (PyInt_Check(indexOrName))
3261 index = PyInt_AsLong(indexOrName);
3262 else if (PyLong_Check(indexOrName))
3263 index = PyLong_AsLong(indexOrName);
3264 else
3265 return NULL;
3266 } else
3267 return NULL;
3268
3269 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
3270 if (!(data))
3271 return NULL;
3272 if ((index >= 0) && (index < number)) {
3273 name = data[index];
3274 } else {
3275 return NULL;
3276 }
3277
3278 arrayValue = SDDS_GetArray(&(dataset_f[fileIndex]), name, NULL);
3279
3280 for (i=0;i<number;i++)
3281 free(data[i]);
3282 free(data);
3283
3284 originalType = arrayValue->definition->type;
3285
3286 if (!(arrayValue))
3287 return NULL;
3288
3289 elements = arrayValue->elements;
3290
3291 /*
3292 if (!(v = PyList_New(arrayValue->definition->dimensions)))
3293 return NULL;
3294 for (i=0;i<arrayValue>dimensions;i++) {
3295 if (!(v[i] = PyList_New(arrayValue->dimension[i])))
3296 return NULL;
3297 }
3298 */
3299 if (!(v = PyList_New(arrayValue->elements)))
3300 return NULL;
3301
3302 switch (originalType) {
3303 case SDDS_SHORT:
3304 for (i=0;i < elements;i++) {
3305 PyList_SetItem(v, i, PyLong_FromLong((long)(((short*)arrayValue->data)[i])));
3306 }
3307 break;
3308 case SDDS_USHORT:
3309 for (i=0;i < elements;i++) {
3310 PyList_SetItem(v, i, PyLong_FromLong((long)(((unsigned short*)arrayValue->data)[i])));
3311 }
3312 break;
3313 case SDDS_LONG:
3314 for (i=0;i < elements;i++) {
3315 PyList_SetItem(v, i, PyLong_FromLong((long)(((int32_t*)arrayValue->data)[i])));
3316 }
3317 break;
3318 case SDDS_ULONG:
3319 for (i=0;i < elements;i++) {
3320 PyList_SetItem(v, i, PyLong_FromUnsignedLong((unsigned long)(((uint32_t*)arrayValue->data)[i])));
3321 }
3322 break;
3323 case SDDS_LONG64:
3324 for (i=0;i < elements;i++) {
3325 PyList_SetItem(v, i, PyLong_FromLongLong((long long)(((int64_t*)arrayValue->data)[i])));
3326 }
3327 break;
3328 case SDDS_ULONG64:
3329 for (i=0;i < elements;i++) {
3330 PyList_SetItem(v, i, PyLong_FromUnsignedLongLong((unsigned long long)(((uint64_t*)arrayValue->data)[i])));
3331 }
3332 break;
3333 case SDDS_FLOAT:
3334 for (i=0;i < elements;i++) {
3335 sprintf(buffer, "%.6E", ((float*)arrayValue->data)[i]);
3336 PyList_SetItem(v, i, PyFloat_FromDouble(atof(buffer)));
3337 }
3338 break;
3339 case SDDS_DOUBLE:
3340 for (i=0;i < elements;i++) {
3341 PyList_SetItem(v, i, PyFloat_FromDouble(((double*)arrayValue->data)[i]));
3342 }
3343 break;
3344 case SDDS_CHARACTER:
3345 for (i=0;i < elements;i++) {
3346 sprintf(buffer, "%c", ((char*)arrayValue->data)[i]);
3347 PyList_SetItem(v, i, PyString_FromString(buffer));
3348 }
3349 break;
3350 case SDDS_STRING:
3351 for (i=0;i < elements;i++) {
3352 PyList_SetItem(v, i, PyString_FromString(((char**)arrayValue->data)[i]));
3353 }
3354 break;
3355 default:
3356 return NULL;
3357 }
3358 SDDS_FreeArray(arrayValue);
3359 return v;
3360}
3361
3362/**
3363 * @brief Retrieves the dimensions of an array in a dataset.
3364 *
3365 * @param self Python object (unused).
3366 * @param args Python tuple containing:
3367 * - fileIndex: Index of the dataset file.
3368 * - indexOrName: Index or name of the array.
3369 *
3370 * @return PyObject*:
3371 * - NULL on error.
3372 * - List of dimensions of the array on success.
3373 */
3374static PyObject* sddsdata_GetArrayDimensions( PyObject* self, PyObject* args )
3375{
3376 long fileIndex;
3377 PyObject *indexOrName;
3378 long i;
3379 SDDS_ARRAY *arrayValue=NULL;
3380 char *name;
3381 char **data;
3382 int32_t number;
3383 long index;
3384 PyObject *v;
3385 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3386 return NULL;
3387 }
3388 if (PyString_Check(indexOrName)) {
3389 index = SDDS_GetArrayIndex(&dataset_f[fileIndex], PyString_AsString(indexOrName));
3390 } else if (PyNumber_Check(indexOrName)) {
3391 if (PyInt_Check(indexOrName))
3392 index = PyInt_AsLong(indexOrName);
3393 else if (PyLong_Check(indexOrName))
3394 index = PyLong_AsLong(indexOrName);
3395 else
3396 return NULL;
3397 } else
3398 return NULL;
3399
3400 data = SDDS_GetArrayNames(&dataset_f[fileIndex], &number);
3401 if (!(data))
3402 return NULL;
3403 if ((index >= 0) && (index < number)) {
3404 name = data[index];
3405 } else {
3406 return NULL;
3407 }
3408
3409 arrayValue = SDDS_GetArray(&(dataset_f[fileIndex]), name, NULL);
3410
3411 for (i=0;i<number;i++)
3412 free(data[i]);
3413 free(data);
3414
3415 if (!(arrayValue))
3416 return NULL;
3417
3418 if (!(v = PyList_New(arrayValue->definition->dimensions)))
3419 return NULL;
3420 for (i=0;i<arrayValue->definition->dimensions;i++) {
3421 PyList_SetItem(v, i, PyLong_FromLong(arrayValue->dimension[i]));
3422 }
3423 SDDS_FreeArray(arrayValue);
3424 return v;
3425}
3426
3427/**
3428 * @brief Retrieves the value of a parameter from a dataset.
3429 *
3430 * @param self Python object (unused).
3431 * @param args Python tuple containing:
3432 * - fileIndex: Index of the dataset file.
3433 * - indexOrName: Index or name of the parameter.
3434 *
3435 * @return PyObject*:
3436 * - NULL on error.
3437 * - Parameter value on success.
3438 */
3439static PyObject* sddsdata_GetParameter( PyObject* self, PyObject* args )
3440{
3441 long fileIndex;
3442 PyObject *indexOrName;
3443 long originalType;
3444 void *parameterValue;
3445 char *name;
3446 char **data;
3447 int32_t number;
3448 char buffer[40];
3449 long index;
3450 long i;
3451 PyObject *v=NULL;
3452 if (!PyArg_ParseTuple(args, "lO", &fileIndex, &indexOrName)) {
3453 return NULL;
3454 }
3455 if (PyString_Check(indexOrName)) {
3456 index = SDDS_GetParameterIndex(&dataset_f[fileIndex], PyString_AsString(indexOrName));
3457 } else if (PyNumber_Check(indexOrName)) {
3458 if (PyInt_Check(indexOrName))
3459 index = PyInt_AsLong(indexOrName);
3460 else if (PyLong_Check(indexOrName))
3461 index = PyLong_AsLong(indexOrName);
3462 else
3463 return NULL;
3464 } else
3465 return NULL;
3466
3467 data = SDDS_GetParameterNames(&dataset_f[fileIndex], &number);
3468 if (!(data))
3469 return NULL;
3470 if ((index >= 0) && (index < number)) {
3471 name = data[index];
3472 } else {
3473 return NULL;
3474 }
3475 if (!name) {
3476 return NULL;
3477 }
3478
3479 parameterValue = SDDS_GetParameter(&(dataset_f[fileIndex]), name, NULL);
3480
3481 for (i=0;i<number;i++)
3482 free(data[i]);
3483 free(data);
3484
3485 if (!(parameterValue)) {
3486 return NULL;
3487 }
3488 originalType = SDDS_GetParameterType(&dataset_f[fileIndex], index);
3489
3490 switch (originalType) {
3491 case SDDS_SHORT:
3492 v = PyLong_FromLong((long)(((short*)parameterValue)[0]));
3493 free((short*)parameterValue);
3494 break;
3495 case SDDS_USHORT:
3496 v = PyLong_FromLong((long)(((unsigned short*)parameterValue)[0]));
3497 free((unsigned short*)parameterValue);
3498 break;
3499 case SDDS_LONG:
3500 v = PyLong_FromLong((long)(((int32_t*)parameterValue)[0]));
3501 free((int32_t*)parameterValue);
3502 break;
3503 case SDDS_ULONG:
3504 v = PyLong_FromUnsignedLong((unsigned long)(((uint32_t*)parameterValue)[0]));
3505 free((uint32_t*)parameterValue);
3506 break;
3507 case SDDS_LONG64:
3508 v = PyLong_FromLongLong((long long)(((int64_t*)parameterValue)[0]));
3509 free((int64_t*)parameterValue);
3510 break;
3511 case SDDS_ULONG64:
3512 v = PyLong_FromUnsignedLongLong((unsigned long long)(((uint64_t*)parameterValue)[0]));
3513 free((uint64_t*)parameterValue);
3514 break;
3515 case SDDS_FLOAT:
3516 sprintf(buffer, "%.6E", ((float*)parameterValue)[0]);
3517 v = PyFloat_FromDouble(atof(buffer));
3518 free((float*)parameterValue);
3519 break;
3520 case SDDS_DOUBLE:
3521 v = PyFloat_FromDouble(((double*)parameterValue)[0]);
3522 free((double*)parameterValue);
3523 break;
3524 case SDDS_CHARACTER:
3525 sprintf(buffer, "%c", ((char*)parameterValue)[0]);
3526 v = PyString_FromString(buffer);
3527 free((char*)parameterValue);
3528 break;
3529 case SDDS_STRING:
3530 v = PyString_FromString(((char**)parameterValue)[0]);
3531 free(((char**)parameterValue)[0]);
3532 free((char**)parameterValue);
3533 break;
3534 }
3535 return v;
3536}
3537
3538/**
3539 * @brief Retrieves the data mode of a dataset.
3540 *
3541 * @param self Python object (unused).
3542 * @param args Python tuple containing:
3543 * - fileIndex: Index of the dataset file.
3544 *
3545 * @return PyObject*:
3546 * - Data mode of the dataset.
3547 */
3548static PyObject* sddsdata_GetMode( PyObject* self, PyObject* args )
3549{
3550 long fileIndex;
3551 if (!PyArg_ParseTuple(args, "l", &fileIndex)) {
3552 return NULL;
3553 }
3554 return PyLong_FromLong(dataset_f[fileIndex].layout.data_mode.mode);
3555}
3556
3558 PyObject *error;
3559};
3560
3561#if PY_MAJOR_VERSION >= 3
3562#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
3563#else
3564#define GETSTATE(m) (&_state)
3565static struct module_state _state;
3566#endif
3567
3568static PyMethodDef sddsdata_methods[] = {
3569 { "InitializeInput", sddsdata_InitializeInput, METH_VARARGS },
3570 { "InitializeAppend", sddsdata_InitializeAppend, METH_VARARGS },
3571 { "InitializeAppendToPage", sddsdata_InitializeAppendToPage, METH_VARARGS },
3572 { "InitializeOutput", sddsdata_InitializeOutput, METH_VARARGS },
3573 { "SetColumnMajorOrder", sddsdata_SetColumnMajorOrder, METH_VARARGS },
3574 { "SetRowMajorOrder", sddsdata_SetRowMajorOrder, METH_VARARGS },
3575 { "SetFixedRowCountMode", sddsdata_SetFixedRowCountMode, METH_VARARGS },
3576 { "EnableFSync", sddsdata_EnableFSync, METH_VARARGS },
3577 { "DisableFSync", sddsdata_DisableFSync, METH_VARARGS },
3578 { "Terminate", sddsdata_Terminate, METH_VARARGS },
3579 { "SetTerminateMode", sddsdata_SetTerminateMode, METH_VARARGS },
3580 { "DefineParameter", sddsdata_DefineParameter, METH_VARARGS },
3581 { "DefineArray", sddsdata_DefineArray, METH_VARARGS },
3582 { "DefineColumn", sddsdata_DefineColumn, METH_VARARGS },
3583 { "IsValidName", sddsdata_IsValidName, METH_VARARGS },
3584 { "SetNameValidityFlags", sddsdata_SetNameValidityFlags, METH_VARARGS },
3585 { "DefineSimpleColumn", sddsdata_DefineSimpleColumn, METH_VARARGS },
3586 { "DefineSimpleArray", sddsdata_DefineSimpleArray, METH_VARARGS },
3587 { "DefineSimpleParameter", sddsdata_DefineSimpleParameter, METH_VARARGS },
3588 { "WriteLayout", sddsdata_WriteLayout, METH_VARARGS },
3589 { "EraseData", sddsdata_EraseData, METH_VARARGS },
3590 { "ProcessColumnString", sddsdata_ProcessColumnString, METH_VARARGS },
3591 { "ProcessArrayString", sddsdata_ProcessArrayString, METH_VARARGS },
3592 { "ProcessParameterString", sddsdata_ProcessParameterString, METH_VARARGS },
3593 { "InitializeCopy", sddsdata_InitializeCopy, METH_VARARGS },
3594 { "CopyLayout", sddsdata_CopyLayout, METH_VARARGS },
3595 { "AppendLayout", sddsdata_AppendLayout, METH_VARARGS },
3596 { "CopyPage", sddsdata_CopyPage, METH_VARARGS },
3597 { "CopyParameters", sddsdata_CopyParameters, METH_VARARGS },
3598 { "CopyArrays", sddsdata_CopyArrays, METH_VARARGS },
3599 { "CopyColumns", sddsdata_CopyColumns, METH_VARARGS },
3600 { "CopyRow", sddsdata_CopyRow, METH_VARARGS },
3601 { "CopyRowDirect", sddsdata_CopyRowDirect, METH_VARARGS },
3602 { "CopyAdditionalRows", sddsdata_CopyAdditionalRows, METH_VARARGS },
3603 { "DeferSavingLayout", sddsdata_DeferSavingLayout, METH_VARARGS },
3604 { "SaveLayout", sddsdata_SaveLayout, METH_VARARGS },
3605 { "RestoreLayout", sddsdata_RestoreLayout, METH_VARARGS },
3606 { "StartPage", sddsdata_StartPage, METH_VARARGS },
3607 { "ClearPage", sddsdata_ClearPage, METH_VARARGS },
3608 { "LengthenTable", sddsdata_LengthenTable, METH_VARARGS },
3609 { "WritePage", sddsdata_WritePage, METH_VARARGS },
3610 { "UpdatePage", sddsdata_UpdatePage, METH_VARARGS },
3611 { "InitHeaderlessInput", sddsdata_InitHeaderlessInput, METH_VARARGS },
3612 { "ReadPage", sddsdata_ReadPage, METH_VARARGS },
3613 { "ReadPageSparse", sddsdata_ReadPageSparse, METH_VARARGS },
3614 { "ReadPageLastRows", sddsdata_ReadPageLastRows, METH_VARARGS },
3615 { "RowCount", sddsdata_RowCount, METH_VARARGS },
3616 { "SetColumnFlags", sddsdata_SetColumnFlags, METH_VARARGS },
3617 { "SetRowFlags", sddsdata_SetRowFlags, METH_VARARGS },
3618 { "GetRowFlag", sddsdata_GetRowFlag, METH_VARARGS },
3619 { "DeleteColumn", sddsdata_DeleteColumn, METH_VARARGS },
3620 { "DeleteParameter", sddsdata_DeleteParameter, METH_VARARGS },
3621 { "DeleteUnsetColumns", sddsdata_DeleteUnsetColumns, METH_VARARGS },
3622 { "DeleteUnsetRows", sddsdata_DeleteUnsetRows, METH_VARARGS },
3623 { "ColumnCount", sddsdata_ColumnCount, METH_VARARGS },
3624 { "ArrayCount", sddsdata_ArrayCount, METH_VARARGS },
3625 { "ParameterCount", sddsdata_ParameterCount, METH_VARARGS },
3626 { "GetDescription", sddsdata_GetDescription, METH_VARARGS },
3627 { "GetDescriptionText", sddsdata_GetDescriptionText, METH_VARARGS },
3628 { "GetDescriptionContents", sddsdata_GetDescriptionContents, METH_VARARGS },
3629 { "NumberOfErrors", sddsdata_NumberOfErrors, METH_VARARGS },
3630 { "ClearErrors", sddsdata_ClearErrors, METH_VARARGS },
3631 { "SetError", sddsdata_SetError, METH_VARARGS },
3632 { "Bomb", sddsdata_Bomb, METH_VARARGS },
3633 { "Warning", sddsdata_Warning, METH_VARARGS },
3634 { "RegisterProgramName", sddsdata_RegisterProgramName, METH_VARARGS },
3635 { "PrintErrors", sddsdata_PrintErrors, METH_VARARGS },
3636 { "TransferColumnDefinition", sddsdata_TransferColumnDefinition, METH_VARARGS },
3637 { "TransferArrayDefinition", sddsdata_TransferArrayDefinition, METH_VARARGS },
3638 { "TransferParameterDefinition", sddsdata_TransferParameterDefinition, METH_VARARGS },
3639 { "DefineColumnLikeParameter", sddsdata_DefineColumnLikeParameter, METH_VARARGS },
3640 { "DefineParameterLikeColumn", sddsdata_DefineParameterLikeColumn, METH_VARARGS },
3641 { "TransferAllColumnDefinitions", sddsdata_TransferAllColumnDefinitions, METH_VARARGS },
3642 { "TransferAllArrayDefinitions", sddsdata_TransferAllArrayDefinitions, METH_VARARGS },
3643 { "TransferAllParameterDefinitions", sddsdata_TransferAllParameterDefinitions, METH_VARARGS },
3644 { "GetColumnIndex", sddsdata_GetColumnIndex, METH_VARARGS },
3645 { "GetArrayIndex", sddsdata_GetArrayIndex, METH_VARARGS },
3646 { "GetParameterIndex", sddsdata_GetParameterIndex, METH_VARARGS },
3647 { "GetColumnType", sddsdata_GetColumnType, METH_VARARGS },
3648 { "GetArrayType", sddsdata_GetArrayType, METH_VARARGS },
3649 { "GetNamedColumnType", sddsdata_GetNamedColumnType, METH_VARARGS },
3650 { "GetNamedArrayType", sddsdata_GetNamedArrayType, METH_VARARGS },
3651 { "GetColumnDefinition", sddsdata_GetColumnDefinition, METH_VARARGS },
3652 { "GetArrayDefinition", sddsdata_GetArrayDefinition, METH_VARARGS },
3653 { "GetParameterType", sddsdata_GetParameterType, METH_VARARGS },
3654 { "GetNamedParameterType", sddsdata_GetNamedParameterType, METH_VARARGS },
3655 { "GetParameterDefinition", sddsdata_GetParameterDefinition, METH_VARARGS },
3656 { "GetTypeSize", sddsdata_GetTypeSize, METH_VARARGS },
3657 { "GetTypeName", sddsdata_GetTypeName, METH_VARARGS },
3658 { "IdentifyType", sddsdata_IdentifyType, METH_VARARGS },
3659 { "CheckColumn", sddsdata_CheckColumn, METH_VARARGS },
3660 { "CheckArray", sddsdata_CheckArray, METH_VARARGS },
3661 { "CheckParameter", sddsdata_CheckParameter, METH_VARARGS },
3662 { "HasWhitespace", sddsdata_HasWhitespace, METH_VARARGS },
3663 { "StringIsBlank", sddsdata_StringIsBlank, METH_VARARGS },
3664 { "ApplyFactorToParameter", sddsdata_ApplyFactorToParameter, METH_VARARGS },
3665 { "ApplyFactorToColumn", sddsdata_ApplyFactorToColumn, METH_VARARGS },
3666 { "DeleteParameterFixedValues", sddsdata_DeleteParameterFixedValues, METH_VARARGS },
3667 { "SetDataMode", sddsdata_SetDataMode, METH_VARARGS },
3668 { "CheckDataset", sddsdata_CheckDataset, METH_VARARGS },
3669 { "SetAutoCheckMode", sddsdata_SetAutoCheckMode, METH_VARARGS },
3670 { "GetColumnNameFromIndex", sddsdata_GetColumnNameFromIndex, METH_VARARGS },
3671 { "GetColumnNames", sddsdata_GetColumnNames, METH_VARARGS },
3672 { "GetArrayNameFromIndex", sddsdata_GetArrayNameFromIndex, METH_VARARGS },
3673 { "GetArrayNames", sddsdata_GetArrayNames, METH_VARARGS },
3674 { "GetParameterNameFromIndex", sddsdata_GetParameterNameFromIndex, METH_VARARGS },
3675 { "GetParameterNames", sddsdata_GetParameterNames, METH_VARARGS },
3676 { "SetParameter", sddsdata_SetParameter, METH_VARARGS },
3677 { "SetColumn", sddsdata_SetColumn, METH_VARARGS },
3678 { "SetArray", sddsdata_SetArray, METH_VARARGS },
3679 { "SetRowValues", sddsdata_SetRowValues, METH_VARARGS },
3680 { "GetColumn", sddsdata_GetColumn, METH_VARARGS },
3681 { "GetArray", sddsdata_GetArray, METH_VARARGS },
3682 { "GetArrayDimensions", sddsdata_GetArrayDimensions, METH_VARARGS },
3683 { "GetParameter", sddsdata_GetParameter, METH_VARARGS },
3684 { "GetMode", sddsdata_GetMode, METH_VARARGS },
3685 { NULL, NULL }
3686};
3687
3688#if PY_MAJOR_VERSION >= 3
3689 #if defined(_WIN32)
3690 __declspec(dllexport) PyObject* PyInit_sddsdata(void);
3691 #endif
3692#else
3693 #if defined(_WIN32)
3694 __declspec(dllexport) void initsddsdata(void);
3695 #endif
3696#endif
3697
3698#if PY_MAJOR_VERSION >= 3
3699static int sddsdata_traverse(PyObject *m, visitproc visit, void *arg) {
3700 Py_VISIT(GETSTATE(m)->error);
3701 return 0;
3702}
3703static int sddsdata_clear(PyObject *m) {
3704 Py_CLEAR(GETSTATE(m)->error);
3705 return 0;
3706}
3707static struct PyModuleDef moduledef = {
3708 PyModuleDef_HEAD_INIT,
3709 "sddsdata",
3710 NULL,
3711 sizeof(struct module_state),
3712 sddsdata_methods,
3713 NULL,
3714 sddsdata_traverse,
3715 sddsdata_clear,
3716 NULL
3717};
3718#define INITERROR return NULL
3719#else
3720#define INITERROR return
3721#endif
3722
3723#if PY_MAJOR_VERSION >= 3
3724//PyObject * PyInit_sddsdata(void)
3725PyMODINIT_FUNC PyInit_sddsdata(void)
3726#else
3727void initsddsdata(void)
3728#endif
3729{
3730 struct module_state *st;
3731#if PY_MAJOR_VERSION >= 3
3732 PyObject *module = PyModule_Create(&moduledef);
3733#else
3734 PyObject *module = Py_InitModule( "sddsdata", sddsdata_methods );
3735#endif
3736 if (module == NULL)
3737 INITERROR;
3738
3739 st = GETSTATE(module);
3740
3741 st->error = PyErr_NewException("sddsedir.Error", NULL, NULL);
3742 if (st->error == NULL) {
3743 Py_DECREF(module);
3744 INITERROR;
3745 }
3746
3747#if PY_MAJOR_VERSION >= 3
3748 return module;
3749#endif
3750
3751}
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
void SDDS_DeferSavingLayout(SDDS_DATASET *SDDS_dataset, int32_t mode)
Definition SDDS_copy.c:603
int32_t SDDS_CopyLayout(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:222
int32_t SDDS_CopyColumns(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:387
int32_t SDDS_CopyParameters(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:286
int32_t SDDS_SaveLayout(SDDS_DATASET *SDDS_dataset)
Definition SDDS_copy.c:615
int32_t SDDS_AppendLayout(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, uint32_t mode)
Definition SDDS_copy.c:158
int32_t SDDS_InitializeCopy(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source, char *filename, char *filemode)
Definition SDDS_copy.c:40
int32_t SDDS_CopyAdditionalRows(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:519
int32_t SDDS_CopyRowDirect(SDDS_DATASET *SDDS_target, int64_t target_row, SDDS_DATASET *SDDS_source, int64_t source_row)
Definition SDDS_copy.c:834
int32_t SDDS_CopyPage(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:578
int32_t SDDS_CopyArrays(SDDS_DATASET *SDDS_target, SDDS_DATASET *SDDS_source)
Definition SDDS_copy.c:334
int32_t SDDS_CopyRow(SDDS_DATASET *SDDS_target, int64_t target_row, SDDS_DATASET *SDDS_source, int64_t source_srow)
Definition SDDS_copy.c:778
int32_t SDDS_RestoreLayout(SDDS_DATASET *SDDS_dataset)
Definition SDDS_copy.c:697
int32_t SDDS_LengthenTable(SDDS_DATASET *SDDS_dataset, int64_t n_additional_rows)
int32_t SDDS_SetRowValues(SDDS_DATASET *SDDS_dataset, int32_t mode, int64_t row,...)
int32_t SDDS_StartPage(SDDS_DATASET *SDDS_dataset, int64_t expected_n_rows)
int32_t SDDS_SetParameters(SDDS_DATASET *SDDS_dataset, int32_t mode,...)
int32_t SDDS_ClearPage(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_SetColumn(SDDS_DATASET *SDDS_dataset, int32_t mode, void *data, int64_t rows,...)
Sets the values for one data column in the current data table of an SDDS dataset.
int32_t SDDS_SetArray(SDDS_DATASET *SDDS_dataset, char *array_name, int32_t mode, void *data_pointer, int32_t *dimension)
Sets the values of an array variable in the SDDS dataset using specified dimensions.
void * SDDS_GetColumn(SDDS_DATASET *SDDS_dataset, char *column_name)
Retrieves a copy of the data for a specified column, including only rows marked as "of interest".
int32_t SDDS_GetRowFlag(SDDS_DATASET *SDDS_dataset, int64_t row)
Retrieves the acceptance flag of a specific row in the current data table.
int32_t SDDS_SetRowFlags(SDDS_DATASET *SDDS_dataset, int32_t row_flag_value)
Sets the acceptance flags for all rows in the current data table of a data set.
int32_t SDDS_DeleteUnsetColumns(SDDS_DATASET *SDDS_dataset)
Deletes all columns from an SDDS dataset that are not marked as "of interest".
SDDS_ARRAY * SDDS_GetArray(SDDS_DATASET *SDDS_dataset, char *array_name, SDDS_ARRAY *memory)
Retrieves an array from the current data table of an SDDS dataset.
void * SDDS_GetParameter(SDDS_DATASET *SDDS_dataset, char *parameter_name, void *memory)
Retrieves the value of a specified parameter from the current data table of a data set.
int32_t SDDS_DeleteColumn(SDDS_DATASET *SDDS_dataset, char *column_name)
Deletes a specified column from an SDDS dataset.
int32_t SDDS_DeleteUnsetRows(SDDS_DATASET *SDDS_dataset)
Deletes rows from an SDDS dataset that are not marked as "of interest".
int32_t SDDS_DeleteParameter(SDDS_DATASET *SDDS_dataset, char *parameter_name)
Deletes a specified parameter from an SDDS dataset.
int32_t SDDS_SetColumnFlags(SDDS_DATASET *SDDS_dataset, int32_t column_flag_value)
Sets the acceptance flags for all columns in the current data table of a data set.
int32_t SDDS_GetDescription(SDDS_DATASET *SDDS_dataset, char **text, char **contents)
Retrieves the text and contents descriptions from an SDDS dataset.
int32_t SDDS_ReadPageLastRows(SDDS_DATASET *SDDS_dataset, int64_t last_rows)
void SDDS_SetTerminateMode(uint32_t mode)
int32_t SDDS_ReadPageSparse(SDDS_DATASET *SDDS_dataset, uint32_t mode, int64_t sparse_interval, int64_t sparse_offset, int32_t sparse_statistics)
int32_t SDDS_InitializeInput(SDDS_DATASET *SDDS_dataset, char *filename)
Definition SDDS_input.c:49
int32_t SDDS_InitializeHeaderlessInput(SDDS_DATASET *SDDS_dataset, char *filename)
Initializes the SDDS dataset for headerless input.
Definition SDDS_input.c:175
int32_t SDDS_Terminate(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_ReadPage(SDDS_DATASET *SDDS_dataset)
int32_t SDDS_DefineParameter1(SDDS_DATASET *SDDS_dataset, const char *name, const char *symbol, const char *units, const char *description, const char *format_string, int32_t type, void *fixed_value)
Defines a data parameter with a fixed numerical value.
int32_t SDDS_InitializeAppend(SDDS_DATASET *SDDS_dataset, const char *filename)
Initializes the SDDS dataset for appending data by adding a new page to an existing file.
int32_t SDDS_InitializeOutput(SDDS_DATASET *SDDS_dataset, int32_t data_mode, int32_t lines_per_row, const char *description, const char *contents, const char *filename)
Initializes the SDDS output dataset.
int32_t SDDS_InitializeAppendToPage(SDDS_DATASET *SDDS_dataset, const char *filename, int64_t updateInterval, int64_t *rowsPresentReturn)
Initializes the SDDS dataset for appending data to the last page of an existing file.
int32_t SDDS_DefineSimpleColumn(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data column within the SDDS dataset.
int32_t SDDS_EraseData(SDDS_DATASET *SDDS_dataset)
Erases all data entries in the SDDS dataset.
int32_t SDDS_DefineSimpleParameter(SDDS_DATASET *SDDS_dataset, const char *name, const char *unit, int32_t type)
Defines a simple data parameter within the SDDS dataset.
int32_t SDDS_SetRowCountMode(SDDS_DATASET *SDDS_dataset, uint32_t mode)
Sets the row count mode 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_UpdatePage(SDDS_DATASET *SDDS_dataset, uint32_t mode)
Updates the current page of the SDDS dataset.
int32_t SDDS_SetNameValidityFlags(uint32_t flags)
Sets the validity flags for parameter and column names in the SDDS dataset.
int32_t SDDS_WritePage(SDDS_DATASET *SDDS_dataset)
Writes the current data table to the output file.
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_WriteLayout(SDDS_DATASET *SDDS_dataset)
Writes the SDDS layout header to the output file.
int32_t SDDS_IsValidName(const char *name, const char *class)
Checks if a given name is valid for a specified class 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.
int32_t SDDS_ProcessParameterString(SDDS_DATASET *SDDS_dataset, char *string, int32_t mode)
Process a parameter definition string.
int32_t SDDS_ProcessColumnString(SDDS_DATASET *SDDS_dataset, char *string, int32_t mode)
Process a column definition string.
int32_t SDDS_ProcessArrayString(SDDS_DATASET *SDDS_dataset, char *string)
Process an array definition string.
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_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_FreeArray(SDDS_ARRAY *array)
Frees memory allocated for an SDDS array structure.
int32_t SDDS_CheckArray(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if an array exists in the SDDS dataset with the specified name, units, and type.
int32_t SDDS_GetNamedArrayType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of an array in the SDDS dataset by its name.
uint32_t SDDS_SetAutoCheckMode(uint32_t newMode)
Sets the automatic check mode for SDDS dataset validation.
Definition SDDS_utils.c:533
int32_t SDDS_GetNamedColumnType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of a column in the SDDS dataset by its name.
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
Definition SDDS_utils.c:379
int32_t SDDS_GetParameterType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a parameter in the SDDS dataset by its index.
int32_t SDDS_GetNamedParameterType(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the data type of a parameter in the SDDS dataset by its name.
int32_t SDDS_SetDataMode(SDDS_DATASET *SDDS_dataset, int32_t newmode)
Sets the data mode (ASCII or Binary) for 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_ParameterCount(SDDS_DATASET *page)
Retrieves the number of parameters in the SDDS dataset.
int32_t SDDS_FreeParameterDefinition(PARAMETER_DEFINITION *source)
Frees memory allocated for a parameter definition.
char ** SDDS_GetParameterNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all parameters 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_SprintTypedValue(void *data, int64_t index, int32_t type, const char *format, char *buffer, uint32_t mode)
Formats a data value of a specified type into a string buffer using an optional printf format string.
Definition SDDS_utils.c:151
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
int32_t SDDS_ColumnCount(SDDS_DATASET *page)
Retrieves the number of columns in the SDDS dataset.
char * SDDS_GetTypeName(int32_t type)
Retrieves the name of a specified SDDS data type as a string.
int32_t SDDS_CheckColumn(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a column exists in the SDDS dataset with the specified name, units, and type.
char ** SDDS_GetColumnNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all columns in the SDDS dataset.
int32_t SDDS_GetArrayType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of an array in the SDDS dataset by its index.
int32_t SDDS_CheckDataset(SDDS_DATASET *SDDS_dataset, const char *caller)
Validates the SDDS dataset pointer.
Definition SDDS_utils.c:552
void SDDS_PrintErrors(FILE *fp, int32_t mode)
Prints recorded error messages to a specified file stream.
Definition SDDS_utils.c:432
int32_t SDDS_DeleteParameterFixedValues(SDDS_DATASET *SDDS_dataset)
Deletes fixed values from all parameters in the SDDS dataset.
void SDDS_ClearErrors()
Clears all recorded error messages from the SDDS error stack.
Definition SDDS_utils.c:318
int32_t SDDS_ApplyFactorToColumn(SDDS_DATASET *SDDS_dataset, char *name, double factor)
Applies a scaling factor to all elements of a specific column in the SDDS dataset.
void SDDS_RegisterProgramName(const char *name)
Registers the executable program name for use in error messages.
Definition SDDS_utils.c:288
int32_t SDDS_NumberOfErrors()
Retrieves the number of errors recorded by SDDS library routines.
Definition SDDS_utils.c:304
int32_t SDDS_IdentifyType(char *typeName)
Identifies the SDDS data type based on its string name.
int32_t SDDS_ArrayCount(SDDS_DATASET *page)
Retrieves the number of arrays in the SDDS dataset.
int32_t SDDS_GetTypeSize(int32_t type)
Retrieves the size in bytes of a specified SDDS data type.
int32_t SDDS_StringIsBlank(char *s)
Checks if a string is blank (contains only whitespace characters).
int32_t SDDS_ApplyFactorToParameter(SDDS_DATASET *SDDS_dataset, char *name, double factor)
Applies a scaling factor to a specific parameter in the SDDS dataset.
int32_t SDDS_GetColumnType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a column in the SDDS dataset by its index.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
Definition SDDS_utils.c:342
int32_t SDDS_CheckParameter(SDDS_DATASET *SDDS_dataset, char *name, char *units, int32_t type, FILE *fp_message)
Checks if a parameter exists in the SDDS dataset with the specified name, units, and type.
char ** SDDS_GetArrayNames(SDDS_DATASET *SDDS_dataset, int32_t *number)
Retrieves the names of all arrays in the SDDS dataset.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
Definition SDDS_utils.c:856
int32_t SDDS_HasWhitespace(char *string)
Checks if a string contains any whitespace characters.
void SDDS_Warning(char *message)
Prints a warning message to stderr.
Definition SDDS_utils.c:362
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
#define SDDS_ULONG
Identifier for the unsigned 32-bit integer data type.
Definition SDDStypes.h:67
#define SDDS_FLOAT
Identifier for the float data type.
Definition SDDStypes.h:43
#define SDDS_STRING
Identifier for the string data type.
Definition SDDStypes.h:85
#define SDDS_ULONG64
Identifier for the unsigned 64-bit integer data type.
Definition SDDStypes.h:55
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
Definition SDDStypes.h:61
#define SDDS_SHORT
Identifier for the signed short integer data type.
Definition SDDStypes.h:73
#define SDDS_CHARACTER
Identifier for the character data type.
Definition SDDStypes.h:91
#define SDDS_USHORT
Identifier for the unsigned short integer data type.
Definition SDDStypes.h:79
#define SDDS_DOUBLE
Identifier for the double data type.
Definition SDDStypes.h:37
#define SDDS_LONG64
Identifier for the signed 64-bit integer data type.
Definition SDDStypes.h:49
static PyObject * sddsdata_GetMode(PyObject *self, PyObject *args)
Retrieves the data mode of a dataset.
static PyObject * sddsdata_GetArrayNames(PyObject *self, PyObject *args)
Retrieves all array names from a dataset.
static PyObject * sddsdata_ApplyFactorToColumn(PyObject *self, PyObject *args)
Applies a scaling factor to a column in a dataset.
static PyObject * sddsdata_GetNamedColumnType(PyObject *self, PyObject *args)
Retrieves the type of a column by name in a dataset.
static PyObject * sddsdata_CopyRow(PyObject *self, PyObject *args)
Copies a row from one SDDS dataset to another.
static PyObject * sddsdata_SetArray(PyObject *self, PyObject *args)
Sets an array value in a dataset.
static PyObject * sddsdata_GetDescriptionText(PyObject *self, PyObject *args)
Retrieves the description text for a dataset.
static PyObject * sddsdata_ProcessColumnString(PyObject *self, PyObject *args)
Processes a column definition string.
static PyObject * sddsdata_EraseData(PyObject *self, PyObject *args)
Erases data from an SDDS dataset.
static PyObject * sddsdata_GetParameter(PyObject *self, PyObject *args)
Retrieves the value of a parameter from a dataset.
SDDS_DATASET dataset_f[20]
Array of SDDS dataset structures.
static PyObject * sddsdata_DeleteUnsetRows(PyObject *self, PyObject *args)
Deletes all unset rows in the dataset.
static PyObject * sddsdata_EnableFSync(PyObject *self, PyObject *args)
Enables filesystem synchronization (fsync) for an SDDS dataset.
static PyObject * sddsdata_GetColumnIndex(PyObject *self, PyObject *args)
Retrieves the index of a column in a dataset.
static PyObject * sddsdata_CopyArrays(PyObject *self, PyObject *args)
Copies arrays from one SDDS dataset to another.
static PyObject * sddsdata_InitializeCopy(PyObject *self, PyObject *args)
Initializes a copy from one SDDS dataset to another.
static PyObject * sddsdata_ProcessParameterString(PyObject *self, PyObject *args)
Processes a parameter definition string.
static PyObject * sddsdata_SetRowMajorOrder(PyObject *self, PyObject *args)
Sets the data order for the SDDS dataset to row-major.
static PyObject * sddsdata_ProcessArrayString(PyObject *self, PyObject *args)
Processes an array definition string.
static PyObject * sddsdata_HasWhitespace(PyObject *self, PyObject *args)
Determines if a string contains whitespace.
static PyObject * sddsdata_GetColumnNames(PyObject *self, PyObject *args)
Retrieves all column names from a dataset.
static PyObject * sddsdata_GetRowFlag(PyObject *self, PyObject *args)
Gets the flag value for a specific row in the dataset.
static PyObject * sddsdata_GetColumn(PyObject *self, PyObject *args)
Retrieves a column's data from a dataset.
static PyObject * sddsdata_TransferArrayDefinition(PyObject *self, PyObject *args)
Transfers an array definition from one dataset to another.
static PyObject * sddsdata_GetParameterNames(PyObject *self, PyObject *args)
Retrieves all parameter names from a dataset.
static PyObject * sddsdata_SetNameValidityFlags(PyObject *self, PyObject *args)
Sets name validity flags to allow any name.
static PyObject * sddsdata_TransferAllParameterDefinitions(PyObject *self, PyObject *args)
Transfers all parameter definitions from one dataset to another.
static PyObject * sddsdata_GetColumnDefinition(PyObject *self, PyObject *args)
Retrieves the definition of a column in a dataset.
static PyObject * sddsdata_GetNamedArrayType(PyObject *self, PyObject *args)
Retrieves the type of an array by name in a dataset.
static PyObject * sddsdata_GetDescription(PyObject *self, PyObject *args)
Gets the description (text and contents) of the dataset.
static PyObject * sddsdata_LengthenTable(PyObject *self, PyObject *args)
Lengthens the table by adding additional rows.
static PyObject * sddsdata_SetRowFlags(PyObject *self, PyObject *args)
Sets the row flags for the dataset.
static PyObject * sddsdata_CheckColumn(PyObject *self, PyObject *args)
Verifies the existence and type of a column in a dataset.
static PyObject * sddsdata_GetParameterNameFromIndex(PyObject *self, PyObject *args)
Retrieves a parameter name by its index from a dataset.
static PyObject * sddsdata_StartPage(PyObject *self, PyObject *args)
Starts a page in an SDDS dataset.
static PyObject * sddsdata_GetNamedParameterType(PyObject *self, PyObject *args)
Retrieves the type of a parameter by name in a dataset.
static PyObject * sddsdata_DefineSimpleParameter(PyObject *self, PyObject *args)
Defines a simple parameter in an SDDS dataset.
static PyObject * sddsdata_CopyLayout(PyObject *self, PyObject *args)
Copies the layout from one SDDS dataset to another.
static PyObject * sddsdata_InitializeInput(PyObject *self, PyObject *args)
Initializes an SDDS dataset for input from a file.
static PyObject * sddsdata_NumberOfErrors(PyObject *self, PyObject *args)
Returns the number of errors recorded.
static PyObject * sddsdata_SetParameter(PyObject *self, PyObject *args)
Sets a parameter value in a dataset by index or name.
static PyObject * sddsdata_InitializeAppend(PyObject *self, PyObject *args)
Initializes an SDDS dataset for appending data to a file.
static PyObject * sddsdata_DisableFSync(PyObject *self, PyObject *args)
Disables filesystem synchronization (fsync) for an SDDS dataset.
static PyObject * sddsdata_DefineParameterLikeColumn(PyObject *self, PyObject *args)
Defines a parameter in one dataset based on a column in another dataset.
static PyObject * sddsdata_ApplyFactorToParameter(PyObject *self, PyObject *args)
Applies a scaling factor to a parameter in a dataset.
static PyObject * sddsdata_SaveLayout(PyObject *self, PyObject *args)
Saves the layout of an SDDS dataset.
static PyObject * sddsdata_SetFixedRowCountMode(PyObject *self, PyObject *args)
Sets the row count mode for an SDDS dataset to fixed row count mode.
static PyObject * sddsdata_DeferSavingLayout(PyObject *self, PyObject *args)
Defers saving the layout of an SDDS dataset.
static PyObject * sddsdata_RestoreLayout(PyObject *self, PyObject *args)
Restores the layout of an SDDS dataset.
static PyObject * sddsdata_InitHeaderlessInput(PyObject *self, PyObject *args)
Initializes a headerless input for a dataset file.
static PyObject * sddsdata_ReadPageLastRows(PyObject *self, PyObject *args)
Reads the last rows of the current page from the dataset file.
static PyObject * sddsdata_Warning(PyObject *self, PyObject *args)
Displays a warning message on stderr.
static PyObject * sddsdata_TransferColumnDefinition(PyObject *self, PyObject *args)
Transfers a column definition from one dataset to another.
static PyObject * sddsdata_DeleteUnsetColumns(PyObject *self, PyObject *args)
Deletes all unset columns in the dataset.
static PyObject * sddsdata_CheckArray(PyObject *self, PyObject *args)
Verifies the existence and type of an array in a dataset.
static PyObject * sddsdata_SetColumnFlags(PyObject *self, PyObject *args)
Sets the column flags for the dataset.
static PyObject * sddsdata_GetArrayNameFromIndex(PyObject *self, PyObject *args)
Retrieves an array name by its index from a dataset.
static PyObject * sddsdata_SetTerminateMode(PyObject *self, PyObject *args)
Sets the termination mode for SDDS to avoid freeing strings in arrays and tables.
static PyObject * sddsdata_RowCount(PyObject *self, PyObject *args)
Gets the number of rows in the dataset.
static PyObject * sddsdata_ParameterCount(PyObject *self, PyObject *args)
Gets the count of parameters in the dataset.
static PyObject * sddsdata_GetParameterIndex(PyObject *self, PyObject *args)
Retrieves the index of a parameter in a dataset.
static PyObject * sddsdata_ReadPage(PyObject *self, PyObject *args)
Reads the current page from the dataset file.
static PyObject * sddsdata_DefineSimpleArray(PyObject *self, PyObject *args)
Defines a simple array in an SDDS dataset.
static PyObject * sddsdata_SetColumnMajorOrder(PyObject *self, PyObject *args)
Sets the data order for the SDDS dataset to column-major.
static PyObject * sddsdata_WritePage(PyObject *self, PyObject *args)
Writes the current page of the dataset to the file.
static PyObject * sddsdata_GetArray(PyObject *self, PyObject *args)
Retrieves an array's data from a dataset.
static PyObject * sddsdata_DeleteParameter(PyObject *self, PyObject *args)
Deletes a parameter from the dataset.
static PyObject * sddsdata_RegisterProgramName(PyObject *self, PyObject *args)
Registers a program name for use in error messages.
static PyObject * sddsdata_ClearPage(PyObject *self, PyObject *args)
Clears the current page in an SDDS dataset.
static PyObject * sddsdata_DeleteColumn(PyObject *self, PyObject *args)
Deletes a column from the dataset.
static PyObject * sddsdata_GetArrayType(PyObject *self, PyObject *args)
Retrieves the type of an array in a dataset.
static PyObject * sddsdata_SetColumn(PyObject *self, PyObject *args)
Sets a column value in a dataset.
static PyObject * sddsdata_AppendLayout(PyObject *self, PyObject *args)
Appends the layout of one SDDS dataset to another.
static PyObject * sddsdata_CopyPage(PyObject *self, PyObject *args)
Copies a page from one SDDS dataset to another.
static PyObject * sddsdata_ReadPageSparse(PyObject *self, PyObject *args)
Reads a sparse page from the dataset file.
static PyObject * sddsdata_CheckParameter(PyObject *self, PyObject *args)
Verifies the existence and type of a parameter in a dataset.
static PyObject * sddsdata_StringIsBlank(PyObject *self, PyObject *args)
Checks if a string is blank.
static PyObject * sddsdata_IdentifyType(PyObject *self, PyObject *args)
Identifies the SDDS data type for a given type name.
static PyObject * sddsdata_CopyRowDirect(PyObject *self, PyObject *args)
Directly copies a row from one SDDS dataset to another.
static PyObject * sddsdata_SetError(PyObject *self, PyObject *args)
Sets an error description.
static PyObject * sddsdata_GetTypeSize(PyObject *self, PyObject *args)
Retrieves the size of a given SDDS data type.
static PyObject * sddsdata_CopyAdditionalRows(PyObject *self, PyObject *args)
Copies additional rows from one SDDS dataset to another.
static PyObject * sddsdata_GetColumnNameFromIndex(PyObject *self, PyObject *args)
Retrieves a column name by its index from a dataset.
static PyObject * sddsdata_TransferParameterDefinition(PyObject *self, PyObject *args)
Transfers a parameter definition from one dataset to another.
static PyObject * sddsdata_GetArrayIndex(PyObject *self, PyObject *args)
Retrieves the index of an array in a dataset.
static PyObject * sddsdata_GetParameterType(PyObject *self, PyObject *args)
Retrieves the type of a parameter in a dataset.
static PyObject * sddsdata_SetDataMode(PyObject *self, PyObject *args)
Sets the data mode for a given dataset.
static PyObject * sddsdata_Bomb(PyObject *self, PyObject *args)
Displays a message on stderr and exits the program.
static PyObject * sddsdata_ArrayCount(PyObject *self, PyObject *args)
Gets the count of arrays in the dataset.
static PyObject * sddsdata_DefineColumn(PyObject *self, PyObject *args)
Defines a column in an SDDS dataset.
static PyObject * sddsdata_ColumnCount(PyObject *self, PyObject *args)
Gets the count of columns in the dataset.
static PyObject * sddsdata_DefineParameter(PyObject *self, PyObject *args)
Defines a parameter in an SDDS dataset.
static PyObject * sddsdata_SetRowValues(PyObject *self, PyObject *args)
Sets values for a specific row in a dataset.
static PyObject * sddsdata_GetArrayDefinition(PyObject *self, PyObject *args)
Retrieves the definition of an array in a dataset.
static PyObject * sddsdata_CopyParameters(PyObject *self, PyObject *args)
Copies parameters from one SDDS dataset to another.
static PyObject * sddsdata_DefineSimpleColumn(PyObject *self, PyObject *args)
Defines a simple column in an SDDS dataset.
static PyObject * sddsdata_GetArrayDimensions(PyObject *self, PyObject *args)
Retrieves the dimensions of an array in a dataset.
static PyObject * sddsdata_DefineArray(PyObject *self, PyObject *args)
Defines an array in an SDDS dataset.
static PyObject * sddsdata_CheckDataset(PyObject *self, PyObject *args)
Checks the validity of a dataset.
static PyObject * sddsdata_TransferAllArrayDefinitions(PyObject *self, PyObject *args)
Transfers all array definitions from one dataset to another.
static PyObject * sddsdata_PrintErrors(PyObject *self, PyObject *args)
Prints error messages based on the provided mode.
static PyObject * sddsdata_InitializeOutput(PyObject *self, PyObject *args)
Initializes an SDDS dataset for output to a file.
static PyObject * sddsdata_SetAutoCheckMode(PyObject *self, PyObject *args)
Sets the auto-check mode for datasets.
static PyObject * sddsdata_CopyColumns(PyObject *self, PyObject *args)
Copies columns from one SDDS dataset to another.
static PyObject * sddsdata_UpdatePage(PyObject *self, PyObject *args)
Updates the page based on the specified mode.
static PyObject * sddsdata_TransferAllColumnDefinitions(PyObject *self, PyObject *args)
Transfers all column definitions from one dataset to another.
static PyObject * sddsdata_WriteLayout(PyObject *self, PyObject *args)
Writes the layout of an SDDS dataset.
static PyObject * sddsdata_InitializeAppendToPage(PyObject *self, PyObject *args)
Initializes appending data to an existing SDDS page in a file.
static PyObject * sddsdata_DefineColumnLikeParameter(PyObject *self, PyObject *args)
Defines a column in one dataset based on a parameter in another dataset.
static PyObject * sddsdata_ClearErrors(PyObject *self, PyObject *args)
Clears all recorded errors.
static PyObject * sddsdata_IsValidName(PyObject *self, PyObject *args)
Validates a name for SDDS compatibility.
static PyObject * sddsdata_DeleteParameterFixedValues(PyObject *self, PyObject *args)
Deletes fixed parameter values for a given dataset.
static PyObject * sddsdata_GetColumnType(PyObject *self, PyObject *args)
Retrieves the type of a column in a dataset.
static PyObject * sddsdata_Terminate(PyObject *self, PyObject *args)
Terminates an SDDS dataset, releasing any associated resources.
static PyObject * sddsdata_GetDescriptionContents(PyObject *self, PyObject *args)
Retrieves the description contents for a dataset.
static PyObject * sddsdata_GetTypeName(PyObject *self, PyObject *args)
Retrieves the name of a given SDDS data type.
static PyObject * sddsdata_GetParameterDefinition(PyObject *self, PyObject *args)
Retrieves the definition of a parameter in a dataset.