SDDS ToolKit Programs and Libraries for C and Python
Loading...
Searching...
No Matches
SDDSFile.cc
Go to the documentation of this file.
1/**
2 * @file SDDSFile.cc
3 * @brief Archived implementation of the original SDDS3 file class.
4 *
5 * @details Provides the historical monolithic file, layout, page, and error
6 * handling implementation selected only by the unmodernized SDDS3 API.
7 *
8 * @note This source is retained for migration reference and is not compiled
9 * into libSDDSpp.
10 *
11 * @copyright
12 * - (c) The University of Chicago
13 *
14 * @license
15 * This file is distributed under the terms of the Software License Agreement
16 * found in the file LICENSE included with this distribution.
17 */
18
19/* TODO
20 Add fixed row count support
21 Add ability to open .F and .Z files using freeze and uncompress
22 Add better support for different row counts while an SDDS file is being edited
23 Add recovery mode support
24 Add rowlimit support
25 Add lines per row support for output files
26 Add array type support
27 Add more setparameter types
28*/
29
30#include <stdio.h>
31#include <string.h>
32#include <stdlib.h>
33#include <stdarg.h>
34#include <limits.h>
35#include <math.h>
36
37#if defined(_WIN32)
38#include <fcntl.h>
39#include <io.h>
40#if defined(__BORLANDC__)
41#define _setmode(handle, amode) setmode(handle, amode)
42#endif
43#endif
44
45#include "SDDS3.h"
46#include "mdb.h"
47
48SDDSFile::SDDSFile() {
49 fileName = NULL;
50 bigEndian = (bool)SDDS_isBigEndianMachine();
51 n_errors = 0;
52 asciiFile = true;
53 noRowCount = false;
54 linesPerRow = 1;
55 additionalHeaderLines = 0;
56 isURL = false;
57 descriptionText = NULL;
58 descriptionContents = NULL;
59 arrayCount = 0;
60 arrayObject = NULL;
61 parameterCount = 0;
62 parameterObject = NULL;
63 columnCount = 0;
64 columnObject = NULL;
65 n_errors = 0;
66 error_description = NULL;
67 gzipFile = false;
68 fp = NULL;
69 gzfp = NULL;
70 layoutVersion = SDDS_VERSION;
71 defaultIOBufferSize = 262144;
72 recoveryPossible = 0;
73 columnMajorOrder = true;
74}
75
76SDDSFile::SDDSFile(char *filename) {
77 fileName = (char*)SDDS_malloc(sizeof(char) * strlen(filename) + 1);
78 strcpy(fileName, filename);
79 bigEndian = (bool)SDDS_isBigEndianMachine();
80 n_errors = 0;
81 asciiFile = true;
82 noRowCount = false;
83 linesPerRow = 1;
84 additionalHeaderLines = 0;
85 isURL = false;
86 descriptionText = NULL;
87 descriptionContents = NULL;
88 arrayCount = 0;
89 arrayObject = NULL;
90 parameterCount = 0;
91 parameterObject = NULL;
92 columnCount = 0;
93 columnObject = NULL;
94 n_errors = 0;
95 error_description = NULL;
96 gzipFile = false;
97 fp = NULL;
98 gzfp = NULL;
99 layoutVersion = SDDS_VERSION;
100 defaultIOBufferSize = 262144;
101 recoveryPossible = 0;
102 columnMajorOrder = true;
103}
104
105SDDSFile::SDDSFile(bool binary) {
106 fileName = NULL;
107 bigEndian = (bool)SDDS_isBigEndianMachine();
108 n_errors = 0;
109 asciiFile = !binary;
110 noRowCount = false;
111 linesPerRow = 1;
112 additionalHeaderLines = 0;
113 isURL = false;
114 descriptionText = NULL;
115 descriptionContents = NULL;
116 arrayCount = 0;
117 arrayObject = NULL;
118 parameterCount = 0;
119 parameterObject = NULL;
120 columnCount = 0;
121 columnObject = NULL;
122 n_errors = 0;
123 error_description = NULL;
124 gzipFile = false;
125 fp = NULL;
126 gzfp = NULL;
127 layoutVersion = SDDS_VERSION;
128 defaultIOBufferSize = 262144;
129 recoveryPossible = 0;
130 columnMajorOrder = true;
131}
132
133SDDSFile::SDDSFile(char *filename, bool binary) {
134 fileName = (char*)SDDS_malloc(sizeof(char) * strlen(filename) + 1);
135 strcpy(fileName, filename);
136 bigEndian = (bool)SDDS_isBigEndianMachine();
137 n_errors = 0;
138 asciiFile = !binary;
139 noRowCount = false;
140 linesPerRow = 1;
141 additionalHeaderLines = 0;
142 isURL = false;
143 descriptionText = NULL;
144 descriptionContents = NULL;
145 arrayCount = 0;
146 arrayObject = NULL;
147 parameterCount = 0;
148 parameterObject = NULL;
149 columnCount = 0;
150 columnObject = NULL;
151 n_errors = 0;
152 error_description = NULL;
153 gzipFile = false;
154 fp = NULL;
155 gzfp = NULL;
156 layoutVersion = SDDS_VERSION;
157 defaultIOBufferSize = 262144;
158 recoveryPossible = 0;
159 columnMajorOrder = true;
160}
161
162/***********************************************************************************************
163 * SDDSFile_new *
164 * *
165 * C Arguments: int32_t mode, ... *
166 * mode=SDDSFILE_NEW_DEFAULT *
167 * mode=SDDSFILE_NEW_WITH_FILENAME, char *filename *
168 * mode=SDDSFILE_NEW_WITH_MODE, int32_t binary *
169 * mode=SDDSFILE_NEW_WITH_FILENAME+SDDSFILE_NEW_WITH_MODE, *
170 * char *filename, int32_t binary *
171 * *
172 * Results: pointer to SDDSFile object *
173 ***********************************************************************************************/
174void *SDDSFile_new(int32_t mode, ...) {
175 va_list ap;
176 char *filename;
177 int32_t binary;
178
179 if (mode&SDDSFILE_NEW_WITH_FILENAME) {
180 if (mode&SDDSFILE_NEW_WITH_MODE) {
181 va_start(ap, mode);
182 filename = va_arg(ap, char *);
183 binary = va_arg(ap, int32_t);
184 if (binary == SDDS_ASCII)
185 binary = 0;
186 return((void*) new SDDSFile(filename, binary));
187 } else {
188 va_start(ap, mode);
189 filename = va_arg(ap, char *);
190 return((void*) new SDDSFile(filename));
191 }
192 } else if (mode&SDDSFILE_NEW_WITH_MODE) {
193 va_start(ap, mode);
194 binary = va_arg(ap, int32_t);
195 if (binary == SDDS_ASCII)
196 binary = 0;
197 return((void*) new SDDSFile(binary));
198 } else {
199 return((void*) new SDDSFile());
200 }
201}
202
203SDDSFile::~SDDSFile() {
204 int32_t i;
205 if (fileName != NULL)
206 SDDS_free(fileName);
207 if (descriptionText != NULL)
208 SDDS_free(descriptionText);
209 if (descriptionContents != NULL)
210 SDDS_free(descriptionContents);
211 for (i=0 ; i<arrayCount ; i++) {
212 delete arrayObject[i];
213 }
214 SDDS_free(arrayObject);
215 for (i=0 ; i<parameterCount ; i++) {
216 delete parameterObject[i];
217 }
218 SDDS_free(parameterObject);
219 for (i=0 ; i<columnCount ; i++) {
220 delete columnObject[i];
221 }
222 SDDS_free(columnObject);
223}
224
225/*
226 * SDDSFile_delete used to delete an SDDSFile object.
227 *
228 */
229void SDDSFile_delete(void* sddsfile) {
230 delete (SDDSFile*)sddsfile;
231}
232
233/***********************************************************************************************
234 * setFileName *
235 * *
236 * C++ Arguments: char *filename *
237 * *
238 * C Arguments: void *sddsfile, char *filename *
239 * *
240 * Results: none *
241 ***********************************************************************************************/
242void SDDSFile::setFileName(char *filename) {
243 if (fileName != NULL)
244 SDDS_free(fileName);
245 if (filename == NULL)
246 fileName = NULL;
247 else {
248 fileName = (char*)SDDS_malloc(sizeof(char) * strlen(filename) + 1);
249 strcpy(fileName, filename);
250 }
251}
252void SDDSFile_setFileName(void *sddsfile, char *filename) {
253 ((SDDSFile*)sddsfile)->setFileName(filename);
254}
255
256/***********************************************************************************************
257 * getDataMode *
258 * *
259 * C++ Arguments: none *
260 * *
261 * C Arguments: void *sddsfile *
262 * *
263 * Results: SDDS_BINARY or SDDS_ASCII *
264 ***********************************************************************************************/
265uint32_t SDDSFile::getDataMode() {
266 if (asciiFile) {
267 return(SDDS_ASCII);
268 } else {
269 return(SDDS_BINARY);
270 }
271}
272uint32_t SDDSFile_getDataMode(void *sddsfile) {
273 return(((SDDSFile*)sddsfile)->getDataMode());
274}
275
276/***********************************************************************************************
277 * setDataMode *
278 * *
279 * C++ Arguments: uint32_t mode *
280 * *
281 * C Arguments: void *sddsfile, uint32_t mode *
282 * *
283 * Results: SDDS_BINARY or SDDS_ASCII *
284 ***********************************************************************************************/
285void SDDSFile::setDataMode(uint32_t mode) {
286 if (mode == SDDS_ASCII) {
287 asciiFile = true;
288 } else {
289 asciiFile = false;
290 }
291}
292void SDDSFile_setDataMode(void *sddsfile, uint32_t mode) {
293 ((SDDSFile*)sddsfile)->setDataMode(mode);
294}
295
296/***********************************************************************************************
297 * setLayoutVersion *
298 * *
299 * C++ Arguments: int32_t version *
300 * *
301 * C Arguments: void *sddsfile, int32_t version *
302 * *
303 * Results: None *
304 ***********************************************************************************************/
305void SDDSFile::setLayoutVersion(int32_t version) {
306 if ((version >= 1) && (version <= SDDS_VERSION)) {
307 layoutVersion = version;
308 }
309}
310void SDDSFile_setLayoutVersion(void *sddsfile, int32_t version) {
311 ((SDDSFile*)sddsfile)->setLayoutVersion(version);
312}
313
314/***********************************************************************************************
315 * setColumnMajorOrder *
316 * *
317 * C++ Arguments: none *
318 * *
319 * C Arguments: void *sddsfile *
320 * *
321 * Results: None *
322 ***********************************************************************************************/
323void SDDSFile::setColumnMajorOrder() {
324 columnMajorOrder = true;
325}
326void SDDSFile_setColumnMajorOrder(void *sddsfile) {
327 ((SDDSFile*)sddsfile)->setColumnMajorOrder();
328}
329
330/***********************************************************************************************
331 * setRowMajorOrder *
332 * *
333 * C++ Arguments: none *
334 * *
335 * C Arguments: void *sddsfile *
336 * *
337 * Results: None *
338 ***********************************************************************************************/
339void SDDSFile::setRowMajorOrder() {
340 columnMajorOrder = false;
341}
342void SDDSFile_setRowMajorOrder(void *sddsfile) {
343 ((SDDSFile*)sddsfile)->setRowMajorOrder();
344}
345
346/***********************************************************************************************
347 * setBinaryMode *
348 * *
349 * C++ Arguments: none *
350 * *
351 * C Arguments: void *sddsfile *
352 * *
353 * Results: none *
354 ***********************************************************************************************/
355void SDDSFile::setBinaryMode() {
356 asciiFile = false;
357}
358void SDDSFile_setBinaryMode(void *sddsfile) {
359 ((SDDSFile*)sddsfile)->setBinaryMode();
360}
361
362/***********************************************************************************************
363 * setAsciiMode *
364 * *
365 * C++ Arguments: none *
366 * *
367 * C Arguments: void *sddsfile *
368 * *
369 * Results: none *
370 ***********************************************************************************************/
371void SDDSFile::setAsciiMode() {
372 asciiFile = true;
373}
374void SDDSFile_setAsciiMode(void *sddsfile) {
375 ((SDDSFile*)sddsfile)->setAsciiMode();
376}
377
378/***********************************************************************************************
379 * setNonNativeEndian *
380 * *
381 * C++ Arguments: none *
382 * *
383 * C Arguments: void *sddsfile *
384 * *
385 * Results: none *
386 ***********************************************************************************************/
387void SDDSFile::setNonNativeEndian() {
388 bigEndian = (bool)(!SDDS_isBigEndianMachine());
389}
390void SDDSFile_setNonNativeEndian(void *sddsfile) {
391 ((SDDSFile*)sddsfile)->setNonNativeEndian();
392}
393
394/***********************************************************************************************
395 * setNativeEndian *
396 * *
397 * C++ Arguments: none *
398 * *
399 * C Arguments: void *sddsfile *
400 * *
401 * Results: none *
402 ***********************************************************************************************/
403void SDDSFile::setNativeEndian() {
404 bigEndian = (bool)(SDDS_isBigEndianMachine());
405}
406void SDDSFile_setNativeEndian(void *sddsfile) {
407 ((SDDSFile*)sddsfile)->setNativeEndian();
408}
409
410/***********************************************************************************************
411 * setNoRowCount *
412 * *
413 * C++ Arguments: none *
414 * *
415 * C Arguments: void *sddsfile *
416 * *
417 * Results: none *
418 ***********************************************************************************************/
419void SDDSFile::setNoRowCount() {
420 noRowCount = true;
421}
422void SDDSFile_setNoRowCount(void *sddsfile) {
423 ((SDDSFile*)sddsfile)->setNoRowCount();
424}
425
426/***********************************************************************************************
427 * setUseRowCount *
428 * *
429 * C++ Arguments: none *
430 * *
431 * C Arguments: void *sddsfile *
432 * *
433 * Results: none *
434 ***********************************************************************************************/
435void SDDSFile::setUseRowCount() {
436 noRowCount = true;
437}
438void SDDSFile_setUseRowCount(void *sddsfile) {
439 ((SDDSFile*)sddsfile)->setUseRowCount();
440}
441
442/***********************************************************************************************
443 * setDescription *
444 * *
445 * C++ Arguments: char *text, char *contents *
446 * *
447 * C Arguments: void *sddsfile, char *text, char *contents *
448 * *
449 * Results: none *
450 ***********************************************************************************************/
451void SDDSFile::setDescription(char *text, char *contents) {
452 if (descriptionText != NULL)
453 SDDS_free(descriptionText);
454 if (descriptionContents != NULL)
455 SDDS_free(descriptionContents);
456 if (text == NULL)
457 descriptionText = NULL;
458 else {
459 descriptionText = (char*)SDDS_malloc(sizeof(char) * strlen(text) + 1);
460 strcpy(descriptionText, text);
461 }
462 if (contents == NULL)
463 descriptionContents = NULL;
464 else {
465 descriptionContents = (char*)SDDS_malloc(sizeof(char) * strlen(contents) + 1);
466 strcpy(descriptionContents, contents);
467 }
468}
469void SDDSFile_setDescription(void *sddsfile, char *text, char *contents) {
470 ((SDDSFile*)sddsfile)->setDescription(text, contents);
471}
472
473/***********************************************************************************************
474 * getDescription *
475 * *
476 * C++ Arguments: char **text, char **contents *
477 * *
478 * C Arguments: void *sddsfile, char **text, char **contents *
479 * *
480 * Results: 0 on success *
481 * 1 on failure *
482 ***********************************************************************************************/
483int32_t SDDSFile::getDescription(char **text, char **contents) {
484 if (descriptionText != NULL) {
485 *text = NULL;
486 if (SDDS_copyString(text, descriptionText)) {
487 setError((char*)"Unable to retrieve description data (SDDSFile::getDescription)");
488 return(1);
489 }
490 }
491 if (descriptionContents != NULL) {
492 *contents = NULL;
493 if (SDDS_copyString(contents, descriptionContents)) {
494 setError((char*)"Unable to retrieve description data (SDDSFile::getDescription)");
495 return(1);
496 }
497 }
498 return(0);
499}
500int32_t SDDSFile_getDescription(void *sddsfile, char **text, char **contents) {
501 return(((SDDSFile*)sddsfile)->getDescription(text, contents));
502}
503
504/*
505 * defineArray
506 *
507 * C++ Arguments: char *name, char *symbol, char *units, char *description,
508 * char *format_string, char *group_name, int32_t type,
509 * uint32_t field_length, uint32_t dimensions
510 * char *name, char *symbol, char *units, char *description,
511 * char *format_string, char *group_name, char *type,
512 * uint32_t field_length, uint32_t dimensions
513 * char *name, int32_t type, uint32_t dimensions
514 * char *name, char *type, uint32_t dimensions
515 *
516 * C Arguments: void *sddsfile, int32_t mode, ...
517 * mode=SDDSFILE_DEFINEARRAY_DEFAULT, char *name, int32_t type, uint32_t dimensions
518 * mode=SDDSFILE_DEFINEARRAY_WITH_STRINGTYPE, char *name, char *type, uint32_t dimensions
519 * mode=SDDSFILE_DEFINEARRAY_EXTENSIVE,
520 * char *name, char *symbol, char *units, char *description,
521 * char *format_string, char *group_name, int32_t type,
522 * uint32_t field_length, uint32_t dimensions
523 * mode=SDDSFILE_DEFINEARRAY_WITH_STRINGTYPE+SDDSFILE_DEFINEARRAY_EXTENSIVE,
524 * char *name, char *symbol, char *units, char *description,
525 * char *format_string, char *group_name, char *type,
526 * uint32_t field_length, uint32_t dimensions
527 *
528 * Results: array index on success
529 * -1 on failure (calling program should call printErrors)
530 */
531int32_t SDDSFile::defineArray(char *name, char *symbol, char *units, char *description,
532 char *format_string, char *group_name, int32_t type,
533 uint32_t field_length, uint32_t dimensions) {
534 int32_t i, j;
535 char s[SDDS_MAXLINE];
536
537 i = arrayCount + 1;
538 if (name == NULL) {
539 setError((char*)"Warning: NULL name not allowed for array definition (SDDSFile::defineArray)");
540 return(-1);
541 }
542 if (!SDDS_isValidName(name)) {
543 sprintf(s, "Warning: The following array name is invalid: >%s< (SDDSFile::defineArray)", name);
544 setError(s);
545 return(-1);
546 }
547 for (j=0 ; j<arrayCount ; j++) {
548 if (strcmp(name, arrayObject[j]->getName()) == 0) {
549 sprintf(s, "Warning: array %s already exists (SDDSFile::defineArray)", name);
550 setError(s);
551 return(-1);
552 }
553 }
554 if (!SDDS_isValidType(type)) {
555 setError((char*)"Warning: unknown data type (SDDSFile::defineArray)");
556 return(-1);
557 }
558 if (format_string != NULL) {
559 if (!SDDS_verifyPrintfFormat(format_string, type)) {
560 setError((char*)"Warning: invalid format string (SDDSFile::defineArray)");
561 return(-1);
562 }
563 }
564 arrayObject = (SDDSArray**)SDDS_realloc(arrayObject, sizeof(SDDSArray*) * (arrayCount + 1));
565 arrayObject[arrayCount] = new SDDSArray();
566 arrayObject[arrayCount]->setupArray(name, symbol, units, description, format_string, group_name, type, field_length, dimensions);
567 arrayObject[arrayCount]->informAboutParent(this);
568 arrayCount++;
569 return(arrayCount);
570}
571
572int32_t SDDSFile::defineArray(char *name, char *symbol, char *units, char *description,
573 char *format_string, char *group_name, char *type,
574 uint32_t field_length, uint32_t dimensions) {
575 return(defineArray(name, symbol, units, description, format_string, group_name, SDDS_identifyType(type), field_length, dimensions));
576}
577
578int32_t SDDSFile::defineArray(char *name, int32_t type, uint32_t dimensions) {
579 return(defineArray(name, NULL, NULL, NULL, NULL, NULL, type, 0, dimensions));
580}
581
582int32_t SDDSFile::defineArray(char *name, char *type, uint32_t dimensions) {
583 return(defineArray(name, NULL, NULL, NULL, NULL, NULL, SDDS_identifyType(type), 0, dimensions));
584}
585
586int32_t SDDSFile_defineArray(void *sddsfile, int32_t mode, ...) {
587 va_list ap;
588 char *name;
589 char *symbol;
590 char *units;
591 char *description;
592 char *format_string;
593 char *group_name;
594 char *typeChar;
595 int32_t typeInt;
596 uint32_t field_length;
597 uint32_t dimensions;
598
599 va_start(ap, mode);
600 if (mode&SDDSFILE_DEFINEARRAY_EXTENSIVE) {
601 if (mode&SDDSFILE_DEFINEARRAY_WITH_STRINGTYPE) {
602 name = va_arg(ap, char *);
603 symbol = va_arg(ap, char *);
604 units = va_arg(ap, char *);
605 description = va_arg(ap, char *);
606 format_string = va_arg(ap, char *);
607 group_name = va_arg(ap, char *);
608 typeChar = va_arg(ap, char *);
609 field_length = va_arg(ap, uint32_t);
610 dimensions = va_arg(ap, uint32_t);
611 return(((SDDSFile*)sddsfile)->defineArray(name, symbol, units, description, format_string, group_name, typeChar, field_length, dimensions));
612 } else {
613 name = va_arg(ap, char *);
614 symbol = va_arg(ap, char *);
615 units = va_arg(ap, char *);
616 description = va_arg(ap, char *);
617 format_string = va_arg(ap, char *);
618 group_name = va_arg(ap, char *);
619 typeInt = va_arg(ap, int32_t);
620 field_length = va_arg(ap, uint32_t);
621 dimensions = va_arg(ap, uint32_t);
622 return(((SDDSFile*)sddsfile)->defineArray(name, symbol, units, description, format_string, group_name, typeInt, field_length, dimensions));
623 }
624 } else if (mode&SDDSFILE_DEFINEARRAY_WITH_STRINGTYPE) {
625 name = va_arg(ap, char *);
626 typeChar = va_arg(ap, char *);
627 dimensions = va_arg(ap, uint32_t);
628 return(((SDDSFile*)sddsfile)->defineArray(name, typeChar, dimensions));
629 } else {
630 name = va_arg(ap, char *);
631 typeInt = va_arg(ap, int32_t);
632 dimensions = va_arg(ap, uint32_t);
633 return(((SDDSFile*)sddsfile)->defineArray(name, typeInt, dimensions));
634 }
635}
636
637/****************************************************************************************************
638 * defineParameter *
639 * *
640 * C++ Arguments: char *name, char *symbol, char *units, char *description, *
641 * char *format_string, int32_t type, char *fixed_value *
642 * char *name, char *symbol, char *units, char *description, *
643 * char *format_string, char *type, char *fixed_value *
644 * char *name, int32_t type *
645 * char *name, char *type *
646 * *
647 * C Arguments: void *sddsfile, int32_t mode, ... *
648 * mode=SDDSFILE_DEFINEPARAMETER_DEFAULT, char *name, int32_t type *
649 * mode=SDDSFILE_DEFINEPARAMETER_WITH_STRINGTYPE, char *name, char *type *
650 * mode=SDDSFILE_DEFINEPARAMETER_EXTENSIVE, *
651 * char *name, char *symbol, char *units, char *description, *
652 * char *format_string, int32_t type, char *fixed_value *
653 * mode=SDDSFILE_DEFINEPARAMETER_WITH_STRINGTYPE+SDDSFILE_DEFINEPARAMETER_EXTENSIVE, *
654 * char *name, char *symbol, char *units, char *description, *
655 * char *format_string, char *type, char *fixed_value *
656 * *
657 * Results: parameter index on success *
658 * -1 on failure (calling program should call printErrors) *
659 ****************************************************************************************************/
660int32_t SDDSFile::defineParameter(char *name, char *symbol, char *units, char *description,
661 char *format_string, int32_t type, char *fixed_value) {
662 int32_t i, j;
663 char s[SDDS_MAXLINE];
664
665 i = parameterCount + 1;
666 if (name == NULL) {
667 setError((char*)"Warning: NULL name not allowed for parameter definition (SDDSFile::defineParameter)");
668 return(-1);
669 }
670 if (!SDDS_isValidName(name)) {
671 sprintf(s, "Warning: The following parameter name is invalid: >%s< (SDDSFile::defineParameter)", name);
672 setError(s);
673 return(-1);
674 }
675 for (j=0 ; j<parameterCount ; j++) {
676 if (strcmp(name, parameterObject[j]->getName()) == 0) {
677 sprintf(s, "Warning: parameter %s already exists (SDDSFile::defineParameter)", name);
678 setError(s);
679 return(-1);
680 }
681 }
682 if (!SDDS_isValidType(type)) {
683 setError((char*)"Warning: unknown data type (SDDSFile::defineParameter)");
684 return(-1);
685 }
686 if (format_string != NULL) {
687 if (!SDDS_verifyPrintfFormat(format_string, type)) {
688 setError((char*)"Warning: invalid format string (SDDSFile::defineParameter)");
689 return(-1);
690 }
691 }
692 parameterObject = (SDDSParameter**)SDDS_realloc(parameterObject, sizeof(SDDSParameter*) * (parameterCount + 1));
693 parameterObject[parameterCount] = new SDDSParameter();
694 parameterObject[parameterCount]->setupParameter(name, symbol, units, description, format_string, type, fixed_value);
695 parameterObject[parameterCount]->informAboutParent(this);
696 parameterCount++;
697 return(parameterCount);
698}
699
700int32_t SDDSFile::defineParameter(char *name, char *symbol, char *units, char *description,
701 char *format_string, char *type, char *fixed_value) {
702 return(defineParameter(name, symbol, units, description, format_string, SDDS_identifyType(type), fixed_value));
703}
704
705int32_t SDDSFile::defineParameter(char *name, int32_t type) {
706 return(defineParameter(name, NULL, NULL, NULL, NULL, type, NULL));
707}
708
709int32_t SDDSFile::defineParameter(char *name, char *type) {
710 return(defineParameter(name, NULL, NULL, NULL, NULL, SDDS_identifyType(type), NULL));
711}
712
713int32_t SDDSFile_defineParameter(void *sddsfile, int32_t mode, ...) {
714 va_list ap;
715 char *name;
716 char *symbol;
717 char *units;
718 char *description;
719 char *format_string;
720 char *typeChar;
721 int32_t typeInt;
722 char *fixed_value;
723
724 va_start(ap, mode);
725 if (mode&SDDSFILE_DEFINEPARAMETER_EXTENSIVE) {
726 if (mode&SDDSFILE_DEFINEPARAMETER_WITH_STRINGTYPE) {
727 name = va_arg(ap, char *);
728 symbol = va_arg(ap, char *);
729 units = va_arg(ap, char *);
730 description = va_arg(ap, char *);
731 format_string = va_arg(ap, char *);
732 typeChar = va_arg(ap, char *);
733 fixed_value = va_arg(ap, char *);
734 return(((SDDSFile*)sddsfile)->defineParameter(name, symbol, units, description, format_string, typeChar, fixed_value));
735 } else {
736 name = va_arg(ap, char *);
737 symbol = va_arg(ap, char *);
738 units = va_arg(ap, char *);
739 description = va_arg(ap, char *);
740 format_string = va_arg(ap, char *);
741 typeInt = va_arg(ap, int32_t);
742 fixed_value = va_arg(ap, char *);
743 return(((SDDSFile*)sddsfile)->defineParameter(name, symbol, units, description, format_string, typeInt, fixed_value));
744 }
745 } else if (mode&SDDSFILE_DEFINEPARAMETER_WITH_STRINGTYPE) {
746 name = va_arg(ap, char *);
747 typeChar = va_arg(ap, char *);
748 return(((SDDSFile*)sddsfile)->defineParameter(name, typeChar));
749 } else {
750 name = va_arg(ap, char *);
751 typeInt = va_arg(ap, int32_t);
752 return(((SDDSFile*)sddsfile)->defineParameter(name, typeInt));
753 }
754}
755
756/****************************************************************************************************
757 * defineColumn *
758 * *
759 * C++ Arguments: char *name, char *symbol, char *units, char *description, *
760 * char *format_string, int32_t type, uint32_t field_length *
761 * char *name, char *symbol, char *units, char *description, *
762 * char *format_string, char *type, uint32_t field_length *
763 * char *name, int32_t type *
764 * char *name, char *type *
765 * *
766 * C Arguments: void *sddsfile, int32_t mode, ... *
767 * mode=SDDSFILE_DEFINECOLUMN_DEFAULT, char *name, int32_t type *
768 * mode=SDDSFILE_DEFINECOLUMN_WITH_STRINGTYPE, char *name, char *type *
769 * mode=SDDSFILE_DEFINECOLUMN_EXTENSIVE, *
770 * char *name, char *symbol, char *units, char *description, *
771 * char *format_string, int32_t type, uint32_t field_length *
772 * mode=SDDSFILE_DEFINECOLUMN_WITH_STRINGTYPE+SDDSFILE_DEFINECOLUMN_EXTENSIVE, *
773 * char *name, char *symbol, char *units, char *description, *
774 * char *format_string, char *type, uint32_t field_length *
775 * *
776 * Results: column index on success *
777 * -1 on failure (calling program should call printErrors) *
778 ****************************************************************************************************/
779int32_t SDDSFile::defineColumn(char *name, char *symbol, char *units, char *description,
780 char *format_string, int32_t type, uint32_t field_length) {
781 int32_t i, j;
782 char s[SDDS_MAXLINE];
783
784 i = columnCount + 1;
785 if (name == NULL) {
786 setError((char*)"Warning: NULL name not allowed for column definition (SDDSFile::defineColumn)");
787 return(-1);
788 }
789 if (!SDDS_isValidName(name)) {
790 sprintf(s, "Warning: The following column name is invalid: >%s< (SDDSFile::defineColumn)", name);
791 setError(s);
792 return(-1);
793 }
794 for (j=0 ; j<columnCount ; j++) {
795 if (strcmp(name, columnObject[j]->getName()) == 0) {
796 sprintf(s, "Warning: column %s already exists (SDDSFile::defineColumn)", name);
797 setError(s);
798 return(-1);
799 }
800 }
801 if (!SDDS_isValidType(type)) {
802 setError((char*)"Warning: unknown data type (SDDSFile::defineColumn)");
803 return(-1);
804 }
805 if (format_string != NULL) {
806 if (!SDDS_verifyPrintfFormat(format_string, type)) {
807 setError((char*)"Warning: invalid format string (SDDSFile::defineColumn)");
808 return(-1);
809 }
810 }
811 columnObject = (SDDSColumn**)SDDS_realloc(columnObject, sizeof(SDDSColumn*) * (columnCount + 1));
812 columnObject[columnCount] = new SDDSColumn();
813 columnObject[columnCount]->setupColumn(name, symbol, units, description, format_string, type, field_length);
814 columnObject[columnCount]->informAboutParent(this);
815 columnCount++;
816 return(columnCount);
817}
818
819int32_t SDDSFile::defineColumn(char *name, char *symbol, char *units, char *description,
820 char *format_string, char *type, uint32_t field_length) {
821 return(defineColumn(name, symbol, units, description, format_string, SDDS_identifyType(type), field_length));
822}
823
824int32_t SDDSFile::defineColumn(char *name, int32_t type) {
825 return(defineColumn(name, NULL, NULL, NULL, NULL, type, 0));
826}
827
828int32_t SDDSFile::defineColumn(char *name, char *type) {
829 return(defineColumn(name, NULL, NULL, NULL, NULL, SDDS_identifyType(type), 0));
830}
831
832int32_t SDDSFile_defineColumn(void *sddsfile, int32_t mode, ...) {
833 va_list ap;
834 char *name;
835 char *symbol;
836 char *units;
837 char *description;
838 char *format_string;
839 char *typeChar;
840 int32_t typeInt;
841 uint32_t field_length;
842
843 va_start(ap, mode);
844 if (mode&SDDSFILE_DEFINECOLUMN_EXTENSIVE) {
845 if (mode&SDDSFILE_DEFINECOLUMN_WITH_STRINGTYPE) {
846 name = va_arg(ap, char *);
847 symbol = va_arg(ap, char *);
848 units = va_arg(ap, char *);
849 description = va_arg(ap, char *);
850 format_string = va_arg(ap, char *);
851 typeChar = va_arg(ap, char *);
852 field_length = va_arg(ap, uint32_t);
853 return(((SDDSFile*)sddsfile)->defineColumn(name, symbol, units, description, format_string, typeChar, field_length));
854 } else {
855 name = va_arg(ap, char *);
856 symbol = va_arg(ap, char *);
857 units = va_arg(ap, char *);
858 description = va_arg(ap, char *);
859 format_string = va_arg(ap, char *);
860 typeInt = va_arg(ap, int32_t);
861 field_length = va_arg(ap, uint32_t);
862 return(((SDDSFile*)sddsfile)->defineColumn(name, symbol, units, description, format_string, typeInt, field_length));
863 }
864 } else if (mode&SDDSFILE_DEFINECOLUMN_WITH_STRINGTYPE) {
865 name = va_arg(ap, char *);
866 typeChar = va_arg(ap, char *);
867 return(((SDDSFile*)sddsfile)->defineColumn(name, typeChar));
868 } else {
869 name = va_arg(ap, char *);
870 typeInt = va_arg(ap, int32_t);
871 return(((SDDSFile*)sddsfile)->defineColumn(name, typeInt));
872 }
873}
874
875/*
876 * defineArrays
877 *
878 * C++ Arguments: int32_t number, char **name, char **symbol, char **units,
879 * char **description, char **format_string, char **group_name,
880 * int32_t *type, uint32_t *field_length, uint32_t *dimensions
881 * int32_t number, char **name, char **symbol, char **units,
882 * char **description, char **format_string, char **group_name,
883 * char **type, uint32_t *field_length, uint32_t *dimensions
884 * int32_t number, char **name, int32_t *type, uint32_t *dimensions
885 * int32_t number, char **name, char **type, uint32_t *dimensions
886 *
887 * Results: 0 on success
888 * 1 on failure (calling program should call printErrors)
889 */
890int32_t SDDSFile::defineArrays(int32_t number, char **name, char **symbol,
891 char **units, char **description, char **format_string,
892 char **group_name, int32_t *type, uint32_t *field_length,
893 uint32_t *dimensions) {
894 int32_t i;
895 if (number < 1)
896 return(0);
897 if (name == NULL)
898 return(1);
899 if (symbol == NULL)
900 return(1);
901 if (units == NULL)
902 return(1);
903 if (description == NULL)
904 return(1);
905 if (format_string == NULL)
906 return(1);
907 if (group_name == NULL)
908 return(1);
909 if (type == NULL)
910 return(1);
911 if (field_length == NULL)
912 return(1);
913 if (dimensions == NULL)
914 return(1);
915 for (i=0 ; i<number ; i++) {
916 if (defineArray(name[i], symbol[i], units[i], description[i], format_string[i], group_name[i], type[i], field_length[i], dimensions[i]) < 0) {
917 return(1);
918 }
919 }
920 return(0);
921}
922
923int32_t SDDSFile::defineArrays(int32_t number, char **name, char **symbol,
924 char **units, char **description, char **format_string,
925 char **group_name, char **type, uint32_t *field_length,
926 uint32_t *dimensions) {
927 int32_t i;
928 if (number < 1)
929 return(0);
930 if (name == NULL)
931 return(1);
932 if (symbol == NULL)
933 return(1);
934 if (units == NULL)
935 return(1);
936 if (description == NULL)
937 return(1);
938 if (format_string == NULL)
939 return(1);
940 if (group_name == NULL)
941 return(1);
942 if (type == NULL)
943 return(1);
944 if (field_length == NULL)
945 return(1);
946 if (dimensions == NULL)
947 return(1);
948 for (i=0 ; i<number ; i++) {
949 if (defineArray(name[i], symbol[i], units[i], description[i], format_string[i], group_name[i], type[i], field_length[i], dimensions[i]) < 0) {
950 return(1);
951 }
952 }
953 return(0);
954}
955
956int32_t SDDSFile::defineArrays(int32_t number, char **name, int32_t *type, uint32_t *dimensions) {
957 int32_t i;
958 if (number < 1)
959 return(0);
960 if (name == NULL)
961 return(1);
962 if (type == NULL)
963 return(1);
964 if (dimensions == NULL)
965 return(1);
966 for (i=0 ; i<number ; i++) {
967 if (defineArray(name[i], type[i], dimensions[i]) < 0) {
968 return(1);
969 }
970 }
971 return(0);
972}
973
974int32_t SDDSFile::defineArrays(int32_t number, char **name, char **type, uint32_t *dimensions) {
975 int32_t i;
976 if (number < 1)
977 return(0);
978 if (name == NULL)
979 return(1);
980 if (type == NULL)
981 return(1);
982 if (dimensions == NULL)
983 return(1);
984 for (i=0 ; i<number ; i++) {
985 if (defineArray(name[i], type[i], dimensions[i]) < 0) {
986 return(1);
987 }
988 }
989 return(0);
990}
991
992/*
993 * defineParameters
994 *
995 * C++ Arguments: int32_t number, char **name, char **symbol, char **units, char **description,
996 * char **format_string, int32_t *type, char **fixed_value
997 * int32_t number, char **name, char **symbol, char **units, char **description,
998 * char **format_string, char **type, char **fixed_value
999 * int32_t number, char **name, int32_t *type
1000 * int32_t number, char **name, char **type
1001 *
1002 * Results: 0 on success
1003 * 1 on failure (calling program should call printErrors)
1004 */
1005int32_t SDDSFile::defineParameters(int32_t number, char **name, char **symbol, char **units,
1006 char **description, char **format_string, int32_t *type, char **fixed_value) {
1007 int32_t i;
1008 if (number < 1)
1009 return(0);
1010 if (name == NULL)
1011 return(1);
1012 if (symbol == NULL)
1013 return(1);
1014 if (units == NULL)
1015 return(1);
1016 if (description == NULL)
1017 return(1);
1018 if (format_string == NULL)
1019 return(1);
1020 if (type == NULL)
1021 return(1);
1022 if (fixed_value == NULL)
1023 return(1);
1024 for (i=0 ; i<number ; i++) {
1025 if (defineParameter(name[i], symbol[i], units[i], description[i], format_string[i], type[i], fixed_value[i]) < 0) {
1026 return(1);
1027 }
1028 }
1029 return(0);
1030}
1031
1032int32_t SDDSFile::defineParameters(int32_t number, char **name, char **symbol, char **units,
1033 char **description, char **format_string, char **type, char **fixed_value) {
1034 int32_t i;
1035 if (number < 1)
1036 return(0);
1037 if (name == NULL)
1038 return(1);
1039 if (symbol == NULL)
1040 return(1);
1041 if (units == NULL)
1042 return(1);
1043 if (description == NULL)
1044 return(1);
1045 if (format_string == NULL)
1046 return(1);
1047 if (type == NULL)
1048 return(1);
1049 if (fixed_value == NULL)
1050 return(1);
1051 for (i=0 ; i<number ; i++) {
1052 if (defineParameter(name[i], symbol[i], units[i], description[i], format_string[i], type[i], fixed_value[i]) < 0) {
1053 return(1);
1054 }
1055 }
1056 return(0);
1057}
1058
1059int32_t SDDSFile::defineParameters(int32_t number, char **name, int32_t *type) {
1060 int32_t i;
1061 if (number < 1)
1062 return(0);
1063 if (name == NULL)
1064 return(1);
1065 if (type == NULL)
1066 return(1);
1067 for (i=0 ; i<number ; i++) {
1068 if (defineParameter(name[i], type[i]) < 0) {
1069 return(1);
1070 }
1071 }
1072 return(0);
1073}
1074
1075int32_t SDDSFile::defineParameters(int32_t number, char **name, char **type) {
1076 int32_t i;
1077 if (number < 1)
1078 return(0);
1079 if (name == NULL)
1080 return(1);
1081 if (type == NULL)
1082 return(1);
1083 for (i=0 ; i<number ; i++) {
1084 if (defineParameter(name[i], type[i]) < 0) {
1085 return(1);
1086 }
1087 }
1088 return(0);
1089}
1090
1091/*
1092 * defineColumns
1093 *
1094 * C++ Arguments: int32_t number, char **name, char **symbol, char **units, char **description,
1095 * char **format_string, int32_t *type, uint32_t *field_length
1096 * int32_t number, char **name, char **symbol, char **units, char **description,
1097 * char **format_string, char *type, uint32_t *field_length
1098 * int32_t number, char **name, int32_t *type
1099 * int32_t number, char **name, char **type
1100 *
1101 * Results: 0 on success
1102 * 1 on failure (calling program should call printErrors)
1103 */
1104int32_t SDDSFile::defineColumns(int32_t number, char **name, char **symbol, char **units,
1105 char **description, char **format_string, int32_t *type, uint32_t *field_length) {
1106 int32_t i;
1107 if (number < 1)
1108 return(0);
1109 if (name == NULL)
1110 return(1);
1111 if (symbol == NULL)
1112 return(1);
1113 if (units == NULL)
1114 return(1);
1115 if (description == NULL)
1116 return(1);
1117 if (format_string == NULL)
1118 return(1);
1119 if (type == NULL)
1120 return(1);
1121 if (field_length == NULL)
1122 return(1);
1123 for (i=0 ; i<number ; i++) {
1124 if (defineColumn(name[i], symbol[i], units[i], description[i], format_string[i], type[i], field_length[i]) < 0) {
1125 return(1);
1126 }
1127 }
1128 return(0);
1129}
1130
1131int32_t SDDSFile::defineColumns(int32_t number, char **name, char **symbol, char **units,
1132 char **description, char **format_string, char **type, uint32_t *field_length) {
1133 int32_t i;
1134 if (number < 1)
1135 return(0);
1136 if (name == NULL)
1137 return(1);
1138 if (symbol == NULL)
1139 return(1);
1140 if (units == NULL)
1141 return(1);
1142 if (description == NULL)
1143 return(1);
1144 if (format_string == NULL)
1145 return(1);
1146 if (type == NULL)
1147 return(1);
1148 if (field_length == NULL)
1149 return(1);
1150 for (i=0 ; i<number ; i++) {
1151 if (defineColumn(name[i], symbol[i], units[i], description[i], format_string[i], type[i], field_length[i]) < 0) {
1152 return(1);
1153 }
1154 }
1155 return(0);
1156}
1157
1158int32_t SDDSFile::defineColumns(int32_t number, char **name, int32_t *type) {
1159 int32_t i;
1160 if (number < 1)
1161 return(0);
1162 if (name == NULL)
1163 return(1);
1164 if (type == NULL)
1165 return(1);
1166 for (i=0 ; i<number ; i++) {
1167 if (defineColumn(name[i], type[i]) < 0) {
1168 return(1);
1169 }
1170 }
1171 return(0);
1172}
1173
1174int32_t SDDSFile::defineColumns(int32_t number, char **name, char **type) {
1175 int32_t i;
1176 if (number < 1)
1177 return(0);
1178 if (name == NULL)
1179 return(1);
1180 if (type == NULL)
1181 return(1);
1182 for (i=0 ; i<number ; i++) {
1183 if (defineColumn(name[i], type[i]) < 0) {
1184 return(1);
1185 }
1186 }
1187 return(0);
1188}
1189
1190/*
1191 * setArraySymbol
1192 *
1193 * C++ Arguments: int32_t index, char *symbol
1194 * char *name, char *symbol
1195 *
1196 * C Arguments: void *sddsfile, int32_t index, char *symbol
1197 *
1198 * Results: none
1199 */
1200void SDDSFile::setArraySymbol(int32_t index, char *symbol) {
1201 if ((index < 0) || (index >= arrayCount))
1202 return;
1203 arrayObject[index]->setSymbol(symbol);
1204}
1205void SDDSFile::setArraySymbol(char *name, char *symbol) {
1206 int32_t index;
1207 index = getArrayIndex(name);
1208 if ((index < 0) || (index >= arrayCount))
1209 return;
1210 arrayObject[index]->setSymbol(symbol);
1211}
1212void SDDSFile_setArraySymbol(void *sddsfile, int32_t index, char *symbol) {
1213 ((SDDSFile*)sddsfile)->setArraySymbol(index, symbol);
1214}
1215
1216/*
1217 * setParameterSymbol
1218 *
1219 * C++ Arguments: int32_t index, char *symbol
1220 * char *name, char *symbol
1221 *
1222 * C Arguments: void *sddsfile, int32_t index, char *symbol
1223 *
1224 * Results: none
1225 */
1226void SDDSFile::setParameterSymbol(int32_t index, char *symbol) {
1227 if ((index < 0) || (index >= parameterCount))
1228 return;
1229 parameterObject[index]->setSymbol(symbol);
1230}
1231void SDDSFile::setParameterSymbol(char *name, char *symbol) {
1232 int32_t index;
1233 index = getParameterIndex(name);
1234 if ((index < 0) || (index >= parameterCount))
1235 return;
1236 parameterObject[index]->setSymbol(symbol);
1237}
1238void SDDSFile_setParameterSymbol(void *sddsfile, int32_t index, char *symbol) {
1239 ((SDDSFile*)sddsfile)->setParameterSymbol(index, symbol);
1240}
1241
1242/***********************************************************************************************
1243 * setColumnSymbol *
1244 * *
1245 * C++ Arguments: int32_t index, char *symbol *
1246 * char *name, char *symbol *
1247 * *
1248 * C Arguments: void *sddsfile, int32_t index, char *symbol *
1249 * *
1250 * Results: none *
1251 ***********************************************************************************************/
1252void SDDSFile::setColumnSymbol(int32_t index, char *symbol) {
1253 if ((index < 0) || (index >= columnCount))
1254 return;
1255 columnObject[index]->setSymbol(symbol);
1256}
1257void SDDSFile::setColumnSymbol(char *name, char *symbol) {
1258 int32_t index;
1259 index = getColumnIndex(name);
1260 if ((index < 0) || (index >= columnCount))
1261 return;
1262 columnObject[index]->setSymbol(symbol);
1263}
1264void SDDSFile_setColumnSymbol(void *sddsfile, int32_t index, char *symbol) {
1265 ((SDDSFile*)sddsfile)->setColumnSymbol(index, symbol);
1266}
1267
1268/*
1269 * setArrayUnits
1270 *
1271 * C++ Arguments: int32_t index, char *units
1272 * char *name, char *units
1273 *
1274 * C Arguments: void *sddsfile, int32_t index, char *units
1275 *
1276 * Results: none
1277 */
1278void SDDSFile::setArrayUnits(int32_t index, char *units) {
1279 if ((index < 0) || (index >= arrayCount))
1280 return;
1281 arrayObject[index]->setUnits(units);
1282}
1283void SDDSFile::setArrayUnits(char *name, char *units) {
1284 int32_t index;
1285 index = getArrayIndex(name);
1286 if ((index < 0) || (index >= arrayCount))
1287 return;
1288 arrayObject[index]->setUnits(units);
1289}
1290void SDDSFile_setArrayUnits(void *sddsfile, int32_t index, char *units) {
1291 ((SDDSFile*)sddsfile)->setArrayUnits(index, units);
1292}
1293
1294/*
1295 * setParameterUnits
1296 *
1297 * C++ Arguments: int32_t index, char *units
1298 * char *name, char *units
1299 *
1300 * C Arguments: void *sddsfile, int32_t index, char *units
1301 *
1302 * Results: none
1303 */
1304void SDDSFile::setParameterUnits(int32_t index, char *units) {
1305 if ((index < 0) || (index >= parameterCount))
1306 return;
1307 parameterObject[index]->setUnits(units);
1308}
1309void SDDSFile::setParameterUnits(char *name, char *units) {
1310 int32_t index;
1311 index = getParameterIndex(name);
1312 if ((index < 0) || (index >= parameterCount))
1313 return;
1314 parameterObject[index]->setUnits(units);
1315}
1316void SDDSFile_setParameterUnits(void *sddsfile, int32_t index, char *units) {
1317 ((SDDSFile*)sddsfile)->setParameterUnits(index, units);
1318}
1319
1320/***********************************************************************************************
1321 * setColumnUnits *
1322 * *
1323 * C++ Arguments: int32_t index, char *units *
1324 * char *name, char *units *
1325 * *
1326 * C Arguments: void *sddsfile, int32_t index, char *units *
1327 * *
1328 * Results: none *
1329 ***********************************************************************************************/
1330void SDDSFile::setColumnUnits(int32_t index, char *units) {
1331 if ((index < 0) || (index >= columnCount))
1332 return;
1333 columnObject[index]->setUnits(units);
1334}
1335void SDDSFile::setColumnUnits(char *name, char *units) {
1336 int32_t index;
1337 index = getColumnIndex(name);
1338 if ((index < 0) || (index >= columnCount))
1339 return;
1340 columnObject[index]->setUnits(units);
1341}
1342void SDDSFile_setColumnUnits(void *sddsfile, int32_t index, char *units) {
1343 ((SDDSFile*)sddsfile)->setColumnUnits(index, units);
1344}
1345
1346/*
1347 * setArrayDescription
1348 *
1349 * C++ Arguments: int32_t index, char *description
1350 * char *name, char *description
1351 *
1352 * C Arguments: void *sddsfile, int32_t index, char *description
1353 *
1354 * Results: none
1355 */
1356void SDDSFile::setArrayDescription(int32_t index, char *description) {
1357 if ((index < 0) || (index >= arrayCount))
1358 return;
1359 arrayObject[index]->setDescription(description);
1360}
1361void SDDSFile::setArrayDescription(char *name, char *description) {
1362 int32_t index;
1363 index = getArrayIndex(name);
1364 if ((index < 0) || (index >= arrayCount))
1365 return;
1366 arrayObject[index]->setDescription(description);
1367}
1368void SDDSFile_setArrayDescription(void *sddsfile, int32_t index, char *description) {
1369 ((SDDSFile*)sddsfile)->setArrayDescription(index, description);
1370}
1371
1372/*
1373 * setParameterDescription
1374 *
1375 * C++ Arguments: int32_t index, char *description
1376 * char *name, char *description
1377 *
1378 * C Arguments: void *sddsfile, int32_t index, char *description
1379 *
1380 * Results: none
1381 */
1382void SDDSFile::setParameterDescription(int32_t index, char *description) {
1383 if ((index < 0) || (index >= parameterCount))
1384 return;
1385 parameterObject[index]->setDescription(description);
1386}
1387void SDDSFile::setParameterDescription(char *name, char *description) {
1388 int32_t index;
1389 index = getParameterIndex(name);
1390 if ((index < 0) || (index >= parameterCount))
1391 return;
1392 parameterObject[index]->setDescription(description);
1393}
1394void SDDSFile_setParameterDescription(void *sddsfile, int32_t index, char *description) {
1395 ((SDDSFile*)sddsfile)->setParameterDescription(index, description);
1396}
1397
1398/***********************************************************************************************
1399 * setColumnDescription *
1400 * *
1401 * C++ Arguments: int32_t index, char *description *
1402 * char *name, char *description *
1403 * *
1404 * C Arguments: void *sddsfile, int32_t index, char *description *
1405 * *
1406 * Results: none *
1407 ***********************************************************************************************/
1408void SDDSFile::setColumnDescription(int32_t index, char *description) {
1409 if ((index < 0) || (index >= columnCount))
1410 return;
1411 columnObject[index]->setDescription(description);
1412}
1413void SDDSFile::setColumnDescription(char *name, char *description) {
1414 int32_t index;
1415 index = getColumnIndex(name);
1416 if ((index < 0) || (index >= columnCount))
1417 return;
1418 columnObject[index]->setDescription(description);
1419}
1420void SDDSFile_setColumnDescription(void *sddsfile, int32_t index, char *description) {
1421 ((SDDSFile*)sddsfile)->setColumnDescription(index, description);
1422}
1423
1424/*
1425 * setArrayFormatString
1426 *
1427 * C++ Arguments: int32_t index, char *format_string
1428 * char *name, char *format_string
1429 *
1430 * C Arguments: void *sddsfile, int32_t index, char *format_string
1431 *
1432 * Results: none
1433 */
1434void SDDSFile::setArrayFormatString(int32_t index, char *format_string) {
1435 if ((index < 0) || (index >= arrayCount))
1436 return;
1437 arrayObject[index]->setFormatString(format_string);
1438}
1439void SDDSFile::setArrayFormatString(char *name, char *format_string) {
1440 int32_t index;
1441 index = getArrayIndex(name);
1442 if ((index < 0) || (index >= arrayCount))
1443 return;
1444 arrayObject[index]->setFormatString(format_string);
1445}
1446void SDDSFile_setArrayFormatString(void *sddsfile, int32_t index, char *format_string) {
1447 ((SDDSFile*)sddsfile)->setArrayFormatString(index, format_string);
1448}
1449
1450/*
1451 * setParameterFormatString
1452 *
1453 * C++ Arguments: int32_t index, char *format_string
1454 * char *name, char *format_string
1455 *
1456 * C Arguments: void *sddsfile, int32_t index, char *format_string
1457 *
1458 * Results: none
1459 */
1460void SDDSFile::setParameterFormatString(int32_t index, char *format_string) {
1461 if ((index < 0) || (index >= parameterCount))
1462 return;
1463 parameterObject[index]->setFormatString(format_string);
1464}
1465void SDDSFile::setParameterFormatString(char *name, char *format_string) {
1466 int32_t index;
1467 index = getParameterIndex(name);
1468 if ((index < 0) || (index >= parameterCount))
1469 return;
1470 parameterObject[index]->setFormatString(format_string);
1471}
1472void SDDSFile_setParameterFormatString(void *sddsfile, int32_t index, char *format_string) {
1473 ((SDDSFile*)sddsfile)->setParameterFormatString(index, format_string);
1474}
1475
1476/***********************************************************************************************
1477 * setColumnFormatString *
1478 * *
1479 * C++ Arguments: int32_t index, char *format_string *
1480 * char *name, char *format_string *
1481 * *
1482 * C Arguments: void *sddsfile, int32_t index, char *format_string *
1483 * *
1484 * Results: none *
1485 ***********************************************************************************************/
1486void SDDSFile::setColumnFormatString(int32_t index, char *format_string) {
1487 if ((index < 0) || (index >= columnCount))
1488 return;
1489 columnObject[index]->setFormatString(format_string);
1490}
1491void SDDSFile::setColumnFormatString(char *name, char *format_string) {
1492 int32_t index;
1493 index = getColumnIndex(name);
1494 if ((index < 0) || (index >= columnCount))
1495 return;
1496 columnObject[index]->setFormatString(format_string);
1497}
1498void SDDSFile_setColumnFormatString(void *sddsfile, int32_t index, char *format_string) {
1499 ((SDDSFile*)sddsfile)->setColumnFormatString(index, format_string);
1500}
1501
1502/***********************************************************************************************
1503 * setParameterFixedValue *
1504 * *
1505 * C++ Arguments: int32_t index, char *fixed_value *
1506 * char *name, char *fixed_value *
1507 * *
1508 * C Arguments: void *sddsfile, int32_t index, char *fixed_value *
1509 * *
1510 * Results: none *
1511 ***********************************************************************************************/
1512void SDDSFile::setParameterFixedValue(int32_t index, char *fixed_value) {
1513 if ((index < 0) || (index >= parameterCount))
1514 return;
1515 parameterObject[index]->setFixedValue(fixed_value);
1516}
1517void SDDSFile::setParameterFixedValue(char *name, char *fixed_value) {
1518 int32_t index;
1519 index = getParameterIndex(name);
1520 if ((index < 0) || (index >= parameterCount))
1521 return;
1522 parameterObject[index]->setFixedValue(fixed_value);
1523}
1524void SDDSFile_setParameterFixedValue(void *sddsfile, int32_t index, char *fixed_value) {
1525 ((SDDSFile*)sddsfile)->setParameterFixedValue(index, fixed_value);
1526}
1527
1528/*
1529 * setArrayFieldLength
1530 *
1531 * C++ Arguments: int32_t index, uint32_t field_length
1532 * char *name, uint32_t field_length
1533 *
1534 * C Arguments: void *sddsfile, int32_t index, uint32_t field_length
1535 *
1536 * Results: none
1537 */
1538void SDDSFile::setArrayFieldLength(int32_t index, uint32_t field_length) {
1539 if ((index < 0) || (index >= arrayCount))
1540 return;
1541 arrayObject[index]->setFieldLength(field_length);
1542}
1543void SDDSFile::setArrayFieldLength(char *name, uint32_t field_length) {
1544 int32_t index;
1545 index = getArrayIndex(name);
1546 if ((index < 0) || (index >= arrayCount))
1547 return;
1548 arrayObject[index]->setFieldLength(field_length);
1549}
1550void SDDSFile_setArrayFieldLength(void *sddsfile, int32_t index, uint32_t field_length) {
1551 ((SDDSFile*)sddsfile)->setArrayFieldLength(index, field_length);
1552}
1553
1554/*
1555 * setColumnFieldLength
1556 *
1557 * C++ Arguments: int32_t index, uint32_t field_length
1558 * char *name, uint32_t field_length
1559 *
1560 * C Arguments: void *sddsfile, int32_t index, uint32_t field_length
1561 *
1562 * Results: none
1563 */
1564void SDDSFile::setColumnFieldLength(int32_t index, uint32_t field_length) {
1565 if ((index < 0) || (index >= columnCount))
1566 return;
1567 columnObject[index]->setFieldLength(field_length);
1568}
1569void SDDSFile::setColumnFieldLength(char *name, uint32_t field_length) {
1570 int32_t index;
1571 index = getColumnIndex(name);
1572 if ((index < 0) || (index >= columnCount))
1573 return;
1574 columnObject[index]->setFieldLength(field_length);
1575}
1576void SDDSFile_setColumnFieldLength(void *sddsfile, int32_t index, uint32_t field_length) {
1577 ((SDDSFile*)sddsfile)->setColumnFieldLength(index, field_length);
1578}
1579
1580/*
1581 * setArrayGroupName
1582 *
1583 * C++ Arguments: int32_t index, char *group_name
1584 * char *name, char *group_name
1585 *
1586 * C Arguments: void *sddsfile, int32_t index, char *group_name
1587 *
1588 * Results: none
1589 */
1590void SDDSFile::setArrayGroupName(int32_t index, char *group_name) {
1591 if ((index < 0) || (index >= arrayCount))
1592 return;
1593 arrayObject[index]->setGroupName(group_name);
1594}
1595void SDDSFile::setArrayGroupName(char *name, char *group_name) {
1596 int32_t index;
1597 index = getArrayIndex(name);
1598 if ((index < 0) || (index >= arrayCount))
1599 return;
1600 arrayObject[index]->setGroupName(group_name);
1601}
1602void SDDSFile_setArrayGroupName(void *sddsfile, int32_t index, char *group_name) {
1603 ((SDDSFile*)sddsfile)->setArrayGroupName(index, group_name);
1604}
1605
1606/*
1607 * setArrayDimensions
1608 *
1609 * C++ Arguments: int32_t index, uint32_t dimensions
1610 * char *name, uint32_t dimensions
1611 *
1612 * C Arguments: void *sddsfile, int32_t index, uint32_t dimensions
1613 *
1614 * Results: none
1615 */
1616void SDDSFile::setArrayDimensions(int32_t index, uint32_t dimensions) {
1617 if ((index < 0) || (index >= arrayCount))
1618 return;
1619 arrayObject[index]->setDimensions(dimensions);
1620}
1621void SDDSFile::setArrayDimensions(char *name, uint32_t dimensions) {
1622 int32_t index;
1623 index = getArrayIndex(name);
1624 if ((index < 0) || (index >= arrayCount))
1625 return;
1626 arrayObject[index]->setDimensions(dimensions);
1627}
1628void SDDSFile_setArrayDimensions(void *sddsfile, int32_t index, uint32_t dimensions) {
1629 ((SDDSFile*)sddsfile)->setArrayDimensions(index, dimensions);
1630}
1631
1632/*
1633 * setArrayDim
1634 *
1635 * C++ Arguments: uint32_t page, int32_t index, uint32_t *dimensions
1636 * uint32_t page, char *name, uint32_t *dimensions
1637 *
1638 * C Arguments: void *sddsfile, uint32_t page, uint32_t *dimensions, int32_t mode, ...
1639 * mode=SDDSFILE_SETARRAY_WITH_INDEX,
1640 * int32_t arrayIndex
1641 * mode=SDDSFILE_SETARRAY_WITH_NAME,
1642 * char *name
1643 *
1644 * Results: none
1645 */
1646void SDDSFile::setArrayDim(uint32_t page, int32_t index, uint32_t *dimensions) {
1647 if ((index < 0) || (index >= arrayCount))
1648 return;
1649 arrayObject[index]->setDim(page, dimensions);
1650}
1651void SDDSFile::setArrayDim(uint32_t page, char *name, uint32_t *dimensions) {
1652 int32_t index;
1653 index = getArrayIndex(name);
1654 if ((index < 0) || (index >= arrayCount))
1655 return;
1656 arrayObject[index]->setDim(page, dimensions);
1657}
1658void SDDSFile_setArrayDim(void *sddsfile, uint32_t page, uint32_t *dimensions, int32_t mode, ...) {
1659 va_list ap;
1660 int32_t index;
1661 char *name;
1662
1663 va_start(ap, mode);
1664 if (mode&SDDSFILE_SETARRAY_WITH_INDEX) {
1665 index = va_arg(ap, int32_t);
1666 ((SDDSFile*)sddsfile)->setArrayDim(page, index, dimensions);
1667 } else {
1668 name = va_arg(ap, char *);
1669 ((SDDSFile*)sddsfile)->setArrayDim(page, name, dimensions);
1670 }
1671}
1672
1673/*
1674 * getArrayName
1675 *
1676 * C++ Arguments: int32_t index
1677 *
1678 * C Arguments: void *sddsfile, int32_t index
1679 *
1680 * Results: pointer to name on success (do not free result)
1681 * NULL if name not defined
1682 */
1683char* SDDSFile::getArrayName(int32_t index) {
1684 if ((index < 0) || (index >= arrayCount))
1685 return(NULL);
1686 return(arrayObject[index]->getName());
1687}
1688char* SDDSFile_getArrayName(void *sddsfile, int32_t index) {
1689 return(((SDDSFile*)sddsfile)->getArrayName(index));
1690}
1691
1692/*
1693 * getParameterName
1694 *
1695 * C++ Arguments: int32_t index
1696 *
1697 * C Arguments: void *sddsfile, int32_t index
1698 *
1699 * Results: pointer to name on success (do not free result)
1700 * NULL if name not defined
1701 */
1702char* SDDSFile::getParameterName(int32_t index) {
1703 if ((index < 0) || (index >= parameterCount))
1704 return(NULL);
1705 return(parameterObject[index]->getName());
1706}
1707char* SDDSFile_getParameterName(void *sddsfile, int32_t index) {
1708 return(((SDDSFile*)sddsfile)->getParameterName(index));
1709}
1710
1711/***********************************************************************************************
1712 * getColumnName *
1713 * *
1714 * C++ Arguments: int32_t index *
1715 * *
1716 * C Arguments: void *sddsfile, int32_t index *
1717 * *
1718 * Results: pointer to name on success (do not free result) *
1719 * NULL if name not defined *
1720 ***********************************************************************************************/
1721char* SDDSFile::getColumnName(int32_t index) {
1722 if ((index < 0) || (index >= columnCount))
1723 return(NULL);
1724 return(columnObject[index]->getName());
1725}
1726char* SDDSFile_getColumnName(void *sddsfile, int32_t index) {
1727 return(((SDDSFile*)sddsfile)->getColumnName(index));
1728}
1729
1730/*
1731 * getArrayNames
1732 *
1733 * C++ Arguments: none
1734 *
1735 * C Arguments: void *sddsfile
1736 *
1737 * Results: pointer to array of names on success (you must free the pointer but not the
1738 * elements inside the pointer)
1739 * elements inside the array may be NULL if name not defined
1740 */
1741char** SDDSFile::getArrayNames() {
1742 int32_t i;
1743 char **names;
1744 names = (char**)SDDS_malloc(sizeof(char*) * arrayCount);
1745 for (i=0;i<arrayCount;i++) {
1746 names[i] = getArrayName(i);
1747 }
1748 return(names);
1749}
1750char** SDDSFile_getArrayNames(void *sddsfile) {
1751 return(((SDDSFile*)sddsfile)->getArrayNames());
1752}
1753
1754/*
1755 * getArrayCount
1756 *
1757 * C++ Arguments: none
1758 *
1759 * C Arguments: void *sddsfile
1760 *
1761 * Results: number of arrays
1762 */
1763int32_t SDDSFile::getArrayCount() {
1764 return(arrayCount);
1765}
1766int32_t SDDSFile_getArrayCount(void *sddsfile) {
1767 return(((SDDSFile*)sddsfile)->getArrayCount());
1768}
1769
1770/*
1771 * getParameterNames
1772 *
1773 * C++ Arguments: none
1774 *
1775 * C Arguments: void *sddsfile
1776 *
1777 * Results: pointer to array of names on success (you must free the pointer but not the
1778 * elements inside the pointer)
1779 * elements inside the array may be NULL if name not defined
1780 */
1781char** SDDSFile::getParameterNames() {
1782 int32_t i;
1783 char **names;
1784 names = (char**)SDDS_malloc(sizeof(char*) * parameterCount);
1785 for (i=0;i<parameterCount;i++) {
1786 names[i] = getParameterName(i);
1787 }
1788 return(names);
1789}
1790char** SDDSFile_getParameterNames(void *sddsfile) {
1791 return(((SDDSFile*)sddsfile)->getParameterNames());
1792}
1793
1794/*
1795 * getParameterCount
1796 *
1797 * C++ Arguments: none
1798 *
1799 * C Arguments: void *sddsfile
1800 *
1801 * Results: number of parameters
1802 */
1803int32_t SDDSFile::getParameterCount() {
1804 return(parameterCount);
1805}
1806int32_t SDDSFile_getParameterCount(void *sddsfile) {
1807 return(((SDDSFile*)sddsfile)->getParameterCount());
1808}
1809
1810/***********************************************************************************************
1811 * getColumnNames *
1812 * *
1813 * C++ Arguments: none *
1814 * *
1815 * C Arguments: void *sddsfile *
1816 * *
1817 * Results: pointer to array of names on success (you must free the pointer but not the *
1818 * elements inside the pointer) *
1819 * elements inside the array may be NULL if name not defined *
1820 ***********************************************************************************************/
1821char** SDDSFile::getColumnNames() {
1822 int32_t i;
1823 char **names;
1824 names = (char**)SDDS_malloc(sizeof(char*) * columnCount);
1825 for (i=0;i<columnCount;i++) {
1826 names[i] = getColumnName(i);
1827 }
1828 return(names);
1829}
1830char** SDDSFile_getColumnNames(void *sddsfile) {
1831 return(((SDDSFile*)sddsfile)->getColumnNames());
1832}
1833
1834/***********************************************************************************************
1835 * getColumnCount *
1836 * *
1837 * C++ Arguments: none *
1838 * *
1839 * C Arguments: void *sddsfile *
1840 * *
1841 * Results: number of columns *
1842 ***********************************************************************************************/
1843int32_t SDDSFile::getColumnCount() {
1844 return(columnCount);
1845}
1846int32_t SDDSFile_getColumnCount(void *sddsfile) {
1847 return(((SDDSFile*)sddsfile)->getColumnCount());
1848}
1849
1850/*
1851 * getArrayUnits
1852 *
1853 * C++ Arguments: int32_t index
1854 * char *name
1855 *
1856 * C Arguments: void *sddsfile, int32_t index
1857 *
1858 * Results: pointer to units on success (do not free result)
1859 * NULL if units not defined
1860 */
1861char* SDDSFile::getArrayUnits(int32_t index) {
1862 if ((index < 0) || (index >= arrayCount))
1863 return(NULL);
1864 return(arrayObject[index]->getUnits());
1865}
1866char* SDDSFile::getArrayUnits(char *name) {
1867 int32_t index;
1868 index = getArrayIndex(name);
1869 if ((index < 0) || (index >= arrayCount))
1870 return(NULL);
1871 return(arrayObject[index]->getUnits());
1872}
1873char* SDDSFile_getArrayUnits(void *sddsfile, int32_t index) {
1874 return(((SDDSFile*)sddsfile)->getArrayUnits(index));
1875}
1876
1877/*
1878 * getParameterUnits
1879 *
1880 * C++ Arguments: int32_t index
1881 * char *name
1882 *
1883 * C Arguments: void *sddsfile, int32_t index
1884 *
1885 * Results: pointer to units on success (do not free result)
1886 * NULL if units not defined
1887 */
1888char* SDDSFile::getParameterUnits(int32_t index) {
1889 if ((index < 0) || (index >= parameterCount))
1890 return(NULL);
1891 return(parameterObject[index]->getUnits());
1892}
1893char* SDDSFile::getParameterUnits(char *name) {
1894 int32_t index;
1895 index = getParameterIndex(name);
1896 if ((index < 0) || (index >= parameterCount))
1897 return(NULL);
1898 return(parameterObject[index]->getUnits());
1899}
1900char* SDDSFile_getParameterUnits(void *sddsfile, int32_t index) {
1901 return(((SDDSFile*)sddsfile)->getParameterUnits(index));
1902}
1903
1904/***********************************************************************************************
1905 * getColumnUnits *
1906 * *
1907 * C++ Arguments: int32_t index *
1908 * char *name *
1909 * *
1910 * C Arguments: void *sddsfile, int32_t index *
1911 * *
1912 * Results: pointer to units on success (do not free result) *
1913 * NULL if units not defined *
1914 ***********************************************************************************************/
1915char* SDDSFile::getColumnUnits(int32_t index) {
1916 if ((index < 0) || (index >= columnCount))
1917 return(NULL);
1918 return(columnObject[index]->getUnits());
1919}
1920char* SDDSFile::getColumnUnits(char *name) {
1921 int32_t index;
1922 index = getColumnIndex(name);
1923 if ((index < 0) || (index >= columnCount))
1924 return(NULL);
1925 return(columnObject[index]->getUnits());
1926}
1927char* SDDSFile_getColumnUnits(void *sddsfile, int32_t index) {
1928 return(((SDDSFile*)sddsfile)->getColumnUnits(index));
1929}
1930
1931/*
1932 * getAllArrayUnits
1933 *
1934 * C++ Arguments: none
1935 *
1936 * C Arguments: void *sddsfile
1937 *
1938 * Results: pointer to array of units on success (you must free the pointer but not the
1939 * elements inside the pointer)
1940 * elements inside the array may be NULL if unit not defined
1941 */
1942char** SDDSFile::getAllArrayUnits() {
1943 int32_t i;
1944 char **units;
1945 units = (char**)SDDS_malloc(sizeof(char*) * arrayCount);
1946 for (i=0;i<arrayCount;i++) {
1947 units[i] = getArrayUnits(i);
1948 }
1949 return(units);
1950}
1951char** SDDSFile_getAllArrayUnits(void *sddsfile) {
1952 return(((SDDSFile*)sddsfile)->getAllArrayUnits());
1953}
1954
1955/*
1956 * getAllParameterUnits
1957 *
1958 * C++ Arguments: none
1959 *
1960 * C Arguments: void *sddsfile
1961 *
1962 * Results: pointer to array of units on success (you must free the pointer but not the
1963 * elements inside the pointer)
1964 * elements inside the array may be NULL if unit not defined
1965 */
1966char** SDDSFile::getAllParameterUnits() {
1967 int32_t i;
1968 char **units;
1969 units = (char**)SDDS_malloc(sizeof(char*) * parameterCount);
1970 for (i=0;i<parameterCount;i++) {
1971 units[i] = getParameterUnits(i);
1972 }
1973 return(units);
1974}
1975char** SDDSFile_getAllParameterUnits(void *sddsfile) {
1976 return(((SDDSFile*)sddsfile)->getAllParameterUnits());
1977}
1978
1979/***********************************************************************************************
1980 * getAllColumnUnits *
1981 * *
1982 * C++ Arguments: none *
1983 * *
1984 * C Arguments: void *sddsfile *
1985 * *
1986 * Results: pointer to array of units on success (you must free the pointer but not the *
1987 * elements inside the pointer) *
1988 * elements inside the array may be NULL if unit not defined *
1989 ***********************************************************************************************/
1990char** SDDSFile::getAllColumnUnits() {
1991 int32_t i;
1992 char **units;
1993 units = (char**)SDDS_malloc(sizeof(char*) * columnCount);
1994 for (i=0;i<columnCount;i++) {
1995 units[i] = getColumnUnits(i);
1996 }
1997 return(units);
1998}
1999char** SDDSFile_getAllColumnUnits(void *sddsfile) {
2000 return(((SDDSFile*)sddsfile)->getAllColumnUnits());
2001}
2002
2003/*
2004 * getArraySymbol
2005 *
2006 * C++ Arguments: int32_t index
2007 * char *name
2008 *
2009 * C Arguments: void *sddsfile, int32_t index
2010 *
2011 * Results: pointer to symbol on success (do not free result)
2012 * NULL if symbol not defined
2013 */
2014char* SDDSFile::getArraySymbol(int32_t index) {
2015 if ((index < 0) || (index >= arrayCount))
2016 return(NULL);
2017 return(arrayObject[index]->getSymbol());
2018}
2019char* SDDSFile::getArraySymbol(char *name) {
2020 int32_t index;
2021 index = getArrayIndex(name);
2022 if ((index < 0) || (index >= arrayCount))
2023 return(NULL);
2024 return(arrayObject[index]->getSymbol());
2025}
2026char* SDDSFile_getArraySymbol(void *sddsfile, int32_t index) {
2027 return(((SDDSFile*)sddsfile)->getArraySymbol(index));
2028}
2029
2030/*
2031 * getParameterSymbol
2032 *
2033 * C++ Arguments: int32_t index
2034 * char *name
2035 *
2036 * C Arguments: void *sddsfile, int32_t index
2037 *
2038 * Results: pointer to symbol on success (do not free result)
2039 * NULL if symbol not defined
2040 */
2041char* SDDSFile::getParameterSymbol(int32_t index) {
2042 if ((index < 0) || (index >= parameterCount))
2043 return(NULL);
2044 return(parameterObject[index]->getSymbol());
2045}
2046char* SDDSFile::getParameterSymbol(char *name) {
2047 int32_t index;
2048 index = getParameterIndex(name);
2049 if ((index < 0) || (index >= parameterCount))
2050 return(NULL);
2051 return(parameterObject[index]->getSymbol());
2052}
2053char* SDDSFile_getParameterSymbol(void *sddsfile, int32_t index) {
2054 return(((SDDSFile*)sddsfile)->getParameterSymbol(index));
2055}
2056
2057/***********************************************************************************************
2058 * getColumnSymbol *
2059 * *
2060 * C++ Arguments: int32_t index *
2061 * char *name *
2062 * *
2063 * C Arguments: void *sddsfile, int32_t index *
2064 * *
2065 * Results: pointer to symbol on success (do not free result) *
2066 * NULL if symbol not defined *
2067 ***********************************************************************************************/
2068char* SDDSFile::getColumnSymbol(int32_t index) {
2069 if ((index < 0) || (index >= columnCount))
2070 return(NULL);
2071 return(columnObject[index]->getSymbol());
2072}
2073char* SDDSFile::getColumnSymbol(char *name) {
2074 int32_t index;
2075 index = getColumnIndex(name);
2076 if ((index < 0) || (index >= columnCount))
2077 return(NULL);
2078 return(columnObject[index]->getSymbol());
2079}
2080char* SDDSFile_getColumnSymbol(void *sddsfile, int32_t index) {
2081 return(((SDDSFile*)sddsfile)->getColumnSymbol(index));
2082}
2083
2084/*
2085 * getArraySymbols
2086 *
2087 * C++ Arguments: none
2088 *
2089 * C Arguments: void *sddsfile
2090 *
2091 * Results: pointer to array of symbols on success (you must free the pointer but not the
2092 * elements inside the pointer)
2093 * elements inside the array may be NULL if unit not defined
2094 */
2095char** SDDSFile::getArraySymbols() {
2096 int32_t i;
2097 char **symbols;
2098 symbols = (char**)SDDS_malloc(sizeof(char*) * arrayCount);
2099 for (i=0;i<arrayCount;i++) {
2100 symbols[i] = getArraySymbol(i);
2101 }
2102 return(symbols);
2103}
2104char** SDDSFile_getArraySymbols(void *sddsfile) {
2105 return(((SDDSFile*)sddsfile)->getArraySymbols());
2106}
2107
2108/*
2109 * getParameterSymbols
2110 *
2111 * C++ Arguments: none
2112 *
2113 * C Arguments: void *sddsfile
2114 *
2115 * Results: pointer to array of symbols on success (you must free the pointer but not the
2116 * elements inside the pointer)
2117 * elements inside the array may be NULL if unit not defined
2118 */
2119char** SDDSFile::getParameterSymbols() {
2120 int32_t i;
2121 char **symbols;
2122 symbols = (char**)SDDS_malloc(sizeof(char*) * parameterCount);
2123 for (i=0;i<parameterCount;i++) {
2124 symbols[i] = getParameterSymbol(i);
2125 }
2126 return(symbols);
2127}
2128char** SDDSFile_getParameterSymbols(void *sddsfile) {
2129 return(((SDDSFile*)sddsfile)->getParameterSymbols());
2130}
2131
2132/***********************************************************************************************
2133 * getColumnSymbols *
2134 * *
2135 * C++ Arguments: none *
2136 * *
2137 * C Arguments: void *sddsfile *
2138 * *
2139 * Results: pointer to array of symbols on success (you must free the pointer but not the *
2140 * elements inside the pointer) *
2141 * elements inside the array may be NULL if unit not defined *
2142 ***********************************************************************************************/
2143char** SDDSFile::getColumnSymbols() {
2144 int32_t i;
2145 char **symbols;
2146 symbols = (char**)SDDS_malloc(sizeof(char*) * columnCount);
2147 for (i=0;i<columnCount;i++) {
2148 symbols[i] = getColumnSymbol(i);
2149 }
2150 return(symbols);
2151}
2152char** SDDSFile_getColumnSymbols(void *sddsfile) {
2153 return(((SDDSFile*)sddsfile)->getColumnSymbols());
2154}
2155
2156/*
2157 * getArrayFormatString
2158 *
2159 * C++ Arguments: int32_t index
2160 * char *name
2161 *
2162 * C Arguments: void *sddsfile, int32_t index
2163 *
2164 * Results: pointer to format string on success (do not free result)
2165 * NULL if format string not defined
2166 */
2167char* SDDSFile::getArrayFormatString(int32_t index) {
2168 if ((index < 0) || (index >= arrayCount))
2169 return(NULL);
2170 return(arrayObject[index]->getFormatString());
2171}
2172char* SDDSFile::getArrayFormatString(char *name) {
2173 int32_t index;
2174 index = getArrayIndex(name);
2175 if ((index < 0) || (index >= arrayCount))
2176 return(NULL);
2177 return(arrayObject[index]->getFormatString());
2178}
2179char* SDDSFile_getArrayFormatString(void *sddsfile, int32_t index) {
2180 return(((SDDSFile*)sddsfile)->getArrayFormatString(index));
2181}
2182
2183/*
2184 * getParameterFormatString
2185 *
2186 * C++ Arguments: int32_t index
2187 * char *name
2188 *
2189 * C Arguments: void *sddsfile, int32_t index
2190 *
2191 * Results: pointer to format string on success (do not free result)
2192 * NULL if format string not defined
2193 */
2194char* SDDSFile::getParameterFormatString(int32_t index) {
2195 if ((index < 0) || (index >= parameterCount))
2196 return(NULL);
2197 return(parameterObject[index]->getFormatString());
2198}
2199char* SDDSFile::getParameterFormatString(char *name) {
2200 int32_t index;
2201 index = getParameterIndex(name);
2202 if ((index < 0) || (index >= parameterCount))
2203 return(NULL);
2204 return(parameterObject[index]->getFormatString());
2205}
2206char* SDDSFile_getParameterFormatString(void *sddsfile, int32_t index) {
2207 return(((SDDSFile*)sddsfile)->getParameterFormatString(index));
2208}
2209
2210/***********************************************************************************************
2211 * getColumnFormatString *
2212 * *
2213 * C++ Arguments: int32_t index *
2214 * char *name *
2215 * *
2216 * C Arguments: void *sddsfile, int32_t index *
2217 * *
2218 * Results: pointer to format string on success (do not free result) *
2219 * NULL if format string not defined *
2220 ***********************************************************************************************/
2221char* SDDSFile::getColumnFormatString(int32_t index) {
2222 if ((index < 0) || (index >= columnCount))
2223 return(NULL);
2224 return(columnObject[index]->getFormatString());
2225}
2226char* SDDSFile::getColumnFormatString(char *name) {
2227 int32_t index;
2228 index = getColumnIndex(name);
2229 if ((index < 0) || (index >= columnCount))
2230 return(NULL);
2231 return(columnObject[index]->getFormatString());
2232}
2233char* SDDSFile_getColumnFormatString(void *sddsfile, int32_t index) {
2234 return(((SDDSFile*)sddsfile)->getColumnFormatString(index));
2235}
2236
2237/*
2238 * getArrayFormatStrings
2239 *
2240 * C++ Arguments: none
2241 *
2242 * C Arguments: void *sddsfile
2243 *
2244 * Results: pointer to array of format strings on success (you must free the pointer but not
2245 * the elements inside the pointer)
2246 * elements inside the array may be NULL if unit not defined
2247 */
2248char** SDDSFile::getArrayFormatStrings() {
2249 int32_t i;
2250 char **format_strings;
2251 format_strings = (char**)SDDS_malloc(sizeof(char*) * arrayCount);
2252 for (i=0;i<arrayCount;i++) {
2253 format_strings[i] = getArrayFormatString(i);
2254 }
2255 return(format_strings);
2256}
2257char** SDDSFile_getArrayFormatStrings(void *sddsfile) {
2258 return(((SDDSFile*)sddsfile)->getArrayFormatStrings());
2259}
2260
2261/*
2262 * getParameterFormatStrings
2263 *
2264 * C++ Arguments: none
2265 *
2266 * C Arguments: void *sddsfile
2267 *
2268 * Results: pointer to array of format strings on success (you must free the pointer but not
2269 * the elements inside the pointer)
2270 * elements inside the array may be NULL if unit not defined
2271 */
2272char** SDDSFile::getParameterFormatStrings() {
2273 int32_t i;
2274 char **format_strings;
2275 format_strings = (char**)SDDS_malloc(sizeof(char*) * parameterCount);
2276 for (i=0;i<parameterCount;i++) {
2277 format_strings[i] = getParameterFormatString(i);
2278 }
2279 return(format_strings);
2280}
2281char** SDDSFile_getParameterFormatStrings(void *sddsfile) {
2282 return(((SDDSFile*)sddsfile)->getParameterFormatStrings());
2283}
2284
2285/***********************************************************************************************
2286 * getColumnFormatStrings *
2287 * *
2288 * C++ Arguments: none *
2289 * *
2290 * C Arguments: void *sddsfile *
2291 * *
2292 * Results: pointer to array of format strings on success (you must free the pointer but not *
2293 * the elements inside the pointer) *
2294 * elements inside the array may be NULL if unit not defined *
2295 ***********************************************************************************************/
2296char** SDDSFile::getColumnFormatStrings() {
2297 int32_t i;
2298 char **format_strings;
2299 format_strings = (char**)SDDS_malloc(sizeof(char*) * columnCount);
2300 for (i=0;i<columnCount;i++) {
2301 format_strings[i] = getColumnFormatString(i);
2302 }
2303 return(format_strings);
2304}
2305char** SDDSFile_getColumnFormatStrings(void *sddsfile) {
2306 return(((SDDSFile*)sddsfile)->getColumnFormatStrings());
2307}
2308
2309/*
2310 * getArrayType
2311 *
2312 * C++ Arguments: int32_t index
2313 * char *name
2314 *
2315 * C Arguments: void *sddsfile, int32_t index
2316 *
2317 * Results: int32 representing the array type
2318 * 0 if array type not defined
2319 */
2320int32_t SDDSFile::getArrayType(int32_t index) {
2321 if ((index < 0) || (index >= arrayCount))
2322 return(0);
2323 return(arrayObject[index]->getType());
2324}
2325int32_t SDDSFile::getArrayType(char *name) {
2326 int32_t index;
2327 index = getArrayIndex(name);
2328 if ((index < 0) || (index >= arrayCount))
2329 return(0);
2330 return(arrayObject[index]->getType());
2331}
2332int32_t SDDSFile_getArrayType(void *sddsfile, int32_t index) {
2333 return(((SDDSFile*)sddsfile)->getArrayType(index));
2334}
2335
2336/*
2337 * getParameterType
2338 *
2339 * C++ Arguments: int32_t index
2340 * char *name
2341 *
2342 * C Arguments: void *sddsfile, int32_t index
2343 *
2344 * Results: int32 representing the parameter type
2345 * 0 if parameter type not defined
2346 */
2347int32_t SDDSFile::getParameterType(int32_t index) {
2348 if ((index < 0) || (index >= parameterCount))
2349 return(0);
2350 return(parameterObject[index]->getType());
2351}
2352int32_t SDDSFile::getParameterType(char *name) {
2353 int32_t index;
2354 index = getParameterIndex(name);
2355 if ((index < 0) || (index >= parameterCount))
2356 return(0);
2357 return(parameterObject[index]->getType());
2358}
2359int32_t SDDSFile_getParameterType(void *sddsfile, int32_t index) {
2360 return(((SDDSFile*)sddsfile)->getParameterType(index));
2361}
2362
2363/***********************************************************************************************
2364 * getColumnType *
2365 * *
2366 * C++ Arguments: int32_t index *
2367 * char *name *
2368 * *
2369 * C Arguments: void *sddsfile, int32_t index *
2370 * *
2371 * Results: int32 representing the column type *
2372 * 0 if column type not defined *
2373 ***********************************************************************************************/
2374int32_t SDDSFile::getColumnType(int32_t index) {
2375 if ((index < 0) || (index >= columnCount))
2376 return(0);
2377 return(columnObject[index]->getType());
2378}
2379int32_t SDDSFile::getColumnType(char *name) {
2380 int32_t index;
2381 index = getColumnIndex(name);
2382 if ((index < 0) || (index >= columnCount))
2383 return(0);
2384 return(columnObject[index]->getType());
2385}
2386int32_t SDDSFile_getColumnType(void *sddsfile, int32_t index) {
2387 return(((SDDSFile*)sddsfile)->getColumnType(index));
2388}
2389
2390/*
2391 * getArrayTypes
2392 *
2393 * C++ Arguments: none
2394 *
2395 * C Arguments: void *sddsfile
2396 *
2397 * Results: pointer to array of array types on success (you must free the pointer)
2398 * elements inside the array may be 0 if unit not defined
2399 */
2400int32_t* SDDSFile::getArrayTypes() {
2401 int32_t i;
2402 int32_t *types;
2403 types = (int32_t*)SDDS_malloc(sizeof(int32_t) * arrayCount);
2404 for (i=0;i<arrayCount;i++) {
2405 types[i] = getArrayType(i);
2406 }
2407 return(types);
2408}
2409int32_t* SDDSFile_getArrayTypes(void *sddsfile) {
2410 return(((SDDSFile*)sddsfile)->getArrayTypes());
2411}
2412
2413/*
2414 * getParameterTypes
2415 *
2416 * C++ Arguments: none
2417 *
2418 * C Arguments: void *sddsfile
2419 *
2420 * Results: pointer to array of parameter types on success (you must free the pointer)
2421 * elements inside the array may be 0 if unit not defined
2422 */
2423int32_t* SDDSFile::getParameterTypes() {
2424 int32_t i;
2425 int32_t *types;
2426 types = (int32_t*)SDDS_malloc(sizeof(int32_t) * parameterCount);
2427 for (i=0;i<parameterCount;i++) {
2428 types[i] = getParameterType(i);
2429 }
2430 return(types);
2431}
2432int32_t* SDDSFile_getParameterTypes(void *sddsfile) {
2433 return(((SDDSFile*)sddsfile)->getParameterTypes());
2434}
2435
2436/***********************************************************************************************
2437 * getColumnTypes *
2438 * *
2439 * C++ Arguments: none *
2440 * *
2441 * C Arguments: void *sddsfile *
2442 * *
2443 * Results: pointer to array of column types on success (you must free the pointer) *
2444 * elements inside the array may be 0 if unit not defined *
2445 ***********************************************************************************************/
2446int32_t* SDDSFile::getColumnTypes() {
2447 int32_t i;
2448 int32_t *types;
2449 types = (int32_t*)SDDS_malloc(sizeof(int32_t) * columnCount);
2450 for (i=0;i<columnCount;i++) {
2451 types[i] = getColumnType(i);
2452 }
2453 return(types);
2454}
2455int32_t* SDDSFile_getColumnTypes(void *sddsfile) {
2456 return(((SDDSFile*)sddsfile)->getColumnTypes());
2457}
2458
2459/*
2460 * getArrayDescription
2461 *
2462 * C++ Arguments: int32_t index
2463 * char *name
2464 *
2465 * C Arguments: void *sddsfile, int32_t index
2466 *
2467 * Results: pointer to description on success (do not free result)
2468 * NULL if description not defined
2469 */
2470char* SDDSFile::getArrayDescription(int32_t index) {
2471 if ((index < 0) || (index >= arrayCount))
2472 return(NULL);
2473 return(arrayObject[index]->getDescription());
2474}
2475char* SDDSFile::getArrayDescription(char *name) {
2476 int32_t index;
2477 index = getArrayIndex(name);
2478 if ((index < 0) || (index >= arrayCount))
2479 return(NULL);
2480 return(arrayObject[index]->getDescription());
2481}
2482char* SDDSFile_getArrayDescription(void *sddsfile, int32_t index) {
2483 return(((SDDSFile*)sddsfile)->getArrayDescription(index));
2484}
2485
2486/*
2487 * getParameterDescription
2488 *
2489 * C++ Arguments: int32_t index
2490 * char *name
2491 *
2492 * C Arguments: void *sddsfile, int32_t index
2493 *
2494 * Results: pointer to description on success (do not free result)
2495 * NULL if description not defined
2496 */
2497char* SDDSFile::getParameterDescription(int32_t index) {
2498 if ((index < 0) || (index >= parameterCount))
2499 return(NULL);
2500 return(parameterObject[index]->getDescription());
2501}
2502char* SDDSFile::getParameterDescription(char *name) {
2503 int32_t index;
2504 index = getParameterIndex(name);
2505 if ((index < 0) || (index >= parameterCount))
2506 return(NULL);
2507 return(parameterObject[index]->getDescription());
2508}
2509char* SDDSFile_getParameterDescription(void *sddsfile, int32_t index) {
2510 return(((SDDSFile*)sddsfile)->getParameterDescription(index));
2511}
2512
2513/***********************************************************************************************
2514 * getColumnDescription *
2515 * *
2516 * C++ Arguments: int32_t index *
2517 * char *name *
2518 * *
2519 * C Arguments: void *sddsfile, int32_t index *
2520 * *
2521 * Results: pointer to description on success (do not free result) *
2522 * NULL if description not defined *
2523 ***********************************************************************************************/
2524char* SDDSFile::getColumnDescription(int32_t index) {
2525 if ((index < 0) || (index >= columnCount))
2526 return(NULL);
2527 return(columnObject[index]->getDescription());
2528}
2529char* SDDSFile::getColumnDescription(char *name) {
2530 int32_t index;
2531 index = getColumnIndex(name);
2532 if ((index < 0) || (index >= columnCount))
2533 return(NULL);
2534 return(columnObject[index]->getDescription());
2535}
2536char* SDDSFile_getColumnDescription(void *sddsfile, int32_t index) {
2537 return(((SDDSFile*)sddsfile)->getColumnDescription(index));
2538}
2539
2540/*
2541 * getArrayDescriptions
2542 *
2543 * C++ Arguments: none
2544 *
2545 * C Arguments: void *sddsfile
2546 *
2547 * Results: pointer to array of descriptions on success (you must free the pointer but not
2548 * the elements inside the pointer)
2549 * elements inside the array may be NULL if unit not defined
2550 */
2551char** SDDSFile::getArrayDescriptions() {
2552 int32_t i;
2553 char **descriptions;
2554 descriptions = (char**)SDDS_malloc(sizeof(char*) * arrayCount);
2555 for (i=0;i<arrayCount;i++) {
2556 descriptions[i] = getArrayDescription(i);
2557 }
2558 return(descriptions);
2559}
2560char** SDDSFile_getArrayDescriptions(void *sddsfile) {
2561 return(((SDDSFile*)sddsfile)->getArrayDescriptions());
2562}
2563
2564/*
2565 * getParameterDescriptions
2566 *
2567 * C++ Arguments: none
2568 *
2569 * C Arguments: void *sddsfile
2570 *
2571 * Results: pointer to array of descriptions on success (you must free the pointer but not
2572 * the elements inside the pointer)
2573 * elements inside the array may be NULL if unit not defined
2574 */
2575char** SDDSFile::getParameterDescriptions() {
2576 int32_t i;
2577 char **descriptions;
2578 descriptions = (char**)SDDS_malloc(sizeof(char*) * parameterCount);
2579 for (i=0;i<parameterCount;i++) {
2580 descriptions[i] = getParameterDescription(i);
2581 }
2582 return(descriptions);
2583}
2584char** SDDSFile_getParameterDescriptions(void *sddsfile) {
2585 return(((SDDSFile*)sddsfile)->getParameterDescriptions());
2586}
2587
2588/***********************************************************************************************
2589 * getColumnDescriptions *
2590 * *
2591 * C++ Arguments: none *
2592 * *
2593 * C Arguments: void *sddsfile *
2594 * *
2595 * Results: pointer to array of descriptions on success (you must free the pointer but not *
2596 * the elements inside the pointer) *
2597 * elements inside the array may be NULL if unit not defined *
2598 ***********************************************************************************************/
2599char** SDDSFile::getColumnDescriptions() {
2600 int32_t i;
2601 char **descriptions;
2602 descriptions = (char**)SDDS_malloc(sizeof(char*) * columnCount);
2603 for (i=0;i<columnCount;i++) {
2604 descriptions[i] = getColumnDescription(i);
2605 }
2606 return(descriptions);
2607}
2608char** SDDSFile_getColumnDescriptions(void *sddsfile) {
2609 return(((SDDSFile*)sddsfile)->getColumnDescriptions());
2610}
2611
2612/*
2613 * getArrayGroupName
2614 *
2615 * C++ Arguments: int32_t index
2616 * char *name
2617 *
2618 * C Arguments: void *sddsfile, int32_t index
2619 *
2620 * Results: pointer to group name on success (do not free result)
2621 * NULL if group name not defined
2622 */
2623char* SDDSFile::getArrayGroupName(int32_t index) {
2624 if ((index < 0) || (index >= arrayCount))
2625 return(NULL);
2626 return(arrayObject[index]->getGroupName());
2627}
2628char* SDDSFile::getArrayGroupName(char *name) {
2629 int32_t index;
2630 index = getArrayIndex(name);
2631 if ((index < 0) || (index >= arrayCount))
2632 return(NULL);
2633 return(arrayObject[index]->getGroupName());
2634}
2635char* SDDSFile_getArrayGroupName(void *sddsfile, int32_t index) {
2636 return(((SDDSFile*)sddsfile)->getArrayGroupName(index));
2637}
2638
2639/*
2640 * getArrayGroupNames
2641 *
2642 * C++ Arguments: none
2643 *
2644 * C Arguments: void *sddsfile
2645 *
2646 * Results: pointer to array of group names on success (you must free the pointer but not
2647 * the elements inside the pointer)
2648 * elements inside the array may be NULL if unit not defined
2649 */
2650char** SDDSFile::getArrayGroupNames() {
2651 int32_t i;
2652 char **group_names;
2653 group_names = (char**)SDDS_malloc(sizeof(char*) * arrayCount);
2654 for (i=0;i<arrayCount;i++) {
2655 group_names[i] = getArrayGroupName(i);
2656 }
2657 return(group_names);
2658}
2659char** SDDSFile_getArrayGroupNames(void *sddsfile) {
2660 return(((SDDSFile*)sddsfile)->getArrayGroupNames());
2661}
2662
2663/***********************************************************************************************
2664 * getParameterFixedValue *
2665 * *
2666 * C++ Arguments: int32_t index *
2667 * char *name *
2668 * *
2669 * C Arguments: void *sddsfile, int32_t index *
2670 * *
2671 * Results: pointer to fixed value on success (do not free result) *
2672 * NULL if fixed value not defined *
2673 ***********************************************************************************************/
2674char* SDDSFile::getParameterFixedValue(int32_t index) {
2675 if ((index < 0) || (index >= parameterCount))
2676 return(NULL);
2677 return(parameterObject[index]->getFixedValue());
2678}
2679char* SDDSFile::getParameterFixedValue(char *name) {
2680 int32_t index;
2681 index = getParameterIndex(name);
2682 if ((index < 0) || (index >= parameterCount))
2683 return(NULL);
2684 return(parameterObject[index]->getFixedValue());
2685}
2686char* SDDSFile_getParameterFixedValue(void *sddsfile, int32_t index) {
2687 return(((SDDSFile*)sddsfile)->getParameterFixedValue(index));
2688}
2689
2690/***********************************************************************************************
2691 * getParameterFixedValues *
2692 * *
2693 * C++ Arguments: none *
2694 * *
2695 * C Arguments: void *sddsfile *
2696 * *
2697 * Results: pointer to array of fixed values on success (you must free the pointer but not *
2698 * the elements inside the pointer) *
2699 * elements inside the array may be NULL if unit not defined *
2700 ***********************************************************************************************/
2701char** SDDSFile::getParameterFixedValues() {
2702 int32_t i;
2703 char **fixed_values;
2704 fixed_values = (char**)SDDS_malloc(sizeof(char*) * parameterCount);
2705 for (i=0;i<parameterCount;i++) {
2706 fixed_values[i] = getParameterFixedValue(i);
2707 }
2708 return(fixed_values);
2709}
2710char** SDDSFile_getParameterFixedValues(void *sddsfile) {
2711 return(((SDDSFile*)sddsfile)->getParameterFixedValues());
2712}
2713
2714/*
2715 * getArrayFieldLength
2716 *
2717 * C++ Arguments: int32_t index
2718 * char *name
2719 *
2720 * C Arguments: void *sddsfile, int32_t index
2721 *
2722 * Results: uint32 representing the array field length
2723 * 0 if array type not defined
2724 */
2725uint32_t SDDSFile::getArrayFieldLength(int32_t index) {
2726 if ((index < 0) || (index >= arrayCount))
2727 return(0);
2728 return(arrayObject[index]->getFieldLength());
2729}
2730uint32_t SDDSFile::getArrayFieldLength(char *name) {
2731 int32_t index;
2732 index = getArrayIndex(name);
2733 if ((index < 0) || (index >= arrayCount))
2734 return(0);
2735 return(arrayObject[index]->getFieldLength());
2736}
2737uint32_t SDDSFile_getArrayFieldLength(void *sddsfile, int32_t index) {
2738 return(((SDDSFile*)sddsfile)->getArrayFieldLength(index));
2739}
2740
2741/*
2742 * getArrayFieldLengths
2743 *
2744 * C++ Arguments: none
2745 *
2746 * C Arguments: void *sddsfile
2747 *
2748 * Results: pointer to array of array field lengths on success (you must free the pointer)
2749 * elements inside the array may be 0 if unit not defined
2750 */
2751uint32_t* SDDSFile::getArrayFieldLengths() {
2752 int32_t i;
2753 uint32_t *fls;
2754 fls = (uint32_t*)SDDS_malloc(sizeof(uint32_t) * arrayCount);
2755 for (i=0;i<arrayCount;i++) {
2756 fls[i] = getArrayFieldLength(i);
2757 }
2758 return(fls);
2759}
2760uint32_t* SDDSFile_getArrayFieldLengths(void *sddsfile) {
2761 return(((SDDSFile*)sddsfile)->getArrayFieldLengths());
2762}
2763
2764/*
2765 * getArrayDimensions
2766 *
2767 * C++ Arguments: int32_t index
2768 * char *name
2769 *
2770 * C Arguments: void *sddsfile, int32_t index
2771 *
2772 * Results: uint32 representing the array dimension
2773 * 0 if array type not defined
2774 */
2775uint32_t SDDSFile::getArrayDimensions(int32_t index) {
2776 if ((index < 0) || (index >= arrayCount))
2777 return(0);
2778 return(arrayObject[index]->getDimensions());
2779}
2780uint32_t SDDSFile::getArrayDimensions(char *name) {
2781 int32_t index;
2782 index = getArrayIndex(name);
2783 if ((index < 0) || (index >= arrayCount))
2784 return(0);
2785 return(arrayObject[index]->getDimensions());
2786}
2787uint32_t SDDSFile_getArrayDimensions(void *sddsfile, int32_t index) {
2788 return(((SDDSFile*)sddsfile)->getArrayDimensions(index));
2789}
2790
2791/*
2792 * getAllArrayDimensions
2793 *
2794 * C++ Arguments: none
2795 *
2796 * C Arguments: void *sddsfile
2797 *
2798 * Results: pointer to array of array dimensions on success (you must free the pointer)
2799 * elements inside the array may be 0 if unit not defined
2800 */
2801uint32_t* SDDSFile::getAllArrayDimensions() {
2802 int32_t i;
2803 uint32_t *fls;
2804 fls = (uint32_t*)SDDS_malloc(sizeof(uint32_t) * arrayCount);
2805 for (i=0;i<arrayCount;i++) {
2806 fls[i] = getArrayDimensions(i);
2807 }
2808 return(fls);
2809}
2810uint32_t* SDDSFile_getAllArrayDimensions(void *sddsfile) {
2811 return(((SDDSFile*)sddsfile)->getAllArrayDimensions());
2812}
2813
2814/*
2815 * getColumnFieldLength
2816 *
2817 * C++ Arguments: int32_t index
2818 * char *name
2819 *
2820 * C Arguments: void *sddsfile, int32_t index
2821 *
2822 * Results: uint32 representing the column field length
2823 * 0 if column type not defined
2824 */
2825uint32_t SDDSFile::getColumnFieldLength(int32_t index) {
2826 if ((index < 0) || (index >= columnCount))
2827 return(0);
2828 return(columnObject[index]->getFieldLength());
2829}
2830uint32_t SDDSFile::getColumnFieldLength(char *name) {
2831 int32_t index;
2832 index = getColumnIndex(name);
2833 if ((index < 0) || (index >= columnCount))
2834 return(0);
2835 return(columnObject[index]->getFieldLength());
2836}
2837uint32_t SDDSFile_getColumnFieldLength(void *sddsfile, int32_t index) {
2838 return(((SDDSFile*)sddsfile)->getColumnFieldLength(index));
2839}
2840
2841/*
2842 * getColumnFieldLengths
2843 *
2844 * C++ Arguments: none
2845 *
2846 * C Arguments: void *sddsfile
2847 *
2848 * Results: pointer to array of column field lengths on success (you must free the pointer)
2849 * elements inside the array may be 0 if unit not defined
2850 */
2851uint32_t* SDDSFile::getColumnFieldLengths() {
2852 int32_t i;
2853 uint32_t *fls;
2854 fls = (uint32_t*)SDDS_malloc(sizeof(uint32_t) * columnCount);
2855 for (i=0;i<columnCount;i++) {
2856 fls[i] = getColumnFieldLength(i);
2857 }
2858 return(fls);
2859}
2860uint32_t* SDDSFile_getColumnFieldLengths(void *sddsfile) {
2861 return(((SDDSFile*)sddsfile)->getColumnFieldLengths());
2862}
2863
2864/*
2865 * getArrayIndex
2866 *
2867 * C++ Arguments: char *name
2868 *
2869 * C Arguments: void *sddsfile, char *name
2870 *
2871 * Results: array index on success
2872 * -1 on failure (calling program should call printErrors)
2873 */
2874int32_t SDDSFile::getArrayIndex(char *name) {
2875 int32_t i;
2876 char s[SDDS_MAXLINE];
2877 for ( i=0 ; i<arrayCount ; i++ )
2878 if (strcmp(name, arrayObject[i]->getName()) == 0)
2879 return(i);
2880 sprintf(s, "Warning: array %s does not exist (SDDSFile::getArrayIndex)", name);
2881 setError(s);
2882 return(-1);
2883}
2884int32_t SDDSFile_getArrayIndex(void *sddsfile, char *name) {
2885 return(((SDDSFile*)sddsfile)->getArrayIndex(name));
2886}
2887
2888/*
2889 * getParameterIndex
2890 *
2891 * C++ Arguments: char *name
2892 *
2893 * C Arguments: void *sddsfile, char *name
2894 *
2895 * Results: parameter index on success
2896 * -1 on failure (calling program should call printErrors)
2897 */
2898int32_t SDDSFile::getParameterIndex(char *name) {
2899 int32_t i;
2900 char s[SDDS_MAXLINE];
2901 for ( i=0 ; i<parameterCount ; i++ )
2902 if (strcmp(name, parameterObject[i]->getName()) == 0)
2903 return(i);
2904 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterIndex)", name);
2905 setError(s);
2906 return(-1);
2907}
2908int32_t SDDSFile_getParameterIndex(void *sddsfile, char *name) {
2909 return(((SDDSFile*)sddsfile)->getParameterIndex(name));
2910}
2911
2912/***********************************************************************************************
2913 * getColumnIndex *
2914 * *
2915 * C++ Arguments: char *name *
2916 * *
2917 * C Arguments: void *sddsfile, char *name *
2918 * *
2919 * Results: column index on success *
2920 * -1 on failure (calling program should call printErrors) *
2921 ***********************************************************************************************/
2922int32_t SDDSFile::getColumnIndex(char *name) {
2923 int32_t i;
2924 char s[SDDS_MAXLINE];
2925 for ( i=0 ; i<columnCount ; i++ )
2926 if (strcmp(name, columnObject[i]->getName()) == 0)
2927 return(i);
2928 sprintf(s, "Warning: column %s does not exist (SDDSFile::getColumnIndex)", name);
2929 setError(s);
2930 return(-1);
2931}
2932int32_t SDDSFile_getColumnIndex(void *sddsfile, char *name) {
2933 return(((SDDSFile*)sddsfile)->getColumnIndex(name));
2934}
2935
2936/*
2937 * getArrayIndexes
2938 *
2939 * C++ Arguments: char **names, int32_t numberOfNames
2940 *
2941 * C Arguments: void *sddsfile, char **names, int32_t numberOfNames
2942 *
2943 * Results: array of array indexes on success (you must free the pointer)
2944 * an element in the array may be -1 if there was a problem (calling program should
2945 * call printErrors)
2946 */
2947int32_t* SDDSFile::getArrayIndexes(char** names, int32_t number) {
2948 int32_t *n;
2949 int32_t i;
2950 n = (int32_t*)SDDS_malloc(sizeof(int32_t) * number);
2951 for (i=0 ; i<number ; i++)
2952 n[i] = getArrayIndex(names[i]);
2953 return(n);
2954}
2955int32_t* SDDSFile_getArrayIndexes(void *sddsfile, char** names, int32_t number) {
2956 return(((SDDSFile*)sddsfile)->getArrayIndexes(names, number));
2957}
2958
2959/*
2960 * getParameterIndexes
2961 *
2962 * C++ Arguments: char **names, int32_t numberOfNames
2963 *
2964 * C Arguments: void *sddsfile, char **names, int32_t numberOfNames
2965 *
2966 * Results: array of parameter indexes on success (you must free the pointer)
2967 * an element in the array may be -1 if there was a problem (calling program should
2968 * call printErrors)
2969 */
2970int32_t* SDDSFile::getParameterIndexes(char** names, int32_t number) {
2971 int32_t *n;
2972 int32_t i;
2973 n = (int32_t*)SDDS_malloc(sizeof(int32_t) * number);
2974 for (i=0 ; i<number ; i++)
2975 n[i] = getParameterIndex(names[i]);
2976 return(n);
2977}
2978int32_t* SDDSFile_getParameterIndexes(void *sddsfile, char** names, int32_t number) {
2979 return(((SDDSFile*)sddsfile)->getParameterIndexes(names, number));
2980}
2981
2982/***********************************************************************************************
2983 * getColumnIndexes *
2984 * *
2985 * C++ Arguments: char **names, int32_t numberOfNames *
2986 * *
2987 * C Arguments: void *sddsfile, char **names, int32_t numberOfNames *
2988 * *
2989 * Results: array of column indexes on success (you must free the pointer) *
2990 * an element in the array may be -1 if there was a problem (calling program should *
2991 * call printErrors) *
2992 ***********************************************************************************************/
2993int32_t* SDDSFile::getColumnIndexes(char** names, int32_t number) {
2994 int32_t *n;
2995 int32_t i;
2996 n = (int32_t*)SDDS_malloc(sizeof(int32_t) * number);
2997 for (i=0 ; i<number ; i++)
2998 n[i] = getColumnIndex(names[i]);
2999 return(n);
3000}
3001int32_t* SDDSFile_getColumnIndexes(void *sddsfile, char** names, int32_t number) {
3002 return(((SDDSFile*)sddsfile)->getColumnIndexes(names, number));
3003}
3004
3005/*
3006 * setArray
3007 *
3008 * C++ Arguments: int32_t arrayIndex, uint32_t page, int32_t *values, uint32_t elements
3009 * char *name, uint32_t page, int32_t *values, uint32_t elements
3010 * int32_t arrayIndex, uint32_t page, uint32_t *values, uint32_t elements
3011 * char *name, uint32_t page, uint32_t *values, uint32_t elements
3012 * int32_t arrayIndex, uint32_t page, double *values, uint32_t elements
3013 * char *name, uint32_t page, double *values, uint32_t elements
3014 * int32_t arrayIndex, uint32_t page, char **values, uint32_t elements
3015 * char *name, uint32_t page, char **values, uint32_t elements
3016 *
3017 * C Arguments: void *sddsfile, uint32_t page, uint32_t elements, int32_t mode, ...
3018 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_INT16,
3019 * int32_t arrayIndex, int16_t *value
3020 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_INT16,
3021 * char *name, int16_t *value
3022 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_UINT16,
3023 * int32_t arrayIndex, uint16_t *value
3024 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_UINT16,
3025 * char *name, uint16_t *value
3026 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_INT32,
3027 * int32_t arrayIndex, int32_t *value
3028 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_INT32,
3029 * char *name, int32_t *value
3030 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_UINT32,
3031 * int32_t arrayIndex, uint32_t *value
3032 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_UINT32,
3033 * char *name, uint32_t *value
3034 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_REAL32,
3035 * int32_t arrayIndex, float *value
3036 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_REAL32,
3037 * char *name, float *value
3038 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_REAL64,
3039 * int32_t arrayIndex, double *value
3040 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_REAL64,
3041 * char *name, double *value
3042 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_STRING,
3043 * int32_t arrayIndex, char **value
3044 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_STRING,
3045 * char *name, char **value
3046 * mode=SDDSFILE_SETARRAY_WITH_INDEX+SDDSFILE_SETARRAY_WITH_CHARACTER,
3047 * int32_t arrayIndex, char *value
3048 * mode=SDDSFILE_SETARRAY_WITH_NAME+SDDSFILE_SETARRAY_WITH_CHARACTER,
3049 * char *name, char *value
3050 *
3051 * Results: 0 for success
3052 * 1 for failure : calling program should call printErrors
3053 */
3054int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, int16_t *values, uint32_t elements) {
3055 int32_t result;
3056 char s[SDDS_MAXLINE];
3057 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3058 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3059 setError(s);
3060 return(1);
3061 }
3062 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3063 if (result == 0) {
3064 return(0);
3065 } else if (result == 1) {
3066 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3067 return(1);
3068 } else if (result == 2) {
3069 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3070 return(1);
3071 } else if (result == 3) {
3072 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3073 return(1);
3074 }
3075 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3076 return(1);
3077}
3078
3079int32_t SDDSFile::setArray(char *name, uint32_t page, int16_t *values, uint32_t elements) {
3080 int32_t arrayIndex, result;
3081 char s[SDDS_MAXLINE];
3082 arrayIndex = getArrayIndex(name);
3083 if (arrayIndex < 0) {
3084 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3085 setError(s);
3086 return(1);
3087 }
3088 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3089 if (result == 0) {
3090 return(0);
3091 } else if (result == 1) {
3092 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3093 return(1);
3094 } else if (result == 2) {
3095 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3096 return(1);
3097 } else if (result == 3) {
3098 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3099 return(1);
3100 }
3101 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3102 return(1);
3103}
3104
3105int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, uint16_t *values, uint32_t elements) {
3106 int32_t result;
3107 char s[SDDS_MAXLINE];
3108 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3109 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3110 setError(s);
3111 return(1);
3112 }
3113 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3114 if (result == 0) {
3115 return(0);
3116 } else if (result == 1) {
3117 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3118 return(1);
3119 } else if (result == 2) {
3120 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3121 return(1);
3122 } else if (result == 3) {
3123 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3124 return(1);
3125 }
3126 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3127 return(1);
3128}
3129
3130int32_t SDDSFile::setArray(char *name, uint32_t page, uint16_t *values, uint32_t elements) {
3131 int32_t arrayIndex, result;
3132 char s[SDDS_MAXLINE];
3133 arrayIndex = getArrayIndex(name);
3134 if (arrayIndex < 0) {
3135 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3136 setError(s);
3137 return(1);
3138 }
3139 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3140 if (result == 0) {
3141 return(0);
3142 } else if (result == 1) {
3143 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3144 return(1);
3145 } else if (result == 2) {
3146 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3147 return(1);
3148 } else if (result == 3) {
3149 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3150 return(1);
3151 }
3152 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3153 return(1);
3154}
3155
3156int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, int32_t *values, uint32_t elements) {
3157 int32_t result;
3158 char s[SDDS_MAXLINE];
3159 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3160 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3161 setError(s);
3162 return(1);
3163 }
3164 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3165 if (result == 0) {
3166 return(0);
3167 } else if (result == 1) {
3168 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3169 return(1);
3170 } else if (result == 2) {
3171 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3172 return(1);
3173 } else if (result == 3) {
3174 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3175 return(1);
3176 }
3177 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3178 return(1);
3179}
3180
3181int32_t SDDSFile::setArray(char *name, uint32_t page, int32_t *values, uint32_t elements) {
3182 int32_t arrayIndex, result;
3183 char s[SDDS_MAXLINE];
3184 arrayIndex = getArrayIndex(name);
3185 if (arrayIndex < 0) {
3186 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3187 setError(s);
3188 return(1);
3189 }
3190 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3191 if (result == 0) {
3192 return(0);
3193 } else if (result == 1) {
3194 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3195 return(1);
3196 } else if (result == 2) {
3197 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3198 return(1);
3199 } else if (result == 3) {
3200 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3201 return(1);
3202 }
3203 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3204 return(1);
3205}
3206
3207int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, uint32_t *values, uint32_t elements) {
3208 int32_t result;
3209 char s[SDDS_MAXLINE];
3210 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3211 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3212 setError(s);
3213 return(1);
3214 }
3215 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3216 if (result == 0) {
3217 return(0);
3218 } else if (result == 1) {
3219 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3220 return(1);
3221 } else if (result == 2) {
3222 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3223 return(1);
3224 } else if (result == 3) {
3225 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3226 return(1);
3227 }
3228 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3229 return(1);
3230}
3231
3232int32_t SDDSFile::setArray(char *name, uint32_t page, uint32_t *values, uint32_t elements) {
3233 int32_t arrayIndex, result;
3234 char s[SDDS_MAXLINE];
3235 arrayIndex = getArrayIndex(name);
3236 if (arrayIndex < 0) {
3237 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3238 setError(s);
3239 return(1);
3240 }
3241 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3242 if (result == 0) {
3243 return(0);
3244 } else if (result == 1) {
3245 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3246 return(1);
3247 } else if (result == 2) {
3248 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3249 return(1);
3250 } else if (result == 3) {
3251 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3252 return(1);
3253 }
3254 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3255 return(1);
3256}
3257
3258int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, float *values, uint32_t elements) {
3259 int32_t result;
3260 char s[SDDS_MAXLINE];
3261 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3262 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3263 setError(s);
3264 return(1);
3265 }
3266 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3267 if (result == 0) {
3268 return(0);
3269 } else if (result == 1) {
3270 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3271 return(1);
3272 } else if (result == 2) {
3273 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3274 return(1);
3275 } else if (result == 3) {
3276 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3277 return(1);
3278 }
3279 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3280 return(1);
3281}
3282
3283int32_t SDDSFile::setArray(char *name, uint32_t page, float *values, uint32_t elements) {
3284 int32_t arrayIndex, result;
3285 char s[SDDS_MAXLINE];
3286 arrayIndex = getArrayIndex(name);
3287 if (arrayIndex < 0) {
3288 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3289 setError(s);
3290 return(1);
3291 }
3292 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3293 if (result == 0) {
3294 return(0);
3295 } else if (result == 1) {
3296 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3297 return(1);
3298 } else if (result == 2) {
3299 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3300 return(1);
3301 } else if (result == 3) {
3302 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3303 return(1);
3304 }
3305 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3306 return(1);
3307}
3308
3309int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, double *values, uint32_t elements) {
3310 int32_t result;
3311 char s[SDDS_MAXLINE];
3312 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3313 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3314 setError(s);
3315 return(1);
3316 }
3317 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3318 if (result == 0) {
3319 return(0);
3320 } else if (result == 1) {
3321 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3322 return(1);
3323 } else if (result == 2) {
3324 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3325 return(1);
3326 } else if (result == 3) {
3327 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3328 return(1);
3329 }
3330 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3331 return(1);
3332}
3333
3334int32_t SDDSFile::setArray(char *name, uint32_t page, double *values, uint32_t elements) {
3335 int32_t arrayIndex, result;
3336 char s[SDDS_MAXLINE];
3337 arrayIndex = getArrayIndex(name);
3338 if (arrayIndex < 0) {
3339 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3340 setError(s);
3341 return(1);
3342 }
3343 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3344 if (result == 0) {
3345 return(0);
3346 } else if (result == 1) {
3347 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3348 return(1);
3349 } else if (result == 2) {
3350 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3351 return(1);
3352 } else if (result == 3) {
3353 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3354 return(1);
3355 }
3356 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3357 return(1);
3358}
3359
3360int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, char **values, uint32_t elements) {
3361 int32_t result;
3362 char s[SDDS_MAXLINE];
3363 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3364 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3365 setError(s);
3366 return(1);
3367 }
3368 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3369 if (result == 0) {
3370 return(0);
3371 } else if (result == 1) {
3372 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3373 return(1);
3374 } else if (result == 2) {
3375 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3376 return(1);
3377 } else if (result == 3) {
3378 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3379 return(1);
3380 }
3381 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3382 return(1);
3383}
3384
3385int32_t SDDSFile::setArray(char *name, uint32_t page, char **values, uint32_t elements) {
3386 int32_t arrayIndex, result;
3387 char s[SDDS_MAXLINE];
3388 arrayIndex = getArrayIndex(name);
3389 if (arrayIndex < 0) {
3390 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3391 setError(s);
3392 return(1);
3393 }
3394 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3395 if (result == 0) {
3396 return(0);
3397 } else if (result == 1) {
3398 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3399 return(1);
3400 } else if (result == 2) {
3401 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3402 return(1);
3403 } else if (result == 3) {
3404 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3405 return(1);
3406 }
3407 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3408 return(1);
3409}
3410
3411int32_t SDDSFile::setArray(int32_t arrayIndex, uint32_t page, char *values, uint32_t elements) {
3412 int32_t result;
3413 char s[SDDS_MAXLINE];
3414 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
3415 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::setArray)", arrayIndex);
3416 setError(s);
3417 return(1);
3418 }
3419 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3420 if (result == 0) {
3421 return(0);
3422 } else if (result == 1) {
3423 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3424 return(1);
3425 } else if (result == 2) {
3426 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3427 return(1);
3428 } else if (result == 3) {
3429 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3430 return(1);
3431 }
3432 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3433 return(1);
3434}
3435
3436int32_t SDDSFile::setArray(char *name, uint32_t page, char *values, uint32_t elements) {
3437 int32_t arrayIndex, result;
3438 char s[SDDS_MAXLINE];
3439 arrayIndex = getArrayIndex(name);
3440 if (arrayIndex < 0) {
3441 sprintf(s, "Warning: array %s does not exist (SDDSFile::setArray)", name);
3442 setError(s);
3443 return(1);
3444 }
3445 result = arrayObject[arrayIndex]->setValues(values, page, elements);
3446 if (result == 0) {
3447 return(0);
3448 } else if (result == 1) {
3449 setError((char*)"Warning: invalid page number (SDDSFile::setArray)");
3450 return(1);
3451 } else if (result == 2) {
3452 setError((char*)"Warning: unable to convert given value to proper array type (SDDSFile::setArray)");
3453 return(1);
3454 } else if (result == 3) {
3455 setError((char*)"Warning: invalid array type (SDDSFile::setArray)");
3456 return(1);
3457 }
3458 setError((char*)"Warning: unexpected error (SDDSFile::setArray)");
3459 return(1);
3460}
3461
3462int32_t SDDSFile_setArray(void *sddsfile, uint32_t page, uint32_t elements, int32_t mode, ...) {
3463 va_list ap;
3464 int16_t *int16Val;
3465 uint16_t *uint16Val;
3466 int32_t *int32Val;
3467 uint32_t *uint32Val;
3468 float *real32Val;
3469 double *real64Val;
3470 char **stringVal;
3471 char *charVal;
3472 int32_t index;
3473 char *name;
3474
3475 va_start(ap, mode);
3476 if (mode&SDDSFILE_SETARRAY_WITH_INDEX) {
3477 index = va_arg(ap, int32_t);
3478 if (mode&SDDSFILE_SETARRAY_WITH_INT16) {
3479 int16Val = va_arg(ap, int16_t*);
3480 return(((SDDSFile*)sddsfile)->setArray(index, page, int16Val, elements));
3481 } else if (mode&SDDSFILE_SETARRAY_WITH_UINT16) {
3482 uint16Val = va_arg(ap, uint16_t*);
3483 return(((SDDSFile*)sddsfile)->setArray(index, page, uint16Val, elements));
3484 } else if (mode&SDDSFILE_SETARRAY_WITH_INT32) {
3485 int32Val = va_arg(ap, int32_t*);
3486 return(((SDDSFile*)sddsfile)->setArray(index, page, int32Val, elements));
3487 } else if (mode&SDDSFILE_SETARRAY_WITH_UINT32) {
3488 uint32Val = va_arg(ap, uint32_t*);
3489 return(((SDDSFile*)sddsfile)->setArray(index, page, uint32Val, elements));
3490 } else if (mode&SDDSFILE_SETARRAY_WITH_REAL32) {
3491 real32Val = va_arg(ap, float*);
3492 return(((SDDSFile*)sddsfile)->setArray(index, page, real32Val, elements));
3493 } else if (mode&SDDSFILE_SETARRAY_WITH_REAL64) {
3494 real64Val = va_arg(ap, double*);
3495 return(((SDDSFile*)sddsfile)->setArray(index, page, real64Val, elements));
3496 } else if (mode&SDDSFILE_SETARRAY_WITH_STRING) {
3497 stringVal = va_arg(ap, char**);
3498 return(((SDDSFile*)sddsfile)->setArray(index, page, stringVal, elements));
3499 } else {
3500 charVal = va_arg(ap, char*);
3501 return(((SDDSFile*)sddsfile)->setArray(index, page, charVal, elements));
3502 }
3503 } else {
3504 name = va_arg(ap, char *);
3505 if (mode&SDDSFILE_SETARRAY_WITH_INT16) {
3506 int16Val = va_arg(ap, int16_t*);
3507 return(((SDDSFile*)sddsfile)->setArray(name, page, int16Val, elements));
3508 } else if (mode&SDDSFILE_SETARRAY_WITH_UINT16) {
3509 uint16Val = va_arg(ap, uint16_t*);
3510 return(((SDDSFile*)sddsfile)->setArray(name, page, uint16Val, elements));
3511 } else if (mode&SDDSFILE_SETARRAY_WITH_INT32) {
3512 int32Val = va_arg(ap, int32_t*);
3513 return(((SDDSFile*)sddsfile)->setArray(name, page, int32Val, elements));
3514 } else if (mode&SDDSFILE_SETARRAY_WITH_UINT32) {
3515 uint32Val = va_arg(ap, uint32_t*);
3516 return(((SDDSFile*)sddsfile)->setArray(name, page, uint32Val, elements));
3517 } else if (mode&SDDSFILE_SETARRAY_WITH_REAL32) {
3518 real32Val = va_arg(ap, float*);
3519 return(((SDDSFile*)sddsfile)->setArray(name, page, real32Val, elements));
3520 } else if (mode&SDDSFILE_SETARRAY_WITH_REAL64) {
3521 real64Val = va_arg(ap, double*);
3522 return(((SDDSFile*)sddsfile)->setArray(name, page, real64Val, elements));
3523 } else if (mode&SDDSFILE_SETARRAY_WITH_STRING) {
3524 stringVal = va_arg(ap, char**);
3525 return(((SDDSFile*)sddsfile)->setArray(name, page, stringVal, elements));
3526 } else {
3527 charVal = va_arg(ap, char*);
3528 return(((SDDSFile*)sddsfile)->setArray(name, page, charVal, elements));
3529 }
3530 }
3531}
3532
3533/***********************************************************************************************
3534 * setParameter *
3535 * *
3536 * C++ Arguments: uint32_t page, int32_t parameterIndex, int32_t value *
3537 * uint32_t page, char *name, int32_t value *
3538 * uint32_t page, int32_t parameterIndex, uint32_t value *
3539 * uint32_t page, char *name, uint32_t value *
3540 * uint32_t page, int32_t parameterIndex, double value *
3541 * uint32_t page, char *name, double value *
3542 * uint32_t page, int32_t parameterIndex, char *value *
3543 * uint32_t page, char *name, char *value *
3544 * uint32_t startPage, uint32_t pages, int32_t parameterIndex, int32_t *value *
3545 * uint32_t startPage, uint32_t pages, char *name, int32_t *value *
3546 * uint32_t startPage, uint32_t pages, int32_t parameterIndex, uint32_t *value *
3547 * uint32_t startPage, uint32_t pages, char *name, uint32_t *value *
3548 * uint32_t startPage, uint32_t pages, int32_t parameterIndex, double *value *
3549 * uint32_t startPage, uint32_t pages, char *name, double *value *
3550 * uint32_t startPage, uint32_t pages, int32_t parameterIndex, char **value *
3551 * uint32_t startPage, uint32_t pages, char *name, char **value *
3552 * *
3553 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ... *
3554 * mode=SDDSFILE_SETPARAMETER_WITH_INDEX+SDDSFILE_SETPARAMETER_WITH_INT, *
3555 * int32_t parameterIndex, int32_t value *
3556 * mode=SDDSFILE_SETPARAMETER_WITH_NAME+SDDSFILE_SETPARAMETER_WITH_INT, *
3557 * char *name, int32_t value *
3558 * mode=SDDSFILE_SETPARAMETER_WITH_INDEX+SDDSFILE_SETPARAMETER_WITH_UINT, *
3559 * int32_t parameterIndex, uint32_t value *
3560 * mode=SDDSFILE_SETPARAMETER_WITH_NAME+SDDSFILE_SETPARAMETER_WITH_UINT, *
3561 * char *name, uint32_t value *
3562 * mode=SDDSFILE_SETPARAMETER_WITH_INDEX+SDDSFILE_SETPARAMETER_WITH_FLOAT, *
3563 * int32_t parameterIndex, double value *
3564 * mode=SDDSFILE_SETPARAMETER_WITH_NAME+SDDSFILE_SETPARAMETER_WITH_FLOAT, *
3565 * char *name, double value *
3566 * mode=SDDSFILE_SETPARAMETER_WITH_INDEX+SDDSFILE_SETPARAMETER_WITH_STRING, *
3567 * int32_t parameterIndex, char *value *
3568 * mode=SDDSFILE_SETPARAMETER_WITH_NAME+SDDSFILE_SETPARAMETER_WITH_STRING, *
3569 * char *name, char *value *
3570 * *
3571 * Results: 0 for success *
3572 * 1 for failure : calling program should call printErrors *
3573 ***********************************************************************************************/
3574int32_t SDDSFile::setParameter(uint32_t page, int32_t parameterIndex, int32_t value) {
3575 char s[SDDS_MAXLINE];
3576 int32_t result;
3577 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3578 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3579 setError(s);
3580 return(1);
3581 }
3582 result = parameterObject[parameterIndex]->setValue(value, page);
3583 if (result == 0) {
3584 return(0);
3585 } else if (result == 1) {
3586 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3587 return(1);
3588 } else if (result == 2) {
3589 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3590 return(1);
3591 } else if (result == 3) {
3592 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3593 return(1);
3594 }
3595 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3596 return(1);
3597}
3598
3599int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, int32_t parameterIndex, int32_t *value) {
3600 int32_t result;
3601 uint32_t i;
3602 char s[SDDS_MAXLINE];
3603 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3604 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3605 setError(s);
3606 return(1);
3607 }
3608 for (i=0; i<pages; i++) {
3609 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3610 if (result == 0) {
3611 continue;
3612 } else if (result == 1) {
3613 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3614 return(1);
3615 } else if (result == 2) {
3616 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3617 return(1);
3618 } else if (result == 3) {
3619 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3620 return(1);
3621 }
3622 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3623 return(1);
3624 }
3625 return(0);
3626}
3627
3628int32_t SDDSFile::setParameter(uint32_t page, char *name, int32_t value) {
3629 int32_t parameterIndex, result;
3630 char s[SDDS_MAXLINE];
3631 parameterIndex = getParameterIndex(name);
3632 if (parameterIndex < 0) {
3633 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3634 setError(s);
3635 return(1);
3636 }
3637 result = parameterObject[parameterIndex]->setValue(value, page);
3638 if (result == 0) {
3639 return(0);
3640 } else if (result == 1) {
3641 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3642 return(1);
3643 } else if (result == 2) {
3644 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3645 return(1);
3646 } else if (result == 3) {
3647 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3648 return(1);
3649 }
3650 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3651 return(1);
3652}
3653
3654int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, char *name, int32_t *value) {
3655 int32_t parameterIndex, result;
3656 uint32_t i;
3657 char s[SDDS_MAXLINE];
3658 parameterIndex = getParameterIndex(name);
3659 if (parameterIndex < 0) {
3660 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3661 setError(s);
3662 return(1);
3663 }
3664 for (i=0; i<pages; i++) {
3665 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3666 if (result == 0) {
3667 continue;
3668 } else if (result == 1) {
3669 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3670 return(1);
3671 } else if (result == 2) {
3672 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3673 return(1);
3674 } else if (result == 3) {
3675 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3676 return(1);
3677 }
3678 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3679 return(1);
3680 }
3681 return(0);
3682}
3683
3684int32_t SDDSFile::setParameter(uint32_t page, int32_t parameterIndex, uint32_t value) {
3685 char s[SDDS_MAXLINE];
3686 int32_t result;
3687 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3688 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3689 setError(s);
3690 return(1);
3691 }
3692 result = parameterObject[parameterIndex]->setValue(value, page);
3693 if (result == 0) {
3694 return(0);
3695 } else if (result == 1) {
3696 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3697 return(1);
3698 } else if (result == 2) {
3699 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3700 return(1);
3701 } else if (result == 3) {
3702 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3703 return(1);
3704 }
3705 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3706 return(1);
3707}
3708
3709int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, int32_t parameterIndex, uint32_t *value) {
3710 int32_t result;
3711 uint32_t i;
3712 char s[SDDS_MAXLINE];
3713 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3714 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3715 setError(s);
3716 return(1);
3717 }
3718 for (i=0; i<pages; i++) {
3719 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3720 if (result == 0) {
3721 continue;
3722 } else if (result == 1) {
3723 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3724 return(1);
3725 } else if (result == 2) {
3726 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3727 return(1);
3728 } else if (result == 3) {
3729 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3730 return(1);
3731 }
3732 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3733 return(1);
3734 }
3735 return(0);
3736}
3737
3738int32_t SDDSFile::setParameter(uint32_t page, char *name, uint32_t value) {
3739 int32_t parameterIndex, result;
3740 char s[SDDS_MAXLINE];
3741 parameterIndex = getParameterIndex(name);
3742 if (parameterIndex < 0) {
3743 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3744 setError(s);
3745 return(1);
3746 }
3747 result = parameterObject[parameterIndex]->setValue(value, page);
3748 if (result == 0) {
3749 return(0);
3750 } else if (result == 1) {
3751 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3752 return(1);
3753 } else if (result == 2) {
3754 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3755 return(1);
3756 } else if (result == 3) {
3757 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3758 return(1);
3759 }
3760 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3761 return(1);
3762}
3763
3764int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, char *name, uint32_t *value) {
3765 int32_t parameterIndex, result;
3766 uint32_t i;
3767 char s[SDDS_MAXLINE];
3768 parameterIndex = getParameterIndex(name);
3769 if (parameterIndex < 0) {
3770 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3771 setError(s);
3772 return(1);
3773 }
3774 for (i=0; i<pages; i++) {
3775 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3776 if (result == 0) {
3777 continue;
3778 } else if (result == 1) {
3779 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3780 return(1);
3781 } else if (result == 2) {
3782 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3783 return(1);
3784 } else if (result == 3) {
3785 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3786 return(1);
3787 }
3788 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3789 return(1);
3790 }
3791 return(0);
3792}
3793
3794int32_t SDDSFile::setParameter(uint32_t page, int32_t parameterIndex, double value) {
3795 char s[SDDS_MAXLINE];
3796 int32_t result;
3797 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3798 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3799 setError(s);
3800 return(1);
3801 }
3802 result = parameterObject[parameterIndex]->setValue(value, page);
3803 if (result == 0) {
3804 return(0);
3805 } else if (result == 1) {
3806 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3807 return(1);
3808 } else if (result == 2) {
3809 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3810 return(1);
3811 } else if (result == 3) {
3812 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3813 return(1);
3814 }
3815 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3816 return(1);
3817}
3818
3819int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, int32_t parameterIndex, double *value) {
3820 int32_t result;
3821 uint32_t i;
3822 char s[SDDS_MAXLINE];
3823 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3824 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3825 setError(s);
3826 return(1);
3827 }
3828 for (i=0; i<pages; i++) {
3829 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3830 if (result == 0) {
3831 continue;
3832 } else if (result == 1) {
3833 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3834 return(1);
3835 } else if (result == 2) {
3836 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3837 return(1);
3838 } else if (result == 3) {
3839 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3840 return(1);
3841 }
3842 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3843 return(1);
3844 }
3845 return(0);
3846}
3847
3848int32_t SDDSFile::setParameter(uint32_t page, char *name, double value) {
3849 int32_t parameterIndex, result;
3850 char s[SDDS_MAXLINE];
3851 parameterIndex = getParameterIndex(name);
3852 if (parameterIndex < 0) {
3853 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3854 setError(s);
3855 return(1);
3856 }
3857 result = parameterObject[parameterIndex]->setValue(value, page);
3858 if (result == 0) {
3859 return(0);
3860 } else if (result == 1) {
3861 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3862 return(1);
3863 } else if (result == 2) {
3864 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3865 return(1);
3866 } else if (result == 3) {
3867 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3868 return(1);
3869 }
3870 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3871 return(1);
3872}
3873
3874int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, char *name, double *value) {
3875 int32_t parameterIndex, result;
3876 uint32_t i;
3877 char s[SDDS_MAXLINE];
3878 parameterIndex = getParameterIndex(name);
3879 if (parameterIndex < 0) {
3880 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3881 setError(s);
3882 return(1);
3883 }
3884 for (i=0; i<pages; i++) {
3885 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3886 if (result == 0) {
3887 continue;
3888 } else if (result == 1) {
3889 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3890 return(1);
3891 } else if (result == 2) {
3892 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3893 return(1);
3894 } else if (result == 3) {
3895 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3896 return(1);
3897 }
3898 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3899 return(1);
3900 }
3901 return(0);
3902}
3903
3904int32_t SDDSFile::setParameter(uint32_t page, int32_t parameterIndex, char *value) {
3905 char s[SDDS_MAXLINE];
3906 int32_t result;
3907 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3908 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3909 setError(s);
3910 return(1);
3911 }
3912 result = parameterObject[parameterIndex]->setValue(value, page);
3913 if (result == 0) {
3914 return(0);
3915 } else if (result == 1) {
3916 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3917 return(1);
3918 } else if (result == 2) {
3919 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3920 return(1);
3921 } else if (result == 3) {
3922 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3923 return(1);
3924 }
3925 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3926 return(1);
3927}
3928
3929int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, int32_t parameterIndex, char **value) {
3930 int32_t result;
3931 uint32_t i;
3932 char s[SDDS_MAXLINE];
3933 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
3934 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::setParameter)", parameterIndex);
3935 setError(s);
3936 return(1);
3937 }
3938 for (i=0; i<pages; i++) {
3939 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3940 if (result == 0) {
3941 continue;
3942 } else if (result == 1) {
3943 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3944 return(1);
3945 } else if (result == 2) {
3946 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3947 return(1);
3948 } else if (result == 3) {
3949 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3950 return(1);
3951 }
3952 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3953 return(1);
3954 }
3955 return(0);
3956}
3957
3958int32_t SDDSFile::setParameter(uint32_t page, char *name, char *value) {
3959 int32_t parameterIndex, result;
3960 char s[SDDS_MAXLINE];
3961 parameterIndex = getParameterIndex(name);
3962 if (parameterIndex < 0) {
3963 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3964 setError(s);
3965 return(1);
3966 }
3967 result = parameterObject[parameterIndex]->setValue(value, page);
3968 if (result == 0) {
3969 return(0);
3970 } else if (result == 1) {
3971 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
3972 return(1);
3973 } else if (result == 2) {
3974 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
3975 return(1);
3976 } else if (result == 3) {
3977 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
3978 return(1);
3979 }
3980 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
3981 return(1);
3982}
3983
3984int32_t SDDSFile::setParameter(uint32_t startPage, uint32_t pages, char *name, char **value) {
3985 int32_t parameterIndex, result;
3986 uint32_t i;
3987 char s[SDDS_MAXLINE];
3988 parameterIndex = getParameterIndex(name);
3989 if (parameterIndex < 0) {
3990 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::setParameter)", name);
3991 setError(s);
3992 return(1);
3993 }
3994 for (i=0; i<pages; i++) {
3995 result = parameterObject[parameterIndex]->setValue(value[i], startPage + i);
3996 if (result == 0) {
3997 continue;
3998 } else if (result == 1) {
3999 setError((char*)"Warning: invalid page number (SDDSFile::setParameter)");
4000 return(1);
4001 } else if (result == 2) {
4002 setError((char*)"Warning: unable to convert given value to proper parameter type (SDDSFile::setParameter)");
4003 return(1);
4004 } else if (result == 3) {
4005 setError((char*)"Warning: invalid parameter type (SDDSFile::setParameter)");
4006 return(1);
4007 }
4008 setError((char*)"Warning: unexpected error (SDDSFile::setParameter)");
4009 return(1);
4010 }
4011 return(0);
4012}
4013
4014int32_t SDDSFile_setParameter(void *sddsfile, uint32_t page, int32_t mode, ...) {
4015 va_list ap;
4016 int32_t intval;
4017 uint32_t uintval;
4018 double doubleval;
4019 char *stringval;
4020 int32_t index;
4021 char *name;
4022
4023 va_start(ap, mode);
4024 if (mode&SDDSFILE_SETPARAMETER_WITH_INDEX) {
4025 index = va_arg(ap, int32_t);
4026 if (mode&SDDSFILE_SETPARAMETER_WITH_INT) {
4027 intval = va_arg(ap, int32_t);
4028 return(((SDDSFile*)sddsfile)->setParameter(page, index, intval));
4029 } else if (mode&SDDSFILE_SETPARAMETER_WITH_UINT) {
4030 uintval = va_arg(ap, uint32_t);
4031 return(((SDDSFile*)sddsfile)->setParameter(page, index, uintval));
4032 } else if (mode&SDDSFILE_SETPARAMETER_WITH_FLOAT) {
4033 doubleval = va_arg(ap, double);
4034 return(((SDDSFile*)sddsfile)->setParameter(page, index, doubleval));
4035 } else {
4036 stringval = va_arg(ap, char*);
4037 return(((SDDSFile*)sddsfile)->setParameter(page, index, stringval));
4038 }
4039 } else {
4040 name = va_arg(ap, char *);
4041 if (mode&SDDSFILE_SETPARAMETER_WITH_INT) {
4042 intval = va_arg(ap, int32_t);
4043 return(((SDDSFile*)sddsfile)->setParameter(page, name, intval));
4044 } else if (mode&SDDSFILE_SETPARAMETER_WITH_UINT) {
4045 uintval = va_arg(ap, uint32_t);
4046 return(((SDDSFile*)sddsfile)->setParameter(page, name, uintval));
4047 } else if (mode&SDDSFILE_SETPARAMETER_WITH_FLOAT) {
4048 doubleval = va_arg(ap, double);
4049 return(((SDDSFile*)sddsfile)->setParameter(page, name, doubleval));
4050 } else {
4051 stringval = va_arg(ap, char*);
4052 return(((SDDSFile*)sddsfile)->setParameter(page, name, stringval));
4053 }
4054 }
4055}
4056
4057/******************************************************************************************************
4058 * setColumn *
4059 * *
4060 * C++ Arguments: int32_t columnIndex, uint32_t page, uint32_t startRow, int32_t *values, uint32_t rows *
4061 * char *name, uint32_t page, uint32_t startRow, int32_t *values, uint32_t rows *
4062 * int32_t columnIndex, uint32_t page, uint32_t startRow, uint32_t *values, uint32_t rows *
4063 * char *name, uint32_t page, uint32_t startRow, uint32_t *values, uint32_t rows *
4064 * int32_t columnIndex, uint32_t page, uint32_t startRow, double *values, uint32_t rows *
4065 * char *name, uint32_t page, uint32_t startRow, double *values, uint32_t rows *
4066 * int32_t columnIndex, uint32_t page, uint32_t startRow, char **values, uint32_t rows *
4067 * char *name, uint32_t page, uint32_t startRow, char **values, uint32_t rows *
4068 * *
4069 * C Arguments: void *sddsfile, uint32_t page, uint32_t startRow, uint32_t rows, int32_t mode, ... *
4070 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_INT16, *
4071 * int32_t columnIndex, int16_t *value *
4072 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_INT16, *
4073 * char *name, int16_t *value *
4074 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_UINT16, *
4075 * int32_t columnIndex, uint16_t *value *
4076 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_UINT16, *
4077 * char *name, uint16_t *value *
4078 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_INT32, *
4079 * int32_t columnIndex, int32_t *value *
4080 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_INT32, *
4081 * char *name, int32_t *value *
4082 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_UINT32, *
4083 * int32_t columnIndex, uint32_t *value *
4084 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_UINT32, *
4085 * char *name, uint32_t *value *
4086 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_REAL32, *
4087 * int32_t columnIndex, float *value *
4088 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_REAL32, *
4089 * char *name, float *value *
4090 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_REAL64, *
4091 * int32_t columnIndex, double *value *
4092 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_REAL64, *
4093 * char *name, double *value *
4094 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_STRING, *
4095 * int32_t columnIndex, char **value *
4096 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_STRING, *
4097 * char *name, char **value *
4098 * mode=SDDSFILE_SETCOLUMN_WITH_INDEX+SDDSFILE_SETCOLUMN_WITH_CHARACTER, *
4099 * int32_t columnIndex, char *value *
4100 * mode=SDDSFILE_SETCOLUMN_WITH_NAME+SDDSFILE_SETCOLUMN_WITH_CHARACTER, *
4101 * char *name, char *value *
4102 * *
4103 * Results: 0 for success *
4104 * 1 for failure : calling program should call printErrors *
4105 ******************************************************************************************************/
4106int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, int16_t *values, uint32_t rows) {
4107 int32_t result;
4108 char s[SDDS_MAXLINE];
4109 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4110 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4111 setError(s);
4112 return(1);
4113 }
4114 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4115 if (result == 0) {
4116 return(0);
4117 } else if (result == 1) {
4118 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4119 return(1);
4120 } else if (result == 2) {
4121 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4122 return(1);
4123 } else if (result == 3) {
4124 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4125 return(1);
4126 } else if (result == 4) {
4127 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4128 return(1);
4129 }
4130 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4131 return(1);
4132}
4133
4134int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, int16_t *values, uint32_t rows) {
4135 int32_t columnIndex, result;
4136 char s[SDDS_MAXLINE];
4137 columnIndex = getColumnIndex(name);
4138 if (columnIndex < 0) {
4139 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4140 setError(s);
4141 return(1);
4142 }
4143 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4144 if (result == 0) {
4145 return(0);
4146 } else if (result == 1) {
4147 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4148 return(1);
4149 } else if (result == 2) {
4150 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4151 return(1);
4152 } else if (result == 3) {
4153 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4154 return(1);
4155 } else if (result == 4) {
4156 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4157 return(1);
4158 }
4159 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4160 return(1);
4161}
4162
4163int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, uint16_t *values, uint32_t rows) {
4164 int32_t result;
4165 char s[SDDS_MAXLINE];
4166 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4167 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4168 setError(s);
4169 return(1);
4170 }
4171 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4172 if (result == 0) {
4173 return(0);
4174 } else if (result == 1) {
4175 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4176 return(1);
4177 } else if (result == 2) {
4178 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4179 return(1);
4180 } else if (result == 3) {
4181 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4182 return(1);
4183 } else if (result == 4) {
4184 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4185 return(1);
4186 }
4187 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4188 return(1);
4189}
4190
4191int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, uint16_t *values, uint32_t rows) {
4192 int32_t columnIndex, result;
4193 char s[SDDS_MAXLINE];
4194 columnIndex = getColumnIndex(name);
4195 if (columnIndex < 0) {
4196 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4197 setError(s);
4198 return(1);
4199 }
4200 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4201 if (result == 0) {
4202 return(0);
4203 } else if (result == 1) {
4204 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4205 return(1);
4206 } else if (result == 2) {
4207 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4208 return(1);
4209 } else if (result == 3) {
4210 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4211 return(1);
4212 } else if (result == 4) {
4213 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4214 return(1);
4215 }
4216 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4217 return(1);
4218}
4219
4220int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, int32_t *values, uint32_t rows) {
4221 int32_t result;
4222 char s[SDDS_MAXLINE];
4223 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4224 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4225 setError(s);
4226 return(1);
4227 }
4228 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4229 if (result == 0) {
4230 return(0);
4231 } else if (result == 1) {
4232 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4233 return(1);
4234 } else if (result == 2) {
4235 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4236 return(1);
4237 } else if (result == 3) {
4238 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4239 return(1);
4240 } else if (result == 4) {
4241 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4242 return(1);
4243 }
4244 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4245 return(1);
4246}
4247
4248int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, int32_t *values, uint32_t rows) {
4249 int32_t columnIndex, result;
4250 char s[SDDS_MAXLINE];
4251 columnIndex = getColumnIndex(name);
4252 if (columnIndex < 0) {
4253 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4254 setError(s);
4255 return(1);
4256 }
4257 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4258 if (result == 0) {
4259 return(0);
4260 } else if (result == 1) {
4261 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4262 return(1);
4263 } else if (result == 2) {
4264 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4265 return(1);
4266 } else if (result == 3) {
4267 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4268 return(1);
4269 } else if (result == 4) {
4270 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4271 return(1);
4272 }
4273 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4274 return(1);
4275}
4276
4277int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, uint32_t *values, uint32_t rows) {
4278 int32_t result;
4279 char s[SDDS_MAXLINE];
4280 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4281 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4282 setError(s);
4283 return(1);
4284 }
4285 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4286 if (result == 0) {
4287 return(0);
4288 } else if (result == 1) {
4289 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4290 return(1);
4291 } else if (result == 2) {
4292 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4293 return(1);
4294 } else if (result == 3) {
4295 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4296 return(1);
4297 } else if (result == 4) {
4298 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4299 return(1);
4300 }
4301 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4302 return(1);
4303}
4304
4305int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, uint32_t *values, uint32_t rows) {
4306 int32_t columnIndex, result;
4307 char s[SDDS_MAXLINE];
4308 columnIndex = getColumnIndex(name);
4309 if (columnIndex < 0) {
4310 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4311 setError(s);
4312 return(1);
4313 }
4314 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4315 if (result == 0) {
4316 return(0);
4317 } else if (result == 1) {
4318 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4319 return(1);
4320 } else if (result == 2) {
4321 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4322 return(1);
4323 } else if (result == 3) {
4324 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4325 return(1);
4326 } else if (result == 4) {
4327 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4328 return(1);
4329 }
4330 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4331 return(1);
4332}
4333
4334int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, float *values, uint32_t rows) {
4335 int32_t result;
4336 char s[SDDS_MAXLINE];
4337 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4338 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4339 setError(s);
4340 return(1);
4341 }
4342 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4343 if (result == 0) {
4344 return(0);
4345 } else if (result == 1) {
4346 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4347 return(1);
4348 } else if (result == 2) {
4349 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4350 return(1);
4351 } else if (result == 3) {
4352 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4353 return(1);
4354 } else if (result == 4) {
4355 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4356 return(1);
4357 }
4358 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4359 return(1);
4360}
4361
4362int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, float *values, uint32_t rows) {
4363 int32_t columnIndex, result;
4364 char s[SDDS_MAXLINE];
4365 columnIndex = getColumnIndex(name);
4366 if (columnIndex < 0) {
4367 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4368 setError(s);
4369 return(1);
4370 }
4371 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4372 if (result == 0) {
4373 return(0);
4374 } else if (result == 1) {
4375 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4376 return(1);
4377 } else if (result == 2) {
4378 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4379 return(1);
4380 } else if (result == 3) {
4381 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4382 return(1);
4383 } else if (result == 4) {
4384 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4385 return(1);
4386 }
4387 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4388 return(1);
4389}
4390
4391int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, double *values, uint32_t rows) {
4392 int32_t result;
4393 char s[SDDS_MAXLINE];
4394 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4395 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4396 setError(s);
4397 return(1);
4398 }
4399 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4400 if (result == 0) {
4401 return(0);
4402 } else if (result == 1) {
4403 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4404 return(1);
4405 } else if (result == 2) {
4406 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4407 return(1);
4408 } else if (result == 3) {
4409 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4410 return(1);
4411 } else if (result == 4) {
4412 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4413 return(1);
4414 }
4415 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4416 return(1);
4417}
4418
4419int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, double *values, uint32_t rows) {
4420 int32_t columnIndex, result;
4421 char s[SDDS_MAXLINE];
4422 columnIndex = getColumnIndex(name);
4423 if (columnIndex < 0) {
4424 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4425 setError(s);
4426 return(1);
4427 }
4428 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4429 if (result == 0) {
4430 return(0);
4431 } else if (result == 1) {
4432 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4433 return(1);
4434 } else if (result == 2) {
4435 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4436 return(1);
4437 } else if (result == 3) {
4438 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4439 return(1);
4440 } else if (result == 4) {
4441 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4442 return(1);
4443 }
4444 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4445 return(1);
4446}
4447
4448int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, char **values, uint32_t rows) {
4449 int32_t result;
4450 char s[SDDS_MAXLINE];
4451 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4452 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4453 setError(s);
4454 return(1);
4455 }
4456 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4457 if (result == 0) {
4458 return(0);
4459 } else if (result == 1) {
4460 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4461 return(1);
4462 } else if (result == 2) {
4463 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4464 return(1);
4465 } else if (result == 3) {
4466 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4467 return(1);
4468 } else if (result == 4) {
4469 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4470 return(1);
4471 }
4472 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4473 return(1);
4474}
4475
4476int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, char **values, uint32_t rows) {
4477 int32_t columnIndex, result;
4478 char s[SDDS_MAXLINE];
4479 columnIndex = getColumnIndex(name);
4480 if (columnIndex < 0) {
4481 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4482 setError(s);
4483 return(1);
4484 }
4485 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4486 if (result == 0) {
4487 return(0);
4488 } else if (result == 1) {
4489 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4490 return(1);
4491 } else if (result == 2) {
4492 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4493 return(1);
4494 } else if (result == 3) {
4495 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4496 return(1);
4497 } else if (result == 4) {
4498 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4499 return(1);
4500 }
4501 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4502 return(1);
4503}
4504
4505int32_t SDDSFile::setColumn(int32_t columnIndex, uint32_t page, uint32_t startRow, char *values, uint32_t rows) {
4506 int32_t result;
4507 char s[SDDS_MAXLINE];
4508 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
4509 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::setColumn)", columnIndex);
4510 setError(s);
4511 return(1);
4512 }
4513 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4514 if (result == 0) {
4515 return(0);
4516 } else if (result == 1) {
4517 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4518 return(1);
4519 } else if (result == 2) {
4520 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4521 return(1);
4522 } else if (result == 3) {
4523 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4524 return(1);
4525 } else if (result == 4) {
4526 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4527 return(1);
4528 }
4529 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4530 return(1);
4531}
4532
4533int32_t SDDSFile::setColumn(char *name, uint32_t page, uint32_t startRow, char *values, uint32_t rows) {
4534 int32_t columnIndex, result;
4535 char s[SDDS_MAXLINE];
4536 columnIndex = getColumnIndex(name);
4537 if (columnIndex < 0) {
4538 sprintf(s, "Warning: column %s does not exist (SDDSFile::setColumn)", name);
4539 setError(s);
4540 return(1);
4541 }
4542 result = columnObject[columnIndex]->setValues(values, page, startRow, rows);
4543 if (result == 0) {
4544 return(0);
4545 } else if (result == 1) {
4546 setError((char*)"Warning: invalid page number (SDDSFile::setColumn)");
4547 return(1);
4548 } else if (result == 2) {
4549 setError((char*)"Warning: invalid startRow number (SDDSFile::setColumn)");
4550 return(1);
4551 } else if (result == 3) {
4552 setError((char*)"Warning: unable to convert given value to proper column type (SDDSFile::setColumn)");
4553 return(1);
4554 } else if (result == 4) {
4555 setError((char*)"Warning: invalid column type (SDDSFile::setColumn)");
4556 return(1);
4557 }
4558 setError((char*)"Warning: unexpected error (SDDSFile::setColumn)");
4559 return(1);
4560}
4561
4562int32_t SDDSFile_setColumn(void *sddsfile, uint32_t page, uint32_t startRow, uint32_t rows, int32_t mode, ...) {
4563 va_list ap;
4564 int16_t *int16Val;
4565 uint16_t *uint16Val;
4566 int32_t *int32Val;
4567 uint32_t *uint32Val;
4568 float *real32Val;
4569 double *real64Val;
4570 char **stringVal;
4571 char *charVal;
4572 int32_t index;
4573 char *name;
4574
4575 va_start(ap, mode);
4576 if (mode&SDDSFILE_SETCOLUMN_WITH_INDEX) {
4577 index = va_arg(ap, int32_t);
4578 if (mode&SDDSFILE_SETCOLUMN_WITH_INT16) {
4579 int16Val = va_arg(ap, int16_t*);
4580 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, int16Val, rows));
4581 } else if (mode&SDDSFILE_SETCOLUMN_WITH_UINT16) {
4582 uint16Val = va_arg(ap, uint16_t*);
4583 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, uint16Val, rows));
4584 } else if (mode&SDDSFILE_SETCOLUMN_WITH_INT32) {
4585 int32Val = va_arg(ap, int32_t*);
4586 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, int32Val, rows));
4587 } else if (mode&SDDSFILE_SETCOLUMN_WITH_UINT32) {
4588 uint32Val = va_arg(ap, uint32_t*);
4589 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, uint32Val, rows));
4590 } else if (mode&SDDSFILE_SETCOLUMN_WITH_REAL32) {
4591 real32Val = va_arg(ap, float*);
4592 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, real32Val, rows));
4593 } else if (mode&SDDSFILE_SETCOLUMN_WITH_REAL64) {
4594 real64Val = va_arg(ap, double*);
4595 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, real64Val, rows));
4596 } else if (mode&SDDSFILE_SETCOLUMN_WITH_STRING) {
4597 stringVal = va_arg(ap, char**);
4598 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, stringVal, rows));
4599 } else {
4600 charVal = va_arg(ap, char*);
4601 return(((SDDSFile*)sddsfile)->setColumn(index, page, startRow, charVal, rows));
4602 }
4603 } else {
4604 name = va_arg(ap, char *);
4605 if (mode&SDDSFILE_SETCOLUMN_WITH_INT16) {
4606 int16Val = va_arg(ap, int16_t*);
4607 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, int16Val, rows));
4608 } else if (mode&SDDSFILE_SETCOLUMN_WITH_UINT16) {
4609 uint16Val = va_arg(ap, uint16_t*);
4610 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, uint16Val, rows));
4611 } else if (mode&SDDSFILE_SETCOLUMN_WITH_INT32) {
4612 int32Val = va_arg(ap, int32_t*);
4613 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, int32Val, rows));
4614 } else if (mode&SDDSFILE_SETCOLUMN_WITH_UINT32) {
4615 uint32Val = va_arg(ap, uint32_t*);
4616 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, uint32Val, rows));
4617 } else if (mode&SDDSFILE_SETCOLUMN_WITH_REAL32) {
4618 real32Val = va_arg(ap, float*);
4619 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, real32Val, rows));
4620 } else if (mode&SDDSFILE_SETCOLUMN_WITH_REAL64) {
4621 real64Val = va_arg(ap, double*);
4622 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, real64Val, rows));
4623 } else if (mode&SDDSFILE_SETCOLUMN_WITH_STRING) {
4624 stringVal = va_arg(ap, char**);
4625 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, stringVal, rows));
4626 } else {
4627 charVal = va_arg(ap, char*);
4628 return(((SDDSFile*)sddsfile)->setColumn(name, page, startRow, charVal, rows));
4629 }
4630 }
4631}
4632
4633/***********************************************************************************************
4634 * getParameterInInt32 *
4635 * *
4636 * C++ Arguments: int32_t parameterIndex, uint32_t page *
4637 * char *name, uint32_t page *
4638 * *
4639 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ... *
4640 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
4641 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
4642 * *
4643 * Results: int32 value of the parameter on success *
4644 * 0 on failure *
4645 * You should should call checkForErrors to *
4646 * determain if there was a problem getting the value *
4647 ***********************************************************************************************/
4648int32_t SDDSFile::getParameterInInt32(int32_t parameterIndex, uint32_t page) {
4649 int64_t result;
4650 int32_t errorcode;
4651 char s[SDDS_MAXLINE];
4652 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
4653 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInInt32)", parameterIndex);
4654 setError(s);
4655 return((int32_t)0);
4656 }
4657 result = parameterObject[parameterIndex]->getValueInInt32(page, &errorcode);
4658 if (result == LONG_MAX) {
4659 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInInt32)", getParameterName(parameterIndex));
4660 setError(s);
4661 if (errorcode == 1) {
4662 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInInt32)");
4663 } else if (errorcode == 2) {
4664 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInInt32)");
4665 } else if (errorcode == 3) {
4666 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInInt32)");
4667 }
4668 return((int32_t)0);
4669 }
4670 return((int32_t)result);
4671}
4672
4673int32_t SDDSFile::getParameterInInt32(char *name, uint32_t page) {
4674 int64_t result;
4675 int32_t errorcode;
4676 int32_t parameterIndex;
4677 char s[SDDS_MAXLINE];
4678 parameterIndex = getParameterIndex(name);
4679 if (parameterIndex < 0) {
4680 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInInt32)", name);
4681 setError(s);
4682 return((int32_t)0);
4683 }
4684 result = parameterObject[parameterIndex]->getValueInInt32(page, &errorcode);
4685 if (result == LONG_MAX) {
4686 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInInt32)", name);
4687 setError(s);
4688 if (errorcode == 1) {
4689 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInInt32)");
4690 } else if (errorcode == 2) {
4691 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInInt32)");
4692 } else if (errorcode == 3) {
4693 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInInt32)");
4694 }
4695 return((int32_t)0);
4696 }
4697 return((int32_t)result);
4698}
4699
4700int32_t SDDSFile_getParameterInInt32(void *sddsfile, uint32_t page, int32_t mode, ...) {
4701 va_list ap;
4702 int32_t index;
4703 char *name;
4704
4705 va_start(ap, mode);
4706 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
4707 index = va_arg(ap, int32_t);
4708 return(((SDDSFile*)sddsfile)->getParameterInInt32(index, page));
4709 } else {
4710 name = va_arg(ap, char *);
4711 return(((SDDSFile*)sddsfile)->getParameterInInt32(name, page));
4712 }
4713}
4714
4715/***********************************************************************************************
4716 * getParameterInUInt32 *
4717 * *
4718 * C++ Arguments: int32_t parameterIndex, uint32_t page *
4719 * char *name, uint32_t page *
4720 * *
4721 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ... *
4722 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
4723 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
4724 * *
4725 * Results: uint32 value of the parameter on success *
4726 * 0 on failure *
4727 * You should should call checkForErrors to *
4728 * determain if there was a problem getting the value *
4729 ***********************************************************************************************/
4730uint32_t SDDSFile::getParameterInUInt32(int32_t parameterIndex, uint32_t page) {
4731 uint64_t result;
4732 int32_t errorcode;
4733 char s[SDDS_MAXLINE];
4734 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
4735 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInUInt32)", parameterIndex);
4736 setError(s);
4737 return((uint32_t)0);
4738 }
4739 result = parameterObject[parameterIndex]->getValueInUInt32(page, &errorcode);
4740 if (result == ULONG_MAX) {
4741 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInUInt32)", getParameterName(parameterIndex));
4742 setError(s);
4743 if (errorcode == 1) {
4744 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInUInt32)");
4745 } else if (errorcode == 2) {
4746 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInUInt32)");
4747 } else if (errorcode == 3) {
4748 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInUInt32)");
4749 }
4750 return((uint32_t)0);
4751 }
4752 return((uint32_t)result);
4753}
4754
4755uint32_t SDDSFile::getParameterInUInt32(char *name, uint32_t page) {
4756 uint64_t result;
4757 int32_t errorcode;
4758 int32_t parameterIndex;
4759 char s[SDDS_MAXLINE];
4760 parameterIndex = getParameterIndex(name);
4761 if (parameterIndex < 0) {
4762 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInUInt32)", name);
4763 setError(s);
4764 return((uint32_t)0);
4765 }
4766 result = parameterObject[parameterIndex]->getValueInUInt32(page, &errorcode);
4767 if (result == ULONG_MAX) {
4768 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInUInt32)", name);
4769 setError(s);
4770 if (errorcode == 1) {
4771 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInUInt32)");
4772 } else if (errorcode == 2) {
4773 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInUInt32)");
4774 } else if (errorcode == 3) {
4775 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInUInt32)");
4776 }
4777 return((uint32_t)0);
4778 }
4779 return((uint32_t)result);
4780}
4781
4782uint32_t SDDSFile_getParameterInUInt32(void *sddsfile, uint32_t page, int32_t mode, ...) {
4783 va_list ap;
4784 int32_t index;
4785 char *name;
4786
4787 va_start(ap, mode);
4788 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
4789 index = va_arg(ap, int32_t);
4790 return(((SDDSFile*)sddsfile)->getParameterInUInt32(index, page));
4791 } else {
4792 name = va_arg(ap, char *);
4793 return(((SDDSFile*)sddsfile)->getParameterInUInt32(name, page));
4794 }
4795}
4796
4797/***********************************************************************************************
4798 * getParameterInDouble *
4799 * *
4800 * C++ Arguments: int32_t parameterIndex, uint32_t page *
4801 * char *name, uint32_t page *
4802 * *
4803 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ... *
4804 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
4805 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
4806 * *
4807 * Results: double value of the parameter on success *
4808 * 0 on failure *
4809 * You should should call checkForErrors to *
4810 * determain if there was a problem getting the value *
4811 ***********************************************************************************************/
4812double SDDSFile::getParameterInDouble(int32_t parameterIndex, uint32_t page) {
4813 double result;
4814 int32_t errorcode;
4815 char s[SDDS_MAXLINE];
4816 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
4817 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInDouble)", parameterIndex);
4818 setError(s);
4819 return((double)0);
4820 }
4821 result = parameterObject[parameterIndex]->getValueInDouble(page, &errorcode);
4822 if (result == HUGE_VAL) {
4823 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInDouble)", getParameterName(parameterIndex));
4824 setError(s);
4825 if (errorcode == 1) {
4826 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInDouble)");
4827 } else if (errorcode == 2) {
4828 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInDouble)");
4829 } else if (errorcode == 3) {
4830 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInDouble)");
4831 }
4832 return((double)0);
4833 }
4834 return((double)result);
4835}
4836
4837double SDDSFile::getParameterInDouble(char *name, uint32_t page) {
4838 double result;
4839 int32_t errorcode;
4840 int32_t parameterIndex;
4841 char s[SDDS_MAXLINE];
4842 parameterIndex = getParameterIndex(name);
4843 if (parameterIndex < 0) {
4844 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInDouble)", name);
4845 setError(s);
4846 return((double)0);
4847 }
4848 result = parameterObject[parameterIndex]->getValueInDouble(page, &errorcode);
4849 if (result == HUGE_VAL) {
4850 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInDouble)", name);
4851 setError(s);
4852 if (errorcode == 1) {
4853 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInDouble)");
4854 } else if (errorcode == 2) {
4855 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInDouble)");
4856 } else if (errorcode == 3) {
4857 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInDouble)");
4858 }
4859 return((double)0);
4860 }
4861 return((double)result);
4862}
4863
4864double SDDSFile_getParameterInDouble(void *sddsfile, uint32_t page, int32_t mode, ...) {
4865 va_list ap;
4866 int32_t index;
4867 char *name;
4868
4869 va_start(ap, mode);
4870 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
4871 index = va_arg(ap, int32_t);
4872 return(((SDDSFile*)sddsfile)->getParameterInDouble(index, page));
4873 } else {
4874 name = va_arg(ap, char *);
4875 return(((SDDSFile*)sddsfile)->getParameterInDouble(name, page));
4876 }
4877}
4878
4879/***********************************************************************************************
4880 * getParameterInString *
4881 * *
4882 * C++ Arguments: int32_t parameterIndex, uint32_t page *
4883 * char *name, uint32_t page *
4884 * *
4885 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ... *
4886 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
4887 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
4888 * *
4889 * Results: char* value of the parameter on success *
4890 * You should free this pointer to avoid a memory leak *
4891 * NULL on failure *
4892 ***********************************************************************************************/
4893char* SDDSFile::getParameterInString(int32_t parameterIndex, uint32_t page) {
4894 char* result;
4895 int32_t errorcode;
4896 char s[SDDS_MAXLINE];
4897 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
4898 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInString)", parameterIndex);
4899 setError(s);
4900 return((char*)NULL);
4901 }
4902 result = parameterObject[parameterIndex]->getValueInString(page, &errorcode);
4903 if (result == NULL) {
4904 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInString)", getParameterName(parameterIndex));
4905 setError(s);
4906 if (errorcode == 1) {
4907 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInString)");
4908 } else if (errorcode == 2) {
4909 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInString)");
4910 } else if (errorcode == 3) {
4911 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInString)");
4912 }
4913 return((char*)NULL);
4914 }
4915 return((char*)result);
4916}
4917
4918char* SDDSFile::getParameterInString(char *name, uint32_t page) {
4919 char* result;
4920 int32_t errorcode;
4921 int32_t parameterIndex;
4922 char s[SDDS_MAXLINE];
4923 parameterIndex = getParameterIndex(name);
4924 if (parameterIndex < 0) {
4925 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInString)", name);
4926 setError(s);
4927 return((char*)NULL);
4928 }
4929 result = parameterObject[parameterIndex]->getValueInString(page, &errorcode);
4930 if (result == NULL) {
4931 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInString)", name);
4932 setError(s);
4933 if (errorcode == 1) {
4934 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInString)");
4935 } else if (errorcode == 2) {
4936 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInString)");
4937 } else if (errorcode == 3) {
4938 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInString)");
4939 }
4940 return((char*)NULL);
4941 }
4942 return((char*)result);
4943}
4944
4945char* SDDSFile_getParameterInString(void *sddsfile, uint32_t page, int32_t mode, ...) {
4946 va_list ap;
4947 int32_t index;
4948 char *name;
4949
4950 va_start(ap, mode);
4951 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
4952 index = va_arg(ap, int32_t);
4953 return(((SDDSFile*)sddsfile)->getParameterInString(index, page));
4954 } else {
4955 name = va_arg(ap, char *);
4956 return(((SDDSFile*)sddsfile)->getParameterInString(name, page));
4957 }
4958}
4959
4960/*
4961 * getInteralArray
4962 *
4963 * C++ Arguments: int32_t arrayIndex, uint32_t page
4964 * char *name, uint32_t page
4965 *
4966 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
4967 * mode=SDDSFILE_GETARRAY_WITH_INDEX, int32_t arrayIndex
4968 * mode=SDDSFILE_GETARRAY_WITH_NAME, char *name
4969 *
4970 * Results: pointer to values of the array on success
4971 * NULL on failure
4972 */
4973void* SDDSFile::getInternalArray(int32_t arrayIndex, uint32_t page) {
4974 char s[SDDS_MAXLINE];
4975 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
4976 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::getInternalArray)", arrayIndex);
4977 setError(s);
4978 return(NULL);
4979 }
4980 return(arrayObject[arrayIndex]->getInternalValues(page));
4981}
4982void* SDDSFile::getInternalArray(char *name, uint32_t page) {
4983 int32_t arrayIndex;
4984 char s[SDDS_MAXLINE];
4985 arrayIndex = getArrayIndex(name);
4986 if (arrayIndex < 0) {
4987 sprintf(s, "Warning: array %s does not exist (SDDSFile::getInternalArray)", name);
4988 setError(s);
4989 return(NULL);
4990 }
4991 return(arrayObject[arrayIndex]->getInternalValues(page));
4992}
4993void* SDDSFile_getInternalArray(void *sddsfile, uint32_t page, int32_t mode, ...) {
4994 va_list ap;
4995 int32_t index;
4996 char *name;
4997
4998 va_start(ap, mode);
4999 if (mode&SDDSFILE_GETARRAY_WITH_INDEX) {
5000 index = va_arg(ap, int32_t);
5001 return(((SDDSFile*)sddsfile)->getInternalArray(index, page));
5002 } else {
5003 name = va_arg(ap, char *);
5004 return(((SDDSFile*)sddsfile)->getInternalArray(name, page));
5005 }
5006}
5007
5008/*
5009 * getArrayInInt32
5010 *
5011 * C++ Arguments: int32_t arrayIndex, uint32_t page
5012 * char *name, uint32_t page
5013 *
5014 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5015 * mode=SDDSFILE_GETARRAY_WITH_INDEX, int32_t arrayIndex
5016 * mode=SDDSFILE_GETARRAY_WITH_NAME, char *name
5017 *
5018 * Results: pointer to int32 values of the array on success (you must free the pointer)
5019 * NULL on failure
5020 * You should should call checkForErrors to
5021 * determain if there was a problem getting the value because NULL is a valid
5022 * return value if there are zero rows
5023 */
5024int32_t* SDDSFile::getArrayInInt32(int32_t arrayIndex, uint32_t page) {
5025 int32_t *result;
5026 int32_t errorcode;
5027 char s[SDDS_MAXLINE];
5028 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
5029 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::getArrayInInt32)", arrayIndex);
5030 setError(s);
5031 return((int32_t*)NULL);
5032 }
5033 result = arrayObject[arrayIndex]->getValuesInInt32(page, &errorcode);
5034 if (result == NULL) {
5035 if (errorcode == 1) {
5036 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInInt32)");
5037 } else if (errorcode == 2) {
5038 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInInt32)");
5039 } else if (errorcode == 3) {
5040 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInInt32)");
5041 }
5042 }
5043 return((int32_t*)result);
5044}
5045
5046int32_t* SDDSFile::getArrayInInt32(char *name, uint32_t page) {
5047 int32_t *result;
5048 int32_t errorcode;
5049 int32_t arrayIndex;
5050 char s[SDDS_MAXLINE];
5051 arrayIndex = getArrayIndex(name);
5052 if (arrayIndex < 0) {
5053 sprintf(s, "Warning: array %s does not exist (SDDSFile::getArrayInInt32)", name);
5054 setError(s);
5055 return((int32_t*)NULL);
5056 }
5057 result = arrayObject[arrayIndex]->getValuesInInt32(page, &errorcode);
5058 if (result == NULL) {
5059 if (errorcode == 1) {
5060 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInInt32)");
5061 } else if (errorcode == 2) {
5062 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInInt32)");
5063 } else if (errorcode == 3) {
5064 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInInt32)");
5065 }
5066 }
5067 return((int32_t*)result);
5068}
5069
5070int32_t* SDDSFile_getArrayInInt32(void *sddsfile, uint32_t page, int32_t mode, ...) {
5071 va_list ap;
5072 int32_t index;
5073 char *name;
5074
5075 va_start(ap, mode);
5076 if (mode&SDDSFILE_GETARRAY_WITH_INDEX) {
5077 index = va_arg(ap, int32_t);
5078 return(((SDDSFile*)sddsfile)->getArrayInInt32(index, page));
5079 } else {
5080 name = va_arg(ap, char *);
5081 return(((SDDSFile*)sddsfile)->getArrayInInt32(name, page));
5082 }
5083}
5084
5085/*
5086 * getArrayInUInt32
5087 *
5088 * C++ Arguments: int32_t arrayIndex, uint32_t page
5089 * char *name, uint32_t page
5090 *
5091 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5092 * mode=SDDSFILE_GETARRAY_WITH_INDEX, int32_t arrayIndex
5093 * mode=SDDSFILE_GETARRAY_WITH_NAME, char *name
5094 *
5095 * Results: pointer to uint32 values of the array on success (you must free the pointer)
5096 * NULL on failure
5097 * You should should call checkForErrors to
5098 * determain if there was a problem getting the value because NULL is a valid
5099 * return value if there are zero elements
5100 */
5101uint32_t* SDDSFile::getArrayInUInt32(int32_t arrayIndex, uint32_t page) {
5102 uint32_t *result;
5103 int32_t errorcode;
5104 char s[SDDS_MAXLINE];
5105 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
5106 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::getArrayInUInt32)", arrayIndex);
5107 setError(s);
5108 return((uint32_t*)NULL);
5109 }
5110 result = arrayObject[arrayIndex]->getValuesInUInt32(page, &errorcode);
5111 if (result == NULL) {
5112 if (errorcode == 1) {
5113 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInUInt32)");
5114 } else if (errorcode == 2) {
5115 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInUInt32)");
5116 } else if (errorcode == 3) {
5117 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInUInt32)");
5118 }
5119 }
5120 return((uint32_t*)result);
5121}
5122
5123uint32_t* SDDSFile::getArrayInUInt32(char *name, uint32_t page) {
5124 uint32_t *result;
5125 int32_t errorcode;
5126 int32_t arrayIndex;
5127 char s[SDDS_MAXLINE];
5128 arrayIndex = getArrayIndex(name);
5129 if (arrayIndex < 0) {
5130 sprintf(s, "Warning: array %s does not exist (SDDSFile::getArrayInUInt32)", name);
5131 setError(s);
5132 return((uint32_t*)NULL);
5133 }
5134 result = arrayObject[arrayIndex]->getValuesInUInt32(page, &errorcode);
5135 if (result == NULL) {
5136 if (errorcode == 1) {
5137 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInUInt32)");
5138 } else if (errorcode == 2) {
5139 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInUInt32)");
5140 } else if (errorcode == 3) {
5141 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInUInt32)");
5142 }
5143 }
5144 return((uint32_t*)result);
5145}
5146
5147uint32_t* SDDSFile_getArrayInUInt32(void *sddsfile, uint32_t page, int32_t mode, ...) {
5148 va_list ap;
5149 int32_t index;
5150 char *name;
5151
5152 va_start(ap, mode);
5153 if (mode&SDDSFILE_GETARRAY_WITH_INDEX) {
5154 index = va_arg(ap, int32_t);
5155 return(((SDDSFile*)sddsfile)->getArrayInUInt32(index, page));
5156 } else {
5157 name = va_arg(ap, char *);
5158 return(((SDDSFile*)sddsfile)->getArrayInUInt32(name, page));
5159 }
5160}
5161
5162/*
5163 * getArrayInDouble
5164 *
5165 * C++ Arguments: int32_t arrayIndex, uint32_t page
5166 * char *name, uint32_t page
5167 *
5168 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5169 * mode=SDDSFILE_GETARRAY_WITH_INDEX, int32_t arrayIndex
5170 * mode=SDDSFILE_GETARRAY_WITH_NAME, char *name
5171 *
5172 * Results: pointer to double values of the array on success (you must free the pointer)
5173 * NULL on failure
5174 * You should should call checkForErrors to
5175 * determain if there was a problem getting the value because NULL is a valid
5176 * return value if there are zero elements
5177 */
5178double* SDDSFile::getArrayInDouble(int32_t arrayIndex, uint32_t page) {
5179 double *result;
5180 int32_t errorcode;
5181 char s[SDDS_MAXLINE];
5182 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
5183 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::getArrayInDouble)", arrayIndex);
5184 setError(s);
5185 return((double*)NULL);
5186 }
5187 result = arrayObject[arrayIndex]->getValuesInDouble(page, &errorcode);
5188 if (result == NULL) {
5189 if (errorcode == 1) {
5190 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInDouble)");
5191 } else if (errorcode == 2) {
5192 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInDouble)");
5193 } else if (errorcode == 3) {
5194 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInDouble)");
5195 }
5196 }
5197 return((double*)result);
5198}
5199
5200double* SDDSFile::getArrayInDouble(char *name, uint32_t page) {
5201 double *result;
5202 int32_t errorcode;
5203 int32_t arrayIndex;
5204 char s[SDDS_MAXLINE];
5205 arrayIndex = getArrayIndex(name);
5206 if (arrayIndex < 0) {
5207 sprintf(s, "Warning: array %s does not exist (SDDSFile::getArrayInDouble)", name);
5208 setError(s);
5209 return((double*)NULL);
5210 }
5211 result = arrayObject[arrayIndex]->getValuesInDouble(page, &errorcode);
5212 if (result == NULL) {
5213 if (errorcode == 1) {
5214 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInDouble)");
5215 } else if (errorcode == 2) {
5216 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInDouble)");
5217 } else if (errorcode == 3) {
5218 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInDouble)");
5219 }
5220 }
5221 return((double*)result);
5222}
5223
5224double* SDDSFile_getArrayInDouble(void *sddsfile, uint32_t page, int32_t mode, ...) {
5225 va_list ap;
5226 int32_t index;
5227 char *name;
5228
5229 va_start(ap, mode);
5230 if (mode&SDDSFILE_GETARRAY_WITH_INDEX) {
5231 index = va_arg(ap, int32_t);
5232 return(((SDDSFile*)sddsfile)->getArrayInDouble(index, page));
5233 } else {
5234 name = va_arg(ap, char *);
5235 return(((SDDSFile*)sddsfile)->getArrayInDouble(name, page));
5236 }
5237}
5238
5239/*
5240 * getArrayInString
5241 *
5242 * C++ Arguments: int32_t arrayIndex, uint32_t page
5243 * char *name, uint32_t page
5244 *
5245 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5246 * mode=SDDSFILE_GETARRAY_WITH_INDEX, int32_t arrayIndex
5247 * mode=SDDSFILE_GETARRAY_WITH_NAME, char *name
5248 *
5249 * Results: pointer to double values of the array on success (you must free the pointer and
5250 * the elements)
5251 * NULL on failure
5252 * You should should call checkForErrors to
5253 * determain if there was a problem getting the value because NULL is a valid
5254 * return value if there are zero elements
5255 */
5256char** SDDSFile::getArrayInString(int32_t arrayIndex, uint32_t page) {
5257 char **result;
5258 int32_t errorcode;
5259 char s[SDDS_MAXLINE];
5260 if ((arrayIndex < 0) || (arrayIndex >= arrayCount)) {
5261 sprintf(s, "Warning: array index %"PRId32" does not exist (SDDSFile::getArrayInString)", arrayIndex);
5262 setError(s);
5263 return((char**)NULL);
5264 }
5265 result = arrayObject[arrayIndex]->getValuesInString(page, &errorcode);
5266 if (result == NULL) {
5267 if (errorcode == 1) {
5268 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInString)");
5269 } else if (errorcode == 2) {
5270 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInString)");
5271 } else if (errorcode == 3) {
5272 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInString)");
5273 }
5274 }
5275 return((char**)result);
5276}
5277
5278char** SDDSFile::getArrayInString(char *name, uint32_t page) {
5279 char **result;
5280 int32_t errorcode;
5281 int32_t arrayIndex;
5282 char s[SDDS_MAXLINE];
5283 arrayIndex = getArrayIndex(name);
5284 if (arrayIndex < 0) {
5285 sprintf(s, "Warning: array %s does not exist (SDDSFile::getArrayInString)", name);
5286 setError(s);
5287 return((char**)NULL);
5288 }
5289 result = arrayObject[arrayIndex]->getValuesInString(page, &errorcode);
5290 if (result == NULL) {
5291 if (errorcode == 1) {
5292 setError((char*)"Warning: array value undefined (SDDSFile::getArrayInString)");
5293 } else if (errorcode == 2) {
5294 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getArrayInString)");
5295 } else if (errorcode == 3) {
5296 setError((char*)"Warning: invalid array type (SDDSFile::getArrayInString)");
5297 }
5298 }
5299 return((char**)result);
5300}
5301
5302char** SDDSFile_getArrayInString(void *sddsfile, uint32_t page, int32_t mode, ...) {
5303 va_list ap;
5304 int32_t index;
5305 char *name;
5306
5307 va_start(ap, mode);
5308 if (mode&SDDSFILE_GETARRAY_WITH_INDEX) {
5309 index = va_arg(ap, int32_t);
5310 return(((SDDSFile*)sddsfile)->getArrayInString(index, page));
5311 } else {
5312 name = va_arg(ap, char *);
5313 return(((SDDSFile*)sddsfile)->getArrayInString(name, page));
5314 }
5315}
5316
5317/*
5318 * getInteralColumn
5319 *
5320 * C++ Arguments: int32_t columnIndex, uint32_t page
5321 * char *name, uint32_t page
5322 *
5323 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5324 * mode=SDDSFILE_GETCOLUMN_WITH_INDEX, int32_t columnIndex
5325 * mode=SDDSFILE_GETCOLUMN_WITH_NAME, char *name
5326 *
5327 * Results: pointer to values of the column on success
5328 * NULL on failure
5329 */
5330void* SDDSFile::getInternalColumn(int32_t columnIndex, uint32_t page) {
5331 char s[SDDS_MAXLINE];
5332 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
5333 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::getInternalColumn)", columnIndex);
5334 setError(s);
5335 return(NULL);
5336 }
5337 return(columnObject[columnIndex]->getInternalValues(page));
5338}
5339void* SDDSFile::getInternalColumn(char *name, uint32_t page) {
5340 int32_t columnIndex;
5341 char s[SDDS_MAXLINE];
5342 columnIndex = getColumnIndex(name);
5343 if (columnIndex < 0) {
5344 sprintf(s, "Warning: column %s does not exist (SDDSFile::getInternalColumn)", name);
5345 setError(s);
5346 return(NULL);
5347 }
5348 return(columnObject[columnIndex]->getInternalValues(page));
5349}
5350void* SDDSFile_getInternalColumn(void *sddsfile, uint32_t page, int32_t mode, ...) {
5351 va_list ap;
5352 int32_t index;
5353 char *name;
5354
5355 va_start(ap, mode);
5356 if (mode&SDDSFILE_GETCOLUMN_WITH_INDEX) {
5357 index = va_arg(ap, int32_t);
5358 return(((SDDSFile*)sddsfile)->getInternalColumn(index, page));
5359 } else {
5360 name = va_arg(ap, char *);
5361 return(((SDDSFile*)sddsfile)->getInternalColumn(name, page));
5362 }
5363}
5364
5365/*
5366 * getColumnInInt32
5367 *
5368 * C++ Arguments: int32_t columnIndex, uint32_t page
5369 * char *name, uint32_t page
5370 *
5371 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5372 * mode=SDDSFILE_GETCOLUMN_WITH_INDEX, int32_t columnIndex
5373 * mode=SDDSFILE_GETCOLUMN_WITH_NAME, char *name
5374 *
5375 * Results: pointer to int32 values of the column on success (you must free the pointer)
5376 * NULL on failure
5377 * You should should call checkForErrors to
5378 * determain if there was a problem getting the value because NULL is a valid
5379 * return value if there are zero rows
5380 */
5381int32_t* SDDSFile::getColumnInInt32(int32_t columnIndex, uint32_t page) {
5382 int32_t *result;
5383 int32_t errorcode;
5384 char s[SDDS_MAXLINE];
5385 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
5386 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::getColumnInInt32)", columnIndex);
5387 setError(s);
5388 return((int32_t*)NULL);
5389 }
5390 result = columnObject[columnIndex]->getValuesInInt32(page, &errorcode);
5391 if (result == NULL) {
5392 if (errorcode == 1) {
5393 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInInt32)");
5394 } else if (errorcode == 2) {
5395 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInInt32)");
5396 } else if (errorcode == 3) {
5397 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInInt32)");
5398 }
5399 }
5400 return((int32_t*)result);
5401}
5402
5403int32_t* SDDSFile::getColumnInInt32(char *name, uint32_t page) {
5404 int32_t *result;
5405 int32_t errorcode;
5406 int32_t columnIndex;
5407 char s[SDDS_MAXLINE];
5408 columnIndex = getColumnIndex(name);
5409 if (columnIndex < 0) {
5410 sprintf(s, "Warning: column %s does not exist (SDDSFile::getColumnInInt32)", name);
5411 setError(s);
5412 return((int32_t*)NULL);
5413 }
5414 result = columnObject[columnIndex]->getValuesInInt32(page, &errorcode);
5415 if (result == NULL) {
5416 if (errorcode == 1) {
5417 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInInt32)");
5418 } else if (errorcode == 2) {
5419 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInInt32)");
5420 } else if (errorcode == 3) {
5421 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInInt32)");
5422 }
5423 }
5424 return((int32_t*)result);
5425}
5426
5427int32_t* SDDSFile_getColumnInInt32(void *sddsfile, uint32_t page, int32_t mode, ...) {
5428 va_list ap;
5429 int32_t index;
5430 char *name;
5431
5432 va_start(ap, mode);
5433 if (mode&SDDSFILE_GETCOLUMN_WITH_INDEX) {
5434 index = va_arg(ap, int32_t);
5435 return(((SDDSFile*)sddsfile)->getColumnInInt32(index, page));
5436 } else {
5437 name = va_arg(ap, char *);
5438 return(((SDDSFile*)sddsfile)->getColumnInInt32(name, page));
5439 }
5440}
5441
5442/*
5443 * getColumnInUInt32
5444 *
5445 * C++ Arguments: int32_t columnIndex, uint32_t page
5446 * char *name, uint32_t page
5447 *
5448 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5449 * mode=SDDSFILE_GETCOLUMN_WITH_INDEX, int32_t columnIndex
5450 * mode=SDDSFILE_GETCOLUMN_WITH_NAME, char *name
5451 *
5452 * Results: pointer to uint32 values of the column on success (you must free the pointer)
5453 * NULL on failure
5454 * You should should call checkForErrors to
5455 * determain if there was a problem getting the value because NULL is a valid
5456 * return value if there are zero rows
5457 */
5458uint32_t* SDDSFile::getColumnInUInt32(int32_t columnIndex, uint32_t page) {
5459 uint32_t *result;
5460 int32_t errorcode;
5461 char s[SDDS_MAXLINE];
5462 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
5463 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::getColumnInUInt32)", columnIndex);
5464 setError(s);
5465 return((uint32_t*)NULL);
5466 }
5467 result = columnObject[columnIndex]->getValuesInUInt32(page, &errorcode);
5468 if (result == NULL) {
5469 if (errorcode == 1) {
5470 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInUInt32)");
5471 } else if (errorcode == 2) {
5472 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInUInt32)");
5473 } else if (errorcode == 3) {
5474 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInUInt32)");
5475 }
5476 }
5477 return((uint32_t*)result);
5478}
5479
5480uint32_t* SDDSFile::getColumnInUInt32(char *name, uint32_t page) {
5481 uint32_t *result;
5482 int32_t errorcode;
5483 int32_t columnIndex;
5484 char s[SDDS_MAXLINE];
5485 columnIndex = getColumnIndex(name);
5486 if (columnIndex < 0) {
5487 sprintf(s, "Warning: column %s does not exist (SDDSFile::getColumnInUInt32)", name);
5488 setError(s);
5489 return((uint32_t*)NULL);
5490 }
5491 result = columnObject[columnIndex]->getValuesInUInt32(page, &errorcode);
5492 if (result == NULL) {
5493 if (errorcode == 1) {
5494 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInUInt32)");
5495 } else if (errorcode == 2) {
5496 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInUInt32)");
5497 } else if (errorcode == 3) {
5498 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInUInt32)");
5499 }
5500 }
5501 return((uint32_t*)result);
5502}
5503
5504uint32_t* SDDSFile_getColumnInUInt32(void *sddsfile, uint32_t page, int32_t mode, ...) {
5505 va_list ap;
5506 int32_t index;
5507 char *name;
5508
5509 va_start(ap, mode);
5510 if (mode&SDDSFILE_GETCOLUMN_WITH_INDEX) {
5511 index = va_arg(ap, int32_t);
5512 return(((SDDSFile*)sddsfile)->getColumnInUInt32(index, page));
5513 } else {
5514 name = va_arg(ap, char *);
5515 return(((SDDSFile*)sddsfile)->getColumnInUInt32(name, page));
5516 }
5517}
5518
5519/*
5520 * getColumnInDouble
5521 *
5522 * C++ Arguments: int32_t columnIndex, uint32_t page
5523 * char *name, uint32_t page
5524 *
5525 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5526 * mode=SDDSFILE_GETCOLUMN_WITH_INDEX, int32_t columnIndex
5527 * mode=SDDSFILE_GETCOLUMN_WITH_NAME, char *name
5528 *
5529 * Results: pointer to double values of the column on success (you must free the pointer)
5530 * NULL on failure
5531 * You should should call checkForErrors to
5532 * determain if there was a problem getting the value because NULL is a valid
5533 * return value if there are zero rows
5534 */
5535double* SDDSFile::getColumnInDouble(int32_t columnIndex, uint32_t page) {
5536 double *result;
5537 int32_t errorcode;
5538 char s[SDDS_MAXLINE];
5539 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
5540 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::getColumnInDouble)", columnIndex);
5541 setError(s);
5542 return((double*)NULL);
5543 }
5544 result = columnObject[columnIndex]->getValuesInDouble(page, &errorcode);
5545 if (result == NULL) {
5546 if (errorcode == 1) {
5547 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInDouble)");
5548 } else if (errorcode == 2) {
5549 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInDouble)");
5550 } else if (errorcode == 3) {
5551 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInDouble)");
5552 }
5553 }
5554 return((double*)result);
5555}
5556
5557double* SDDSFile::getColumnInDouble(char *name, uint32_t page) {
5558 double *result;
5559 int32_t errorcode;
5560 int32_t columnIndex;
5561 char s[SDDS_MAXLINE];
5562 columnIndex = getColumnIndex(name);
5563 if (columnIndex < 0) {
5564 sprintf(s, "Warning: column %s does not exist (SDDSFile::getColumnInDouble)", name);
5565 setError(s);
5566 return((double*)NULL);
5567 }
5568 result = columnObject[columnIndex]->getValuesInDouble(page, &errorcode);
5569 if (result == NULL) {
5570 if (errorcode == 1) {
5571 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInDouble)");
5572 } else if (errorcode == 2) {
5573 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInDouble)");
5574 } else if (errorcode == 3) {
5575 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInDouble)");
5576 }
5577 }
5578 return((double*)result);
5579}
5580
5581double* SDDSFile_getColumnInDouble(void *sddsfile, uint32_t page, int32_t mode, ...) {
5582 va_list ap;
5583 int32_t index;
5584 char *name;
5585
5586 va_start(ap, mode);
5587 if (mode&SDDSFILE_GETCOLUMN_WITH_INDEX) {
5588 index = va_arg(ap, int32_t);
5589 return(((SDDSFile*)sddsfile)->getColumnInDouble(index, page));
5590 } else {
5591 name = va_arg(ap, char *);
5592 return(((SDDSFile*)sddsfile)->getColumnInDouble(name, page));
5593 }
5594}
5595
5596/*
5597 * getColumnInString
5598 *
5599 * C++ Arguments: int32_t columnIndex, uint32_t page
5600 * char *name, uint32_t page
5601 *
5602 * C Arguments: void *sddsfile, uint32_t page, int32_t mode, ...
5603 * mode=SDDSFILE_GETCOLUMN_WITH_INDEX, int32_t columnIndex
5604 * mode=SDDSFILE_GETCOLUMN_WITH_NAME, char *name
5605 *
5606 * Results: pointer to double values of the column on success (you must free the pointer and
5607 * the elements)
5608 * NULL on failure
5609 * You should should call checkForErrors to
5610 * determain if there was a problem getting the value because NULL is a valid
5611 * return value if there are zero rows
5612 */
5613char** SDDSFile::getColumnInString(int32_t columnIndex, uint32_t page) {
5614 char **result;
5615 int32_t errorcode;
5616 char s[SDDS_MAXLINE];
5617 if ((columnIndex < 0) || (columnIndex >= columnCount)) {
5618 sprintf(s, "Warning: column index %"PRId32" does not exist (SDDSFile::getColumnInString)", columnIndex);
5619 setError(s);
5620 return((char**)NULL);
5621 }
5622 result = columnObject[columnIndex]->getValuesInString(page, &errorcode);
5623 if (result == NULL) {
5624 if (errorcode == 1) {
5625 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInString)");
5626 } else if (errorcode == 2) {
5627 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInString)");
5628 } else if (errorcode == 3) {
5629 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInString)");
5630 }
5631 }
5632 return((char**)result);
5633}
5634
5635char** SDDSFile::getColumnInString(char *name, uint32_t page) {
5636 char **result;
5637 int32_t errorcode;
5638 int32_t columnIndex;
5639 char s[SDDS_MAXLINE];
5640 columnIndex = getColumnIndex(name);
5641 if (columnIndex < 0) {
5642 sprintf(s, "Warning: column %s does not exist (SDDSFile::getColumnInString)", name);
5643 setError(s);
5644 return((char**)NULL);
5645 }
5646 result = columnObject[columnIndex]->getValuesInString(page, &errorcode);
5647 if (result == NULL) {
5648 if (errorcode == 1) {
5649 setError((char*)"Warning: column value undefined (SDDSFile::getColumnInString)");
5650 } else if (errorcode == 2) {
5651 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getColumnInString)");
5652 } else if (errorcode == 3) {
5653 setError((char*)"Warning: invalid column type (SDDSFile::getColumnInString)");
5654 }
5655 }
5656 return((char**)result);
5657}
5658
5659char** SDDSFile_getColumnInString(void *sddsfile, uint32_t page, int32_t mode, ...) {
5660 va_list ap;
5661 int32_t index;
5662 char *name;
5663
5664 va_start(ap, mode);
5665 if (mode&SDDSFILE_GETCOLUMN_WITH_INDEX) {
5666 index = va_arg(ap, int32_t);
5667 return(((SDDSFile*)sddsfile)->getColumnInString(index, page));
5668 } else {
5669 name = va_arg(ap, char *);
5670 return(((SDDSFile*)sddsfile)->getColumnInString(name, page));
5671 }
5672}
5673
5674/***********************************************************************************************
5675 * getParameterInInt32s *
5676 * *
5677 * C++ Arguments: int32_t parameterIndex *
5678 * char *name *
5679 * *
5680 * C Arguments: void *sddsfile, int32_t mode, ... *
5681 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
5682 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
5683 * *
5684 * Results: int32* values of the parameter on success *
5685 * You should free this pointer to avoid a memory leak *
5686 * NULL on failure *
5687 ***********************************************************************************************/
5688int32_t* SDDSFile::getParameterInInt32s(int32_t parameterIndex) {
5689 int32_t* result;
5690 int32_t errorcode;
5691 char s[SDDS_MAXLINE];
5692 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5693 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInInt32s)", parameterIndex);
5694 setError(s);
5695 return((int32_t*)NULL);
5696 }
5697 result = parameterObject[parameterIndex]->getValuesInInt32(&errorcode);
5698 if (result == NULL) {
5699 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInInt32s)", getParameterName(parameterIndex));
5700 setError(s);
5701 if (errorcode == 1) {
5702 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInInt32s)");
5703 } else if (errorcode == 2) {
5704 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInInt32s)");
5705 } else if (errorcode == 3) {
5706 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInInt32s)");
5707 }
5708 return((int32_t*)NULL);
5709 }
5710 return((int32_t*)result);
5711}
5712
5713int32_t* SDDSFile::getParameterInInt32s(char* name) {
5714 int32_t* result;
5715 int32_t errorcode;
5716 int32_t parameterIndex;
5717 char s[SDDS_MAXLINE];
5718 parameterIndex = getParameterIndex(name);
5719 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5720 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInInt32s)", name);
5721 setError(s);
5722 return((int32_t*)NULL);
5723 }
5724 result = parameterObject[parameterIndex]->getValuesInInt32(&errorcode);
5725 if (result == NULL) {
5726 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInInt32s)", name);
5727 setError(s);
5728 if (errorcode == 1) {
5729 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInInt32s)");
5730 } else if (errorcode == 2) {
5731 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInInt32s)");
5732 } else if (errorcode == 3) {
5733 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInInt32s)");
5734 }
5735 return((int32_t*)NULL);
5736 }
5737 return((int32_t*)result);
5738}
5739
5740int32_t* SDDSFile_getParameterInInt32s(void *sddsfile, int32_t mode, ...) {
5741 va_list ap;
5742 int32_t index;
5743 char *name;
5744
5745 va_start(ap, mode);
5746 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
5747 index = va_arg(ap, int32_t);
5748 return(((SDDSFile*)sddsfile)->getParameterInInt32s(index));
5749 } else {
5750 name = va_arg(ap, char *);
5751 return(((SDDSFile*)sddsfile)->getParameterInInt32s(name));
5752 }
5753}
5754
5755/***********************************************************************************************
5756 * getParameterInUInt32s *
5757 * *
5758 * C++ Arguments: int32_t parameterIndex *
5759 * char *name *
5760 * *
5761 * C Arguments: void *sddsfile, int32_t mode, ... *
5762 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
5763 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
5764 * *
5765 * Results: uint32* values of the parameter on success *
5766 * You should free this pointer to avoid a memory leak *
5767 * NULL on failure *
5768 ***********************************************************************************************/
5769uint32_t* SDDSFile::getParameterInUInt32s(int32_t parameterIndex) {
5770 uint32_t* result;
5771 int32_t errorcode;
5772 char s[SDDS_MAXLINE];
5773 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5774 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInUInt32s)", parameterIndex);
5775 setError(s);
5776 return((uint32_t*)NULL);
5777 }
5778 result = parameterObject[parameterIndex]->getValuesInUInt32(&errorcode);
5779 if (result == NULL) {
5780 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInUInt32s)", getParameterName(parameterIndex));
5781 setError(s);
5782 if (errorcode == 1) {
5783 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInUInt32s)");
5784 } else if (errorcode == 2) {
5785 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInUInt32s)");
5786 } else if (errorcode == 3) {
5787 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInUInt32s)");
5788 }
5789 return((uint32_t*)NULL);
5790 }
5791 return((uint32_t*)result);
5792}
5793
5794uint32_t* SDDSFile::getParameterInUInt32s(char* name) {
5795 uint32_t* result;
5796 int32_t errorcode;
5797 int32_t parameterIndex;
5798 char s[SDDS_MAXLINE];
5799 parameterIndex = getParameterIndex(name);
5800 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5801 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInUInt32s)", name);
5802 setError(s);
5803 return((uint32_t*)NULL);
5804 }
5805 result = parameterObject[parameterIndex]->getValuesInUInt32(&errorcode);
5806 if (result == NULL) {
5807 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInUInt32s)", name);
5808 setError(s);
5809 if (errorcode == 1) {
5810 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInUInt32s)");
5811 } else if (errorcode == 2) {
5812 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInUInt32s)");
5813 } else if (errorcode == 3) {
5814 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInUInt32s)");
5815 }
5816 return((uint32_t*)NULL);
5817 }
5818 return((uint32_t*)result);
5819}
5820
5821uint32_t* SDDSFile_getParameterInUInt32s(void *sddsfile, int32_t mode, ...) {
5822 va_list ap;
5823 int32_t index;
5824 char *name;
5825
5826 va_start(ap, mode);
5827 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
5828 index = va_arg(ap, int32_t);
5829 return(((SDDSFile*)sddsfile)->getParameterInUInt32s(index));
5830 } else {
5831 name = va_arg(ap, char *);
5832 return(((SDDSFile*)sddsfile)->getParameterInUInt32s(name));
5833 }
5834}
5835
5836/***********************************************************************************************
5837 * getParameterInDoubles *
5838 * *
5839 * C++ Arguments: int32_t parameterIndex *
5840 * char *name *
5841 * *
5842 * C Arguments: void *sddsfile, int32_t mode, ... *
5843 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
5844 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
5845 * *
5846 * Results: double* values of the parameter on success *
5847 * You should free this pointer to avoid a memory leak *
5848 * NULL on failure *
5849 ***********************************************************************************************/
5850double* SDDSFile::getParameterInDoubles(int32_t parameterIndex) {
5851 double* result;
5852 int32_t errorcode;
5853 char s[SDDS_MAXLINE];
5854 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5855 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInDoubles)", parameterIndex);
5856 setError(s);
5857 return((double*)NULL);
5858 }
5859 result = parameterObject[parameterIndex]->getValuesInDouble(&errorcode);
5860 if (result == NULL) {
5861 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInDoubles)", getParameterName(parameterIndex));
5862 setError(s);
5863 if (errorcode == 1) {
5864 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInDoubles)");
5865 } else if (errorcode == 2) {
5866 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInDoubles)");
5867 } else if (errorcode == 3) {
5868 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInDoubles)");
5869 }
5870 return((double*)NULL);
5871 }
5872 return((double*)result);
5873}
5874
5875double* SDDSFile::getParameterInDoubles(char* name) {
5876 double* result;
5877 int32_t errorcode;
5878 int32_t parameterIndex;
5879 char s[SDDS_MAXLINE];
5880 parameterIndex = getParameterIndex(name);
5881 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5882 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInDoubles)", name);
5883 setError(s);
5884 return((double*)NULL);
5885 }
5886 result = parameterObject[parameterIndex]->getValuesInDouble(&errorcode);
5887 if (result == NULL) {
5888 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInDoubles)", name);
5889 setError(s);
5890 if (errorcode == 1) {
5891 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInDoubles)");
5892 } else if (errorcode == 2) {
5893 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInDoubles)");
5894 } else if (errorcode == 3) {
5895 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInDoubles)");
5896 }
5897 return((double*)NULL);
5898 }
5899 return((double*)result);
5900}
5901
5902double* SDDSFile_getParameterInDoubles(void *sddsfile, int32_t mode, ...) {
5903 va_list ap;
5904 int32_t index;
5905 char *name;
5906
5907 va_start(ap, mode);
5908 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
5909 index = va_arg(ap, int32_t);
5910 return(((SDDSFile*)sddsfile)->getParameterInDoubles(index));
5911 } else {
5912 name = va_arg(ap, char *);
5913 return(((SDDSFile*)sddsfile)->getParameterInDoubles(name));
5914 }
5915}
5916
5917/***********************************************************************************************
5918 * getParameterInStrings *
5919 * *
5920 * C++ Arguments: int32_t parameterIndex *
5921 * char *name *
5922 * *
5923 * C Arguments: void *sddsfile, int32_t mode, ... *
5924 * mode=SDDSFILE_GETPARAMETER_WITH_INDEX, int32_t parameterIndex *
5925 * mode=SDDSFILE_GETPARAMETER_WITH_NAME, char *name *
5926 * *
5927 * Results: char** values of the parameter on success *
5928 * You should free this pointer to avoid a memory leak *
5929 * NULL on failure *
5930 ***********************************************************************************************/
5931char** SDDSFile::getParameterInStrings(int32_t parameterIndex) {
5932 char** result;
5933 int32_t errorcode;
5934 char s[SDDS_MAXLINE];
5935 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5936 sprintf(s, "Warning: parameter index %"PRId32" does not exist (SDDSFile::getParameterInStrings)", parameterIndex);
5937 setError(s);
5938 return((char**)NULL);
5939 }
5940 result = parameterObject[parameterIndex]->getValuesInString(&errorcode);
5941 if (result == NULL) {
5942 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInStrings)", getParameterName(parameterIndex));
5943 setError(s);
5944 if (errorcode == 1) {
5945 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInStrings)");
5946 } else if (errorcode == 2) {
5947 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInStrings)");
5948 } else if (errorcode == 3) {
5949 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInStrings)");
5950 }
5951 return((char**)NULL);
5952 }
5953 return((char**)result);
5954}
5955
5956char** SDDSFile::getParameterInStrings(char* name) {
5957 char** result;
5958 int32_t errorcode;
5959 int32_t parameterIndex;
5960 char s[SDDS_MAXLINE];
5961 parameterIndex = getParameterIndex(name);
5962 if ((parameterIndex < 0) || (parameterIndex >= parameterCount)) {
5963 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::getParameterInStrings)", name);
5964 setError(s);
5965 return((char**)NULL);
5966 }
5967 result = parameterObject[parameterIndex]->getValuesInString(&errorcode);
5968 if (result == NULL) {
5969 sprintf(s, "Warning: unable to get parameter value for %s (SDDSFile::getParameterInStrings)", name);
5970 setError(s);
5971 if (errorcode == 1) {
5972 setError((char*)"Warning: parameter value undefined (SDDSFile::getParameterInStrings)");
5973 } else if (errorcode == 2) {
5974 setError((char*)"Warning: unable to convert value to proper type (SDDSFile::getParameterInStrings)");
5975 } else if (errorcode == 3) {
5976 setError((char*)"Warning: invalid parameter type (SDDSFile::getParameterInStrings)");
5977 }
5978 return((char**)NULL);
5979 }
5980 return((char**)result);
5981}
5982
5983char** SDDSFile_getParameterInStrings(void *sddsfile, int32_t mode, ...) {
5984 va_list ap;
5985 int32_t index;
5986 char *name;
5987
5988 va_start(ap, mode);
5989 if (mode&SDDSFILE_GETPARAMETER_WITH_INDEX) {
5990 index = va_arg(ap, int32_t);
5991 return(((SDDSFile*)sddsfile)->getParameterInStrings(index));
5992 } else {
5993 name = va_arg(ap, char *);
5994 return(((SDDSFile*)sddsfile)->getParameterInStrings(name));
5995 }
5996}
5997
5998/***********************************************************************************************
5999 * setError *
6000 * *
6001 * C++ Arguments: char *error_text *
6002 * *
6003 * C Arguments: void *sddsfile, char *error_text *
6004 * *
6005 * Results: none *
6006 ***********************************************************************************************/
6007void SDDSFile::setError(char *error_text) {
6008 if (error_text != NULL) {
6009 n_errors++;
6010 error_description = (char**)SDDS_realloc(error_description, sizeof(char*) * n_errors);
6011 if (error_text == NULL)
6012 error_description[n_errors - 1] = NULL;
6013 else {
6014 error_description[n_errors - 1] = (char*)SDDS_malloc(sizeof(char) * strlen(error_text) + 1);
6015 strcpy(error_description[n_errors - 1], error_text);
6016 }
6017 }
6018}
6019void SDDSFile_setError(void *sddsfile, char *error_text) {
6020 ((SDDSFile*)sddsfile)->setError(error_text);
6021}
6022
6023/***********************************************************************************************
6024 * printErrors *
6025 * *
6026 * C++ Arguments: FILE *fp, int32_t mode *
6027 * none *
6028 * *
6029 * C Arguments: void *sddsfile, FILE *fp, int32_t mode *
6030 * *
6031 * Valid mode values: SDDS_EXIT_PrintErrors, SDDS_VERBOSE_PrintErrors *
6032 * Please try to avoid writing code that will exit in a subroutine such as this. *
6033 * *
6034 * Results: none *
6035 ***********************************************************************************************/
6036void SDDSFile::printErrors(FILE *fpointer, int32_t mode) {
6037 int32_t i;
6038 char *registeredProgramName;
6039 if (n_errors == 0) {
6040 return;
6041 }
6042 if (fpointer == NULL) {
6043 n_errors = 0;
6044 return;
6045 }
6046 registeredProgramName = SDDS_getProgramName();
6047 if (registeredProgramName) {
6048 fprintf(fpointer, "Error for %s:\n", registeredProgramName);
6049 } else {
6050 fputs("Error:\n", fpointer);
6051 }
6052 if (error_description) {
6053 for (i=0; i<n_errors; i++) {
6054 if (error_description[i] != NULL) {
6055 fprintf(fpointer, "%s\n", error_description[i]);
6056 } else {
6057 fprintf(stderr, "warning: internal error: error_description[%" PRId32 "] pointer is unexpectedly NULL\n", i);
6058 }
6059 }
6060 } else {
6061 fprintf(stderr, "warning: internal error: error_description pointer is unexpectedly NULL\n");
6062 }
6063 fflush(fpointer);
6064 clearErrors();
6065 if (mode&SDDS_EXIT_PrintErrors) {
6066 exit(1);
6067 }
6068}
6069void SDDSFile::printErrors() {
6070 int32_t i;
6071 char *registeredProgramName;
6072 if (n_errors == 0) {
6073 return;
6074 }
6075 registeredProgramName = SDDS_getProgramName();
6076 if (registeredProgramName) {
6077 fprintf(stderr, "Error for %s:\n", registeredProgramName);
6078 } else {
6079 fputs("Error:\n", stderr);
6080 }
6081 if (error_description) {
6082 for (i=0; i<n_errors; i++) {
6083 if (error_description[i] != NULL) {
6084 fprintf(stderr, "%s\n", error_description[i]);
6085 }
6086 }
6087 } else {
6088 fprintf(stderr, "warning: internal error: error_description pointer is unexpectedly NULL\n");
6089 }
6090 clearErrors();
6091}
6092void SDDSFile_printErrors(void *sddsfile) {
6093 ((SDDSFile*)sddsfile)->printErrors();
6094}
6095
6096/***********************************************************************************************
6097 * checkForErrors *
6098 * *
6099 * C++ Arguments: none *
6100 * *
6101 * C Arguments: void *sddsfile *
6102 * *
6103 * Results: number or errors *
6104 ***********************************************************************************************/
6105int32_t SDDSFile::checkForErrors() {
6106 return(n_errors);
6107}
6108int32_t SDDSFile_checkForErrors(void *sddsfile) {
6109 return(((SDDSFile*)sddsfile)->checkForErrors());
6110}
6111
6112/***********************************************************************************************
6113 * clearErrors *
6114 * *
6115 * C++ Arguments: none *
6116 * *
6117 * C Arguments: void *sddsfile *
6118 * *
6119 * Results: none *
6120 ***********************************************************************************************/
6121void SDDSFile::clearErrors() {
6122 int32_t i;
6123 if (n_errors == 0)
6124 return;
6125 if (error_description) {
6126 for (i=0; i<n_errors; i++) {
6127 if (error_description[i] != NULL) {
6128 SDDS_free(error_description[i]);
6129 }
6130 }
6131 SDDS_free(error_description);
6132 error_description = NULL;
6133 }
6134 n_errors = 0;
6135}
6136void SDDSFile_clearErrors(void *sddsfile) {
6137 ((SDDSFile*)sddsfile)->clearErrors();
6138}
6139
6140/***********************************************************************************************
6141 * readFile *
6142 * *
6143 * C++ Arguments: none *
6144 * *
6145 * C Arguments: void *sddsfile *
6146 * *
6147 * Results: 0 on success *
6148 * 1 on failure *
6149 ***********************************************************************************************/
6150int32_t SDDSFile::readFile() {
6151 if (openInputFile()) {
6152 return(1);
6153 }
6154 if (readLayout()) {
6155 return(1);
6156 }
6157 if (readPages()) {
6158 return(1);
6159 }
6160 if (closeFile()) {
6161 return(1);
6162 }
6163 return(0);
6164}
6165int32_t SDDSFile_readFile(void *sddsfile) {
6166 return(((SDDSFile*)sddsfile)->readFile());
6167}
6168
6169/***********************************************************************************************
6170 * initializeInput *
6171 * *
6172 * C++ Arguments: char *filename *
6173 * *
6174 * C Arguments: void *sddsfile, char *filename *
6175 * *
6176 * Results: 0 on success *
6177 * 1 on failure *
6178 ***********************************************************************************************/
6179int32_t SDDSFile::initializeInput(char *filename) {
6180 setFileName(filename);
6181 if (openInputFile()) {
6182 return(1);
6183 }
6184 if (readLayout()) {
6185 return(1);
6186 }
6187 return(0);
6188}
6189int32_t SDDSFile_initializeInput(void *sddsfile, char *filename) {
6190 return(((SDDSFile*)sddsfile)->initializeInput(filename));
6191}
6192
6193/***********************************************************************************************
6194 * initializeOutput *
6195 * *
6196 * C++ Arguments: char *filename *
6197 * *
6198 * C Arguments: void *sddsfile, char *filename *
6199 * *
6200 * Results: 0 on success *
6201 * 1 on failure *
6202 ***********************************************************************************************/
6203int32_t SDDSFile::initializeOutput(int32_t data_mode, int32_t lines_per_row,
6204 char *description, char *contents, char *filename) {
6205 setFileName(filename);
6206 if (data_mode == SDDS_BINARY) {
6207 setBinaryMode();
6208 } else {
6209 setAsciiMode();
6210 }
6211 linesPerRow = lines_per_row;
6212 setDescription(description, contents);
6213 if (openOutputFile()) {
6214 return(1);
6215 }
6216 return(0);
6217}
6218int32_t SDDSFile_initializeOutput(void *sddsfile, int32_t data_mode, int32_t lines_per_row,
6219 char *description, char *contents, char *filename) {
6220 return(((SDDSFile*)sddsfile)->initializeOutput(data_mode, lines_per_row, description, contents, filename));
6221}
6222
6223/***********************************************************************************************
6224 * writeFile *
6225 * *
6226 * C++ Arguments: none *
6227 * *
6228 * C Arguments: void *sddsfile *
6229 * *
6230 * Results: 0 on success *
6231 * 1 on failure *
6232 ***********************************************************************************************/
6233int32_t SDDSFile::writeFile() {
6234 if (openOutputFile()) {
6235 return(1);
6236 }
6237 if (writeLayout()) {
6238 return(1);
6239 }
6240 if (writePages()) {
6241 return(1);
6242 }
6243 if (closeFile()) {
6244 return(1);
6245 }
6246 return(0);
6247}
6248int32_t SDDSFile_writeFile(void *sddsfile) {
6249 return(((SDDSFile*)sddsfile)->writeFile());
6250}
6251
6252/***********************************************************************************************
6253 * openInputFile *
6254 * *
6255 * C++ Arguments: none *
6256 * *
6257 * C Arguments: void *sddsfile *
6258 * *
6259 * Results: 0 on success *
6260 * 1 on failure *
6261 ***********************************************************************************************/
6262int32_t SDDSFile::openInputFile() {
6263 char s[SDDS_MAXLINE];
6264#if defined(zLib)
6265 char *extension;
6266#endif
6267 if (fileName == NULL) {
6268#if defined(_WIN32)
6269 if (_setmode(_fileno(stdin), _O_BINARY) == -1) {
6270 setError((char*)"unable to set stdin to binary mode");
6271 return(1);
6272 }
6273#endif
6274 fp = stdin;
6275 } else {
6276 if (!(fp=fopen(fileName, "rb"))) {
6277 sprintf(s, "Unable to open file %s for reading (SDDSFile::openInputFile)", fileName);
6278 setError(s);
6279 return(1);
6280 }
6281 //setvbuf(fp, NULL, _IOFBF, BUFSIZ);
6282#if defined(zLib)
6283 if ((extension = strrchr(fileName, '.')) && strcmp(extension, ".gz")==0) {
6284 gzipFile = true;
6285 gzfp=(void**)gzdopen(fileno(fp), "rb");
6286 if (gzfp == NULL) {
6287 sprintf(s, "Unable to open compressed file %s for reading (SDDSFile::openInputFile)", fileName);
6288 setError(s);
6289 return(1);
6290 }
6291 }
6292#endif
6293 }
6294 return(0);
6295}
6296int32_t SDDSFile_openInputFile(void *sddsfile) {
6297 return(((SDDSFile*)sddsfile)->openInputFile());
6298}
6299
6300/***********************************************************************************************
6301 * openOutputFile *
6302 * *
6303 * C++ Arguments: none *
6304 * *
6305 * C Arguments: void *sddsfile *
6306 * *
6307 * Results: 0 on success *
6308 * 1 on failure *
6309 ***********************************************************************************************/
6310int32_t SDDSFile::openOutputFile() {
6311 char s[SDDS_MAXLINE];
6312#if defined(zLib)
6313 char *extension;
6314#endif
6315 if (fileName == NULL) {
6316#if defined(_WIN32)
6317 if (_setmode(_fileno(stdout), _O_BINARY) == -1) {
6318 setError((char*)"unable to set stdout to binary mode");
6319 return(1);
6320 }
6321#endif
6322 fp = stdout;
6323 } else {
6324 if (SDDS_fileIsLocked(fileName)) {
6325 sprintf(s, "unable to open file %s for writing--file is locked (SDDSFile::openOutputFile)", fileName);
6326 setError(s);
6327 return(1);
6328 }
6329 if (!(fp=fopen(fileName, "wb"))) {
6330 sprintf(s, "Unable to open file %s for writing (SDDSFile::openOutputFile)", fileName);
6331 setError(s);
6332 return(1);
6333 }
6334 if (!SDDS_lockFile(fp, fileName, (char*)"SDDSFile::openOutputFile"))
6335 return(1);
6336#if defined(zLib)
6337 if ((extension = strrchr(fileName, '.')) && strcmp(extension, ".gz")==0) {
6338 gzipFile = true;
6339 gzfp=(void**)gzdopen(fileno(fp), "wb");
6340 if (gzfp == NULL) {
6341 sprintf(s, "Unable to open compressed file %s for writing (SDDSFile::openOutputFile)", fileName);
6342 setError(s);
6343 return(1);
6344 }
6345 }
6346#endif
6347 }
6348 return(0);
6349}
6350int32_t SDDSFile_openOutputFile(void *sddsfile) {
6351 return(((SDDSFile*)sddsfile)->openOutputFile());
6352}
6353
6354/***********************************************************************************************
6355 * readLayout *
6356 * *
6357 * C++ Arguments: none *
6358 * *
6359 * C Arguments: void *sddsfile *
6360 * *
6361 * Results: 0 on success *
6362 * 1 on failure *
6363 ***********************************************************************************************/
6364int32_t SDDSFile::readLayout() {
6365 char s[SDDS_MAXLINE];
6366 char *groupName, *ptr;
6367 int32_t i, result;
6368 uint32_t commentFlags;
6369#if defined(zLib)
6370 if (gzipFile) {
6371 if (gzfp==NULL) {
6372 setError((char*)"Can't read SDDS layout--file pointer is NULL (SDDSFile::readLayout)");
6373 return(1);
6374 }
6375 } else {
6376#endif
6377 if (fp==NULL) {
6378 setError((char*)"Can't read SDDS layout--file pointer is NULL (SDDSFile::readLayout)");
6379 return(1);
6380 }
6381#if defined(zLib)
6382 }
6383#endif
6384 if (readVersion()) {
6385 setError((char*)"Can't read SDDS layout--error writing version (SDDSFile::readLayout)");
6386 return(1);
6387 }
6388 if ((layoutVersion < 1) || (layoutVersion > SDDS_VERSION)) {
6389 sprintf(s, "Unable to read SDDS version %"PRId32" files", layoutVersion);
6390 setError(s);
6391 return(1);
6392 }
6393 SDDS_resetSpecialCommentsModes();
6394#if defined(zLib)
6395 if (gzipFile) {
6396 result = SDDS_getNamelist(s, SDDS_MAXLINE, gzfp);
6397 } else {
6398#endif
6399 result = SDDS_getNamelist(s, SDDS_MAXLINE, fp);
6400#if defined(zLib)
6401 }
6402#endif
6403 while (result) {
6404 groupName = s+1;
6405 if ((ptr=strpbrk(s, " \t")) == NULL) {
6406 setError((char*)"Unable to read layout---no groupname in namelist (SDDSFile::readLayout)");
6407 return(1);
6408 }
6409 *ptr = 0;
6410 if (strcmp(groupName, (char*)"description") == 0) {
6411 if (processDescription(ptr+1)) {
6412 setError((char*)"Unable to process description (SDDSFile::readLayout)");
6413 return(1);
6414 }
6415 } else if (strcmp(groupName, (char*)"array") == 0) {
6416 if (processArray(ptr+1)) {
6417 setError((char*)"Unable to process array (SDDSFile::readLayout)");
6418 return(1);
6419 }
6420 } else if (strcmp(groupName, (char*)"column") == 0) {
6421 if (processColumn(ptr+1)) {
6422 setError((char*)"Unable to process column (SDDSFile::readLayout)");
6423 return(1);
6424 }
6425 } else if (strcmp(groupName, (char*)"parameter") == 0) {
6426 if (processParameter(ptr+1)) {
6427 setError((char*)"Unable to process parameter (SDDSFile::readLayout)");
6428 return(1);
6429 }
6430 } else if (strcmp(groupName, (char*)"data") == 0) {
6431 if (processData(ptr+1)) {
6432 setError((char*)"Unable to process parameter (SDDSFile::readLayout)");
6433 return(1);
6434 }
6435 commentFlags = SDDS_getSpecialCommentsModes();
6436 if ((commentFlags&SDDS_BIGENDIAN_SEEN) && (commentFlags&SDDS_LITTLEENDIAN_SEEN)) {
6437 setError((char*)"Unable to read data as it says it is both big and little endian (SDDSFile::readLayout)");
6438 return(1);
6439 }
6440 if (commentFlags&SDDS_BIGENDIAN_SEEN) {
6441 bigEndian = true;
6442 }
6443 if (commentFlags&SDDS_LITTLEENDIAN_SEEN) {
6444 bigEndian = false;
6445 }
6446#if defined(zLib)
6447 if (gzipFile) {
6448 for (i=0; i<additionalHeaderLines; i++) {
6449 if (SDDS_fgetsSkipComments(s, SDDS_MAXLINE, gzfp, '!') == NULL) {
6450 setError((char*)"Unexpected end-of-file while skipping past additional header lines (SDDSFile::readLayout)");
6451 return(1);
6452 }
6453 }
6454 } else {
6455#endif
6456 for (i=0; i<additionalHeaderLines; i++) {
6457 if (SDDS_fgetsSkipComments(s, SDDS_MAXLINE, fp, '!') == NULL) {
6458 setError((char*)"Unexpected end-of-file while skipping past additional header lines (SDDSFile::readLayout)");
6459 return(1);
6460 }
6461 }
6462#if defined(zLib)
6463 }
6464#endif
6465 return(0);
6466 } else if (strcmp(groupName, (char*)"associate") == 0) {
6467 fprintf(stderr, "ASSOCIATE\n");
6468 } else if (strcmp(groupName, (char*)"include") == 0) {
6469 fprintf(stderr, "INCLUDE\n");
6470 } else {
6471 sprintf(s, "Unknown layout entry %s given (SDDSFile::readLayout)", groupName);
6472 setError(s);
6473 return(1);
6474 }
6475#if defined(zLib)
6476 if (gzipFile) {
6477 result = SDDS_getNamelist(s, SDDS_MAXLINE, gzfp);
6478 } else {
6479#endif
6480 result = SDDS_getNamelist(s, SDDS_MAXLINE, fp);
6481#if defined(zLib)
6482 }
6483#endif
6484 }
6485 sprintf(s, "Missing data layout entry (SDDSFile::readLayout)");
6486 setError(s);
6487 return(1);
6488}
6489int32_t SDDSFile_readLayout(void *sddsfile) {
6490 return(((SDDSFile*)sddsfile)->readLayout());
6491}
6492
6493/***********************************************************************************************
6494 * writeLayout *
6495 * *
6496 * C++ Arguments: none *
6497 * *
6498 * C Arguments: void *sddsfile *
6499 * *
6500 * Results: 0 on success *
6501 * 1 on failure *
6502 ***********************************************************************************************/
6503int32_t SDDSFile::writeLayout() {
6504 char *outputEndianess = NULL;
6505 if ((outputEndianess = getenv("SDDS_OUTPUT_ENDIANESS"))) {
6506 if (strncmp(outputEndianess, "big", 3) == 0) {
6507 bigEndian = true;
6508 } else if (strncmp(outputEndianess, "little", 6) == 0) {
6509 bigEndian = false;
6510 }
6511 }
6512#if defined(zLib)
6513 if (gzipFile) {
6514 if (gzfp==NULL) {
6515 setError((char*)"Can't write SDDS layout--file pointer is NULL (SDDSFile::writeLayout)");
6516 return(1);
6517 }
6518 } else {
6519#endif
6520 if (fp==NULL) {
6521 setError((char*)"Can't write SDDS layout--file pointer is NULL (SDDSFile::writeLayout)");
6522 return(1);
6523 }
6524#if defined(zLib)
6525 }
6526#endif
6527 if (writeVersion(layoutVersion)) {
6528 setError((char*)"Can't write SDDS layout--error writing version (SDDSFile::writeLayout)");
6529 return(1);
6530 }
6531 if (writeDescription()) {
6532 setError((char*)"Can't write SDDS layout--error writing description (SDDSFile::writeLayout)");
6533 return(1);
6534 }
6535 if (writeParameterDefinitions()) {
6536 setError((char*)"Unable to write layout--error writing parameter definitions (SDDSFile::writeLayout)");
6537 return(1);
6538 }
6539 if (writeArrayDefinitions()) {
6540 setError((char*)"Unable to write layout--error writing array definitions (SDDSFile::writeLayout)");
6541 return(1);
6542 }
6543 if (writeColumnDefinitions()) {
6544 setError((char*)"Unable to write layout--error writing column definitions (SDDSFile::writeLayout)");
6545 return(1);
6546 }
6547 if (writeDataMode()) {
6548 setError((char*)"Unable to write layout--error writing data mode (SDDSFile::writeLayout)");
6549 return(1);
6550 }
6551#if defined(zLib)
6552 if (!gzipFile) {
6553#endif
6554 fflush(fp);
6555#if defined(zLib)
6556 }
6557#endif
6558 return(0);
6559}
6560int32_t SDDSFile_writeLayout(void *sddsfile) {
6561 return(((SDDSFile*)sddsfile)->writeLayout());
6562}
6563
6564/***********************************************************************************************
6565 * readVersion *
6566 * *
6567 * C++ Arguments: none *
6568 * *
6569 * Results: 0 on success *
6570 * 1 on failure *
6571 ***********************************************************************************************/
6572int32_t SDDSFile::readVersion() {
6573 char s[SDDS_MAXLINE];
6574#if defined(zLib)
6575 if (gzipFile) {
6576 if (gzfp==NULL) {
6577 return(1);
6578 }
6579 if (!gzgets(gzfp, s, SDDS_MAXLINE)) {
6580 setError((char*)"Unable to read layout--no header lines found (SDDSFile::readVersion)");
6581 return(1);
6582 }
6583 } else {
6584#endif
6585 if (fp==NULL) {
6586 return(1);
6587 }
6588 if (!fgets(s, SDDS_MAXLINE, fp)) {
6589 setError((char*)"Unable to read layout--no header lines found (SDDSFile::readVersion)");
6590 return(1);
6591 }
6592#if defined(zLib)
6593 }
6594#endif
6595 if (strncmp(s, "SDDS", 4)!=0) {
6596 setError((char*)"Unable to read layout--no header lines found (SDDSFile::readVersion)");
6597 return(1);
6598 }
6599 if (sscanf(s+4, "%" SCNd32, &layoutVersion)!=1) {
6600 setError((char*)"Unable to read layout--no version number on first line (SDDSFile::readVersion)");
6601 return(1);
6602 }
6603 return(0);
6604}
6605/***********************************************************************************************
6606 * writeVersion *
6607 * *
6608 * C++ Arguments: int32_t version_number *
6609 * *
6610 * Results: 0 on success *
6611 * 1 on failure *
6612 ***********************************************************************************************/
6613int32_t SDDSFile::writeVersion(int32_t version_number) {
6614#if defined(zLib)
6615 if (gzipFile) {
6616 if (gzfp==NULL) {
6617 return(1);
6618 }
6619 gzprintf(gzfp, "SDDS%" PRId32 "\n", version_number);
6620 } else {
6621#endif
6622 if (fp==NULL) {
6623 return(1);
6624 }
6625 fprintf(fp, "SDDS%" PRId32 "\n", version_number);
6626#if defined(zLib)
6627 }
6628#endif
6629 return(0);
6630}
6631
6632/***********************************************************************************************
6633 * writeDescription *
6634 * *
6635 * C++ Arguments: int32_t version_number *
6636 * *
6637 * Results: 0 on success *
6638 * 1 on failure *
6639 ***********************************************************************************************/
6640int32_t SDDSFile::writeDescription() {
6641 if ((descriptionText == NULL) && (descriptionContents == NULL)) {
6642 return(0);
6643 }
6644#if defined(zLib)
6645 if (gzipFile) {
6646 if (gzfp == NULL) {
6647 return(1);
6648 }
6649 gzputs(gzfp, "&description ");
6650 if (descriptionText != NULL) {
6651 if (SDDS_printNamelistField(gzfp, (char*)"text", descriptionText)) {
6652 return(1);
6653 }
6654 }
6655 if (descriptionContents != NULL) {
6656 if (SDDS_printNamelistField(gzfp, (char*)"contents", descriptionContents)) {
6657 return(1);
6658 }
6659 }
6660 gzputs(gzfp, "&end\n");
6661 } else {
6662#endif
6663 if (fp == NULL) {
6664 return(1);
6665 }
6666 fputs("&description ", fp);
6667 if (descriptionText != NULL) {
6668 if (SDDS_printNamelistField(fp, (char*)"text", descriptionText)) {
6669 return(1);
6670 }
6671 }
6672 if (descriptionContents != NULL) {
6673 if (SDDS_printNamelistField(fp, (char*)"contents", descriptionContents)) {
6674 return(1);
6675 }
6676 }
6677 fputs("&end\n", fp);
6678#if defined(zLib)
6679 }
6680#endif
6681 return(0);
6682}
6683
6684/*
6685 * writeArrayDefinitions
6686 *
6687 * C++ Arguments: none
6688 *
6689 * Results: 0 on success
6690 * 1 on failure
6691 */
6692int32_t SDDSFile::writeArrayDefinitions() {
6693 int32_t i;
6694 for (i=0; i<arrayCount; i++) {
6695 if (writeArrayDefinition(i)) {
6696 setError((char*)"Error writing array definitions (SDDSFile::writeArrayDefinitions)");
6697 return(1);
6698 }
6699 }
6700 return(0);
6701}
6702
6703/*
6704 * writeArrayDefinition
6705 *
6706 * C++ Arguments: int32_t arrayIndex
6707 *
6708 * Results: 0 on success
6709 * 1 on failure
6710 */
6711int32_t SDDSFile::writeArrayDefinition(int32_t arrayIndex) {
6712#if defined(zLib)
6713 if (gzipFile) {
6714 if (arrayObject[arrayIndex]->writeDefinition(gzfp)) {
6715 setError((char*)"Error writing array definition (SDDSFile::writeArrayDefinition)");
6716 return(1);
6717 }
6718 } else {
6719#endif
6720 if (arrayObject[arrayIndex]->writeDefinition(fp)) {
6721 setError((char*)"Error writing array definition (SDDSFile::writeArrayDefinition)");
6722 return(1);
6723 }
6724#if defined(zLib)
6725 }
6726#endif
6727 return(0);
6728}
6729
6730/*
6731 * writeColumnDefinitions
6732 *
6733 * C++ Arguments: none
6734 *
6735 * Results: 0 on success
6736 * 1 on failure
6737 */
6738int32_t SDDSFile::writeColumnDefinitions() {
6739 int32_t i;
6740 for (i=0; i<columnCount; i++) {
6741 if (writeColumnDefinition(i)) {
6742 setError((char*)"Error writing column definitions (SDDSFile::writeColumnDefinitions)");
6743 return(1);
6744 }
6745 }
6746 return(0);
6747}
6748
6749/*
6750 * writeColumnDefinition
6751 *
6752 * C++ Arguments: int32_t columnIndex
6753 *
6754 * Results: 0 on success
6755 * 1 on failure
6756 */
6757int32_t SDDSFile::writeColumnDefinition(int32_t columnIndex) {
6758#if defined(zLib)
6759 if (gzipFile) {
6760 if (columnObject[columnIndex]->writeDefinition(gzfp)) {
6761 setError((char*)"Error writing column definition (SDDSFile::writeColumnDefinition)");
6762 return(1);
6763 }
6764 } else {
6765#endif
6766 if (columnObject[columnIndex]->writeDefinition(fp)) {
6767 setError((char*)"Error writing column definition (SDDSFile::writeColumnDefinition)");
6768 return(1);
6769 }
6770#if defined(zLib)
6771 }
6772#endif
6773 return(0);
6774}
6775
6776/***********************************************************************************************
6777 * writeParameterDefinitions *
6778 * *
6779 * C++ Arguments: none *
6780 * *
6781 * Results: 0 on success *
6782 * 1 on failure *
6783 ***********************************************************************************************/
6784int32_t SDDSFile::writeParameterDefinitions() {
6785 int32_t i;
6786 for (i=0; i<parameterCount; i++) {
6787 if (writeParameterDefinition(i)) {
6788 setError((char*)"Error writing parameter definitions (SDDSFile::writeParameterDefinitions)");
6789 return(1);
6790 }
6791 }
6792 return(0);
6793}
6794
6795/***********************************************************************************************
6796 * writeParameterDefinition *
6797 * *
6798 * C++ Arguments: int32_t parameterIndex *
6799 * *
6800 * Results: 0 on success *
6801 * 1 on failure *
6802 ***********************************************************************************************/
6803int32_t SDDSFile::writeParameterDefinition(int32_t parameterIndex) {
6804#if defined(zLib)
6805 if (gzipFile) {
6806 if (parameterObject[parameterIndex]->writeDefinition(gzfp)) {
6807 setError((char*)"Error writing parameter definition (SDDSFile::writeParameterDefinition)");
6808 return(1);
6809 }
6810 } else {
6811#endif
6812 if (parameterObject[parameterIndex]->writeDefinition(fp)) {
6813 setError((char*)"Error writing parameter definition (SDDSFile::writeParameterDefinition)");
6814 return(1);
6815 }
6816#if defined(zLib)
6817 }
6818#endif
6819 return(0);
6820}
6821
6822/***********************************************************************************************
6823 * writeDataMode *
6824 * *
6825 * C++ Arguments: none *
6826 * *
6827 * Results: 0 on success *
6828 * 1 on failure *
6829 ***********************************************************************************************/
6830int32_t SDDSFile::writeDataMode() {
6831#if defined(zLib)
6832 if (gzipFile) {
6833 if (gzfp == NULL) {
6834 return(1);
6835 }
6836 gzputs(gzfp, "&data ");
6837 if (asciiFile) {
6838 if (SDDS_printNamelistField(gzfp, (char*)"mode", (char*)"ascii")) {
6839 return(1);
6840 }
6841 if (noRowCount) {
6842 if (layoutVersion >= 3) {
6843 if (SDDS_printNamelistField(gzfp, (char*)"no_row_counts", (char*)"true")) {
6844 return(1);
6845 }
6846 } else {
6847 if (SDDS_printNamelistField(gzfp, (char*)"no_row_counts", (char*)"1")) {
6848 return(1);
6849 }
6850 }
6851 }
6852 } else {
6853 if (SDDS_printNamelistField(gzfp, (char*)"mode", (char*)"binary")) {
6854 return(1);
6855 }
6856 if (layoutVersion >= 3) {
6857 if (bigEndian) {
6858 if (SDDS_printNamelistField(gzfp, (char*)"endian", (char*)"big")) {
6859 return(1);
6860 }
6861 } else {
6862 if (SDDS_printNamelistField(gzfp, (char*)"endian", (char*)"little")) {
6863 return(1);
6864 }
6865 }
6866 }
6867 if (columnMajorOrder && (layoutVersion >= 3)) {
6868 if (SDDS_printNamelistField(gzfp, (char*)"column_major_order", (char*)"true")) {
6869 return(1);
6870 }
6871 }
6872 }
6873
6874 gzputs(gzfp, "&end\n");
6875 } else {
6876#endif
6877 if (fp == NULL) {
6878 return(1);
6879 }
6880 fputs("&data ", fp);
6881 if (asciiFile) {
6882 if (SDDS_printNamelistField(fp, (char*)"mode", (char*)"ascii")) {
6883 return(1);
6884 }
6885 if (noRowCount) {
6886 if (layoutVersion >= 3) {
6887 if (SDDS_printNamelistField(fp, (char*)"no_row_counts", (char*)"true")) {
6888 return(1);
6889 }
6890 } else {
6891 if (SDDS_printNamelistField(fp, (char*)"no_row_counts", (char*)"1")) {
6892 return(1);
6893 }
6894 }
6895 }
6896 } else {
6897 if (SDDS_printNamelistField(fp, (char*)"mode", (char*)"binary")) {
6898 return(1);
6899 }
6900 if (layoutVersion >= 3) {
6901 if (bigEndian) {
6902 if (SDDS_printNamelistField(fp, (char*)"endian", (char*)"big")) {
6903 return(1);
6904 }
6905 } else {
6906 if (SDDS_printNamelistField(fp, (char*)"endian", (char*)"little")) {
6907 return(1);
6908 }
6909 }
6910 }
6911 if (columnMajorOrder && (layoutVersion >= 3)) {
6912 if (SDDS_printNamelistField(fp, (char*)"column_major_order", (char*)"true")) {
6913 return(1);
6914 }
6915 }
6916 }
6917 fputs("&end\n", fp);
6918#if defined(zLib)
6919 }
6920#endif
6921 return(0);
6922}
6923
6924/***********************************************************************************************
6925 * writePages *
6926 * *
6927 * C++ Arguments: none *
6928 * uint32_t startPage, uint32_t endPage *
6929 * *
6930 * C Arguments: void *sddsfile *
6931 * *
6932 * Results: 0 on success *
6933 * 1 on failure *
6934 ***********************************************************************************************/
6935int32_t SDDSFile::writePages() {
6936 return(writePages(1, pageCount()));
6937}
6938int32_t SDDSFile::writePages(uint32_t startPage, uint32_t endPage) {
6939 uint32_t i;
6940 for (i = startPage; i <= endPage ; i++) {
6941 if (writePage(i)) {
6942 return(1);
6943 }
6944 }
6945 return(0);
6946}
6947int32_t SDDSFile_writePages(void *sddsfile) {
6948 return(((SDDSFile*)sddsfile)->writePages());
6949}
6950
6951/***********************************************************************************************
6952 * writePage *
6953 * *
6954 * C++ Arguments: uint32_t page *
6955 * *
6956 * C Arguments: void *sddsfile, uint32_t page *
6957 * *
6958 * Results: 0 on success *
6959 * 1 on failure *
6960 ***********************************************************************************************/
6961int32_t SDDSFile::writePage(uint32_t page) {
6962 if (asciiFile) {
6963 return(writeAsciiPage(page));
6964 } else {
6965 return(writeBinaryPage(page));
6966 }
6967}
6968int32_t SDDSFile_writePage(void *sddsfile, uint32_t page) {
6969 return(((SDDSFile*)sddsfile)->writePage(page));
6970}
6971
6972/***********************************************************************************************
6973 * readPages *
6974 * *
6975 * C++ Arguments: none *
6976 * *
6977 * C Arguments: void *sddsfile *
6978 * *
6979 * Results: 0 on success *
6980 * 1 on failure *
6981 ***********************************************************************************************/
6982int32_t SDDSFile::readPages() {
6983 if (asciiFile) {
6984 return(readAsciiPages());
6985 } else {
6986 return(readBinaryPages());
6987 }
6988}
6989int32_t SDDSFile_readPages(void *sddsfile) {
6990 return(((SDDSFile*)sddsfile)->readPages());
6991}
6992
6993/***********************************************************************************************
6994 * readPage *
6995 * *
6996 * C++ Arguments: none *
6997 * *
6998 * C Arguments: void *sddsfile *
6999 * *
7000 * Results: 0 on success *
7001 * 1 on failure *
7002 ***********************************************************************************************/
7003int32_t SDDSFile::readPage() {
7004 freePage();
7005 if (asciiFile) {
7006 return(readAsciiPage());
7007 } else {
7008 return(readBinaryPage());
7009 }
7010}
7011int32_t SDDSFile_readPage(void *sddsfile) {
7012 return(((SDDSFile*)sddsfile)->readPage());
7013}
7014
7015/***********************************************************************************************
7016 * freePage *
7017 * *
7018 * This is called by readPage because it is assumed that the program only wants to have *
7019 * one page in memory at a time. If this is not the case then the program should call *
7020 * readPages instead. *
7021 * *
7022 * C++ Arguments: none *
7023 * *
7024 * Results: none *
7025 ***********************************************************************************************/
7026void SDDSFile::freePage() {
7027 int32_t i;
7028 for (i=0 ; i<arrayCount ; i++) {
7029 arrayObject[i]->freePage();
7030 }
7031 for (i=0 ; i<parameterCount ; i++) {
7032 parameterObject[i]->freePage();
7033 }
7034 for (i=0 ; i<columnCount ; i++) {
7035 columnObject[i]->freePage();
7036 }
7037}
7038void SDDSFile_freePage(void *sddsfile) {
7039 ((SDDSFile*)sddsfile)->freePage();
7040}
7041
7042/***********************************************************************************************
7043 * writeAsciiPage *
7044 * *
7045 * C++ Arguments: uint32_t page *
7046 * *
7047 * Results: 0 on success *
7048 * 1 on failure *
7049 ***********************************************************************************************/
7050int32_t SDDSFile::writeAsciiPage(uint32_t page) {
7051 char s[SDDS_MAXLINE];
7052 int32_t i;
7053 uint32_t j, rows;
7054 rows = rowCount(page);
7055#if defined(zLib)
7056 if (gzipFile) {
7057 if (gzfp == NULL) {
7058 return(1);
7059 }
7060 if ((noRowCount) && (page > 1) && (columnCount > 0)) {
7061 gzputc(gzfp, '\n');
7062 }
7063 gzprintf(gzfp, "! page number %" PRIu32 "\n", page);
7064 for (i=0 ; i<parameterCount ; i++) {
7065 if (parameterObject[i]->writeAsciiValue(gzfp, page)) {
7066 sprintf(s, "invalid page number (%" PRId32 ") for parameter %s (SDDSFile::writeAsciiPage)", page, parameterObject[i]->getName());
7067 setError(s);
7068 return(1);
7069 }
7070 }
7071 for (i=0 ; i<arrayCount ; i++) {
7072 if (arrayObject[i]->writeAsciiValues(gzfp, page)) {
7073 sprintf(s, "invalid page number (%" PRId32 ") for array %s (SDDSFile::writeAsciiPage)", page, arrayObject[i]->getName());
7074 setError(s);
7075 return(1);
7076 }
7077 }
7078 if ((!noRowCount) && (columnCount > 0)) {
7079 gzprintf(gzfp, "\t%" PRIu32 "\n", rows);
7080 }
7081 if (rows > 0) {
7082 for (j=1; j<=rows; j++) {
7083 for (i=0 ; i<columnCount ; i++) {
7084 if (columnObject[i]->writeAsciiValue(gzfp, page, j)) {
7085 sprintf(s, "invalid page or row number for column %s (SDDSFile::writeAsciiPage)", columnObject[i]->getName());
7086 setError(s);
7087 return(1);
7088 }
7089 }
7090 gzputc(gzfp, '\n');
7091 }
7092 }
7093 } else {
7094#endif
7095 if (fp == NULL) {
7096 return(1);
7097 }
7098 if ((noRowCount) && (page > 1) && (columnCount > 0)) {
7099 fputc('\n', fp);
7100 }
7101 fprintf(fp, "! page number %" PRIu32 "\n", page);
7102 for (i=0 ; i<parameterCount ; i++) {
7103 if (parameterObject[i]->writeAsciiValue(fp, page)) {
7104 sprintf(s, "invalid page number (%" PRId32 ") for parameter %s (SDDSFile::writeAsciiPage)", page, parameterObject[i]->getName());
7105 setError(s);
7106 return(1);
7107 }
7108 }
7109 for (i=0 ; i<arrayCount ; i++) {
7110 if (arrayObject[i]->writeAsciiValues(fp, page)) {
7111 sprintf(s, "invalid page number (%" PRId32 ") for array %s (SDDSFile::writeAsciiPage)", page, arrayObject[i]->getName());
7112 setError(s);
7113 return(1);
7114 }
7115 }
7116 if ((!noRowCount) && (columnCount > 0)) {
7117 fprintf(fp, "\t%" PRIu32 "\n", rows);
7118 }
7119 if (rows > 0) {
7120 for (j=1; j<=rows; j++) {
7121 for (i=0 ; i<columnCount ; i++) {
7122 if (columnObject[i]->writeAsciiValue(fp, page, j)) {
7123 sprintf(s, "invalid page or row number for column %s (SDDSFile::writeAsciiPage)", columnObject[i]->getName());
7124 setError(s);
7125 return(1);
7126 }
7127 }
7128 fputc('\n', fp);
7129 }
7130 }
7131 fflush(fp);
7132#if defined(zLib)
7133 }
7134#endif
7135 return(0);
7136}
7137
7138/***********************************************************************************************
7139 * writeBinaryPage *
7140 * *
7141 * C++ Arguments: uint32_t page *
7142 * *
7143 * Results: 0 on success *
7144 * 1 on failure *
7145 ***********************************************************************************************/
7146int32_t SDDSFile::writeBinaryPage(uint32_t page) {
7147 SDDS_FILEBUFFER fBuffer;
7148 int32_t i;
7149 uint32_t rows, j;
7150 bool big, nonNativeEndian;
7151 big = SDDS_isBigEndianMachine();
7152 if (big == true) {
7153 if (bigEndian == true) {
7154 nonNativeEndian = false;
7155 } else {
7156 nonNativeEndian = true;
7157 }
7158 } else {
7159 if (bigEndian == true) {
7160 nonNativeEndian = true;
7161 } else {
7162 nonNativeEndian = false;
7163 }
7164 }
7165 if ((fBuffer.buffer = fBuffer.data = (char*)SDDS_malloc(sizeof(char)*(defaultIOBufferSize+1))) == NULL) {
7166 setError((char*)"Unable to do buffered write--allocation error (SDDSFile::writeBinaryPage)");
7167 return(1);
7168 }
7169 fBuffer.bufferSize = defaultIOBufferSize;
7170 fBuffer.bytesLeft = defaultIOBufferSize;
7171
7172 rows = rowCount(page);
7173#if defined(zLib)
7174 if (gzipFile) {
7175 if (gzfp == NULL) {
7176 setError((char*)"Invalid file pointer (SDDSFile::writeBinaryPages)");
7177 return(1);
7178 }
7179 if (SDDS_bufferedWrite(&rows, sizeof(rows), gzfp, &fBuffer, this)) {
7180 setError((char*)"Unable to write page--failure writing number of rows (SDDSFile::writeBinaryPage)");
7181 return(1);
7182 }
7183 for (i=0 ; i<parameterCount ; i++) {
7184 if (parameterObject[i]->writeBinaryValue(gzfp, &fBuffer, page, nonNativeEndian)) {
7185 setError((char*)"Unable to write page--failure writing parameter (SDDSFile::writeBinaryPage)");
7186 return(1);
7187 }
7188 }
7189 for (i=0 ; i<arrayCount ; i++) {
7190 if (arrayObject[i]->writeBinaryValues(gzfp, &fBuffer, page, nonNativeEndian)) {
7191 setError((char*)"Unable to write page--failure writing array (SDDSFile::writeBinaryPage)");
7192 return(1);
7193 }
7194 }
7195 if (columnCount > 0) {
7196 page--;
7197 if (columnMajorOrder && (layoutVersion >= 3)) {
7198 if (rows > 0) {
7199 for (i=0 ; i<columnCount ; i++) {
7200 if (columnObject[i]->writeBinaryValues(gzfp, &fBuffer, page, nonNativeEndian)) {
7201 setError((char*)"Unable to write page--failure writing column (SDDSFile::writeBinaryPage)");
7202 return(1);
7203 }
7204 }
7205 }
7206 } else {
7207 for (j=0; j<rows; j++) {
7208 for (i=0 ; i<columnCount ; i++) {
7209 if (columnObject[i]->writeBinaryValue(gzfp, &fBuffer, page, j, nonNativeEndian)) {
7210 setError((char*)"Unable to write page--failure writing column (SDDSFile::writeBinaryPage)");
7211 return(1);
7212 }
7213 }
7214 }
7215 }
7216 page++;
7217 }
7218 if (SDDS_flushBuffer(gzfp, &fBuffer, this)) {
7219 setError((char*)"Unable to write page--buffer flushing problem (SDDSFile::writeBinaryPage)");
7220 return(1);
7221 }
7222 } else {
7223#endif
7224 if (fp == NULL) {
7225 setError((char*)"Invalid file pointer (SDDSFile::writeBinaryPages)");
7226 return(1);
7227 }
7228 if (SDDS_bufferedWrite(&rows, sizeof(rows), fp, &fBuffer, this)) {
7229 setError((char*)"Unable to write page--failure writing number of rows (SDDSFile::writeBinaryPage)");
7230 return(1);
7231 }
7232 for (i=0 ; i<parameterCount ; i++) {
7233 if (parameterObject[i]->writeBinaryValue(fp, &fBuffer, page, nonNativeEndian)) {
7234 setError((char*)"Unable to write page--failure writing parameter (SDDSFile::writeBinaryPage)");
7235 return(1);
7236 }
7237 }
7238 for (i=0 ; i<arrayCount ; i++) {
7239 if (arrayObject[i]->writeBinaryValues(fp, &fBuffer, page, nonNativeEndian)) {
7240 setError((char*)"Unable to write page--failure writing array (SDDSFile::writeBinaryPage)");
7241 return(1);
7242 }
7243 }
7244 if (columnCount > 0) {
7245 page--;
7246 if (columnMajorOrder && (layoutVersion >= 3)) {
7247 if (rows > 0) {
7248 for (i=0 ; i<columnCount ; i++) {
7249 if (columnObject[i]->writeBinaryValues(fp, &fBuffer, page, nonNativeEndian)) {
7250 setError((char*)"Unable to write page--failure writing column (SDDSFile::writeBinaryPage)");
7251 return(1);
7252 }
7253 }
7254 }
7255 } else {
7256 for (j=0; j<rows; j++) {
7257 for (i=0 ; i<columnCount ; i++) {
7258 if (columnObject[i]->writeBinaryValue(fp, &fBuffer, page, j, nonNativeEndian)) {
7259 setError((char*)"Unable to write page--failure writing column (SDDSFile::writeBinaryPage)");
7260 return(1);
7261 }
7262 }
7263 }
7264 }
7265 page++;
7266 }
7267 if (SDDS_flushBuffer(fp, &fBuffer, this)) {
7268 setError((char*)"Unable to write page--buffer flushing problem (SDDSFile::writeBinaryPage)");
7269 return(1);
7270 }
7271#if defined(zLib)
7272 }
7273#endif
7274 SDDS_free(fBuffer.buffer);
7275 return(0);
7276}
7277
7278
7279
7280
7281
7282
7283
7284
7285
7286
7287
7288
7289
7290
7291
7292
7293
7294
7295
7296
7297
7298
7299
7300
7301
7302
7303
7304
7305
7306
7307
7308
7309
7310
7311
7312
7313
7314
7315
7316
7317
7318
7319
7320
7321
7322
7323
7324
7325
7326
7327
7328
7329
7330
7331
7332
7333
7334
7335
7336
7337/***********************************************************************************************
7338 * readAsciiPages *
7339 * *
7340 * C++ Arguments: none *
7341 * *
7342 * Results: 0 on success *
7343 * 1 on failure *
7344 ***********************************************************************************************/
7345int32_t SDDSFile::readAsciiPages() {
7346 int32_t i;
7347 uint32_t page=1;
7348 bool asciiDataExpected=false, first_read;
7349 static char *bigBuffer=NULL;
7350 static int32_t bigBufferSize=0;
7351 char *bigBufferCopy;
7352 int32_t bigBufferCopySize;
7353 int32_t lines, columnIndex;
7354 uint32_t n_rows, j;
7355#if defined(zLib)
7356 if (gzipFile) {
7357 if (gzfp == NULL) {
7358 setError((char*)"Invalid file pointer (SDDSFile::readAsciiPages)");
7359 return(1);
7360 }
7361 } else {
7362#endif
7363 if (fp == NULL) {
7364 setError((char*)"Invalid file pointer (SDDSFile::readAsciiPages)");
7365 return(1);
7366 }
7367#if defined(zLib)
7368 }
7369#endif
7370 setReadRecoveryMode(0);
7371 for (i=0; i<parameterCount; i++) {
7372 if (getParameterFixedValue(i) == NULL) {
7373 asciiDataExpected = true;
7374 break;
7375 }
7376 }
7377 if ((columnCount > 0) || (arrayCount > 0)) {
7378 asciiDataExpected = true;
7379 }
7380 if (!asciiDataExpected) {
7381 return(0);
7382 }
7383 if (bigBufferSize == 0) {
7384 bigBufferSize = SDDS_MAXLINE;
7385 bigBuffer = (char*)SDDS_malloc(sizeof(char) * bigBufferSize);
7386 }
7387 while (true) {
7388 first_read=true;
7389#if defined(zLib)
7390 if (gzipFile) {
7391 if (gzeof(gzfp)) {
7392 if (page==1) {
7393 setError((char*)"No data in file (SDDSFile::readAsciiPages)");
7394 return(1);
7395 } else {
7396 return(0);
7397 }
7398 }
7399 } else {
7400#endif
7401 if (feof(fp)) {
7402 if (page==1) {
7403 setError((char*)"No data in file (SDDSFile::readAsciiPages)");
7404 return(1);
7405 } else {
7406 return(0);
7407 }
7408 }
7409#if defined(zLib)
7410 }
7411#endif
7412 for (i=0; i<parameterCount; i++) {
7413 bigBuffer[0] = 0;
7414 if (getParameterFixedValue(i) == NULL) {
7415#if defined(zLib)
7416 if (gzipFile) {
7417 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, gzfp, '!') == NULL) {
7418 if (first_read) {
7419 return(0);
7420 }
7421 setError((char*)"Unable to read parameter values (SDDSFile::readAsciiPages)");
7422 return(1);
7423 }
7424 } else {
7425#endif
7426 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, fp, '!') == NULL) {
7427 if (first_read) {
7428 return(0);
7429 }
7430 setError((char*)"Unable to read parameter values (SDDSFile::readAsciiPages)");
7431 return(1);
7432 }
7433#if defined(zLib)
7434 }
7435#endif
7436 first_read = false;
7437 bigBufferCopy = bigBuffer;
7438 bigBufferCopySize = strlen(bigBufferCopy);
7439 if (parameterObject[i]->readAsciiValue(&bigBufferCopy, &bigBufferCopySize, page)) {
7440 setError((char*)"Unable to read parameter (SDDSFile::readAsciiPages)");
7441 return(1);
7442 }
7443 }
7444 }
7445 for (i=0; i<arrayCount; i++) {
7446 /* ADD CODE HERE */
7447
7448 }
7449 if (columnCount > 0) {
7450 n_rows=0;
7451 if (noRowCount == false) {
7452#if defined(zLib)
7453 if (gzipFile) {
7454 if (SDDS_fgetsSkipComments(bigBuffer, bigBufferSize, gzfp, '!') == NULL) {
7455 if (first_read) {
7456 return(0);
7457 }
7458 setError((char*)"Unable to read row count (SDDSFile::readAsciiPages)");
7459 return(1);
7460 }
7461 } else {
7462#endif
7463 if (SDDS_fgetsSkipComments(bigBuffer, bigBufferSize, fp, '!') == NULL) {
7464 if (first_read) {
7465 return(0);
7466 }
7467 setError((char*)"Unable to read row count (SDDSFile::readAsciiPages)");
7468 return(1);
7469 }
7470#if defined(zLib)
7471 }
7472#endif
7473 first_read = false;
7474 if (sscanf(bigBuffer, "%" SCNu32, &n_rows)!=1 || n_rows<0) {
7475 setError((char*)"Unable to read page--file has no (valid) number-of-rows entry (SDDSFile::readAsciiPages)");
7476 return(1);
7477 }
7478 if (n_rows == 0) {
7479 page++;
7480 continue;
7481 }
7482 }
7483 j=0;
7484 lines=linesPerRow;
7485 columnIndex=0;
7486 while ((j<n_rows) || noRowCount) {
7487 bigBuffer[0] = 0;
7488#if defined(zLib)
7489 if (gzipFile) {
7490 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, gzfp, '!') == NULL) {
7491 if (noRowCount) {
7492 return(0);
7493 }
7494 setError((char*)"Unable to read column values (SDDSFile::readAsciiPages)");
7495 setReadRecoveryMode(1);
7496 return(1);
7497 }
7498 } else {
7499#endif
7500 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, fp, '!') == NULL) {
7501 if (noRowCount) {
7502 return(0);
7503 }
7504 setError((char*)"Unable to read column values (SDDSFile::readAsciiPages)");
7505 setReadRecoveryMode(1);
7506 return(1);
7507 }
7508#if defined(zLib)
7509 }
7510#endif
7511 if ((noRowCount) && (SDDS_stringIsBlank(bigBuffer))) {
7512 break;
7513 }
7514 bigBufferCopy = bigBuffer;
7515 bigBufferCopySize = strlen(bigBufferCopy);
7516 for (i=columnIndex; i<columnCount; i++) {
7517 if (columnObject[i]->readAsciiValue(&bigBufferCopy, &bigBufferCopySize, page)) {
7518 setError((char*)"Unable to read column (SDDSFile::readAsciiPages)");
7519 setReadRecoveryMode(1);
7520 return(1);
7521 }
7522 if ((i+1 != columnCount) && (SDDS_stringIsBlank(bigBufferCopy))) {
7523 if (lines > 1) {
7524 lines--;
7525 columnIndex = i+1;
7526 j--;
7527 break;
7528 } else {
7529 setError((char*)"Warning: missing element in row (SDDSFile::readAsciiPages)");
7530 setReadRecoveryMode(1);
7531 return(1);
7532 }
7533 } else if (linesPerRow > 1) {
7534 lines=linesPerRow;
7535 columnIndex=0;
7536 }
7537 }
7538 j++;
7539 }
7540 }
7541 page++;
7542 }
7543 return(0);
7544}
7545
7546/***********************************************************************************************
7547 * readAsciiPage *
7548 * *
7549 * C++ Arguments: none *
7550 * *
7551 * Results: page number on success *
7552 * 0 on failure *
7553 * -1 on EOF *
7554 ***********************************************************************************************/
7555uint32_t SDDSFile::readAsciiPage() {
7556 static uint32_t page=1;
7557 int32_t i;
7558 bool asciiDataExpected=false, first_read;
7559 static char *bigBuffer=NULL;
7560 static int32_t bigBufferSize=0;
7561 char *bigBufferCopy;
7562 int32_t bigBufferCopySize;
7563 int32_t lines, columnIndex;
7564 uint32_t n_rows, j;
7565#if defined(zLib)
7566 if (gzipFile) {
7567 if (gzfp == NULL) {
7568 setError((char*)"Invalid file pointer (SDDSFile::readAsciiPage)");
7569 return(0);
7570 }
7571 } else {
7572#endif
7573 if (fp == NULL) {
7574 setError((char*)"Invalid file pointer (SDDSFile::readAsciiPage)");
7575 return(0);
7576 }
7577#if defined(zLib)
7578 }
7579#endif
7580 setReadRecoveryMode(0);
7581 for (i=0; i<parameterCount; i++) {
7582 if (getParameterFixedValue(i) == NULL) {
7583 asciiDataExpected = true;
7584 break;
7585 }
7586 }
7587 if ((columnCount > 0) || (arrayCount > 0)) {
7588 asciiDataExpected = true;
7589 }
7590 if (!asciiDataExpected) {
7591 return(-1);
7592 }
7593 if (bigBufferSize == 0) {
7594 bigBufferSize = SDDS_MAXLINE;
7595 bigBuffer = (char*)SDDS_malloc(sizeof(char) * bigBufferSize);
7596 }
7597 /* while (true) {*/
7598 first_read=true;
7599#if defined(zLib)
7600 if (gzipFile) {
7601 if (gzeof(gzfp)) {
7602 if (page==1) {
7603 setError((char*)"No data in file (SDDSFile::readAsciiPage)");
7604 return(0);
7605 } else {
7606 return(-1);
7607 }
7608 }
7609 } else {
7610#endif
7611 if (feof(fp)) {
7612 if (page==1) {
7613 setError((char*)"No data in file (SDDSFile::readAsciiPage)");
7614 return(0);
7615 } else {
7616 return(-1);
7617 }
7618 }
7619#if defined(zLib)
7620 }
7621#endif
7622 for (i=0; i<parameterCount; i++) {
7623 bigBuffer[0] = 0;
7624 if (getParameterFixedValue(i) == NULL) {
7625#if defined(zLib)
7626 if (gzipFile) {
7627 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, gzfp, '!') == NULL) {
7628 if (first_read) {
7629 return(-1);
7630 }
7631 setError((char*)"Unable to read parameter values (SDDSFile::readAsciiPage)");
7632 return(0);
7633 }
7634 } else {
7635#endif
7636 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, fp, '!') == NULL) {
7637 if (first_read) {
7638 return(-1);
7639 }
7640 setError((char*)"Unable to read parameter values (SDDSFile::readAsciiPage)");
7641 return(0);
7642 }
7643#if defined(zLib)
7644 }
7645#endif
7646 first_read = false;
7647 bigBufferCopy = bigBuffer;
7648 bigBufferCopySize = strlen(bigBufferCopy);
7649 if (parameterObject[i]->readAsciiValue(&bigBufferCopy, &bigBufferCopySize, 1)) {
7650 setError((char*)"Unable to read parameter (SDDSFile::readAsciiPage)");
7651 return(0);
7652 }
7653 }
7654 }
7655 for (i=0; i<arrayCount; i++) {
7656 /* ADD CODE HERE */
7657
7658 }
7659 if (columnCount > 0) {
7660 n_rows=0;
7661 if (noRowCount == false) {
7662#if defined(zLib)
7663 if (gzipFile) {
7664 if (SDDS_fgetsSkipComments(bigBuffer, bigBufferSize, gzfp, '!') == NULL) {
7665 if (first_read) {
7666 return(-1);
7667 }
7668 setError((char*)"Unable to read row count (SDDSFile::readAsciiPage)");
7669 return(0);
7670 }
7671 } else {
7672#endif
7673 if (SDDS_fgetsSkipComments(bigBuffer, bigBufferSize, fp, '!') == NULL) {
7674 if (first_read) {
7675 return(-1);
7676 }
7677 setError((char*)"Unable to read row count (SDDSFile::readAsciiPage)");
7678 return(0);
7679 }
7680#if defined(zLib)
7681 }
7682#endif
7683 first_read = false;
7684 if (sscanf(bigBuffer, "%" SCNu32, &n_rows)!=1 || n_rows<0) {
7685 setError((char*)"Unable to read page--file has no (valid) number-of-rows entry (SDDSFile::readAsciiPage)");
7686 return(0);
7687 }
7688 if (n_rows == 0) {
7689 page++;
7690 return(page - 1);
7691 }
7692 }
7693 j=0;
7694 lines=linesPerRow;
7695 columnIndex=0;
7696 while ((j<n_rows) || noRowCount) {
7697 bigBuffer[0] = 0;
7698#if defined(zLib)
7699 if (gzipFile) {
7700 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, gzfp, '!') == NULL) {
7701 if (noRowCount) {
7702 page++;
7703 return(page - 1);
7704 }
7705 setError((char*)"Unable to read column values (SDDSFile::readAsciiPage)");
7706 setReadRecoveryMode(1);
7707 return(0);
7708 }
7709 } else {
7710#endif
7711 if (SDDS_fgetsSkipCommentsResize(&bigBuffer, &bigBufferSize, fp, '!') == NULL) {
7712 if (noRowCount) {
7713 page++;
7714 return(page - 1);
7715 }
7716 setError((char*)"Unable to read column values (SDDSFile::readAsciiPage)");
7717 setReadRecoveryMode(1);
7718 return(0);
7719 }
7720#if defined(zLib)
7721 }
7722#endif
7723 if ((noRowCount) && (SDDS_stringIsBlank(bigBuffer))) {
7724 break;
7725 }
7726 bigBufferCopy = bigBuffer;
7727 bigBufferCopySize = strlen(bigBufferCopy);
7728 for (i=columnIndex; i<columnCount; i++) {
7729 if (columnObject[i]->readAsciiValue(&bigBufferCopy, &bigBufferCopySize, 1)) {
7730 setError((char*)"Unable to read column (SDDSFile::readAsciiPage)");
7731 setReadRecoveryMode(1);
7732 return(0);
7733 }
7734 if ((i+1 != columnCount) && (SDDS_stringIsBlank(bigBufferCopy))) {
7735 if (lines > 1) {
7736 lines--;
7737 columnIndex = i+1;
7738 j--;
7739 break;
7740 } else {
7741 setError((char*)"Warning: missing element in row (SDDSFile::readAsciiPage)");
7742 setReadRecoveryMode(1);
7743 return(0);
7744 }
7745 } else if (linesPerRow > 1) {
7746 lines=linesPerRow;
7747 columnIndex=0;
7748 }
7749 }
7750 j++;
7751 }
7752 }
7753 page++;
7754 return(page - 1);
7755}
7756
7757/***********************************************************************************************
7758 * readBinaryPages *
7759 * *
7760 * C++ Arguments: none *
7761 * *
7762 * Results: 0 on success *
7763 * 1 on failure *
7764 ***********************************************************************************************/
7765int32_t SDDSFile::readBinaryPages() {
7766 SDDS_FILEBUFFER fBuffer;
7767 int32_t i;
7768 uint32_t page=1;
7769 uint32_t n_rows, j;
7770 char *ptr;
7771 bool big, nonNativeEndian;
7772 big = SDDS_isBigEndianMachine();
7773 if (big == true) {
7774 if (bigEndian == true) {
7775 nonNativeEndian = false;
7776 } else {
7777 nonNativeEndian = true;
7778 }
7779 } else {
7780 if (bigEndian == true) {
7781 nonNativeEndian = true;
7782 } else {
7783 nonNativeEndian = false;
7784 }
7785 }
7786 if ((ptr = fBuffer.buffer = fBuffer.data = (char*)SDDS_malloc(sizeof(char)*(defaultIOBufferSize+1))) == NULL) {
7787 setError((char*)"Unable to do buffered read--allocation error (SDDSFile::readBinaryPages)");
7788 return(1);
7789 }
7790 fBuffer.bufferSize = defaultIOBufferSize;
7791 fBuffer.bytesLeft = 0;
7792
7793#if defined(zLib)
7794 if (gzipFile) {
7795 if (gzfp == NULL) {
7796 setError((char*)"Invalid file pointer (SDDSFile::readBinaryPages)");
7797 return(1);
7798 }
7799 } else {
7800#endif
7801 if (fp == NULL) {
7802 setError((char*)"Invalid file pointer (SDDSFile::readBinaryPages)");
7803 return(1);
7804 }
7805#if defined(zLib)
7806 }
7807#endif
7808 setReadRecoveryMode(0);
7809 while (true) {
7810#if defined(zLib)
7811 if (gzipFile) {
7812 if ((page==1) && (gzeof(gzfp))) {
7813 setError((char*)"No data in file (SDDSFile::readBinaryPages)");
7814 return(1);
7815 }
7816 if (SDDS_bufferedRead(&n_rows, sizeof(n_rows), gzfp, &fBuffer, this)) {
7817 if (gzeof(gzfp)) {
7818 SDDS_free(ptr);
7819 return(0);
7820 }
7821 setError((char*)"Unable to read page--failure reading number of rows (SDDSFile::readBinaryPages)");
7822 return(1);
7823 }
7824 if (columnCount == 0) {
7825 setError((char*)"Unable to read page--rows detected but no columns (SDDSFile::readBinaryPages)");
7826 return(1);
7827 }
7828 for (i=0; i<parameterCount; i++) {
7829 if (getParameterFixedValue(i) == NULL) {
7830 if (parameterObject[i]->readBinaryValue(gzfp, &fBuffer, page, nonNativeEndian)) {
7831 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPages)");
7832 return(1);
7833 }
7834 }
7835 }
7836 for (i=0; i<arrayCount; i++) {
7837 /* ADD CODE HERE */
7838
7839 }
7840 if (columnCount > 0) {
7841 if (columnMajorOrder && (layoutVersion >= 3)) {
7842 for (i=0; i<columnCount; i++) {
7843 if (columnObject[i]->readBinaryValues(gzfp, &fBuffer, page, n_rows, nonNativeEndian)) {
7844 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPages)");
7845 setReadRecoveryMode(1);
7846 return(1);
7847 }
7848 }
7849 } else {
7850 for (j=1; j <= n_rows; j++) {
7851 for (i=0; i<columnCount; i++) {
7852 if (columnObject[i]->readBinaryValue(gzfp, &fBuffer, page, nonNativeEndian)) {
7853 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPages)");
7854 setReadRecoveryMode(1);
7855 return(1);
7856 }
7857 }
7858 }
7859 }
7860 }
7861 } else {
7862#endif
7863 if ((page==1) && (feof(fp))) {
7864 setError((char*)"No data in file (SDDSFile::readBinaryPages)");
7865 return(1);
7866 }
7867 if (SDDS_bufferedRead(&n_rows, sizeof(n_rows), fp, &fBuffer, this)) {
7868 if (feof(fp)) {
7869 SDDS_free(ptr);
7870 return(0);
7871 }
7872 setError((char*)"Unable to read page--failure reading number of rows (SDDSFile::readBinaryPages)");
7873 return(1);
7874 }
7875 if (columnCount == 0) {
7876 setError((char*)"Unable to read page--rows detected but no columns (SDDSFile::readBinaryPages)");
7877 return(1);
7878 }
7879 for (i=0; i<parameterCount; i++) {
7880 if (getParameterFixedValue(i) == NULL) {
7881 if (parameterObject[i]->readBinaryValue(fp, &fBuffer, page, nonNativeEndian)) {
7882 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPages)");
7883 return(1);
7884 }
7885 }
7886 }
7887 for (i=0; i<arrayCount; i++) {
7888 /* ADD CODE HERE */
7889
7890 }
7891 if (columnCount > 0) {
7892 if (columnMajorOrder && (layoutVersion >= 3)) {
7893 for (i=0; i<columnCount; i++) {
7894 if (columnObject[i]->readBinaryValues(fp, &fBuffer, page, n_rows, nonNativeEndian)) {
7895 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPages)");
7896 setReadRecoveryMode(1);
7897 return(1);
7898 }
7899 }
7900 } else {
7901 for (j=1; j <= n_rows; j++) {
7902 for (i=0; i<columnCount; i++) {
7903 if (columnObject[i]->readBinaryValue(fp, &fBuffer, page, nonNativeEndian)) {
7904 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPages)");
7905 setReadRecoveryMode(1);
7906 return(1);
7907 }
7908 }
7909 }
7910 }
7911 }
7912#if defined(zLib)
7913 }
7914#endif
7915 page++;
7916 }
7917 SDDS_free(ptr);
7918 return(0);
7919}
7920
7921/***********************************************************************************************
7922 * readBinaryPage *
7923 * *
7924 * C++ Arguments: none *
7925 * *
7926 * Results: page number on success *
7927 * 0 on failure *
7928 * -1 on EOF *
7929 ***********************************************************************************************/
7930uint32_t SDDSFile::readBinaryPage() {
7931 SDDS_FILEBUFFER fBuffer;
7932 static uint32_t page=1;
7933 int32_t i;
7934 uint32_t n_rows, j;
7935 char *ptr;
7936 bool big, nonNativeEndian;
7937 big = SDDS_isBigEndianMachine();
7938 if (big == true) {
7939 if (bigEndian == true) {
7940 nonNativeEndian = false;
7941 } else {
7942 nonNativeEndian = true;
7943 }
7944 } else {
7945 if (bigEndian == true) {
7946 nonNativeEndian = true;
7947 } else {
7948 nonNativeEndian = false;
7949 }
7950 }
7951 if ((ptr = fBuffer.buffer = fBuffer.data = (char*)SDDS_malloc(sizeof(char)*(defaultIOBufferSize+1))) == NULL) {
7952 setError((char*)"Unable to do buffered read--allocation error (SDDSFile::readBinaryPage)");
7953 return(0);
7954 }
7955 fBuffer.bufferSize = defaultIOBufferSize;
7956 fBuffer.bytesLeft = 0;
7957
7958#if defined(zLib)
7959 if (gzipFile) {
7960 if (gzfp == NULL) {
7961 setError((char*)"Invalid file pointer (SDDSFile::readBinaryPage)");
7962 return(0);
7963 }
7964 } else {
7965#endif
7966 if (fp == NULL) {
7967 setError((char*)"Invalid file pointer (SDDSFile::readBinaryPage)");
7968 return(0);
7969 }
7970#if defined(zLib)
7971 }
7972#endif
7973 setReadRecoveryMode(0);
7974#if defined(zLib)
7975 if (gzipFile) {
7976 if ((page==1) && (gzeof(gzfp))) {
7977 setError((char*)"No data in file (SDDSFile::readBinaryPage)");
7978 return(0);
7979 }
7980 if (SDDS_bufferedRead(&n_rows, sizeof(n_rows), gzfp, &fBuffer, this)) {
7981 if (gzeof(gzfp)) {
7982 SDDS_free(ptr);
7983 return(-1);
7984 }
7985 setError((char*)"Unable to read page--failure reading number of rows (SDDSFile::readBinaryPage)");
7986 return(0);
7987 }
7988 if (columnCount == 0) {
7989 setError((char*)"Unable to read page--rows detected but no columns (SDDSFile::readBinaryPage)");
7990 return(0);
7991 }
7992 for (i=0; i<parameterCount; i++) {
7993 if (getParameterFixedValue(i) == NULL) {
7994 if (parameterObject[i]->readBinaryValue(gzfp, &fBuffer, page, nonNativeEndian)) {
7995 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPage)");
7996 return(0);
7997 }
7998 }
7999 }
8000 for (i=0; i<arrayCount; i++) {
8001 /* ADD CODE HERE */
8002
8003 }
8004 if (columnCount > 0) {
8005 if (columnMajorOrder && (layoutVersion >= 3)) {
8006 for (i=0; i<columnCount; i++) {
8007 if (columnObject[i]->readBinaryValues(gzfp, &fBuffer, page, n_rows, nonNativeEndian)) {
8008 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPage)");
8009 setReadRecoveryMode(1);
8010 return(0);
8011 }
8012 }
8013 } else {
8014 for (j=1; j <= n_rows; j++) {
8015 for (i=0; i<columnCount; i++) {
8016 if (columnObject[i]->readBinaryValue(gzfp, &fBuffer, page, nonNativeEndian)) {
8017 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPage)");
8018 setReadRecoveryMode(1);
8019 return(0);
8020 }
8021 }
8022 }
8023 }
8024 }
8025 } else {
8026#endif
8027 if ((page==1) && (feof(fp))) {
8028 setError((char*)"No data in file (SDDSFile::readBinaryPage)");
8029 return(0);
8030 }
8031 if (SDDS_bufferedRead(&n_rows, sizeof(n_rows), fp, &fBuffer, this)) {
8032 if (feof(fp)) {
8033 SDDS_free(ptr);
8034 return(-1);
8035 }
8036 setError((char*)"Unable to read page--failure reading number of rows (SDDSFile::readBinaryPage)");
8037 return(0);
8038 }
8039 if (columnCount == 0) {
8040 setError((char*)"Unable to read page--rows detected but no columns (SDDSFile::readBinaryPage)");
8041 return(0);
8042 }
8043 for (i=0; i<parameterCount; i++) {
8044 if (getParameterFixedValue(i) == NULL) {
8045 if (parameterObject[i]->readBinaryValue(fp, &fBuffer, page, nonNativeEndian)) {
8046 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPage)");
8047 return(0);
8048 }
8049 }
8050 }
8051 for (i=0; i<arrayCount; i++) {
8052 /* ADD CODE HERE */
8053
8054 }
8055 if (columnCount > 0) {
8056 if (columnMajorOrder && (layoutVersion >= 3)) {
8057 for (i=0; i<columnCount; i++) {
8058 if (columnObject[i]->readBinaryValues(fp, &fBuffer, page, n_rows, nonNativeEndian)) {
8059 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPage)");
8060 setReadRecoveryMode(1);
8061 return(0);
8062 }
8063 }
8064 } else {
8065 for (j=1; j <= n_rows; j++) {
8066 for (i=0; i<columnCount; i++) {
8067 if (columnObject[i]->readBinaryValue(fp, &fBuffer, page, nonNativeEndian)) {
8068 setError((char*)"Unable to read page--failure reading parameter (SDDSFile::readBinaryPage)");
8069 setReadRecoveryMode(1);
8070 return(0);
8071 }
8072 }
8073 }
8074 }
8075 }
8076#if defined(zLib)
8077 }
8078#endif
8079 page++;
8080 SDDS_free(ptr);
8081 return(page - 1);
8082}
8083
8084/***********************************************************************************************
8085 * pageCount *
8086 * *
8087 * C++ Arguments: none *
8088 * *
8089 * C Arguments: void *sddsfile *
8090 * *
8091 * Results: pages in the SDDS file *
8092 ***********************************************************************************************/
8093uint32_t SDDSFile::pageCount() {
8094 int32_t i;
8095 uint32_t endPage, pages;
8096 endPage = 0;
8097 for (i=0;i<parameterCount;i++) {
8098 pages = parameterObject[i]->getPageCount();
8099 if (pages > endPage)
8100 endPage = pages;
8101 }
8102 for (i=0;i<arrayCount;i++) {
8103 pages = arrayObject[i]->getPageCount();
8104 if (pages > endPage)
8105 endPage = pages;
8106 }
8107 for (i=0;i<columnCount;i++) {
8108 pages = columnObject[i]->getPageCount();
8109 if (pages > endPage)
8110 endPage = pages;
8111 }
8112 return endPage;
8113}
8114uint32_t SDDSFile_pageCount(void *sddsfile) {
8115 return(((SDDSFile*)sddsfile)->pageCount());
8116}
8117
8118/***********************************************************************************************
8119 * rowCount *
8120 * *
8121 * C++ Arguments: uint32_t page *
8122 * *
8123 * C Arguments: void *sddsfile, uint32_t page *
8124 * *
8125 * Results: rows in the SDDS file at the given page *
8126 ***********************************************************************************************/
8127uint32_t SDDSFile::rowCount(uint32_t page) {
8128 int32_t i;
8129 uint32_t endRow, rows;
8130 endRow = 0;
8131 for (i=0;i<columnCount;i++) {
8132 rows = columnObject[i]->getRowCount(page);
8133 if (rows > endRow) {
8134 endRow = rows;
8135 if (i > 0) {
8136 fprintf(stderr, "Error: inconsistant row count for page %" PRId32 " (SDDSFile::rowCount)\n", page);
8137 exit(1);
8138 }
8139 }
8140 }
8141 return endRow;
8142}
8143uint32_t SDDSFile_rowCount(void *sddsfile, uint32_t page) {
8144 return(((SDDSFile*)sddsfile)->rowCount(page));
8145}
8146
8147/***********************************************************************************************
8148 * closeFile *
8149 * *
8150 * C++ Arguments: none *
8151 * *
8152 * C Arguments: void *sddsfile *
8153 * *
8154 * Results: 0 on success *
8155 * 1 on failure *
8156 ***********************************************************************************************/
8157int32_t SDDSFile::closeFile() {
8158#if defined(zLib)
8159 if (gzipFile) {
8160 if (gzfp == NULL) {
8161 setError((char*)"Warning: problem closing file (SDDSFile::closeFile)");
8162 return(1);
8163 }
8164 if (gzclose(gzfp)) {
8165 setError((char*)"Warning: problem closing file (SDDSFile::closeFile)");
8166 return(1);
8167 }
8168 } else {
8169#endif
8170 if (fp == NULL) {
8171 setError((char*)"Warning: problem closing file (SDDSFile::closeFile)");
8172 return(1);
8173 }
8174 if (fclose(fp)) {
8175 setError((char*)"Warning: problem closing file (SDDSFile::closeFile)");
8176 return(1);
8177 }
8178#if defined(zLib)
8179 }
8180#endif
8181 return(0);
8182}
8183int32_t SDDSFile_closeFile(void *sddsfile) {
8184 return(((SDDSFile*)sddsfile)->closeFile());
8185}
8186
8187/*
8188 * processArray
8189 *
8190 * C++ Arguments: char *s
8191 *
8192 * Results: 0 on success
8193 * 1 on failure
8194 */
8195int32_t SDDSFile::processArray(char *s) {
8196 char *name=NULL, *symbol=NULL, *units=NULL;
8197 char *description=NULL, *format_string=NULL, *group_name=NULL;
8198 char *type=NULL;
8199 uint32_t field_length=0, dimensions=0;
8200 char *ptr, *tag, *value;
8201 char buffer[SDDS_MAXLINE];
8202
8203 ptr = SDDS_prepareToParseTagValuePairs(s);
8204 while (*ptr && !SDDS_stringIsBlank(ptr) &&
8205 (ptr=getTagValuePair(ptr, &tag, &value))) {
8206 if (!tag) {
8207 break; /* normal termination */
8208 }
8209 if (strcmp(tag, (char*)"name") == 0) {
8210 if (SDDS_copyString(&name, value)) {
8211 setError((char*)"Problem setting string value for namelist");
8212 return(1);
8213 }
8214 } else if (strcmp(tag, (char*)"type") == 0) {
8215 if (SDDS_copyString(&type, value)) {
8216 setError((char*)"Problem setting string value for namelist");
8217 return(1);
8218 }
8219 } else if (strcmp(tag, (char*)"units") == 0) {
8220 if (SDDS_copyString(&units, value)) {
8221 setError((char*)"Problem setting string value for namelist");
8222 return(1);
8223 }
8224 } else if (strcmp(tag, (char*)"symbol") == 0) {
8225 if (SDDS_copyString(&symbol, value)) {
8226 setError((char*)"Problem setting string value for namelist");
8227 return(1);
8228 }
8229 } else if (strcmp(tag, (char*)"description") == 0) {
8230 if (SDDS_copyString(&description, value)) {
8231 setError((char*)"Problem setting string value for namelist");
8232 return(1);
8233 }
8234 } else if (strcmp(tag, (char*)"format_string") == 0) {
8235 if (SDDS_copyString(&format_string, value)) {
8236 setError((char*)"Problem setting string value for namelist");
8237 return(1);
8238 }
8239 } else if (strcmp(tag, (char*)"group_name") == 0) {
8240 if (SDDS_copyString(&group_name, value)) {
8241 setError((char*)"Problem setting string value for namelist");
8242 return(1);
8243 }
8244 } else if (strcmp(tag, (char*)"field_length") == 0) {
8245 if (!sscanf(value, "%" SCNu32, &field_length)) {
8246 setError((char*)"Problem scanning int32_t value for namelist");
8247 return(1);
8248 }
8249 } else if (strcmp(tag, (char*)"dimensions") == 0) {
8250 if (!sscanf(value, "%" SCNu32, &dimensions)) {
8251 setError((char*)"Problem scanning int32_t value for namelist");
8252 return(1);
8253 }
8254 } else {
8255 sprintf(buffer, "Unknown array tag %s", tag);
8256 setError(buffer);
8257 return(1);
8258 }
8259 }
8260 if (!ptr) {
8261 setError((char*)"Problem parsing array namelist");
8262 return(1);
8263 }
8264 if (defineArray(name, symbol, units, description,
8265 format_string, group_name, type, field_length, dimensions) == -1) {
8266 return(1);
8267 }
8268 if (name)
8269 SDDS_free(name);
8270 if (symbol)
8271 SDDS_free(symbol);
8272 if (units)
8273 SDDS_free(units);
8274 if (description)
8275 SDDS_free(description);
8276 if (format_string)
8277 SDDS_free(format_string);
8278 if (group_name)
8279 SDDS_free(group_name);
8280 if (type)
8281 SDDS_free(type);
8282 return(0);
8283}
8284
8285/*
8286 * processColumn
8287 *
8288 * C++ Arguments: char *s
8289 *
8290 * Results: 0 on success
8291 * 1 on failure
8292 */
8293int32_t SDDSFile::processColumn(char *s) {
8294 char *name=NULL, *symbol=NULL, *units=NULL;
8295 char *description=NULL, *format_string=NULL;
8296 char *type=NULL;
8297 uint32_t field_length=0;
8298 char *ptr, *tag, *value;
8299 char buffer[SDDS_MAXLINE];
8300
8301 ptr = SDDS_prepareToParseTagValuePairs(s);
8302 while (*ptr && !SDDS_stringIsBlank(ptr) &&
8303 (ptr=getTagValuePair(ptr, &tag, &value))) {
8304 if (!tag) {
8305 break; /* normal termination */
8306 }
8307 if (strcmp(tag, (char*)"name") == 0) {
8308 if (SDDS_copyString(&name, value)) {
8309 setError((char*)"Problem setting string value for namelist");
8310 return(1);
8311 }
8312 } else if (strcmp(tag, (char*)"type") == 0) {
8313 if (SDDS_copyString(&type, value)) {
8314 setError((char*)"Problem setting string value for namelist");
8315 return(1);
8316 }
8317 } else if (strcmp(tag, (char*)"units") == 0) {
8318 if (SDDS_copyString(&units, value)) {
8319 setError((char*)"Problem setting string value for namelist");
8320 return(1);
8321 }
8322 } else if (strcmp(tag, (char*)"symbol") == 0) {
8323 if (SDDS_copyString(&symbol, value)) {
8324 setError((char*)"Problem setting string value for namelist");
8325 return(1);
8326 }
8327 } else if (strcmp(tag, (char*)"description") == 0) {
8328 if (SDDS_copyString(&description, value)) {
8329 setError((char*)"Problem setting string value for namelist");
8330 return(1);
8331 }
8332 } else if (strcmp(tag, (char*)"format_string") == 0) {
8333 if (SDDS_copyString(&format_string, value)) {
8334 setError((char*)"Problem setting string value for namelist");
8335 return(1);
8336 }
8337 } else if (strcmp(tag, (char*)"field_length") == 0) {
8338 if (!sscanf(value, "%" SCNu32, &field_length)) {
8339 setError((char*)"Problem scanning int32_t value for namelist");
8340 return(1);
8341 }
8342 } else {
8343 sprintf(buffer, "Unknown column tag %s", tag);
8344 setError(buffer);
8345 return(1);
8346 }
8347 }
8348 if (!ptr) {
8349 setError((char*)"Problem parsing column namelist");
8350 return(1);
8351 }
8352 if (defineColumn(name, symbol, units, description,
8353 format_string, type, field_length) == -1) {
8354 return(1);
8355 }
8356 if (name)
8357 SDDS_free(name);
8358 if (symbol)
8359 SDDS_free(symbol);
8360 if (units)
8361 SDDS_free(units);
8362 if (description)
8363 SDDS_free(description);
8364 if (format_string)
8365 SDDS_free(format_string);
8366 if (type)
8367 SDDS_free(type);
8368 return(0);
8369}
8370
8371/************************
8372 processData
8373
8374 C++ Arguments: char *s
8375
8376 Results: 0 on success
8377 1 on failure
8378 ************************/
8379int32_t SDDSFile::processData(char *s) {
8380 int32_t no_row_counts=0;
8381
8382 char *ptr, *tag, *value;
8383 char buffer[SDDS_MAXLINE];
8384
8385 columnMajorOrder = false;
8386 ptr = SDDS_prepareToParseTagValuePairs(s);
8387 while (*ptr && !SDDS_stringIsBlank(ptr) &&
8388 (ptr=getTagValuePair(ptr, &tag, &value))) {
8389 if (!tag) {
8390 break; /* normal termination */
8391 }
8392 if (strcmp(tag, (char*)"mode") == 0) {
8393 if (strcmp(value, (char*)"ascii") == 0) {
8394 setAsciiMode();
8395 } else if (strcmp(value, (char*)"binary") == 0) {
8396 setBinaryMode();
8397 }
8398 } else if (strcmp(tag, (char*)"column_major_order") == 0) {
8399 if (strcmp(value, "true") == 0) {
8400 columnMajorOrder = true;
8401 } else {
8402 columnMajorOrder = false;
8403 }
8404 } else if (strcmp(tag, (char*)"no_row_counts") == 0) {
8405 if (strcmp(value, "true") == 0) {
8406 setNoRowCount();
8407 } else if (strcmp(value, "false") == 0) {
8408 setUseRowCount();
8409 } else {
8410 if (!sscanf(value, "%" SCNd32, &no_row_counts)) {
8411 setError((char*)"Problem scanning int32_t value for namelist");
8412 return(1);
8413 }
8414 if (no_row_counts) {
8415 setNoRowCount();
8416 } else {
8417 setUseRowCount();
8418 }
8419 }
8420 } else if (strcmp(tag, (char*)"endian") == 0) {
8421 if (strcmp(value, (char*)"big") == 0) {
8422 bigEndian = true;
8423 } else if (strcmp(value, (char*)"little") == 0) {
8424 bigEndian = false;
8425 }
8426 } else if (strcmp(tag, (char*)"lines_per_row") == 0) {
8427 if (!sscanf(value, "%" SCNd32, &linesPerRow)) {
8428 setError((char*)"Problem scanning int32_t value for namelist");
8429 return(1);
8430 }
8431 } else if (strcmp(tag, (char*)"additional_header_lines") == 0) {
8432 if (!sscanf(value, "%" SCNd32, &additionalHeaderLines)) {
8433 setError((char*)"Problem scanning int32_t value for namelist");
8434 return(1);
8435 }
8436 } else {
8437 sprintf(buffer, "Unknown data tag %s", tag);
8438 setError(buffer);
8439 return(1);
8440 }
8441 }
8442 if (!ptr) {
8443 setError((char*)"Problem parsing data namelist");
8444 return(1);
8445 }
8446 return(0);
8447}
8448
8449/************************
8450 processDescription
8451
8452 C++ Arguments: char *s
8453
8454 Results: 0 on success
8455 1 on failure
8456 ************************/
8457int32_t SDDSFile::processDescription(char *s) {
8458 char *text=NULL, *contents=NULL;
8459 char *ptr, *tag, *value;
8460 char buffer[SDDS_MAXLINE];
8461
8462 ptr = SDDS_prepareToParseTagValuePairs(s);
8463 while (*ptr && !SDDS_stringIsBlank(ptr) &&
8464 (ptr=getTagValuePair(ptr, &tag, &value))) {
8465 if (!tag) {
8466 break; /* normal termination */
8467 }
8468 if (strcmp(tag, (char*)"text") == 0) {
8469 if (SDDS_copyString(&text, value)) {
8470 setError((char*)"Problem setting string value for namelist");
8471 return(1);
8472 }
8473 } else if (strcmp(tag, (char*)"contents") == 0) {
8474 if (SDDS_copyString(&contents, value)) {
8475 setError((char*)"Problem setting string value for namelist");
8476 return(1);
8477 }
8478 } else {
8479 sprintf(buffer, "Unknown description tag %s", tag);
8480 setError(buffer);
8481 return(1);
8482 }
8483 }
8484 if (!ptr) {
8485 setError((char*)"Problem parsing description namelist");
8486 return(1);
8487 }
8488 setDescription(text, contents);
8489 if (text)
8490 SDDS_free(text);
8491 if (contents)
8492 SDDS_free(contents);
8493 return(0);
8494}
8495
8496/************************
8497 processParameter
8498
8499 C++ Arguments: char *s
8500
8501 Results: 0 on success
8502 1 on failure
8503 ************************/
8504int32_t SDDSFile::processParameter(char *s) {
8505 char *name=NULL, *symbol=NULL, *units=NULL;
8506 char *description=NULL, *format_string=NULL, *fixed_value=NULL;
8507 char *type=NULL;
8508 char *ptr, *tag, *value;
8509 char buffer[SDDS_MAXLINE];
8510
8511 ptr = SDDS_prepareToParseTagValuePairs(s);
8512 while (*ptr && !SDDS_stringIsBlank(ptr) &&
8513 (ptr=getTagValuePair(ptr, &tag, &value))) {
8514 if (!tag) {
8515 break; /* normal termination */
8516 }
8517 if (strcmp(tag, (char*)"name") == 0) {
8518 if (SDDS_copyString(&name, value)) {
8519 setError((char*)"Problem setting string value for namelist");
8520 return(1);
8521 }
8522 } else if (strcmp(tag, (char*)"type") == 0) {
8523 if (SDDS_copyString(&type, value)) {
8524 setError((char*)"Problem setting string value for namelist");
8525 return(1);
8526 }
8527 } else if (strcmp(tag, (char*)"units") == 0) {
8528 if (SDDS_copyString(&units, value)) {
8529 setError((char*)"Problem setting string value for namelist");
8530 return(1);
8531 }
8532 } else if (strcmp(tag, (char*)"symbol") == 0) {
8533 if (SDDS_copyString(&symbol, value)) {
8534 setError((char*)"Problem setting string value for namelist");
8535 return(1);
8536 }
8537 } else if (strcmp(tag, (char*)"description") == 0) {
8538 if (SDDS_copyString(&description, value)) {
8539 setError((char*)"Problem setting string value for namelist");
8540 return(1);
8541 }
8542 } else if (strcmp(tag, (char*)"format_string") == 0) {
8543 if (SDDS_copyString(&format_string, value)) {
8544 setError((char*)"Problem setting string value for namelist");
8545 return(1);
8546 }
8547 } else if (strcmp(tag, (char*)"fixed_value") == 0) {
8548 if (SDDS_copyString(&fixed_value, value)) {
8549 setError((char*)"Problem setting string value for namelist");
8550 return(1);
8551 }
8552 SDDS_interpretEscapes(fixed_value);
8553 } else {
8554 sprintf(buffer, "Unknown parameter tag %s", tag);
8555 setError(buffer);
8556 return(1);
8557 }
8558 }
8559 if (!ptr) {
8560 setError((char*)"Problem parsing parameter namelist");
8561 return(1);
8562 }
8563 if (defineParameter(name, symbol, units, description,
8564 format_string, type, fixed_value) == -1) {
8565 return(1);
8566 }
8567 if (name)
8568 SDDS_free(name);
8569 if (symbol)
8570 SDDS_free(symbol);
8571 if (units)
8572 SDDS_free(units);
8573 if (description)
8574 SDDS_free(description);
8575 if (format_string)
8576 SDDS_free(format_string);
8577 if (fixed_value)
8578 SDDS_free(fixed_value);
8579 if (type)
8580 SDDS_free(type);
8581 return(0);
8582}
8583
8584char* SDDSFile::getTagValuePair(char *ptr, char **tag, char **value) {
8585 char buffer[1024];
8586
8587 if (!*ptr) {
8588 return(NULL);
8589 }
8590 *tag = *value = NULL;
8591 while (*ptr==' ' || *ptr==',' || *ptr=='\t') {
8592 ptr++;
8593 }
8594 if (!*ptr) {
8595 return(ptr);
8596 }
8597
8598 *tag = ptr; /* start of field name */
8599 while (*ptr && *ptr!=' ' && *ptr!='\t' && *ptr!='=') {
8600 ptr++;
8601 }
8602 if (*ptr!='=') {
8603 *ptr++ = 0; /* ends the field name */
8604 /* skip something of the form <0 or more spaces>=<0 or more spaces> */
8605 while (*ptr==' ' || *ptr=='\t') {
8606 ptr++;
8607 }
8608 if (*ptr++!='=' || !*ptr) {
8609 sprintf(buffer, "Namelist error: Field name %s ends string", *tag);
8610 setError(buffer);
8611 return(NULL);
8612 }
8613 } else {
8614 *ptr++ = 0;
8615 }
8616 while (*ptr==' ' || *ptr=='\t') {
8617 ptr++;
8618 }
8619 if (!*ptr) {
8620 sprintf(buffer, "Namelist error: Field name %s ends string", *tag);
8621 setError(buffer);
8622 return(NULL);
8623 }
8624 if (!strlen(*tag)) {
8625 sprintf(buffer, "Namelist error: Field name is blank");
8626 setError(buffer);
8627 return(NULL);
8628 }
8629
8630 if (*ptr=='"' && *(ptr-1)!='\\') {
8631 ptr++;
8632 if (*ptr=='"' && *(ptr-1)!='\\') {
8633 *ptr = 0;
8634 *value = ptr;
8635 return(ptr+1);
8636 }
8637 *value = ptr++;
8638 while (*ptr && !(*ptr=='"' && *(ptr-1)!='\\')) {
8639 ptr++;
8640 }
8641 if (*ptr=='"' && *(ptr-1)!='\\') {
8642 *ptr = 0; /* end of value */
8643 }
8644 } else {
8645 *value = ptr; /* start of value */
8646 while (*ptr!=' ' && *ptr!=',' && *ptr!='\t' && *ptr) {
8647 ptr++;
8648 }
8649 if (!*ptr) {
8650 return ptr;
8651 }
8652 *ptr = 0; /* end of value */
8653 }
8654 return(ptr+1);
8655}
8656
8657/****************************
8658 copyParameterDefinitions
8659
8660 C++ Arguments: void *sdds_source
8661
8662 C Arguments: void *sddsfile, void *sdds_source
8663
8664 Results: 0 on success
8665 1 on failure
8666*****************************/
8667int32_t SDDSFile::copyParameterDefinitions(void *sdds_source) {
8668 int32_t count, i, *type;
8669 char **name, **symbol, **units, **description, **format_string, **fixed_value;
8670
8671 count = ((SDDSFile*)sdds_source)->getParameterCount();
8672 name = ((SDDSFile*)sdds_source)->getParameterNames();
8673 symbol = ((SDDSFile*)sdds_source)->getParameterSymbols();
8674 units = ((SDDSFile*)sdds_source)->getAllParameterUnits();
8675 description = ((SDDSFile*)sdds_source)->getParameterDescriptions();
8676 format_string = ((SDDSFile*)sdds_source)->getParameterFormatStrings();
8677 fixed_value = ((SDDSFile*)sdds_source)->getParameterFixedValues();
8678 type = ((SDDSFile*)sdds_source)->getParameterTypes();
8679 for (i=0 ; i<count ; i++) {
8680 if (defineParameter(name[i], symbol[i], units[i], description[i],
8681 format_string[i], type[i], fixed_value[i]) == -1) {
8682 return(1);
8683 }
8684 }
8685 if (count > 0) {
8686 SDDS_free(name);
8687 SDDS_free(symbol);
8688 SDDS_free(units);
8689 SDDS_free(description);
8690 SDDS_free(format_string);
8691 SDDS_free(fixed_value);
8692 SDDS_free(type);
8693 }
8694 return(0);
8695}
8696int32_t SDDSFile_copyParameterDefinitions(void *sddsfile, void *sdds_source) {
8697 return(((SDDSFile*)sddsfile)->copyParameterDefinitions(sdds_source));
8698}
8699
8700/****************************
8701 copyParameterDefinition
8702
8703 C++ Arguments: void *sdds_source, char *orig_parameter_name, char *new_parameter_name
8704
8705 C Arguments: void *sddsfile, void *sdds_source, char *orig_parameter_name, char *new_parameter_name
8706
8707 Results: 0 on success
8708 1 on failure
8709*****************************/
8710int32_t SDDSFile::copyParameterDefinition(void *sdds_source, char *orig_parameter_name, char *new_parameter_name) {
8711 int32_t i;
8712 char s[SDDS_MAXLINE];
8713 i = ((SDDSFile*)sdds_source)->getParameterIndex(orig_parameter_name);
8714 if (i < 0) {
8715 sprintf(s, "Warning: parameter %s does not exist (SDDSFile::copyParameterDefinition)", orig_parameter_name);
8716 setError(s);
8717 return(1);
8718 }
8719 if (defineParameter(new_parameter_name,
8720 ((SDDSFile*)sdds_source)->getParameterSymbol(i),
8721 ((SDDSFile*)sdds_source)->getParameterUnits(i),
8722 ((SDDSFile*)sdds_source)->getParameterDescription(i),
8723 ((SDDSFile*)sdds_source)->getParameterFormatString(i),
8724 ((SDDSFile*)sdds_source)->getParameterType(i),
8725 ((SDDSFile*)sdds_source)->getParameterFixedValue(i)) == -1) {
8726 return(1);
8727 }
8728 return(0);
8729}
8730int32_t SDDSFile_copyParameterDefinition(void *sddsfile, void *sdds_source, char *orig_parameter_name, char *new_parameter_name) {
8731 return(((SDDSFile*)sddsfile)->copyParameterDefinition(sdds_source, orig_parameter_name, new_parameter_name));
8732}
8733
8734/*
8735 * copyArrayDefinitions
8736 *
8737 * C++ Arguments: void *sdds_source
8738 *
8739 * C Arguments: void *sddsfile, void *sdds_source
8740 *
8741 * Results: 0 on success
8742 * 1 on failure
8743 */
8744int32_t SDDSFile::copyArrayDefinitions(void *sdds_source) {
8745 int32_t count, i, *type;
8746 uint32_t *field_length, *dimensions;
8747 char **name, **symbol, **units, **description, **format_string, **group_name;
8748
8749 count = ((SDDSFile*)sdds_source)->getArrayCount();
8750 name = ((SDDSFile*)sdds_source)->getArrayNames();
8751 symbol = ((SDDSFile*)sdds_source)->getArraySymbols();
8752 units = ((SDDSFile*)sdds_source)->getAllArrayUnits();
8753 description = ((SDDSFile*)sdds_source)->getArrayDescriptions();
8754 format_string = ((SDDSFile*)sdds_source)->getArrayFormatStrings();
8755 group_name = ((SDDSFile*)sdds_source)->getArrayGroupNames();
8756 field_length = ((SDDSFile*)sdds_source)->getArrayFieldLengths();
8757 dimensions = ((SDDSFile*)sdds_source)->getAllArrayDimensions();
8758 type = ((SDDSFile*)sdds_source)->getArrayTypes();
8759 for (i=0 ; i<count ; i++) {
8760 if (defineArray(name[i], symbol[i], units[i], description[i],
8761 format_string[i], group_name[i], type[i], field_length[i], dimensions[i]) == -1) {
8762 return(1);
8763 }
8764 }
8765 if (count > 0) {
8766 SDDS_free(name);
8767 SDDS_free(symbol);
8768 SDDS_free(units);
8769 SDDS_free(description);
8770 SDDS_free(format_string);
8771 SDDS_free(group_name);
8772 SDDS_free(field_length);
8773 SDDS_free(dimensions);
8774 SDDS_free(type);
8775 }
8776 return(0);
8777}
8778int32_t SDDSFile_copyArrayDefinitions(void *sddsfile, void *sdds_source) {
8779 return(((SDDSFile*)sddsfile)->copyArrayDefinitions(sdds_source));
8780}
8781
8782/*
8783 * copyArrayDefinition
8784 *
8785 * C++ Arguments: void *sdds_source, char *orig_array_name, char *new_array_name
8786 *
8787 * C Arguments: void *sddsfile, void *sdds_source, char *orig_array_name, char *new_array_name
8788 *
8789 * Results: 0 on success
8790 * 1 on failure
8791 */
8792int32_t SDDSFile::copyArrayDefinition(void *sdds_source, char *orig_array_name, char *new_array_name) {
8793 int32_t i;
8794 char s[SDDS_MAXLINE];
8795 i = ((SDDSFile*)sdds_source)->getArrayIndex(orig_array_name);
8796 if (i < 0) {
8797 sprintf(s, "Warning: array %s does not exist (SDDSFile::copyArrayDefinition)", orig_array_name);
8798 setError(s);
8799 return(1);
8800 }
8801 if (defineArray(new_array_name,
8802 ((SDDSFile*)sdds_source)->getArraySymbol(i),
8803 ((SDDSFile*)sdds_source)->getArrayUnits(i),
8804 ((SDDSFile*)sdds_source)->getArrayDescription(i),
8805 ((SDDSFile*)sdds_source)->getArrayFormatString(i),
8806 ((SDDSFile*)sdds_source)->getArrayGroupName(i),
8807 ((SDDSFile*)sdds_source)->getArrayType(i),
8808 ((SDDSFile*)sdds_source)->getArrayFieldLength(i),
8809 ((SDDSFile*)sdds_source)->getArrayDimensions(i)) == -1) {
8810 return(1);
8811 }
8812 return(0);
8813}
8814int32_t SDDSFile_copyArrayDefinition(void *sddsfile, void *sdds_source, char *orig_array_name, char *new_array_name) {
8815 return(((SDDSFile*)sddsfile)->copyArrayDefinition(sdds_source, orig_array_name, new_array_name));
8816}
8817
8818/*
8819 * copyColumnDefinitions
8820 *
8821 * C++ Arguments: void *sdds_source
8822 *
8823 * C Arguments: void *sddsfile, void *sdds_source
8824 *
8825 * Results: 0 on success
8826 * 1 on failure
8827 */
8828int32_t SDDSFile::copyColumnDefinitions(void *sdds_source) {
8829 int32_t count, i, *type;
8830 uint32_t *field_length;
8831 char **name, **symbol, **units, **description, **format_string;
8832
8833 count = ((SDDSFile*)sdds_source)->getColumnCount();
8834 name = ((SDDSFile*)sdds_source)->getColumnNames();
8835 symbol = ((SDDSFile*)sdds_source)->getColumnSymbols();
8836 units = ((SDDSFile*)sdds_source)->getAllColumnUnits();
8837 description = ((SDDSFile*)sdds_source)->getColumnDescriptions();
8838 format_string = ((SDDSFile*)sdds_source)->getColumnFormatStrings();
8839 field_length = ((SDDSFile*)sdds_source)->getColumnFieldLengths();
8840 type = ((SDDSFile*)sdds_source)->getColumnTypes();
8841 for (i=0 ; i<count ; i++) {
8842 if (defineColumn(name[i], symbol[i], units[i], description[i],
8843 format_string[i], type[i], field_length[i]) == -1) {
8844 return(1);
8845 }
8846 }
8847 if (count > 0) {
8848 SDDS_free(name);
8849 SDDS_free(symbol);
8850 SDDS_free(units);
8851 SDDS_free(description);
8852 SDDS_free(format_string);
8853 SDDS_free(field_length);
8854 SDDS_free(type);
8855 }
8856 return(0);
8857}
8858int32_t SDDSFile_copyColumnDefinitions(void *sddsfile, void *sdds_source) {
8859 return(((SDDSFile*)sddsfile)->copyColumnDefinitions(sdds_source));
8860}
8861
8862/*
8863 * copyColumnDefinition
8864 *
8865 * C++ Arguments: void *sdds_source, char *orig_column_name, char *new_column_name
8866 *
8867 * C Arguments: void *sddsfile, void *sdds_source, char *orig_column_name, char *new_column_name
8868 *
8869 * Results: 0 on success
8870 * 1 on failure
8871 */
8872int32_t SDDSFile::copyColumnDefinition(void *sdds_source, char *orig_column_name, char *new_column_name) {
8873 int32_t i;
8874 char s[SDDS_MAXLINE];
8875 i = ((SDDSFile*)sdds_source)->getColumnIndex(orig_column_name);
8876 if (i < 0) {
8877 sprintf(s, "Warning: column %s does not exist (SDDSFile::copyColumnDefinition)", orig_column_name);
8878 setError(s);
8879 return(1);
8880 }
8881 if (defineColumn(new_column_name,
8882 ((SDDSFile*)sdds_source)->getColumnSymbol(i),
8883 ((SDDSFile*)sdds_source)->getColumnUnits(i),
8884 ((SDDSFile*)sdds_source)->getColumnDescription(i),
8885 ((SDDSFile*)sdds_source)->getColumnFormatString(i),
8886 ((SDDSFile*)sdds_source)->getColumnType(i),
8887 ((SDDSFile*)sdds_source)->getColumnFieldLength(i)) == -1) {
8888 return(1);
8889 }
8890 return(0);
8891}
8892int32_t SDDSFile_copyColumnDefinition(void *sddsfile, void *sdds_source, char *orig_column_name, char *new_column_name) {
8893 return(((SDDSFile*)sddsfile)->copyColumnDefinition(sdds_source, orig_column_name, new_column_name));
8894}
8895
8896/****************************
8897 readRecoveryPossible
8898
8899 C++ Arguments: none
8900
8901 C Arguments: void *sddsfile
8902
8903 Results: 1 for possible
8904 0 for not possible
8905*****************************/
8906int32_t SDDSFile::readRecoveryPossible(void) {
8907 int32_t returnValue;
8908 returnValue = recoveryPossible;
8909 recoveryPossible = 0;
8910 return(returnValue);
8911}
8912
8913int32_t SDDSFile_readRecoveryPossible(void *sddsfile) {
8914 return(((SDDSFile*)sddsfile)->readRecoveryPossible());
8915}
8916
8917/****************************
8918 setReadRecoveryMode
8919
8920 C++ Arguments:int32_t mode
8921
8922 Results: none
8923*****************************/
8924void SDDSFile::setReadRecoveryMode(int32_t mode) {
8925 recoveryPossible = mode;
8926}