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