23#if defined(_WIN32) && !defined(_MINGW)
50 if (!
SDDS_SetMemory(SDDS_dataset->row_flag, SDDS_dataset->n_rows_allocated,
SDDS_LONG, (int32_t)row_flag_value, (int32_t)0)) {
51 SDDS_SetError(
"Unable to set row flags--memory filling failed (SDDS_SetRowFlags)");
74 if (row < 0 || row >= SDDS_dataset->n_rows)
76 return SDDS_dataset->row_flag[row];
101 if (rows != SDDS_dataset->n_rows) {
105 for (i = 0; i < rows; i++)
106 flag[i] = SDDS_dataset->row_flag[i];
155 int64_t i, rows, startRow, endRow;
158 int32_t *flagArray, flagValue;
162 va_start(argptr, mode);
165 case SDDS_FLAG_ARRAY:
166 if (!(flagArray = va_arg(argptr, int32_t *)))
167 SDDS_SetError(
"NULL flag array pointer seen (SDDS_AssertRowFlags)");
168 else if ((rows = va_arg(argptr, int64_t)) < 0)
169 SDDS_SetError(
"invalid row count seen (SDDS_AssertRowFlags)");
171 if (rows >= SDDS_dataset->n_rows)
172 rows = SDDS_dataset->n_rows;
173 for (i = 0; i < rows; i++)
174 SDDS_dataset->row_flag[i] = flagArray[i];
178 case SDDS_INDEX_LIMITS:
179 if ((startRow = va_arg(argptr, int64_t)) < 0 || (endRow = va_arg(argptr, int64_t)) < startRow)
180 SDDS_SetError(
"invalid start and end row values (SDDS_AssertRowFlags)");
182 flagValue = va_arg(argptr, int32_t);
183 if (endRow >= SDDS_dataset->n_rows || endRow < 0)
184 endRow = SDDS_dataset->n_rows - 1;
185 for (i = startRow; i <= endRow; i++)
186 SDDS_dataset->row_flag[i] = flagValue;
225 if (!
SDDS_SetMemory(SDDS_dataset->column_flag, SDDS_dataset->layout.n_columns,
SDDS_LONG, (int32_t)column_flag_value, (int32_t)0)) {
226 SDDS_SetError(
"Unable to set column flags--memory filling failed (SDDS_SetColumnFlags)");
229 SDDS_dataset->n_of_interest = column_flag_value ? SDDS_dataset->layout.n_columns : 0;
230 for (i = 0; i < SDDS_dataset->layout.n_columns; i++)
231 SDDS_dataset->column_order[i] = column_flag_value ? i : -1;
275 int32_t columns, startColumn, endColumn;
278 int32_t *flagArray, flagValue;
285 va_start(argptr, mode);
288 case SDDS_FLAG_ARRAY:
289 if (!(flagArray = va_arg(argptr, int32_t *)))
290 SDDS_SetError(
"NULL flag array pointer seen (SDDS_AssertColumnFlags)");
291 else if ((columns = va_arg(argptr, int32_t)) < 0)
292 SDDS_SetError(
"invalid column count seen (SDDS_AssertColumnFlags)");
294 if (columns >= SDDS_dataset->layout.n_columns)
295 columns = SDDS_dataset->layout.n_columns - 1;
296 for (i = 0; i < columns; i++)
297 SDDS_dataset->column_flag[i] = flagArray[i];
301 case SDDS_INDEX_LIMITS:
302 if ((startColumn = va_arg(argptr, int32_t)) < 0 || (endColumn = va_arg(argptr, int32_t)) < startColumn)
303 SDDS_SetError(
"invalid start and end column values (SDDS_AssertColumnFlags)");
305 flagValue = va_arg(argptr, int32_t);
306 if (endColumn >= SDDS_dataset->layout.n_columns || endColumn < 0)
307 endColumn = SDDS_dataset->layout.n_columns - 1;
308 for (i = startColumn; i <= endColumn; i++)
309 SDDS_dataset->column_flag[i] = flagValue;
314 SDDS_SetError(
"unknown mode passed (SDDS_AssertColumnFlags)");
319 for (i = j = 0; i < SDDS_dataset->layout.n_columns; i++) {
320 if (SDDS_dataset->column_flag[i])
321 SDDS_dataset->column_order[j++] = i;
324 SDDS_dataset->n_of_interest = j;
345 return (SDDS_dataset->n_of_interest);
370 if (!SDDS_dataset->layout.n_columns)
372 for (i = n_rows = 0; i < SDDS_dataset->n_rows; i++) {
373 if (SDDS_dataset->row_flag[i])
441 int32_t i, j, index, n_names;
445 int32_t local_memory;
446 char buffer[SDDS_MAXLINE];
450 n_names = local_memory = logic = 0;
456 va_start(argptr, mode);
460 case SDDS_NAME_ARRAY:
462 n_names = va_arg(argptr, int32_t);
463 name = va_arg(argptr,
char **);
465 case SDDS_NAMES_STRING:
469 ptr = va_arg(argptr,
char *);
471 while ((ptr = strchr(
string,
',')))
475 SDDS_SetError(
"Unable to process column selection--memory allocation failure (SDDS_SetColumnsOfInterest)");
483 case SDDS_NAME_STRINGS:
487 while ((
string = va_arg(argptr,
char *))) {
488 if (!(name =
SDDS_Realloc(name,
sizeof(*name) * (n_names + 1)))) {
489 SDDS_SetError(
"Unable to process column selection--memory allocation failure (SDDS_SetColumnsOfInterest)");
493 name[n_names++] = string;
496 case SDDS_MATCH_STRING:
499 if (!(
string = va_arg(argptr,
char *))) {
500 SDDS_SetError(
"Unable to process column selection--invalid matching string (SDDS_SetColumnsOfInterest)");
505 logic = va_arg(argptr, int32_t);
508 SDDS_SetError(
"Unable to process column selection--unknown mode (SDDS_SetColumnsOfInterest)");
518 SDDS_SetError(
"Unable to process column selection--no names in call (SDDS_SetColumnsOfInterest)");
521 if (!SDDS_dataset->column_order) {
522 SDDS_SetError(
"Unable to process column selection--'column_order' array in SDDS_DATASET is NULL (SDDS_SetColumnsOfInterest)");
526 if (mode != SDDS_MATCH_STRING) {
527 for (i = 0; i < n_names; i++) {
529 sprintf(buffer,
"Unable to process column selection--unrecognized column name %s seen (SDDS_SetColumnsOfInterest)", name[i]);
533 for (j = 0; j < SDDS_dataset->n_of_interest; j++)
534 if (index == SDDS_dataset->column_order[j])
536 if (j == SDDS_dataset->n_of_interest) {
537 SDDS_dataset->column_flag[index] = 1;
538 SDDS_dataset->column_order[j] = index;
539 SDDS_dataset->n_of_interest++;
543 for (i = 0; i < SDDS_dataset->layout.n_columns; i++) {
546 fprintf(stderr,
"logic match of %s to %s\n", SDDS_dataset->layout.column_definition[i].name,
match_string);
548 for (j = 0; j < SDDS_dataset->n_of_interest; j++)
549 if (i == SDDS_dataset->column_order[j])
551 if (j == SDDS_dataset->n_of_interest) {
552 SDDS_dataset->column_flag[i] = 1;
553 SDDS_dataset->column_order[j] = i;
554 SDDS_dataset->n_of_interest++;
558 fprintf(stderr,
"no logic match of %s to %s\n", SDDS_dataset->layout.column_definition[i].name,
match_string);
560 SDDS_dataset->column_flag[i] = 0;
561 for (j = 0; j < SDDS_dataset->n_of_interest; j++)
562 if (i == SDDS_dataset->column_order[j])
564 if (j != SDDS_dataset->n_of_interest) {
565 for (j++; j < SDDS_dataset->n_of_interest; j++)
566 SDDS_dataset->column_order[j - 1] = SDDS_dataset->column_order[j];
574 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
575 fprintf(stderr,
"column %" PRId32
" will be %s\n", i, SDDS_dataset->layout.column_definition[SDDS_dataset->column_order[i]].name);
578 if (local_memory == 2) {
579 for (i = 0; i < n_names; i++)
582 if (local_memory >= 1)
612 int32_t size, type, index;
613 int64_t i, j, n_rows;
618 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetColumn)");
622 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetColumn)");
626 SDDS_SetError(
"Unable to get column--data type undefined (SDDS_GetColumn)");
631 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetColumn)");
634 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
635 if (SDDS_dataset->row_flag[i]) {
637 memcpy((
char *)data + size * j++, (
char *)SDDS_dataset->data[index] + size * i, size);
638 else if (!
SDDS_CopyString((
char **)data + j++, ((
char ***)SDDS_dataset->data)[index][i]))
643 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumn)");
647 SDDS_dataset->column_track_memory[index] = 0;
652 char **ptr = (
char **)SDDS_dataset->data[index];
653 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
656 free(SDDS_dataset->data[index]);
657 SDDS_dataset->data[index] = NULL;
660 free(SDDS_dataset->data[index]);
661 SDDS_dataset->data[index] = NULL;
693 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetInternalColumn)");
697 SDDS_dataset->column_track_memory[index] = 0;
699 return SDDS_dataset->data[index];
731 int32_t size, type, index;
732 int64_t i, j, n_rows;
741 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetColumnInLongDoubles)");
745 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetColumnInLongDoubles)");
749 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetColumnInLongDoubles)");
752 if (!(data = (
long double *)
SDDS_Malloc(
sizeof(
long double) * n_rows))) {
753 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetColumnInLongDoubles)");
756 rawData = SDDS_dataset->data[index];
759 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
760 if (SDDS_dataset->row_flag[i])
761 data[j++] = ((
long double *)rawData)[i];
765 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
766 if (SDDS_dataset->row_flag[i])
767 data[j++] = ((
double *)rawData)[i];
771 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
772 if (SDDS_dataset->row_flag[i])
773 data[j++] = ((
float *)rawData)[i];
777 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
778 if (SDDS_dataset->row_flag[i])
779 data[j++] = ((int32_t *)rawData)[i];
783 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
784 if (SDDS_dataset->row_flag[i])
785 data[j++] = ((uint32_t *)rawData)[i];
789 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
790 if (SDDS_dataset->row_flag[i])
791 data[j++] = ((int64_t *)rawData)[i];
795 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
796 if (SDDS_dataset->row_flag[i])
797 data[j++] = ((uint64_t *)rawData)[i];
801 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
802 if (SDDS_dataset->row_flag[i])
803 data[j++] = ((
short *)rawData)[i];
807 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
808 if (SDDS_dataset->row_flag[i])
809 data[j++] = ((
unsigned short *)rawData)[i];
813 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
814 if (SDDS_dataset->row_flag[i])
815 data[j++] = ((
char *)rawData)[i];
820 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumnInLongDoubles)");
824 SDDS_dataset->column_track_memory[index] = 0;
829 char **ptr = (
char **)SDDS_dataset->data[index];
830 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
833 free(SDDS_dataset->data[index]);
834 SDDS_dataset->data[index] = NULL;
837 free(SDDS_dataset->data[index]);
838 SDDS_dataset->data[index] = NULL;
873 int32_t size, type, index;
874 int64_t i, j, n_rows;
883 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetColumnInDoubles)");
887 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetColumnInDoubles)");
891 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetColumnInDoubles)");
894 if (!(data = (
double *)
SDDS_Malloc(
sizeof(
double) * n_rows))) {
895 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetColumnInDoubles)");
898 rawData = SDDS_dataset->data[index];
901 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
902 if (SDDS_dataset->row_flag[i])
903 data[j++] = ((
long double *)rawData)[i];
907 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
908 if (SDDS_dataset->row_flag[i])
909 data[j++] = ((
double *)rawData)[i];
913 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
914 if (SDDS_dataset->row_flag[i])
915 data[j++] = ((
float *)rawData)[i];
919 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
920 if (SDDS_dataset->row_flag[i])
921 data[j++] = ((int32_t *)rawData)[i];
925 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
926 if (SDDS_dataset->row_flag[i])
927 data[j++] = ((uint32_t *)rawData)[i];
931 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
932 if (SDDS_dataset->row_flag[i])
933 data[j++] = ((int64_t *)rawData)[i];
937 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
938 if (SDDS_dataset->row_flag[i])
939 data[j++] = ((uint64_t *)rawData)[i];
943 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
944 if (SDDS_dataset->row_flag[i])
945 data[j++] = ((
short *)rawData)[i];
949 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
950 if (SDDS_dataset->row_flag[i])
951 data[j++] = ((
unsigned short *)rawData)[i];
955 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
956 if (SDDS_dataset->row_flag[i])
957 data[j++] = ((
char *)rawData)[i];
962 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumnInDoubles)");
966 SDDS_dataset->column_track_memory[index] = 0;
971 char **ptr = (
char **)SDDS_dataset->data[index];
972 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
975 free(SDDS_dataset->data[index]);
976 SDDS_dataset->data[index] = NULL;
979 free(SDDS_dataset->data[index]);
980 SDDS_dataset->data[index] = NULL;
1015 int32_t size, type, index;
1016 int64_t i, j, n_rows;
1025 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetColumnInFloats)");
1029 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetColumnInFloats)");
1033 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetColumnInFloats)");
1036 if (!(data = (
float *)
SDDS_Malloc(
sizeof(
float) * n_rows))) {
1037 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetColumnInFloats)");
1040 rawData = SDDS_dataset->data[index];
1043 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1044 if (SDDS_dataset->row_flag[i])
1045 data[j++] = ((
long double *)rawData)[i];
1049 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1050 if (SDDS_dataset->row_flag[i])
1051 data[j++] = ((
double *)rawData)[i];
1055 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1056 if (SDDS_dataset->row_flag[i])
1057 data[j++] = ((
float *)rawData)[i];
1061 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1062 if (SDDS_dataset->row_flag[i])
1063 data[j++] = ((int32_t *)rawData)[i];
1067 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1068 if (SDDS_dataset->row_flag[i])
1069 data[j++] = ((uint32_t *)rawData)[i];
1073 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1074 if (SDDS_dataset->row_flag[i])
1075 data[j++] = ((int64_t *)rawData)[i];
1079 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1080 if (SDDS_dataset->row_flag[i])
1081 data[j++] = ((uint64_t *)rawData)[i];
1085 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1086 if (SDDS_dataset->row_flag[i])
1087 data[j++] = ((
short *)rawData)[i];
1091 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1092 if (SDDS_dataset->row_flag[i])
1093 data[j++] = ((
unsigned short *)rawData)[i];
1097 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1098 if (SDDS_dataset->row_flag[i])
1099 data[j++] = ((
char *)rawData)[i];
1104 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumnInFloats)");
1108 SDDS_dataset->column_track_memory[index] = 0;
1113 char **ptr = (
char **)SDDS_dataset->data[index];
1114 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
1117 free(SDDS_dataset->data[index]);
1118 SDDS_dataset->data[index] = NULL;
1121 free(SDDS_dataset->data[index]);
1122 SDDS_dataset->data[index] = NULL;
1158 int32_t size, type, index;
1159 int64_t i, j, n_rows;
1166 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetColumnInLong)");
1170 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetColumnInLong)");
1174 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetColumnInLong)");
1177 if (!(data = (int32_t *)
SDDS_Malloc(
sizeof(int32_t) * n_rows))) {
1178 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetColumnInLong)");
1181 rawData = SDDS_dataset->data[index];
1184 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1185 if (SDDS_dataset->row_flag[i])
1186 data[j++] = ((
long double *)rawData)[i];
1190 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1191 if (SDDS_dataset->row_flag[i])
1192 data[j++] = ((
double *)rawData)[i];
1196 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1197 if (SDDS_dataset->row_flag[i])
1198 data[j++] = ((
float *)rawData)[i];
1202 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1203 if (SDDS_dataset->row_flag[i])
1204 data[j++] = ((int32_t *)rawData)[i];
1208 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1209 if (SDDS_dataset->row_flag[i])
1210 data[j++] = ((uint32_t *)rawData)[i];
1214 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1215 if (SDDS_dataset->row_flag[i])
1216 data[j++] = ((int64_t *)rawData)[i];
1220 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1221 if (SDDS_dataset->row_flag[i])
1222 data[j++] = ((uint64_t *)rawData)[i];
1226 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1227 if (SDDS_dataset->row_flag[i])
1228 data[j++] = ((
short *)rawData)[i];
1232 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1233 if (SDDS_dataset->row_flag[i])
1234 data[j++] = ((
unsigned short *)rawData)[i];
1238 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1239 if (SDDS_dataset->row_flag[i])
1240 data[j++] = ((
char *)rawData)[i];
1245 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumnInLong)");
1249 SDDS_dataset->column_track_memory[index] = 0;
1254 char **ptr = (
char **)SDDS_dataset->data[index];
1255 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
1258 free(SDDS_dataset->data[index]);
1259 SDDS_dataset->data[index] = NULL;
1262 free(SDDS_dataset->data[index]);
1263 SDDS_dataset->data[index] = NULL;
1299 int32_t size, type, index;
1300 int64_t i, j, n_rows;
1307 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetColumnInShort)");
1311 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetColumnInShort)");
1315 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetColumnInShort)");
1318 if (!(data = (
short *)
SDDS_Malloc(
sizeof(
short) * n_rows))) {
1319 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetColumnInShort)");
1322 rawData = SDDS_dataset->data[index];
1325 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1326 if (SDDS_dataset->row_flag[i])
1327 data[j++] = ((
long double *)rawData)[i];
1331 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1332 if (SDDS_dataset->row_flag[i])
1333 data[j++] = ((
double *)rawData)[i];
1337 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1338 if (SDDS_dataset->row_flag[i])
1339 data[j++] = ((
float *)rawData)[i];
1343 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1344 if (SDDS_dataset->row_flag[i])
1345 data[j++] = ((int32_t *)rawData)[i];
1349 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1350 if (SDDS_dataset->row_flag[i])
1351 data[j++] = ((uint32_t *)rawData)[i];
1355 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1356 if (SDDS_dataset->row_flag[i])
1357 data[j++] = ((int64_t *)rawData)[i];
1361 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1362 if (SDDS_dataset->row_flag[i])
1363 data[j++] = ((uint64_t *)rawData)[i];
1367 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1368 if (SDDS_dataset->row_flag[i])
1369 data[j++] = ((
short *)rawData)[i];
1373 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1374 if (SDDS_dataset->row_flag[i])
1375 data[j++] = ((
unsigned short *)rawData)[i];
1379 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1380 if (SDDS_dataset->row_flag[i])
1381 data[j++] = ((
char *)rawData)[i];
1386 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumnInShort)");
1390 SDDS_dataset->column_track_memory[index] = 0;
1395 char **ptr = (
char **)SDDS_dataset->data[index];
1396 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
1399 free(SDDS_dataset->data[index]);
1400 SDDS_dataset->data[index] = NULL;
1403 free(SDDS_dataset->data[index]);
1404 SDDS_dataset->data[index] = NULL;
1440 int32_t size, type, index;
1441 int64_t i, j, n_rows;
1443 char buffer[SDDS_MAXLINE];
1450 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetColumnInString)");
1454 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetColumnInString)");
1460 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetColumnInString)");
1463 if (!(data = (
char **)
SDDS_Malloc(
sizeof(*data) * n_rows))) {
1464 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetColumnInString)");
1467 rawData = SDDS_dataset->data[index];
1470 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1471 if (SDDS_dataset->row_flag[i]) {
1472 if (LDBL_DIG == 18) {
1473 sprintf(buffer,
"%22.18Le", ((
long double *)rawData)[i]);
1475 sprintf(buffer,
"%22.15Le", ((
long double *)rawData)[i]);
1482 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1483 if (SDDS_dataset->row_flag[i]) {
1484 sprintf(buffer,
"%22.15le", ((
double *)rawData)[i]);
1490 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1491 if (SDDS_dataset->row_flag[i]) {
1492 sprintf(buffer,
"%15.8e", ((
float *)rawData)[i]);
1498 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1499 if (SDDS_dataset->row_flag[i]) {
1500 sprintf(buffer,
"%" PRId64, ((int64_t *)rawData)[i]);
1506 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1507 if (SDDS_dataset->row_flag[i]) {
1508 sprintf(buffer,
"%" PRIu64, ((uint64_t *)rawData)[i]);
1514 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1515 if (SDDS_dataset->row_flag[i]) {
1516 sprintf(buffer,
"%" PRId32, ((int32_t *)rawData)[i]);
1522 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1523 if (SDDS_dataset->row_flag[i]) {
1524 sprintf(buffer,
"%" PRIu32, ((uint32_t *)rawData)[i]);
1530 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1531 if (SDDS_dataset->row_flag[i]) {
1532 sprintf(buffer,
"%hd", ((
short *)rawData)[i]);
1538 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1539 if (SDDS_dataset->row_flag[i]) {
1540 sprintf(buffer,
"%hu", ((
unsigned short *)rawData)[i]);
1546 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1547 if (SDDS_dataset->row_flag[i]) {
1548 sprintf(buffer,
"%c", ((
char *)rawData)[i]);
1553 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1554 if (SDDS_dataset->row_flag[i]) {
1561 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumnInString)");
1565 SDDS_dataset->column_track_memory[index] = 0;
1570 char **ptr = (
char **)SDDS_dataset->data[index];
1571 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
1574 free(SDDS_dataset->data[index]);
1575 SDDS_dataset->data[index] = NULL;
1578 free(SDDS_dataset->data[index]);
1579 SDDS_dataset->data[index] = NULL;
1618 int32_t size, type, desiredTypeSize, index;
1619 int64_t i, j, n_rows;
1624 SDDS_SetError(
"Unable to get column--desired type is nonnumeric (SDDS_GetNumericColumn)");
1628 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetNumericColumn)");
1632 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetNumericColumn)");
1635 if (type == desiredType)
1638 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetNumericColumn)");
1642 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetNumericColumn)");
1645 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1646 if (SDDS_dataset->row_flag[i] && !
SDDS_CastValue(SDDS_dataset->data[index], i, type, desiredType, (
char *)data + desiredTypeSize * j++)) {
1647 SDDS_SetError(
"Unable to get column--cast to double failed (SDDS_GetNumericColumn)");
1652 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetNumericColumn)");
1656 SDDS_dataset->column_track_memory[index] = 0;
1661 char **ptr = (
char **)SDDS_dataset->data[index];
1662 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
1665 free(SDDS_dataset->data[index]);
1666 SDDS_dataset->data[index] = NULL;
1669 free(SDDS_dataset->data[index]);
1670 SDDS_dataset->data[index] = NULL;
1707 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1708 if (SDDS_dataset->row_flag[i] && j++ == srow_index)
1711 if (i == SDDS_dataset->n_rows)
1755 int32_t type, size, column_index;
1760 SDDS_SetError(
"Unable to get value--column name is not recognized (SDDS_GetValue)");
1764 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValue)");
1769 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValue)");
1774 SDDS_SetError(
"Unable to get value--memory allocation failure (SDDS_GetValue)");
1777 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
1786 SDDS_SetError(
"Unable to get value--memory allocation failure (SDDS_GetValue)");
1789 if (
SDDS_CopyString(memory, ((
char **)SDDS_dataset->data[column_index])[row_index]))
1822 int32_t type, size, column_index;
1829 SDDS_SetError(
"Unable to get value--column name is not recognized (SDDS_GetValueAsDouble)");
1833 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueAsDouble)");
1838 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValueAsDouble)");
1843 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
1846 value = *(
short *)memory;
1849 value = *(
unsigned short *)memory;
1852 value = *(int32_t *)memory;
1855 value = *(uint32_t *)memory;
1858 value = *(int64_t *)memory;
1861 value = *(uint64_t *)memory;
1864 value = *(
float *)memory;
1867 value = *(
double *)memory;
1870 value = *(
long double *)memory;
1876 SDDS_SetError(
"Unable to get non-numeric value as double (SDDS_GetValueAsDouble)");
1921 if (column_index < 0 || column_index >= SDDS_dataset->layout.n_columns) {
1922 SDDS_SetError(
"Unable to get value--column index out of range (SDDS_GetValueByIndexAsDouble)");
1926 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueByIndexAsDouble)");
1931 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValueByIndexAsDouble)");
1936 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
1939 value = *(
short *)memory;
1942 value = *(
unsigned short *)memory;
1945 value = *(int32_t *)memory;
1948 value = *(uint32_t *)memory;
1951 value = *(int64_t *)memory;
1954 value = *(uint64_t *)memory;
1957 value = *(
float *)memory;
1960 value = *(
double *)memory;
1963 value = *(
long double *)memory;
1969 SDDS_SetError(
"Unable to get non-numeric value as double (SDDS_GetValueByIndexAsDouble)");
2019 if (column_index < 0 || column_index >= SDDS_dataset->layout.n_columns) {
2020 SDDS_SetError(
"Unable to get value--column index out of range (SDDS_GetValueByIndex)");
2024 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueByIndex)");
2029 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValueByIndex)");
2034 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
2037 return ((
char *)SDDS_dataset->data[column_index] + row_index * size);
2046 if (
SDDS_CopyString(memory, ((
char **)SDDS_dataset->data[column_index])[row_index]))
2094 if (column_index < 0 || column_index >= SDDS_dataset->layout.n_columns) {
2095 SDDS_SetError(
"Unable to get value--column index out of range (SDDS_GetValueByAbsIndex)");
2098 if (row_index < 0 || row_index >= SDDS_dataset->n_rows) {
2099 SDDS_SetError(
"Unable to get value--index out of range (SDDS_GetValueByAbsIndex)");
2103 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueByAbsIndex)");
2109 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
2112 return ((
char *)SDDS_dataset->data[column_index] + row_index * size);
2121 if (
SDDS_CopyString(memory, ((
char **)SDDS_dataset->data[column_index])[row_index]))
2155 for (i = 0; i < SDDS_dataset->layout.n_columns; i++) {
2156 if (!SDDS_dataset->column_flag[i])
2159 type = SDDS_dataset->layout.column_definition[i].type;
2160 else if (type != SDDS_dataset->layout.column_definition[i].type) {
2161 SDDS_SetError(
"Unable to get row type--inconsistent data type for selected columns (SDDS_GetRowType)");
2204 int64_t i, row_index;
2209 SDDS_SetError(
"Unable to get row--row index out of range (SDDS_GetRow)");
2212 if (SDDS_dataset->n_of_interest <= 0) {
2213 SDDS_SetError(
"Unable to get row--no columns selected (SDDS_GetRow)");
2217 SDDS_SetError(
"Unable to get row--inconsistent data type in selected columns (SDDS_GetRow)");
2223 else if (!(data =
SDDS_Malloc(size * SDDS_dataset->n_of_interest))) {
2224 SDDS_SetError(
"Unable to get row--memory allocation failure (SDDS_GetRow)");
2228 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2229 memcpy((
char *)data + i * size, (
char *)SDDS_dataset->data[SDDS_dataset->column_order[i]] + row_index * size, size);
2231 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2232 if (!
SDDS_CopyString((
char **)data + i, ((
char **)SDDS_dataset->data[SDDS_dataset->column_order[i]])[row_index]))
2272 if (SDDS_dataset->n_of_interest <= 0) {
2273 SDDS_SetError(
"Unable to get matrix of rows--no columns selected (SDDS_GetMatrixOfRows)");
2279 SDDS_SetError(
"Unable to get row--inconsistent data type in selected columns (SDDS_GetMatrixOfRows)");
2284 SDDS_SetError(
"Unable to get matrix of rows--no rows of interest (SDDS_GetMatrixOfRows)");
2287 if (!(data = (
void **)
SDDS_Malloc(
sizeof(*data) * (*n_rows)))) {
2288 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetMatrixOfRows)");
2291 for (j = k = 0; j < SDDS_dataset->n_rows; j++) {
2292 if (SDDS_dataset->row_flag[j]) {
2293 if (!(data[k] =
SDDS_Malloc(size * SDDS_dataset->n_of_interest))) {
2294 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetMatrixOfRows)");
2298 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2299 memcpy((
char *)data[k] + i * size, (
char *)SDDS_dataset->data[SDDS_dataset->column_order[i]] + j * size, size);
2301 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2302 if (!
SDDS_CopyString((
char **)(data[k]) + i, ((
char **)SDDS_dataset->data[SDDS_dataset->column_order[i]])[j]))
2351 SDDS_SetError(
"Unable to get matrix of rows--no columns selected (SDDS_GetCastMatrixOfRows)");
2354 if (SDDS_dataset->n_of_interest <= 0) {
2355 SDDS_SetError(
"Unable to get matrix of rows--no columns selected (SDDS_GetCastMatrixOfRows)");
2362 SDDS_SetError(
"Unable to get matrix of rows--no rows of interest (SDDS_GetCastMatrixOfRows)");
2365 if (!(data = (
void **)
SDDS_Malloc(
sizeof(*data) * (*n_rows)))) {
2366 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetCastMatrixOfRows)");
2369 for (i = 0; i < SDDS_dataset->n_of_interest; i++) {
2370 if (!
SDDS_NUMERIC_TYPE(SDDS_dataset->layout.column_definition[SDDS_dataset->column_order[i]].type)) {
2371 SDDS_SetError(
"Unable to get matrix of rows--not all columns are numeric (SDDS_GetCastMatrixOfRows)");
2375 for (j = k = 0; j < SDDS_dataset->n_rows; j++) {
2376 if (SDDS_dataset->row_flag[j]) {
2377 if (!(data[k] =
SDDS_Malloc(size * SDDS_dataset->n_of_interest))) {
2378 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetCastMatrixOfRows)");
2381 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2382 SDDS_CastValue(SDDS_dataset->data[SDDS_dataset->column_order[i]], j, SDDS_dataset->layout.column_definition[SDDS_dataset->column_order[i]].type, sddsType, (
char *)data[k] + i *
sizeof(
double));
2425 char s[SDDS_MAXLINE];
2429 va_start(argptr, SDDS_dataset);
2432 if (!(name = va_arg(argptr,
char *)))
2434 if (!(data = va_arg(argptr,
void *)))
2437 sprintf(s,
"Unable to get value of parameter %s (SDDS_GetParameters)", name);
2482 int32_t index, type, size;
2483 char s[SDDS_MAXLINE];
2487 if (!parameter_name) {
2488 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameter)");
2492 sprintf(s,
"Unable to get parameter value--parameter name %s is unrecognized (SDDS_GetParameter)", parameter_name);
2497 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameter)");
2500 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2501 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameter)");
2508 SDDS_SetError(
"Unable to get parameter value--parameter data size is invalid (SDDS_GetParameter)");
2512 memcpy(data, SDDS_dataset->parameter[index], size);
2513 else if (!
SDDS_CopyString((
char **)data, *(
char **)SDDS_dataset->parameter[index]))
2559 if (index < 0 || index >= SDDS_dataset->layout.n_parameters) {
2560 SDDS_SetError(
"Unable to get parameter value--parameter index is invalid (SDDS_GetParameterByIndex)");
2564 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterByIndex)");
2567 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2568 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterByIndex)");
2575 SDDS_SetError(
"Unable to get parameter value--parameter data size is invalid (SDDS_GetParameterByIndex)");
2579 memcpy(data, SDDS_dataset->parameter[index], size);
2580 else if (!
SDDS_CopyString((
char **)data, *(
char **)SDDS_dataset->parameter[index]))
2616 int32_t index, type;
2619 if (!parameter_name) {
2620 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsLong)");
2624 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsLong)");
2628 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsLong)");
2632 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsLong)");
2635 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2636 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsLong)");
2640 if (!memory && !(memory = (int32_t *)
SDDS_Malloc(
sizeof(int32_t)))) {
2641 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsLong)");
2672 int32_t index, type;
2675 if (!parameter_name) {
2676 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsLong64)");
2680 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsLong64)");
2684 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsLong64)");
2688 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsLong64)");
2691 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2692 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsLong64)");
2696 if (!memory && !(memory = (int64_t *)
SDDS_Malloc(
sizeof(int64_t)))) {
2697 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsLong64)");
2728 int32_t index = -1, type = -1;
2731 if (!parameter_name) {
2732 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsLongDouble)");
2736 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsLongDouble)");
2740 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsLongDouble)");
2744 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsLongDouble)");
2747 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2748 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsLongDouble)");
2752 if (!memory && !(memory = (
long double *)
SDDS_Malloc(
sizeof(
long double)))) {
2753 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsLongDouble)");
2783 int32_t index = -1, type = -1;
2786 if (!parameter_name) {
2787 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsDouble)");
2791 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsDouble)");
2795 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsDouble)");
2799 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsDouble)");
2802 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2803 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsDouble)");
2807 if (!memory && !(memory = (
double *)
SDDS_Malloc(
sizeof(
double)))) {
2808 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsDouble)");
2839 int32_t index, type;
2840 char buffer[SDDS_MAXLINE], *parValue;
2845 if (!parameter_name) {
2846 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsString)");
2850 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsString)");
2854 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsString)");
2857 value = SDDS_dataset->parameter[index];
2860 if (LDBL_DIG == 18) {
2861 sprintf(buffer,
"%.18Le", *(
long double *)value);
2863 sprintf(buffer,
"%.15Le", *(
long double *)value);
2867 sprintf(buffer,
"%.15le", *(
double *)value);
2870 sprintf(buffer,
"%.8e", *(
float *)value);
2873 sprintf(buffer,
"%" PRId64, *(int64_t *)value);
2876 sprintf(buffer,
"%" PRIu64, *(uint64_t *)value);
2879 sprintf(buffer,
"%" PRId32, *(int32_t *)value);
2882 sprintf(buffer,
"%" PRIu32, *(uint32_t *)value);
2885 sprintf(buffer,
"%hd", *(
short *)value);
2888 sprintf(buffer,
"%hu", *(
unsigned short *)value);
2891 sprintf(buffer,
"%c", *(
char *)value);
2894 sprintf(buffer,
"%s", *(
char **)value);
2897 SDDS_SetError(
"Unknown data type of parameter (SDDS_GetParameterAsString)");
2900 if (!(parValue = malloc(
sizeof(
char) * (strlen(buffer) + 1)))) {
2901 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsString)");
2904 strcpy(parValue, buffer);
2936 int32_t index, type;
2937 char buffer[SDDS_MAXLINE], *parValue;
2939 char *format = NULL;
2943 if (!parameter_name) {
2944 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsFormattedString)");
2948 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsFormattedString)");
2952 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsFormattedString)");
2955 if (suppliedformat != NULL) {
2956 format = suppliedformat;
2958 SDDS_SetError(
"Unable to get parameter value--given format for parameter is invalid (SDDS_GetParameterAsFormattedString)");
2963 SDDS_SetError(
"Unable to get parameter value--parameter definition is invalid (SDDS_GetParameterAsFormattedString)");
2967 value = SDDS_dataset->parameter[index];
2972 sprintf(buffer, format, *(
long double *)value);
2975 sprintf(buffer, format, *(
double *)value);
2978 sprintf(buffer, format, *(
float *)value);
2981 sprintf(buffer, format, *(int64_t *)value);
2984 sprintf(buffer, format, *(uint64_t *)value);
2987 sprintf(buffer, format, *(int32_t *)value);
2990 sprintf(buffer, format, *(uint32_t *)value);
2993 sprintf(buffer, format, *(
short *)value);
2996 sprintf(buffer, format, *(
unsigned short *)value);
2999 sprintf(buffer, format, *(
char *)value);
3002 sprintf(buffer, format, *(
char **)value);
3005 SDDS_SetError(
"Unknown data type of parameter (SDDS_GetParameterAsFormattedString)");
3011 if (LDBL_DIG == 18) {
3012 sprintf(buffer,
"%22.18Le", *(
long double *)value);
3014 sprintf(buffer,
"%22.15Le", *(
long double *)value);
3018 sprintf(buffer,
"%22.15le", *(
double *)value);
3021 sprintf(buffer,
"%15.8e", *(
float *)value);
3024 sprintf(buffer,
"%" PRId64, *(int64_t *)value);
3027 sprintf(buffer,
"%" PRIu64, *(uint64_t *)value);
3030 sprintf(buffer,
"%" PRId32, *(int32_t *)value);
3033 sprintf(buffer,
"%" PRIu32, *(uint32_t *)value);
3036 sprintf(buffer,
"%hd", *(
short *)value);
3039 sprintf(buffer,
"%hu", *(
unsigned short *)value);
3042 sprintf(buffer,
"%c", *(
char *)value);
3045 sprintf(buffer,
"%s", *(
char **)value);
3048 SDDS_SetError(
"Unknown data type of parameter (SDDS_GetParameterAsFormattedString)");
3052 if (!(parValue = malloc(
sizeof(
char) * (strlen(buffer) + 1)))) {
3053 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsFormattedString)");
3056 strcpy(parValue, buffer);
3085 int32_t index, type, size;
3087 char s[SDDS_MAXLINE];
3091 if (!parameter_name) {
3092 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetFixedValueParameter)");
3096 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetFixedValueParameter)");
3100 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetFixedValueParameter)");
3107 SDDS_SetError(
"Unable to get parameter value--parameter data size is invalid (SDDS_GetFixedValueParameter)");
3110 strcpy(s, SDDS_dataset->layout.parameter_definition[index].fixed_value);
3112 SDDS_SetError(
"Unable to retrieve fixed-value paramter--scan failed (SDDS_GetFixedValueParameter)");
3143 int32_t size, type, index;
3144 int64_t n_rows, i, j;
3145 void **data, *column;
3149 SDDS_SetError(
"Unable to get matrix--column name is NULL (SDDS_GetMatrixFromColumn)");
3153 SDDS_SetError(
"Unable to get matrix--no rows selected (SDDS_GetMatrixFromColumn)");
3156 if (n_rows != dimension1 * dimension2) {
3158 sprintf(s,
"Unable to get matrix--number of rows (%" PRId64
") doesn't correspond to given dimensions (%" PRId64
" x %" PRId64
") (SDDS_GetMatrixFromColumn)", n_rows, dimension1, dimension2);
3163 SDDS_SetError(
"Unable to get matrix--column name is unrecognized (SDDS_GetMatrixFromColumn)");
3167 SDDS_SetError(
"Unable to get matrix (SDDS_GetMatrixFromColumn)");
3171 SDDS_SetError(
"Unable to allocate matrix (SDDS_GetMatrixFromColumn)");
3174 if (mode & SDDS_ROW_MAJOR_DATA || !(mode & SDDS_COLUMN_MAJOR_DATA)) {
3175 for (i = 0; i < dimension1; i++)
3176 memcpy(data[i], (
char *)column + i * dimension2 * size, dimension2 * size);
3178 for (i = 0; i < dimension1; i++) {
3179 for (j = 0; j < dimension2; j++) {
3180 memcpy((
char *)data[i] + size * j, (
char *)column + (j * dimension1 + i) * size, size);
3215 int32_t size, index;
3216 int64_t n_rows, i, j;
3217 void **data, *column;
3221 SDDS_SetError(
"Unable to get matrix--column name is NULL (SDDS_GetDoubleMatrixFromColumn)");
3225 SDDS_SetError(
"Unable to get matrix--no rows selected (SDDS_GetDoubleMatrixFromColumn)");
3228 if (n_rows != dimension1 * dimension2) {
3230 sprintf(s,
"Unable to get matrix--number of rows (%" PRId64
") doesn't correspond to given dimensions (%" PRId64
" x %" PRId64
") (SDDS_GetDoubleMatrixFromColumn)", n_rows, dimension1, dimension2);
3235 SDDS_SetError(
"Unable to get matrix--column name is unrecognized (SDDS_GetDoubleMatrixFromColumn)");
3239 SDDS_SetError(
"Unable to get matrix (SDDS_GetDoubleMatrixFromColumn)");
3242 size =
sizeof(double);
3244 SDDS_SetError(
"Unable to allocate matrix (SDDS_GetDoubleMatrixFromColumn)");
3247 if (mode & SDDS_ROW_MAJOR_DATA || !(mode & SDDS_COLUMN_MAJOR_DATA)) {
3248 for (i = 0; i < dimension1; i++)
3249 memcpy(data[i], (
char *)column + i * dimension2 * size, dimension2 * size);
3251 for (i = 0; i < dimension1; i++) {
3252 for (j = 0; j < dimension2; j++) {
3253 memcpy((
char *)data[i] + size * j, (
char *)column + (j * dimension1 + i) * size, size);
3333 int32_t retval, type, index, n_names;
3336 int32_t local_memory;
3337 char buffer[SDDS_MAXLINE];
3338 int32_t logic, caseSensitive;
3342 n_names = local_memory = logic = 0;
3346 va_start(argptr, mode);
3351 case SDDS_CI_NAME_ARRAY:
3353 case SDDS_NAME_ARRAY:
3355 n_names = va_arg(argptr, int32_t);
3356 name = va_arg(argptr,
char **);
3358 case SDDS_CI_NAMES_STRING:
3360 case SDDS_NAMES_STRING:
3364 ptr = va_arg(argptr,
char *);
3368 SDDS_SetError(
"Unable to process row selection--memory allocation failure (SDDS_SetRowsOfInterest)");
3376 case SDDS_CI_NAME_STRINGS:
3378 case SDDS_NAME_STRINGS:
3382 while ((
string = va_arg(argptr,
char *))) {
3383 if (!(name =
SDDS_Realloc(name,
sizeof(*name) * (n_names + 1)))) {
3384 SDDS_SetError(
"Unable to process row selection--memory allocation failure (SDDS_SetRowsOfInterest)");
3388 name[n_names++] = string;
3391 case SDDS_CI_MATCH_STRING:
3393 case SDDS_MATCH_STRING:
3396 if ((
string = va_arg(argptr,
char *)))
3398 logic = va_arg(argptr, int32_t);
3399 if (logic & SDDS_NOCASE_COMPARE)
3403 SDDS_SetError(
"Unable to process row selection--unknown mode (SDDS_SetRowsOfInterest)");
3412 if (mode != SDDS_MATCH_STRING && mode != SDDS_CI_MATCH_STRING) {
3413 int (*stringCompare)(
const char *s1,
const char *s2);
3415 stringCompare = strcmp;
3419 SDDS_SetError(
"Unable to process row selection--unrecognized selection column name (SDDS_SetRowsOfInterest)");
3423 SDDS_SetError(
"Unable to select rows--selection column is not string type (SDDS_SetRowsOfInterest)");
3427 SDDS_SetError(
"Unable to process row selection--no names in call (SDDS_SetRowsOfInterest)");
3430 for (j = 0; j < n_names; j++) {
3431 for (i = 0; i < SDDS_dataset->n_rows; i++) {
3432 if ((*stringCompare)(*((
char **)SDDS_dataset->data[index] + i), name[j]) == 0)
3433 SDDS_dataset->row_flag[i] = 1;
3437 if (selection_column) {
3438 int (*wildMatch)(
char *string,
char *
template);
3444 SDDS_SetError(
"Unable to select rows--no matching string given (SDDS_SetRowsOfInterest)");
3449 SDDS_SetError(
"Unable to process row selection--unrecognized selection column name (SDDS_SetRowsOfInterest)");
3454 SDDS_SetError(
"Unable to select rows--selection column is not string type (SDDS_SetRowsOfInterest)");
3457 for (i = 0; i < SDDS_dataset->n_rows; i++)
3458 SDDS_dataset->row_flag[i] =
SDDS_Logic(SDDS_dataset->row_flag[i], (*wildMatch)(*((
char **)SDDS_dataset->data[index] + i),
match_string), logic);
3460 for (i = 0; i < SDDS_dataset->n_rows; i++)
3461 SDDS_dataset->row_flag[i] =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3465 if (local_memory == 2) {
3466 for (i = 0; i < n_names; i++)
3471 if (local_memory >= 1)
3474 for (i = count = 0; i < SDDS_dataset->n_rows; i++)
3475 if (SDDS_dataset->row_flag[i])
3507 int32_t match, type, index, indirect_index;
3511# if !defined(_MINGW)
3516 index = type = indirect_index = 0;
3521 if (selection_column) {
3523 SDDS_SetError(
"Unable to select rows--column name is unrecognized (SDDS_MatchRowsOfInterest)");
3527 SDDS_SetError(
"Unable to select rows--selection column is not a string (SDDS_MatchRowsOfInterest)");
3530 if (!label_to_match) {
3531 SDDS_SetError(
"Unable to select rows--selection label is NULL (SDDS_MatchRowsOfInterest)");
3534 if (!(logic & SDDS_INDIRECT_MATCH))
3538 SDDS_SetError(
"Unable to select rows--indirect column name is unrecognized (SDDS_MatchRowsOfInterest)");
3542 SDDS_SetError(
"Unable to select rows--indirect column is not same type as main column (SDDS_MatchRowsOfInterest)");
3548 int (*stringCompare)(
const char *s,
const char *t);
3549 int (*wildMatch)(
char *s,
char *t);
3550 if (logic & SDDS_NOCASE_COMPARE) {
3554 stringCompare = strcmp;
3557 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3558 if (selection_column)
3559 match =
SDDS_Logic(SDDS_dataset->row_flag[i], (logic & SDDS_INDIRECT_MATCH ? (*stringCompare)(*((
char **)SDDS_dataset->data[index] + i), *((
char **)SDDS_dataset->data[indirect_index] + i)) == 0 : (*wildMatch)(*((
char **)SDDS_dataset->data[index] + i),
match_string)), logic);
3561 match =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3562 if ((SDDS_dataset->row_flag[i] = match))
3568 if (!(logic & SDDS_INDIRECT_MATCH))
3570 if (logic & SDDS_NOCASE_COMPARE) {
3572 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3573 c1 = tolower(*((
char *)SDDS_dataset->data[index] + i));
3574 if (selection_column)
3575 match =
SDDS_Logic(SDDS_dataset->row_flag[i], logic & SDDS_INDIRECT_MATCH ? c1 == tolower(*((
char *)SDDS_dataset->data[indirect_index] + i)) : c1 == c2, logic);
3577 match =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3578 if ((SDDS_dataset->row_flag[i] = match))
3582 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3583 c1 = *((
char *)SDDS_dataset->data[index] + i);
3584 if (selection_column)
3585 match =
SDDS_Logic(SDDS_dataset->row_flag[i], logic & SDDS_INDIRECT_MATCH ? c1 == *((
char *)SDDS_dataset->data[indirect_index] + i) : c1 == c2, logic);
3587 match =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3588 if ((SDDS_dataset->row_flag[i] = match))
3629 int32_t accept, type, index;
3633 if (!filter_column) {
3634 SDDS_SetError(
"Unable to filter rows--filter column name not given (SDDS_FilterRowsOfInterest)");
3638 SDDS_SetError(
"Unable to filter rows--column name is unrecognized (SDDS_FilterRowsOfInterest)");
3653 SDDS_SetError(
"Unable to filter rows--filter column is not a numeric type (SDDS_FilterRowsOfInterest)");
3656 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3657 if (logic & SDDS_NEGATE_PREVIOUS)
3658 SDDS_dataset->row_flag[i] = !SDDS_dataset->row_flag[i];
3660 if (logic & SDDS_NEGATE_MATCH)
3662 if (logic & SDDS_AND)
3663 accept = accept && SDDS_dataset->row_flag[i];
3664 else if (logic & SDDS_OR)
3665 accept = accept || SDDS_dataset->row_flag[i];
3666 if (logic & SDDS_NEGATE_EXPRESSION)
3668 if ((SDDS_dataset->row_flag[i] = accept))
3698 int32_t accept, index;
3705 if (!filter_column) {
3706 SDDS_SetError(
"Unable to filter rows--filter column name not given (SDDS_FilterRowsByNumScan)");
3710 SDDS_SetError(
"Unable to filter rows--column name is unrecognized (SDDS_FilterRowsByNumScan)");
3724 SDDS_SetError(
"Unable to filter rows--filter column is not string type (SDDS_FilterRowsByNumScan)");
3729 invert = mode & NUMSCANFILTER_INVERT ? 1 : 0;
3730 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3731 ptr = ((
char **)(SDDS_dataset->data[index]))[i];
3735 if ((SDDS_dataset->row_flag[i] = accept))
3765 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
3766 if (SDDS_dataset->row_flag[i]) {
3768 SDDS_dataset->row_flag[j] = SDDS_dataset->row_flag[i];
3770 SDDS_SetError(
"Unable to delete unset rows--problem copying row (SDDS_DeleteUnsetRows)");
3777 SDDS_dataset->n_rows = j;
3807 for (i = 0; i < SDDS_dataset->layout.n_columns; i++) {
3808 if (SDDS_dataset->layout.column_definition[i].type !=
SDDS_STRING) {
3809 size =
SDDS_type_size[SDDS_dataset->layout.column_definition[i].type - 1];
3810 memcpy((
char *)SDDS_dataset->data[i] + target * size, (
char *)SDDS_dataset->data[i] + source * size, size);
3812 if (((
char ***)SDDS_dataset->data)[i][target])
3813 free(((
char ***)SDDS_dataset->data)[i][target]);
3814 ((
char ***)SDDS_dataset->data)[i][target] = NULL;
3815 if (!
SDDS_CopyString(((
char ***)SDDS_dataset->data)[i] + target, ((
char ***)SDDS_dataset->data)[i][source]))
3816 return ((int32_t)0);
3849 SDDS_Bomb(
"SDDS_DeleteColumn is presently not functional.");
3854 SDDS_SetError(
"Unable to delete column--unrecognized column name (SDDS_DeleteColumn)");
3857 for (i = index + 1; i < SDDS_dataset->layout.n_columns; i++) {
3859 SDDS_SetError(
"Unable to delete column--error copying column (SDDS_DeleteColumn)");
3862 for (j = 0; j < SDDS_dataset->n_of_interest; j++)
3863 if (SDDS_dataset->column_order[j] == index) {
3864 memcpy((
char *)(SDDS_dataset->column_order + j), (
char *)(SDDS_dataset->column_order + j + 1),
sizeof(*SDDS_dataset->column_order) * (SDDS_dataset->n_of_interest - j - 1));
3865 SDDS_dataset->n_of_interest--;
3866 }
else if (SDDS_dataset->column_order[j] > index)
3867 SDDS_dataset->column_order[j] -= 1;
3869 if ((SDDS_dataset->layout.n_columns -= 1) == 0)
3870 SDDS_dataset->n_rows = 0;
3897 for (i = 0; i < SDDS_dataset->layout.n_columns; i++)
3898 if (!SDDS_dataset->column_flag[i]) {
3899 if (!
SDDS_DeleteColumn(SDDS_dataset, SDDS_dataset->layout.column_definition[i].name))
3932 if (target < 0 || source < 0 || target >= SDDS_dataset->layout.n_columns || source >= SDDS_dataset->layout.n_columns) {
3933 SDDS_SetError(
"Unable to copy column--target or source index out of range (SDDS_CopyColumn");
3936 cd_target = SDDS_dataset->layout.column_definition + target;
3937 cd_source = SDDS_dataset->layout.column_definition + source;
3938 SDDS_dataset->column_flag[target] = SDDS_dataset->column_flag[source];
3939 if (SDDS_dataset->n_rows_allocated) {
3940 if (cd_target->type != cd_source->type) {
3941 if (!(SDDS_dataset->data[target] =
SDDS_Realloc(SDDS_dataset->data[target],
SDDS_type_size[cd_source->type - 1] * SDDS_dataset->n_rows_allocated))) {
3942 SDDS_SetError(
"Unable to copy column--memory allocation failure (SDDS_CopyColumn)");
3947 memcpy(SDDS_dataset->data[target], SDDS_dataset->data[source],
SDDS_type_size[cd_source->type - 1] * SDDS_dataset->n_rows);
3948 else if (!
SDDS_CopyStringArray(SDDS_dataset->data[target], SDDS_dataset->data[source], SDDS_dataset->n_rows)) {
3949 SDDS_SetError(
"Unable to copy column--string copy failure (SDDS_CopyColumn)");
3953 memcpy((
char *)cd_target, (
char *)cd_source,
sizeof(*cd_target));
3983 SDDS_SetError(
"Unable to delete parameter--unrecognized parameter name (SDDS_DeleteParameter)");
3986 for (i = index + 1; i < SDDS_dataset->layout.n_parameters; i++) {
3988 SDDS_SetError(
"Unable to delete parameter--error copying parameter (SDDS_DeleteParameter)");
3992 SDDS_dataset->layout.n_parameters -= 1;
4021 if (target < 0 || source < 0 || target >= SDDS_dataset->layout.n_parameters || source >= SDDS_dataset->layout.n_parameters) {
4022 SDDS_SetError(
"Unable to copy parameter--target or source index out of range (SDDS_CopyParameter");
4025 cd_target = SDDS_dataset->layout.parameter_definition + target;
4026 cd_source = SDDS_dataset->layout.parameter_definition + source;
4027 if (SDDS_dataset->parameter) {
4028 if (cd_target->type != cd_source->type) {
4030 SDDS_SetError(
"Unable to copy parameter--memory allocation failure (SDDS_CopyParameter)");
4035 memcpy(SDDS_dataset->parameter[target], SDDS_dataset->parameter[source],
SDDS_type_size[cd_source->type - 1]);
4036 else if (!
SDDS_CopyStringArray(SDDS_dataset->parameter[target], SDDS_dataset->parameter[source], 1)) {
4037 SDDS_SetError(
"Unable to copy parameter--string copy failure (SDDS_CopyParameter)");
4041 memcpy((
char *)cd_target, (
char *)cd_source,
sizeof(*cd_target));
4079 unsigned short ushort_val;
4083 uint64_t ulong64_val;
4084 long double ldouble_val;
4090 if ((short_val = *((
short *)data + index)) < lower_limit || short_val > upper_limit)
4094 if ((ushort_val = *((
unsigned short *)data + index)) < lower_limit || ushort_val > upper_limit)
4098 if ((long_val = *((int32_t *)data + index)) < lower_limit || long_val > upper_limit)
4102 if ((ulong_val = *((uint32_t *)data + index)) < lower_limit || ulong_val > upper_limit)
4106 if ((long64_val = *((int64_t *)data + index)) < lower_limit || long64_val > upper_limit)
4110 if ((ulong64_val = *((uint64_t *)data + index)) < lower_limit || ulong64_val > upper_limit)
4114 if ((float_val = *((
float *)data + index)) < lower_limit || float_val > upper_limit)
4116 if (isnan(float_val) || isinf(float_val))
4120 if ((double_val = *((
double *)data + index)) < lower_limit || double_val > upper_limit)
4122 if (isnan(double_val) || isinf(double_val))
4126 if ((ldouble_val = *((
long double *)data + index)) < lower_limit || ldouble_val > upper_limit)
4128 if (isnan(ldouble_val) || isinf(ldouble_val))
4132 SDDS_SetError(
"Unable to complete window check--item type is non-numeric (SDDS_ItemInsideWindow)");
4165int32_t
SDDS_Logic(int32_t previous, int32_t match, uint32_t logic) {
4166 if (logic & SDDS_0_PREVIOUS)
4168 else if (logic & SDDS_1_PREVIOUS)
4170 if (logic & SDDS_NEGATE_PREVIOUS)
4171 previous = !previous;
4172 if (logic & SDDS_NEGATE_MATCH)
4174 if (logic & SDDS_AND)
4175 match = match && previous;
4176 else if (logic & SDDS_OR)
4177 match = match || previous;
4180 if (logic & SDDS_NEGATE_EXPRESSION)
4210 int32_t index, type, size;
4216 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArray)");
4220 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArray)");
4225 else if (!(copy = (
SDDS_ARRAY *)calloc(1,
sizeof(*copy)))) {
4226 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArray)");
4229 original = SDDS_dataset->array + index;
4231 SDDS_SetError(
"Unable to get array--array definition corrupted (SDDS_GetArray)");
4235 SDDS_SetError(
"Unable to get array--array definition missing (SDDS_GetArray)");
4238 type = copy->definition->type;
4240 if (!(copy->dimension =
SDDS_Realloc(copy->dimension,
sizeof(*copy->dimension) * copy->definition->dimensions))) {
4241 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArray)");
4244 memcpy((
void *)copy->dimension, (
void *)original->dimension,
sizeof(*copy->dimension) * copy->definition->dimensions);
4245 if (!(copy->elements = original->elements))
4247 if (!(copy->data =
SDDS_Realloc(copy->data, size * original->elements))) {
4248 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArray)");
4253 memcpy(copy->data, original->data, size * copy->elements);
4254 else if (!
SDDS_CopyStringArray((
char **)copy->data, (
char **)original->data, original->elements)) {
4255 SDDS_SetError(
"Unable to get array--string copy failure (SDDS_GetArray)");
4260 if (copy->pointer && copy->definition->dimensions != 1)
4261 free(copy->pointer);
4262 if (!(copy->pointer =
SDDS_MakePointerArray(copy->data, type, copy->definition->dimensions, copy->dimension))) {
4263 SDDS_SetError(
"Unable to get array--couldn't make pointer array (SDDS_GetArray)");
4292 int32_t index, type, i, elements;
4295 char buffer[SDDS_MAXLINE];
4302 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArrayInString)");
4306 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArrayInString)");
4309 original = SDDS_dataset->array + index;
4310 type = original->definition->type;
4311 elements = original->elements;
4312 if (!(data = (
char **)
SDDS_Malloc(
sizeof(*data) * elements))) {
4313 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArrayInString)");
4316 rawData = original->data;
4319 for (i = 0; i < elements; i++) {
4320 if (LDBL_DIG == 18) {
4321 sprintf(buffer,
"%22.18Le", ((
long double *)rawData)[i]);
4323 sprintf(buffer,
"%22.15Le", ((
long double *)rawData)[i]);
4329 for (i = 0; i < elements; i++) {
4330 sprintf(buffer,
"%22.15le", ((
double *)rawData)[i]);
4335 for (i = 0; i < elements; i++) {
4336 sprintf(buffer,
"%15.8e", ((
float *)rawData)[i]);
4341 for (i = 0; i < elements; i++) {
4342 sprintf(buffer,
"%" PRId64, ((int64_t *)rawData)[i]);
4347 for (i = 0; i < elements; i++) {
4348 sprintf(buffer,
"%" PRIu64, ((uint64_t *)rawData)[i]);
4353 for (i = 0; i < elements; i++) {
4354 sprintf(buffer,
"%" PRId32, ((int32_t *)rawData)[i]);
4359 for (i = 0; i < elements; i++) {
4360 sprintf(buffer,
"%" PRIu32, ((uint32_t *)rawData)[i]);
4365 for (i = 0; i < elements; i++) {
4366 sprintf(buffer,
"%hd", ((
short *)rawData)[i]);
4371 for (i = 0; i < elements; i++) {
4372 sprintf(buffer,
"%hu", ((
unsigned short *)rawData)[i]);
4377 for (i = 0; i < elements; i++) {
4378 sprintf(buffer,
"%c", ((
char *)rawData)[i]);
4383 for (i = 0; i < elements; i++) {
4414 int32_t index, type, i, elements;
4423 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArrayInDoubles)");
4427 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArrayInDoubles)");
4430 original = SDDS_dataset->array + index;
4431 if ((type = original->definition->type) ==
SDDS_STRING) {
4432 SDDS_SetError(
"Unable to get array--string type (SDDS_GetArrayInDoubles)");
4435 elements = original->elements;
4436 if (!(data =
SDDS_Malloc(
sizeof(*data) * elements))) {
4437 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArrayInDoubles)");
4440 rawData = original->data;
4443 for (i = 0; i < elements; i++) {
4444 data[i] = ((
long double *)rawData)[i];
4448 for (i = 0; i < elements; i++) {
4449 data[i] = ((
double *)rawData)[i];
4453 for (i = 0; i < elements; i++) {
4454 data[i] = ((
float *)rawData)[i];
4458 for (i = 0; i < elements; i++) {
4459 data[i] = ((int64_t *)rawData)[i];
4463 for (i = 0; i < elements; i++) {
4464 data[i] = ((uint64_t *)rawData)[i];
4468 for (i = 0; i < elements; i++) {
4469 data[i] = ((int32_t *)rawData)[i];
4473 for (i = 0; i < elements; i++) {
4474 data[i] = ((uint32_t *)rawData)[i];
4478 for (i = 0; i < elements; i++) {
4479 data[i] = ((
short *)rawData)[i];
4483 for (i = 0; i < elements; i++) {
4484 data[i] = ((
unsigned short *)rawData)[i];
4488 for (i = 0; i < elements; i++) {
4489 data[i] = ((
char *)rawData)[i];
4519 int32_t index, type, i, elements;
4528 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArrayInLong)");
4532 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArrayInLong)");
4535 original = SDDS_dataset->array + index;
4536 if ((type = original->definition->type) ==
SDDS_STRING) {
4537 SDDS_SetError(
"Unable to get array--string type (SDDS_GetArrayInLong)");
4540 elements = original->elements;
4541 if (!(data =
SDDS_Malloc(
sizeof(*data) * elements))) {
4542 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArrayInLong)");
4545 rawData = original->data;
4548 for (i = 0; i < elements; i++) {
4549 data[i] = ((
long double *)rawData)[i];
4553 for (i = 0; i < elements; i++) {
4554 data[i] = ((
double *)rawData)[i];
4558 for (i = 0; i < elements; i++) {
4559 data[i] = ((
float *)rawData)[i];
4563 for (i = 0; i < elements; i++) {
4564 data[i] = ((int64_t *)rawData)[i];
4568 for (i = 0; i < elements; i++) {
4569 data[i] = ((uint64_t *)rawData)[i];
4573 for (i = 0; i < elements; i++) {
4574 data[i] = ((int32_t *)rawData)[i];
4578 for (i = 0; i < elements; i++) {
4579 data[i] = ((uint32_t *)rawData)[i];
4583 for (i = 0; i < elements; i++) {
4584 data[i] = ((
short *)rawData)[i];
4588 for (i = 0; i < elements; i++) {
4589 data[i] = ((
unsigned short *)rawData)[i];
4593 for (i = 0; i < elements; i++) {
4594 data[i] = ((
char *)rawData)[i];
4632 SDDS_SetError(
"Unable to retrieve description data (SDDS_GetDescription)");
4639 SDDS_SetError(
"Unable to retrieve description data (SDDS_GetDescription)");
4676 int32_t index, type;
4681 if (new_units == NULL) {
4682 SDDS_SetError(
"new_units is NULL (SDDS_SetArrayUnitsConversion)");
4686 SDDS_SetError(
"Unable to get array--name is not recognized (SDDS_SetArrayUnitsConversion)");
4690 SDDS_SetError(
"Unable to get array--data type undefined (SDDS_SetArrayUnitsConversion)");
4693 if (SDDS_dataset->layout.array_definition[index].units != NULL) {
4694 if (strcmp(new_units, SDDS_dataset->layout.array_definition[index].units) != 0) {
4695 if ((old_units != NULL) && (strcmp(old_units, SDDS_dataset->layout.array_definition[index].units) != 0)) {
4696 SDDS_SetError(
"Unexpected units value found (SDDS_SetArrayUnitsConversion)");
4700 cp_str(&(SDDS_dataset->layout.array_definition[index].units), new_units);
4703 cp_str(&(SDDS_dataset->layout.array_definition[index].units), new_units);
4706 if (SDDS_dataset->pages_read == 0) {
4709 rawData = SDDS_dataset->array[index].data;
4712 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4713 ((
long double *)rawData)[i] *= factor;
4717 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4718 ((
double *)rawData)[i] *= factor;
4722 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4723 ((
float *)rawData)[i] *= factor;
4727 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4728 ((int32_t *)rawData)[i] *= factor;
4732 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4733 ((uint32_t *)rawData)[i] *= factor;
4737 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4738 ((int64_t *)rawData)[i] *= factor;
4742 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4743 ((uint64_t *)rawData)[i] *= factor;
4747 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4748 ((
short *)rawData)[i] *= factor;
4752 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4753 ((
unsigned short *)rawData)[i] *= factor;
4789 int32_t index, type;
4794 if (new_units == NULL) {
4795 SDDS_SetError(
"new_units is NULL (SDDS_SetColumnUnitsConversion)");
4799 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_SetColumnUnitsConversion)");
4803 SDDS_SetError(
"Unable to get column--data type undefined (SDDS_SetColumnUnitsConversion)");
4806 if (SDDS_dataset->layout.column_definition[index].units != NULL) {
4807 if (strcmp(new_units, SDDS_dataset->layout.column_definition[index].units) != 0) {
4808 if ((old_units != NULL) && (strcmp(old_units, SDDS_dataset->layout.column_definition[index].units) != 0)) {
4809 SDDS_SetError(
"Unexpected units value found (SDDS_SetColumnUnitsConversion)");
4812 free(SDDS_dataset->layout.column_definition[index].units);
4813 cp_str(&(SDDS_dataset->original_layout.column_definition[index].units), new_units);
4814 cp_str(&(SDDS_dataset->layout.column_definition[index].units), new_units);
4817 cp_str(&(SDDS_dataset->original_layout.column_definition[index].units), new_units);
4818 cp_str(&(SDDS_dataset->layout.column_definition[index].units), new_units);
4821 if (SDDS_dataset->pages_read == 0) {
4824 rawData = SDDS_dataset->data[index];
4827 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4828 ((
long double *)rawData)[i] *= factor;
4832 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4833 ((
double *)rawData)[i] *= factor;
4837 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4838 ((
float *)rawData)[i] *= factor;
4842 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4843 ((int32_t *)rawData)[i] *= factor;
4847 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4848 ((uint32_t *)rawData)[i] *= factor;
4852 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4853 ((int64_t *)rawData)[i] *= factor;
4857 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4858 ((uint64_t *)rawData)[i] *= factor;
4862 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4863 ((
short *)rawData)[i] *= factor;
4867 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4868 ((
unsigned short *)rawData)[i] *= factor;
4904 int32_t index, type;
4908 if (new_units == NULL) {
4909 SDDS_SetError(
"new_units is NULL (SDDS_SetParameterUnitsConversion)");
4913 SDDS_SetError(
"Unable to get parameter--name is not recognized (SDDS_SetParameterUnitsConversion)");
4917 SDDS_SetError(
"Unable to get parameter--data type undefined (SDDS_SetParameterUnitsConversion)");
4920 if (SDDS_dataset->layout.parameter_definition[index].units != NULL) {
4921 if (strcmp(new_units, SDDS_dataset->layout.parameter_definition[index].units) != 0) {
4922 if ((old_units != NULL) && (strcmp(old_units, SDDS_dataset->layout.parameter_definition[index].units) != 0)) {
4923 SDDS_SetError(
"Unexpected units value found (SDDS_SetParameterUnitsConversion)");
4927 cp_str(&(SDDS_dataset->layout.parameter_definition[index].units), new_units);
4930 cp_str(&(SDDS_dataset->layout.parameter_definition[index].units), new_units);
4933 if (SDDS_dataset->pages_read == 0) {
4936 rawData = SDDS_dataset->parameter[index];
4939 *((
long double *)rawData) *= factor;
4942 *((
double *)rawData) *= factor;
4945 *((
float *)rawData) *= factor;
4948 *((int32_t *)rawData) *= factor;
4951 *((uint32_t *)rawData) *= factor;
4954 *((int64_t *)rawData) *= factor;
4957 *((uint64_t *)rawData) *= factor;
4960 *((
short *)rawData) *= factor;
4963 *((
unsigned short *)rawData) *= factor;
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
int32_t SDDS_ScanData(char *string, int32_t type, int32_t field_length, void *data, int64_t index, int32_t is_parameter)
Scans a string and saves the parsed value into a data pointer according to the specified data type.
int32_t SDDS_type_size[SDDS_NUM_TYPES]
Array of sizes for each supported data type.
int32_t SDDS_AllocateColumnFlags(SDDS_DATASET *SDDS_target)
int32_t SDDS_GetParameterInformation(SDDS_DATASET *SDDS_dataset, char *field_name, void *memory, int32_t mode,...)
Retrieves information about a specified parameter in the SDDS dataset.
Internal definitions and function declarations for SDDS with LZMA support.
int64_t SDDS_ConvertToLong64(int32_t type, void *data, int64_t index)
Converts a value to a 64-bit integer based on its type.
double SDDS_ConvertToDouble(int32_t type, void *data, int64_t index)
Converts a value to double based on its type.
long double SDDS_ConvertToLongDouble(int32_t type, void *data, int64_t index)
Converts a value to long double based on its type.
int32_t SDDS_ConvertToLong(int32_t type, void *data, int64_t index)
Converts a value to a 32-bit integer based on its type.
void SDDS_SetError(char *error_text)
Records an error message in the SDDS error stack.
int32_t SDDS_GetParameterType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a parameter in the SDDS dataset by its index.
int32_t SDDS_VerifyPrintfFormat(const char *string, int32_t type)
Verifies that a printf format string is compatible with a specified data type.
int32_t SDDS_FreeArrayDefinition(ARRAY_DEFINITION *source)
Frees memory allocated for an array definition.
int32_t SDDS_GetArrayIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named array in the SDDS dataset.
int32_t SDDS_GetParameterIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named parameter in the SDDS dataset.
int32_t SDDS_GetColumnIndex(SDDS_DATASET *SDDS_dataset, char *name)
Retrieves the index of a named column in the SDDS dataset.
void * SDDS_CastValue(void *data, int64_t index, int32_t data_type, int32_t desired_type, void *memory)
Casts a value from one SDDS data type to another.
int32_t SDDS_SetMemory(void *mem, int64_t n_elements, int32_t data_type,...)
Initializes a memory block with a sequence of values based on a specified data type.
void * SDDS_AllocateMatrix(int32_t size, int64_t dim1, int64_t dim2)
Allocates a two-dimensional matrix with zero-initialized elements.
int32_t SDDS_GetArrayType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of an array in the SDDS dataset by its index.
int32_t SDDS_CheckDataset(SDDS_DATASET *SDDS_dataset, const char *caller)
Validates the SDDS dataset pointer.
int32_t SDDS_CopyStringArray(char **target, char **source, int64_t n_strings)
Copies an array of strings from source to target.
void * SDDS_Malloc(size_t size)
Allocates memory of a specified size.
int32_t SDDS_GetTypeSize(int32_t type)
Retrieves the size in bytes of a specified SDDS data type.
int32_t SDDS_StringIsBlank(char *s)
Checks if a string is blank (contains only whitespace characters).
int32_t SDDS_GetToken(char *s, char *buffer, int32_t buflen)
Extracts the next token from a string, handling quoted substrings and escape characters.
ARRAY_DEFINITION * SDDS_CopyArrayDefinition(ARRAY_DEFINITION **target, ARRAY_DEFINITION *source)
Creates a copy of an array definition.
int32_t SDDS_GetColumnType(SDDS_DATASET *SDDS_dataset, int32_t index)
Retrieves the data type of a column in the SDDS dataset by its index.
void SDDS_Bomb(char *message)
Terminates the program after printing an error message and recorded errors.
int32_t SDDS_CopyString(char **target, const char *source)
Copies a source string to a target string with memory allocation.
int32_t SDDS_CheckTabularData(SDDS_DATASET *SDDS_dataset, const char *caller)
Validates the consistency of tabular data within an SDDS dataset.
void * SDDS_Realloc(void *old_ptr, size_t new_size)
Reallocates memory to a new size.
void * SDDS_MakePointerArray(void *data, int32_t type, int32_t dimensions, int32_t *dimension)
Creates a multi-dimensional pointer array from a contiguous data block.
#define SDDS_ULONG
Identifier for the unsigned 32-bit integer data type.
#define SDDS_FLOAT
Identifier for the float data type.
#define SDDS_STRING
Identifier for the string data type.
#define SDDS_ULONG64
Identifier for the unsigned 64-bit integer data type.
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
#define SDDS_SHORT
Identifier for the signed short integer data type.
#define SDDS_CHARACTER
Identifier for the character data type.
#define SDDS_USHORT
Identifier for the unsigned short integer data type.
#define SDDS_DOUBLE
Identifier for the double data type.
#define SDDS_NUMERIC_TYPE(type)
Checks if the given type identifier corresponds to any numeric type.
#define SDDS_LONGDOUBLE
Identifier for the long double data type.
#define SDDS_LONG64
Identifier for the signed 64-bit integer data type.
char * cp_str(char **s, char *t)
Copies a string, allocating memory for storage.
long tokenIsNumber(char *token)
Checks if the given token represents a valid number.
long match_string(char *string, char **option, long n_options, long mode)
Matches a given string against an array of option strings based on specified modes.
int wild_match_ci(char *string, char *template)
Determine whether one string is a case-insensitive wildcard match for another.
int strcmp_ci(const char *s, const char *t)
Compare two strings case-insensitively.
char * expand_ranges(char *template)
Expand range specifiers in a wildcard template into explicit character lists.
int wild_match(char *string, char *template)
Determine whether one string is a wildcard match for another.