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]);
1554 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1555 if (SDDS_dataset->row_flag[i]) {
1562 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetColumnInString)");
1566 SDDS_dataset->column_track_memory[index] = 0;
1571 char **ptr = (
char **)SDDS_dataset->data[index];
1572 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
1575 free(SDDS_dataset->data[index]);
1576 SDDS_dataset->data[index] = NULL;
1579 free(SDDS_dataset->data[index]);
1580 SDDS_dataset->data[index] = NULL;
1619 int32_t size, type, desiredTypeSize, index;
1620 int64_t i, j, n_rows;
1625 SDDS_SetError(
"Unable to get column--desired type is nonnumeric (SDDS_GetNumericColumn)");
1629 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_GetNumericColumn)");
1633 SDDS_SetError(
"Unable to get column--data size or type undefined or non-numeric (SDDS_GetNumericColumn)");
1636 if (type == desiredType)
1639 SDDS_SetError(
"Unable to get column--no rows left (SDDS_GetNumericColumn)");
1643 SDDS_SetError(
"Unable to get column--memory allocation failure (SDDS_GetNumericColumn)");
1646 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1647 if (SDDS_dataset->row_flag[i] && !
SDDS_CastValue(SDDS_dataset->data[index], i, type, desiredType, (
char *)data + desiredTypeSize * j++)) {
1648 SDDS_SetError(
"Unable to get column--cast to double failed (SDDS_GetNumericColumn)");
1653 SDDS_SetError(
"Unable to get column--row number mismatch (SDDS_GetNumericColumn)");
1657 SDDS_dataset->column_track_memory[index] = 0;
1662 char **ptr = (
char **)SDDS_dataset->data[index];
1663 for (i = 0; i < SDDS_dataset->n_rows_allocated; i++, ptr++)
1666 free(SDDS_dataset->data[index]);
1667 SDDS_dataset->data[index] = NULL;
1670 free(SDDS_dataset->data[index]);
1671 SDDS_dataset->data[index] = NULL;
1708 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
1709 if (SDDS_dataset->row_flag[i] && j++ == srow_index)
1712 if (i == SDDS_dataset->n_rows)
1756 int32_t type, size, column_index;
1761 SDDS_SetError(
"Unable to get value--column name is not recognized (SDDS_GetValue)");
1765 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValue)");
1770 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValue)");
1775 SDDS_SetError(
"Unable to get value--memory allocation failure (SDDS_GetValue)");
1778 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
1787 SDDS_SetError(
"Unable to get value--memory allocation failure (SDDS_GetValue)");
1790 if (
SDDS_CopyString(memory, ((
char **)SDDS_dataset->data[column_index])[row_index]))
1823 int32_t type, size, column_index;
1830 SDDS_SetError(
"Unable to get value--column name is not recognized (SDDS_GetValueAsDouble)");
1834 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueAsDouble)");
1839 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValueAsDouble)");
1844 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
1847 value = *(
short *)memory;
1850 value = *(
unsigned short *)memory;
1853 value = *(int32_t *)memory;
1856 value = *(uint32_t *)memory;
1859 value = *(int64_t *)memory;
1862 value = *(uint64_t *)memory;
1865 value = *(
float *)memory;
1868 value = *(
double *)memory;
1871 value = *(
long double *)memory;
1877 SDDS_SetError(
"Unable to get non-numeric value as double (SDDS_GetValueAsDouble)");
1922 if (column_index < 0 || column_index >= SDDS_dataset->layout.n_columns) {
1923 SDDS_SetError(
"Unable to get value--column index out of range (SDDS_GetValueByIndexAsDouble)");
1927 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueByIndexAsDouble)");
1932 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValueByIndexAsDouble)");
1937 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
1940 value = *(
short *)memory;
1943 value = *(
unsigned short *)memory;
1946 value = *(int32_t *)memory;
1949 value = *(uint32_t *)memory;
1952 value = *(int64_t *)memory;
1955 value = *(uint64_t *)memory;
1958 value = *(
float *)memory;
1961 value = *(
double *)memory;
1964 value = *(
long double *)memory;
1970 SDDS_SetError(
"Unable to get non-numeric value as double (SDDS_GetValueByIndexAsDouble)");
2020 if (column_index < 0 || column_index >= SDDS_dataset->layout.n_columns) {
2021 SDDS_SetError(
"Unable to get value--column index out of range (SDDS_GetValueByIndex)");
2025 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueByIndex)");
2030 SDDS_SetError(
"Unable to get value--row index out of range (SDDS_GetValueByIndex)");
2035 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
2038 return ((
char *)SDDS_dataset->data[column_index] + row_index * size);
2047 if (
SDDS_CopyString(memory, ((
char **)SDDS_dataset->data[column_index])[row_index]))
2095 if (column_index < 0 || column_index >= SDDS_dataset->layout.n_columns) {
2096 SDDS_SetError(
"Unable to get value--column index out of range (SDDS_GetValueByAbsIndex)");
2099 if (row_index < 0 || row_index >= SDDS_dataset->n_rows) {
2100 SDDS_SetError(
"Unable to get value--index out of range (SDDS_GetValueByAbsIndex)");
2104 SDDS_SetError(
"Unable to get value--data type undefined (SDDS_GetValueByAbsIndex)");
2110 memcpy(memory, (
char *)SDDS_dataset->data[column_index] + row_index * size, size);
2113 return ((
char *)SDDS_dataset->data[column_index] + row_index * size);
2122 if (
SDDS_CopyString(memory, ((
char **)SDDS_dataset->data[column_index])[row_index]))
2156 for (i = 0; i < SDDS_dataset->layout.n_columns; i++) {
2157 if (!SDDS_dataset->column_flag[i])
2160 type = SDDS_dataset->layout.column_definition[i].type;
2161 else if (type != SDDS_dataset->layout.column_definition[i].type) {
2162 SDDS_SetError(
"Unable to get row type--inconsistent data type for selected columns (SDDS_GetRowType)");
2205 int64_t i, row_index;
2210 SDDS_SetError(
"Unable to get row--row index out of range (SDDS_GetRow)");
2213 if (SDDS_dataset->n_of_interest <= 0) {
2214 SDDS_SetError(
"Unable to get row--no columns selected (SDDS_GetRow)");
2218 SDDS_SetError(
"Unable to get row--inconsistent data type in selected columns (SDDS_GetRow)");
2224 else if (!(data =
SDDS_Malloc(size * SDDS_dataset->n_of_interest))) {
2225 SDDS_SetError(
"Unable to get row--memory allocation failure (SDDS_GetRow)");
2229 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2230 memcpy((
char *)data + i * size, (
char *)SDDS_dataset->data[SDDS_dataset->column_order[i]] + row_index * size, size);
2232 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2233 if (!
SDDS_CopyString((
char **)data + i, ((
char **)SDDS_dataset->data[SDDS_dataset->column_order[i]])[row_index]))
2273 if (SDDS_dataset->n_of_interest <= 0) {
2274 SDDS_SetError(
"Unable to get matrix of rows--no columns selected (SDDS_GetMatrixOfRows)");
2280 SDDS_SetError(
"Unable to get row--inconsistent data type in selected columns (SDDS_GetMatrixOfRows)");
2285 SDDS_SetError(
"Unable to get matrix of rows--no rows of interest (SDDS_GetMatrixOfRows)");
2288 if (!(data = (
void **)
SDDS_Malloc(
sizeof(*data) * (*n_rows)))) {
2289 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetMatrixOfRows)");
2292 for (j = k = 0; j < SDDS_dataset->n_rows; j++) {
2293 if (SDDS_dataset->row_flag[j]) {
2294 if (!(data[k] =
SDDS_Malloc(size * SDDS_dataset->n_of_interest))) {
2295 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetMatrixOfRows)");
2299 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2300 memcpy((
char *)data[k] + i * size, (
char *)SDDS_dataset->data[SDDS_dataset->column_order[i]] + j * size, size);
2302 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2303 if (!
SDDS_CopyString((
char **)(data[k]) + i, ((
char **)SDDS_dataset->data[SDDS_dataset->column_order[i]])[j]))
2352 SDDS_SetError(
"Unable to get matrix of rows--no columns selected (SDDS_GetCastMatrixOfRows)");
2355 if (SDDS_dataset->n_of_interest <= 0) {
2356 SDDS_SetError(
"Unable to get matrix of rows--no columns selected (SDDS_GetCastMatrixOfRows)");
2363 SDDS_SetError(
"Unable to get matrix of rows--no rows of interest (SDDS_GetCastMatrixOfRows)");
2366 if (!(data = (
void **)
SDDS_Malloc(
sizeof(*data) * (*n_rows)))) {
2367 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetCastMatrixOfRows)");
2370 for (i = 0; i < SDDS_dataset->n_of_interest; i++) {
2371 if (!
SDDS_NUMERIC_TYPE(SDDS_dataset->layout.column_definition[SDDS_dataset->column_order[i]].type)) {
2372 SDDS_SetError(
"Unable to get matrix of rows--not all columns are numeric (SDDS_GetCastMatrixOfRows)");
2376 for (j = k = 0; j < SDDS_dataset->n_rows; j++) {
2377 if (SDDS_dataset->row_flag[j]) {
2378 if (!(data[k] =
SDDS_Malloc(size * SDDS_dataset->n_of_interest))) {
2379 SDDS_SetError(
"Unable to get matrix of rows--memory allocation failure (SDDS_GetCastMatrixOfRows)");
2382 for (i = 0; i < SDDS_dataset->n_of_interest; i++)
2383 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));
2426 char s[SDDS_MAXLINE];
2430 va_start(argptr, SDDS_dataset);
2433 if (!(name = va_arg(argptr,
char *)))
2435 if (!(data = va_arg(argptr,
void *)))
2438 sprintf(s,
"Unable to get value of parameter %s (SDDS_GetParameters)", name);
2483 int32_t index, type, size;
2484 char s[SDDS_MAXLINE];
2488 if (!parameter_name) {
2489 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameter)");
2493 sprintf(s,
"Unable to get parameter value--parameter name %s is unrecognized (SDDS_GetParameter)", parameter_name);
2498 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameter)");
2501 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2502 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameter)");
2509 SDDS_SetError(
"Unable to get parameter value--parameter data size is invalid (SDDS_GetParameter)");
2513 memcpy(data, SDDS_dataset->parameter[index], size);
2514 else if (!
SDDS_CopyString((
char **)data, *(
char **)SDDS_dataset->parameter[index]))
2560 if (index < 0 || index >= SDDS_dataset->layout.n_parameters) {
2561 SDDS_SetError(
"Unable to get parameter value--parameter index is invalid (SDDS_GetParameterByIndex)");
2565 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterByIndex)");
2568 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2569 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterByIndex)");
2576 SDDS_SetError(
"Unable to get parameter value--parameter data size is invalid (SDDS_GetParameterByIndex)");
2580 memcpy(data, SDDS_dataset->parameter[index], size);
2581 else if (!
SDDS_CopyString((
char **)data, *(
char **)SDDS_dataset->parameter[index]))
2617 int32_t index, type;
2620 if (!parameter_name) {
2621 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsLong)");
2625 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsLong)");
2629 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsLong)");
2633 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsLong)");
2636 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2637 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsLong)");
2641 if (!memory && !(memory = (int32_t *)
SDDS_Malloc(
sizeof(int32_t)))) {
2642 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsLong)");
2673 int32_t index, type;
2676 if (!parameter_name) {
2677 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsLong64)");
2681 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsLong64)");
2685 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsLong64)");
2689 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsLong64)");
2692 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2693 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsLong64)");
2697 if (!memory && !(memory = (int64_t *)
SDDS_Malloc(
sizeof(int64_t)))) {
2698 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsLong64)");
2729 int32_t index = -1, type = -1;
2732 if (!parameter_name) {
2733 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsLongDouble)");
2737 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsLongDouble)");
2741 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsLongDouble)");
2745 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsLongDouble)");
2748 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2749 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsLongDouble)");
2753 if (!memory && !(memory = (
long double *)
SDDS_Malloc(
sizeof(
long double)))) {
2754 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsLongDouble)");
2784 int32_t index = -1, type = -1;
2787 if (!parameter_name) {
2788 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsDouble)");
2792 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsDouble)");
2796 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsDouble)");
2800 SDDS_SetError(
"Unable to get parameter value--parameter data type is SDDS_STRING (SDDS_GetParameterAsDouble)");
2803 if (!SDDS_dataset->parameter || !SDDS_dataset->parameter[index]) {
2804 SDDS_SetError(
"Unable to get parameter value--parameter data array is NULL (SDDS_GetParameterAsDouble)");
2808 if (!memory && !(memory = (
double *)
SDDS_Malloc(
sizeof(
double)))) {
2809 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsDouble)");
2840 int32_t index, type;
2841 char buffer[SDDS_MAXLINE], *parValue;
2846 if (!parameter_name) {
2847 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsString)");
2851 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsString)");
2855 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsString)");
2858 value = SDDS_dataset->parameter[index];
2861 if (LDBL_DIG == 18) {
2862 sprintf(buffer,
"%.18Le", *(
long double *)value);
2864 sprintf(buffer,
"%.15Le", *(
long double *)value);
2868 sprintf(buffer,
"%.15le", *(
double *)value);
2871 sprintf(buffer,
"%.8e", *(
float *)value);
2874 sprintf(buffer,
"%" PRId64, *(int64_t *)value);
2877 sprintf(buffer,
"%" PRIu64, *(uint64_t *)value);
2880 sprintf(buffer,
"%" PRId32, *(int32_t *)value);
2883 sprintf(buffer,
"%" PRIu32, *(uint32_t *)value);
2886 sprintf(buffer,
"%hd", *(
short *)value);
2889 sprintf(buffer,
"%hu", *(
unsigned short *)value);
2892 sprintf(buffer,
"%c", *(
char *)value);
2895 sprintf(buffer,
"%s", *(
char **)value);
2898 SDDS_SetError(
"Unknown data type of parameter (SDDS_GetParameterAsString)");
2901 if (!(parValue = malloc(
sizeof(
char) * (strlen(buffer) + 1)))) {
2902 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsString)");
2905 strcpy(parValue, buffer);
2937 int32_t index, type;
2938 char buffer[SDDS_MAXLINE], *parValue;
2940 char *format = NULL;
2944 if (!parameter_name) {
2945 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetParameterAsFormattedString)");
2949 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetParameterAsFormattedString)");
2953 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetParameterAsFormattedString)");
2956 if (suppliedformat != NULL) {
2957 format = suppliedformat;
2959 SDDS_SetError(
"Unable to get parameter value--given format for parameter is invalid (SDDS_GetParameterAsFormattedString)");
2964 SDDS_SetError(
"Unable to get parameter value--parameter definition is invalid (SDDS_GetParameterAsFormattedString)");
2968 value = SDDS_dataset->parameter[index];
2973 sprintf(buffer, format, *(
long double *)value);
2976 sprintf(buffer, format, *(
double *)value);
2979 sprintf(buffer, format, *(
float *)value);
2982 sprintf(buffer, format, *(int64_t *)value);
2985 sprintf(buffer, format, *(uint64_t *)value);
2988 sprintf(buffer, format, *(int32_t *)value);
2991 sprintf(buffer, format, *(uint32_t *)value);
2994 sprintf(buffer, format, *(
short *)value);
2997 sprintf(buffer, format, *(
unsigned short *)value);
3000 sprintf(buffer, format, *(
char *)value);
3003 sprintf(buffer, format, *(
char **)value);
3006 SDDS_SetError(
"Unknown data type of parameter (SDDS_GetParameterAsFormattedString)");
3012 if (LDBL_DIG == 18) {
3013 sprintf(buffer,
"%22.18Le", *(
long double *)value);
3015 sprintf(buffer,
"%22.15Le", *(
long double *)value);
3019 sprintf(buffer,
"%22.15le", *(
double *)value);
3022 sprintf(buffer,
"%15.8e", *(
float *)value);
3025 sprintf(buffer,
"%" PRId64, *(int64_t *)value);
3028 sprintf(buffer,
"%" PRIu64, *(uint64_t *)value);
3031 sprintf(buffer,
"%" PRId32, *(int32_t *)value);
3034 sprintf(buffer,
"%" PRIu32, *(uint32_t *)value);
3037 sprintf(buffer,
"%hd", *(
short *)value);
3040 sprintf(buffer,
"%hu", *(
unsigned short *)value);
3043 sprintf(buffer,
"%c", *(
char *)value);
3046 sprintf(buffer,
"%s", *(
char **)value);
3049 SDDS_SetError(
"Unknown data type of parameter (SDDS_GetParameterAsFormattedString)");
3053 if (!(parValue = malloc(
sizeof(
char) * (strlen(buffer) + 1)))) {
3054 SDDS_SetError(
"Unable to get parameter value--memory allocation failure (SDDS_GetParameterAsFormattedString)");
3057 strcpy(parValue, buffer);
3086 int32_t index, type, size;
3088 char s[SDDS_MAXLINE];
3092 if (!parameter_name) {
3093 SDDS_SetError(
"Unable to get parameter value--parameter name pointer is NULL (SDDS_GetFixedValueParameter)");
3097 SDDS_SetError(
"Unable to get parameter value--parameter name is unrecognized (SDDS_GetFixedValueParameter)");
3101 SDDS_SetError(
"Unable to get parameter value--parameter data type is invalid (SDDS_GetFixedValueParameter)");
3108 SDDS_SetError(
"Unable to get parameter value--parameter data size is invalid (SDDS_GetFixedValueParameter)");
3111 strcpy(s, SDDS_dataset->layout.parameter_definition[index].fixed_value);
3113 SDDS_SetError(
"Unable to retrieve fixed-value paramter--scan failed (SDDS_GetFixedValueParameter)");
3144 int32_t size, type, index;
3145 int64_t n_rows, i, j;
3146 void **data, *column;
3150 SDDS_SetError(
"Unable to get matrix--column name is NULL (SDDS_GetMatrixFromColumn)");
3154 SDDS_SetError(
"Unable to get matrix--no rows selected (SDDS_GetMatrixFromColumn)");
3157 if (n_rows != dimension1 * dimension2) {
3159 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);
3164 SDDS_SetError(
"Unable to get matrix--column name is unrecognized (SDDS_GetMatrixFromColumn)");
3168 SDDS_SetError(
"Unable to get matrix (SDDS_GetMatrixFromColumn)");
3172 SDDS_SetError(
"Unable to allocate matrix (SDDS_GetMatrixFromColumn)");
3175 if (mode & SDDS_ROW_MAJOR_DATA || !(mode & SDDS_COLUMN_MAJOR_DATA)) {
3176 for (i = 0; i < dimension1; i++)
3177 memcpy(data[i], (
char *)column + i * dimension2 * size, dimension2 * size);
3179 for (i = 0; i < dimension1; i++) {
3180 for (j = 0; j < dimension2; j++) {
3181 memcpy((
char *)data[i] + size * j, (
char *)column + (j * dimension1 + i) * size, size);
3216 int32_t size, index;
3217 int64_t n_rows, i, j;
3218 void **data, *column;
3222 SDDS_SetError(
"Unable to get matrix--column name is NULL (SDDS_GetDoubleMatrixFromColumn)");
3226 SDDS_SetError(
"Unable to get matrix--no rows selected (SDDS_GetDoubleMatrixFromColumn)");
3229 if (n_rows != dimension1 * dimension2) {
3231 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);
3236 SDDS_SetError(
"Unable to get matrix--column name is unrecognized (SDDS_GetDoubleMatrixFromColumn)");
3240 SDDS_SetError(
"Unable to get matrix (SDDS_GetDoubleMatrixFromColumn)");
3243 size =
sizeof(double);
3245 SDDS_SetError(
"Unable to allocate matrix (SDDS_GetDoubleMatrixFromColumn)");
3248 if (mode & SDDS_ROW_MAJOR_DATA || !(mode & SDDS_COLUMN_MAJOR_DATA)) {
3249 for (i = 0; i < dimension1; i++)
3250 memcpy(data[i], (
char *)column + i * dimension2 * size, dimension2 * size);
3252 for (i = 0; i < dimension1; i++) {
3253 for (j = 0; j < dimension2; j++) {
3254 memcpy((
char *)data[i] + size * j, (
char *)column + (j * dimension1 + i) * size, size);
3334 int32_t retval, type, index, n_names;
3337 int32_t local_memory;
3338 char buffer[SDDS_MAXLINE];
3339 int32_t logic, caseSensitive;
3343 n_names = local_memory = logic = 0;
3347 va_start(argptr, mode);
3352 case SDDS_CI_NAME_ARRAY:
3354 case SDDS_NAME_ARRAY:
3356 n_names = va_arg(argptr, int32_t);
3357 name = va_arg(argptr,
char **);
3359 case SDDS_CI_NAMES_STRING:
3361 case SDDS_NAMES_STRING:
3365 ptr = va_arg(argptr,
char *);
3369 SDDS_SetError(
"Unable to process row selection--memory allocation failure (SDDS_SetRowsOfInterest)");
3377 case SDDS_CI_NAME_STRINGS:
3379 case SDDS_NAME_STRINGS:
3383 while ((
string = va_arg(argptr,
char *))) {
3384 if (!(name =
SDDS_Realloc(name,
sizeof(*name) * (n_names + 1)))) {
3385 SDDS_SetError(
"Unable to process row selection--memory allocation failure (SDDS_SetRowsOfInterest)");
3389 name[n_names++] = string;
3392 case SDDS_CI_MATCH_STRING:
3394 case SDDS_MATCH_STRING:
3397 if ((
string = va_arg(argptr,
char *)))
3399 logic = va_arg(argptr, int32_t);
3400 if (logic & SDDS_NOCASE_COMPARE)
3404 SDDS_SetError(
"Unable to process row selection--unknown mode (SDDS_SetRowsOfInterest)");
3413 if (mode != SDDS_MATCH_STRING && mode != SDDS_CI_MATCH_STRING) {
3414 int (*stringCompare)(
const char *s1,
const char *s2);
3416 stringCompare = strcmp;
3420 SDDS_SetError(
"Unable to process row selection--unrecognized selection column name (SDDS_SetRowsOfInterest)");
3424 SDDS_SetError(
"Unable to select rows--selection column is not string type (SDDS_SetRowsOfInterest)");
3428 SDDS_SetError(
"Unable to process row selection--no names in call (SDDS_SetRowsOfInterest)");
3431 for (j = 0; j < n_names; j++) {
3432 for (i = 0; i < SDDS_dataset->n_rows; i++) {
3433 if ((*stringCompare)(*((
char **)SDDS_dataset->data[index] + i), name[j]) == 0)
3434 SDDS_dataset->row_flag[i] = 1;
3438 if (selection_column) {
3439 int (*wildMatch)(
char *string,
char *
template);
3445 SDDS_SetError(
"Unable to select rows--no matching string given (SDDS_SetRowsOfInterest)");
3450 SDDS_SetError(
"Unable to process row selection--unrecognized selection column name (SDDS_SetRowsOfInterest)");
3455 SDDS_SetError(
"Unable to select rows--selection column is not string type (SDDS_SetRowsOfInterest)");
3458 for (i = 0; i < SDDS_dataset->n_rows; i++)
3459 SDDS_dataset->row_flag[i] =
SDDS_Logic(SDDS_dataset->row_flag[i], (*wildMatch)(*((
char **)SDDS_dataset->data[index] + i),
match_string), logic);
3461 for (i = 0; i < SDDS_dataset->n_rows; i++)
3462 SDDS_dataset->row_flag[i] =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3466 if (local_memory == 2) {
3467 for (i = 0; i < n_names; i++)
3472 if (local_memory >= 1)
3475 for (i = count = 0; i < SDDS_dataset->n_rows; i++)
3476 if (SDDS_dataset->row_flag[i])
3508 int32_t match, type, index, indirect_index;
3512# if !defined(_MINGW)
3517 index = type = indirect_index = 0;
3522 if (selection_column) {
3524 SDDS_SetError(
"Unable to select rows--column name is unrecognized (SDDS_MatchRowsOfInterest)");
3528 SDDS_SetError(
"Unable to select rows--selection column is not a string (SDDS_MatchRowsOfInterest)");
3531 if (!label_to_match) {
3532 SDDS_SetError(
"Unable to select rows--selection label is NULL (SDDS_MatchRowsOfInterest)");
3535 if (!(logic & SDDS_INDIRECT_MATCH))
3539 SDDS_SetError(
"Unable to select rows--indirect column name is unrecognized (SDDS_MatchRowsOfInterest)");
3543 SDDS_SetError(
"Unable to select rows--indirect column is not same type as main column (SDDS_MatchRowsOfInterest)");
3549 int (*stringCompare)(
const char *s,
const char *t);
3550 int (*wildMatch)(
char *s,
char *t);
3551 if (logic & SDDS_NOCASE_COMPARE) {
3555 stringCompare = strcmp;
3558 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3559 if (selection_column)
3560 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);
3562 match =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3563 if ((SDDS_dataset->row_flag[i] = match))
3569 if (!(logic & SDDS_INDIRECT_MATCH))
3571 if (logic & SDDS_NOCASE_COMPARE) {
3573 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3574 c1 = tolower(*((
char *)SDDS_dataset->data[index] + i));
3575 if (selection_column)
3576 match =
SDDS_Logic(SDDS_dataset->row_flag[i], logic & SDDS_INDIRECT_MATCH ? c1 == tolower(*((
char *)SDDS_dataset->data[indirect_index] + i)) : c1 == c2, logic);
3578 match =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3579 if ((SDDS_dataset->row_flag[i] = match))
3583 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3584 c1 = *((
char *)SDDS_dataset->data[index] + i);
3585 if (selection_column)
3586 match =
SDDS_Logic(SDDS_dataset->row_flag[i], logic & SDDS_INDIRECT_MATCH ? c1 == *((
char *)SDDS_dataset->data[indirect_index] + i) : c1 == c2, logic);
3588 match =
SDDS_Logic(SDDS_dataset->row_flag[i], 0, logic & ~(SDDS_AND | SDDS_OR));
3589 if ((SDDS_dataset->row_flag[i] = match))
3630 int32_t accept, type, index;
3634 if (!filter_column) {
3635 SDDS_SetError(
"Unable to filter rows--filter column name not given (SDDS_FilterRowsOfInterest)");
3639 SDDS_SetError(
"Unable to filter rows--column name is unrecognized (SDDS_FilterRowsOfInterest)");
3654 SDDS_SetError(
"Unable to filter rows--filter column is not a numeric type (SDDS_FilterRowsOfInterest)");
3657 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3658 if (logic & SDDS_NEGATE_PREVIOUS)
3659 SDDS_dataset->row_flag[i] = !SDDS_dataset->row_flag[i];
3661 if (logic & SDDS_NEGATE_MATCH)
3663 if (logic & SDDS_AND)
3664 accept = accept && SDDS_dataset->row_flag[i];
3665 else if (logic & SDDS_OR)
3666 accept = accept || SDDS_dataset->row_flag[i];
3667 if (logic & SDDS_NEGATE_EXPRESSION)
3669 if ((SDDS_dataset->row_flag[i] = accept))
3699 int32_t accept, index;
3706 if (!filter_column) {
3707 SDDS_SetError(
"Unable to filter rows--filter column name not given (SDDS_FilterRowsByNumScan)");
3711 SDDS_SetError(
"Unable to filter rows--column name is unrecognized (SDDS_FilterRowsByNumScan)");
3725 SDDS_SetError(
"Unable to filter rows--filter column is not string type (SDDS_FilterRowsByNumScan)");
3730 invert = mode & NUMSCANFILTER_INVERT ? 1 : 0;
3731 for (i = count = 0; i < SDDS_dataset->n_rows; i++) {
3732 ptr = ((
char **)(SDDS_dataset->data[index]))[i];
3736 if ((SDDS_dataset->row_flag[i] = accept))
3766 for (i = j = 0; i < SDDS_dataset->n_rows; i++) {
3767 if (SDDS_dataset->row_flag[i]) {
3769 SDDS_dataset->row_flag[j] = SDDS_dataset->row_flag[i];
3771 SDDS_SetError(
"Unable to delete unset rows--problem copying row (SDDS_DeleteUnsetRows)");
3778 SDDS_dataset->n_rows = j;
3808 for (i = 0; i < SDDS_dataset->layout.n_columns; i++) {
3809 if (SDDS_dataset->layout.column_definition[i].type !=
SDDS_STRING) {
3810 size =
SDDS_type_size[SDDS_dataset->layout.column_definition[i].type - 1];
3811 memcpy((
char *)SDDS_dataset->data[i] + target * size, (
char *)SDDS_dataset->data[i] + source * size, size);
3813 if (((
char ***)SDDS_dataset->data)[i][target])
3814 free(((
char ***)SDDS_dataset->data)[i][target]);
3815 ((
char ***)SDDS_dataset->data)[i][target] = NULL;
3816 if (!
SDDS_CopyString(((
char ***)SDDS_dataset->data)[i] + target, ((
char ***)SDDS_dataset->data)[i][source]))
3817 return ((int32_t)0);
3850 SDDS_Bomb(
"SDDS_DeleteColumn is presently not functional.");
3855 SDDS_SetError(
"Unable to delete column--unrecognized column name (SDDS_DeleteColumn)");
3858 for (i = index + 1; i < SDDS_dataset->layout.n_columns; i++) {
3860 SDDS_SetError(
"Unable to delete column--error copying column (SDDS_DeleteColumn)");
3863 for (j = 0; j < SDDS_dataset->n_of_interest; j++)
3864 if (SDDS_dataset->column_order[j] == index) {
3865 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));
3866 SDDS_dataset->n_of_interest--;
3867 }
else if (SDDS_dataset->column_order[j] > index)
3868 SDDS_dataset->column_order[j] -= 1;
3870 if ((SDDS_dataset->layout.n_columns -= 1) == 0)
3871 SDDS_dataset->n_rows = 0;
3898 for (i = 0; i < SDDS_dataset->layout.n_columns; i++)
3899 if (!SDDS_dataset->column_flag[i]) {
3900 if (!
SDDS_DeleteColumn(SDDS_dataset, SDDS_dataset->layout.column_definition[i].name))
3933 if (target < 0 || source < 0 || target >= SDDS_dataset->layout.n_columns || source >= SDDS_dataset->layout.n_columns) {
3934 SDDS_SetError(
"Unable to copy column--target or source index out of range (SDDS_CopyColumn");
3937 cd_target = SDDS_dataset->layout.column_definition + target;
3938 cd_source = SDDS_dataset->layout.column_definition + source;
3939 SDDS_dataset->column_flag[target] = SDDS_dataset->column_flag[source];
3940 if (SDDS_dataset->n_rows_allocated) {
3941 if (cd_target->type != cd_source->type) {
3942 if (!(SDDS_dataset->data[target] =
SDDS_Realloc(SDDS_dataset->data[target],
SDDS_type_size[cd_source->type - 1] * SDDS_dataset->n_rows_allocated))) {
3943 SDDS_SetError(
"Unable to copy column--memory allocation failure (SDDS_CopyColumn)");
3948 memcpy(SDDS_dataset->data[target], SDDS_dataset->data[source],
SDDS_type_size[cd_source->type - 1] * SDDS_dataset->n_rows);
3949 else if (!
SDDS_CopyStringArray(SDDS_dataset->data[target], SDDS_dataset->data[source], SDDS_dataset->n_rows)) {
3950 SDDS_SetError(
"Unable to copy column--string copy failure (SDDS_CopyColumn)");
3954 memcpy((
char *)cd_target, (
char *)cd_source,
sizeof(*cd_target));
3984 SDDS_SetError(
"Unable to delete parameter--unrecognized parameter name (SDDS_DeleteParameter)");
3987 for (i = index + 1; i < SDDS_dataset->layout.n_parameters; i++) {
3989 SDDS_SetError(
"Unable to delete parameter--error copying parameter (SDDS_DeleteParameter)");
3993 SDDS_dataset->layout.n_parameters -= 1;
4022 if (target < 0 || source < 0 || target >= SDDS_dataset->layout.n_parameters || source >= SDDS_dataset->layout.n_parameters) {
4023 SDDS_SetError(
"Unable to copy parameter--target or source index out of range (SDDS_CopyParameter");
4026 cd_target = SDDS_dataset->layout.parameter_definition + target;
4027 cd_source = SDDS_dataset->layout.parameter_definition + source;
4028 if (SDDS_dataset->parameter) {
4029 if (cd_target->type != cd_source->type) {
4031 SDDS_SetError(
"Unable to copy parameter--memory allocation failure (SDDS_CopyParameter)");
4036 memcpy(SDDS_dataset->parameter[target], SDDS_dataset->parameter[source],
SDDS_type_size[cd_source->type - 1]);
4037 else if (!
SDDS_CopyStringArray(SDDS_dataset->parameter[target], SDDS_dataset->parameter[source], 1)) {
4038 SDDS_SetError(
"Unable to copy parameter--string copy failure (SDDS_CopyParameter)");
4042 memcpy((
char *)cd_target, (
char *)cd_source,
sizeof(*cd_target));
4080 unsigned short ushort_val;
4084 uint64_t ulong64_val;
4085 long double ldouble_val;
4091 if ((short_val = *((
short *)data + index)) < lower_limit || short_val > upper_limit)
4095 if ((ushort_val = *((
unsigned short *)data + index)) < lower_limit || ushort_val > upper_limit)
4099 if ((long_val = *((int32_t *)data + index)) < lower_limit || long_val > upper_limit)
4103 if ((ulong_val = *((uint32_t *)data + index)) < lower_limit || ulong_val > upper_limit)
4107 if ((long64_val = *((int64_t *)data + index)) < lower_limit || long64_val > upper_limit)
4111 if ((ulong64_val = *((uint64_t *)data + index)) < lower_limit || ulong64_val > upper_limit)
4115 if ((float_val = *((
float *)data + index)) < lower_limit || float_val > upper_limit)
4117 if (isnan(float_val) || isinf(float_val))
4121 if ((double_val = *((
double *)data + index)) < lower_limit || double_val > upper_limit)
4123 if (isnan(double_val) || isinf(double_val))
4127 if ((ldouble_val = *((
long double *)data + index)) < lower_limit || ldouble_val > upper_limit)
4129 if (isnan(ldouble_val) || isinf(ldouble_val))
4133 SDDS_SetError(
"Unable to complete window check--item type is non-numeric (SDDS_ItemInsideWindow)");
4166int32_t
SDDS_Logic(int32_t previous, int32_t match, uint32_t logic) {
4167 if (logic & SDDS_0_PREVIOUS)
4169 else if (logic & SDDS_1_PREVIOUS)
4171 if (logic & SDDS_NEGATE_PREVIOUS)
4172 previous = !previous;
4173 if (logic & SDDS_NEGATE_MATCH)
4175 if (logic & SDDS_AND)
4176 match = match && previous;
4177 else if (logic & SDDS_OR)
4178 match = match || previous;
4181 if (logic & SDDS_NEGATE_EXPRESSION)
4211 int32_t index, type, size;
4217 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArray)");
4221 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArray)");
4226 else if (!(copy = (
SDDS_ARRAY *)calloc(1,
sizeof(*copy)))) {
4227 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArray)");
4230 original = SDDS_dataset->array + index;
4232 SDDS_SetError(
"Unable to get array--array definition corrupted (SDDS_GetArray)");
4236 SDDS_SetError(
"Unable to get array--array definition missing (SDDS_GetArray)");
4239 type = copy->definition->type;
4241 if (!(copy->dimension =
SDDS_Realloc(copy->dimension,
sizeof(*copy->dimension) * copy->definition->dimensions))) {
4242 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArray)");
4245 memcpy((
void *)copy->dimension, (
void *)original->dimension,
sizeof(*copy->dimension) * copy->definition->dimensions);
4246 if (!(copy->elements = original->elements))
4248 if (!(copy->data =
SDDS_Realloc(copy->data, size * original->elements))) {
4249 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArray)");
4254 memcpy(copy->data, original->data, size * copy->elements);
4255 else if (!
SDDS_CopyStringArray((
char **)copy->data, (
char **)original->data, original->elements)) {
4256 SDDS_SetError(
"Unable to get array--string copy failure (SDDS_GetArray)");
4261 if (copy->pointer && copy->definition->dimensions != 1)
4262 free(copy->pointer);
4263 if (!(copy->pointer =
SDDS_MakePointerArray(copy->data, type, copy->definition->dimensions, copy->dimension))) {
4264 SDDS_SetError(
"Unable to get array--couldn't make pointer array (SDDS_GetArray)");
4293 int32_t index, type, i, elements;
4296 char buffer[SDDS_MAXLINE];
4303 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArrayInString)");
4307 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArrayInString)");
4310 original = SDDS_dataset->array + index;
4311 type = original->definition->type;
4312 elements = original->elements;
4313 if (!(data = (
char **)
SDDS_Malloc(
sizeof(*data) * elements))) {
4314 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArrayInString)");
4317 rawData = original->data;
4320 for (i = 0; i < elements; i++) {
4321 if (LDBL_DIG == 18) {
4322 sprintf(buffer,
"%22.18Le", ((
long double *)rawData)[i]);
4324 sprintf(buffer,
"%22.15Le", ((
long double *)rawData)[i]);
4330 for (i = 0; i < elements; i++) {
4331 sprintf(buffer,
"%22.15le", ((
double *)rawData)[i]);
4336 for (i = 0; i < elements; i++) {
4337 sprintf(buffer,
"%15.8e", ((
float *)rawData)[i]);
4342 for (i = 0; i < elements; i++) {
4343 sprintf(buffer,
"%" PRId64, ((int64_t *)rawData)[i]);
4348 for (i = 0; i < elements; i++) {
4349 sprintf(buffer,
"%" PRIu64, ((uint64_t *)rawData)[i]);
4354 for (i = 0; i < elements; i++) {
4355 sprintf(buffer,
"%" PRId32, ((int32_t *)rawData)[i]);
4360 for (i = 0; i < elements; i++) {
4361 sprintf(buffer,
"%" PRIu32, ((uint32_t *)rawData)[i]);
4366 for (i = 0; i < elements; i++) {
4367 sprintf(buffer,
"%hd", ((
short *)rawData)[i]);
4372 for (i = 0; i < elements; i++) {
4373 sprintf(buffer,
"%hu", ((
unsigned short *)rawData)[i]);
4378 for (i = 0; i < elements; i++) {
4379 sprintf(buffer,
"%c", ((
char *)rawData)[i]);
4384 for (i = 0; i < elements; i++) {
4415 int32_t index, type, i, elements;
4424 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArrayInDoubles)");
4428 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArrayInDoubles)");
4431 original = SDDS_dataset->array + index;
4432 if ((type = original->definition->type) ==
SDDS_STRING) {
4433 SDDS_SetError(
"Unable to get array--string type (SDDS_GetArrayInDoubles)");
4436 elements = original->elements;
4437 if (!(data =
SDDS_Malloc(
sizeof(*data) * elements))) {
4438 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArrayInDoubles)");
4441 rawData = original->data;
4444 for (i = 0; i < elements; i++) {
4445 data[i] = ((
long double *)rawData)[i];
4449 for (i = 0; i < elements; i++) {
4450 data[i] = ((
double *)rawData)[i];
4454 for (i = 0; i < elements; i++) {
4455 data[i] = ((
float *)rawData)[i];
4459 for (i = 0; i < elements; i++) {
4460 data[i] = ((int64_t *)rawData)[i];
4464 for (i = 0; i < elements; i++) {
4465 data[i] = ((uint64_t *)rawData)[i];
4469 for (i = 0; i < elements; i++) {
4470 data[i] = ((int32_t *)rawData)[i];
4474 for (i = 0; i < elements; i++) {
4475 data[i] = ((uint32_t *)rawData)[i];
4479 for (i = 0; i < elements; i++) {
4480 data[i] = ((
short *)rawData)[i];
4484 for (i = 0; i < elements; i++) {
4485 data[i] = ((
unsigned short *)rawData)[i];
4489 for (i = 0; i < elements; i++) {
4490 data[i] = ((
char *)rawData)[i];
4520 int32_t index, type, i, elements;
4529 SDDS_SetError(
"Unable to get array--array name pointer is NULL (SDDS_GetArrayInLong)");
4533 SDDS_SetError(
"Unable to get array--array name is unrecognized (SDDS_GetArrayInLong)");
4536 original = SDDS_dataset->array + index;
4537 if ((type = original->definition->type) ==
SDDS_STRING) {
4538 SDDS_SetError(
"Unable to get array--string type (SDDS_GetArrayInLong)");
4541 elements = original->elements;
4542 if (!(data =
SDDS_Malloc(
sizeof(*data) * elements))) {
4543 SDDS_SetError(
"Unable to get array--allocation failure (SDDS_GetArrayInLong)");
4546 rawData = original->data;
4549 for (i = 0; i < elements; i++) {
4550 data[i] = ((
long double *)rawData)[i];
4554 for (i = 0; i < elements; i++) {
4555 data[i] = ((
double *)rawData)[i];
4559 for (i = 0; i < elements; i++) {
4560 data[i] = ((
float *)rawData)[i];
4564 for (i = 0; i < elements; i++) {
4565 data[i] = ((int64_t *)rawData)[i];
4569 for (i = 0; i < elements; i++) {
4570 data[i] = ((uint64_t *)rawData)[i];
4574 for (i = 0; i < elements; i++) {
4575 data[i] = ((int32_t *)rawData)[i];
4579 for (i = 0; i < elements; i++) {
4580 data[i] = ((uint32_t *)rawData)[i];
4584 for (i = 0; i < elements; i++) {
4585 data[i] = ((
short *)rawData)[i];
4589 for (i = 0; i < elements; i++) {
4590 data[i] = ((
unsigned short *)rawData)[i];
4594 for (i = 0; i < elements; i++) {
4595 data[i] = ((
char *)rawData)[i];
4633 SDDS_SetError(
"Unable to retrieve description data (SDDS_GetDescription)");
4640 SDDS_SetError(
"Unable to retrieve description data (SDDS_GetDescription)");
4677 int32_t index, type;
4682 if (new_units == NULL) {
4683 SDDS_SetError(
"new_units is NULL (SDDS_SetArrayUnitsConversion)");
4687 SDDS_SetError(
"Unable to get array--name is not recognized (SDDS_SetArrayUnitsConversion)");
4691 SDDS_SetError(
"Unable to get array--data type undefined (SDDS_SetArrayUnitsConversion)");
4694 if (SDDS_dataset->layout.array_definition[index].units != NULL) {
4695 if (strcmp(new_units, SDDS_dataset->layout.array_definition[index].units) != 0) {
4696 if ((old_units != NULL) && (strcmp(old_units, SDDS_dataset->layout.array_definition[index].units) != 0)) {
4697 SDDS_SetError(
"Unexpected units value found (SDDS_SetArrayUnitsConversion)");
4701 cp_str(&(SDDS_dataset->layout.array_definition[index].units), new_units);
4704 cp_str(&(SDDS_dataset->layout.array_definition[index].units), new_units);
4707 if (SDDS_dataset->pages_read == 0) {
4710 rawData = SDDS_dataset->array[index].data;
4713 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4714 ((
long double *)rawData)[i] *= factor;
4718 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4719 ((
double *)rawData)[i] *= factor;
4723 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4724 ((
float *)rawData)[i] *= factor;
4728 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4729 ((int32_t *)rawData)[i] *= factor;
4733 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4734 ((uint32_t *)rawData)[i] *= factor;
4738 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4739 ((int64_t *)rawData)[i] *= factor;
4743 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4744 ((uint64_t *)rawData)[i] *= factor;
4748 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4749 ((
short *)rawData)[i] *= factor;
4753 for (i = 0; i < SDDS_dataset->array[index].elements; i++) {
4754 ((
unsigned short *)rawData)[i] *= factor;
4790 int32_t index, type;
4795 if (new_units == NULL) {
4796 SDDS_SetError(
"new_units is NULL (SDDS_SetColumnUnitsConversion)");
4800 SDDS_SetError(
"Unable to get column--name is not recognized (SDDS_SetColumnUnitsConversion)");
4804 SDDS_SetError(
"Unable to get column--data type undefined (SDDS_SetColumnUnitsConversion)");
4807 if (SDDS_dataset->layout.column_definition[index].units != NULL) {
4808 if (strcmp(new_units, SDDS_dataset->layout.column_definition[index].units) != 0) {
4809 if ((old_units != NULL) && (strcmp(old_units, SDDS_dataset->layout.column_definition[index].units) != 0)) {
4810 SDDS_SetError(
"Unexpected units value found (SDDS_SetColumnUnitsConversion)");
4813 free(SDDS_dataset->layout.column_definition[index].units);
4814 cp_str(&(SDDS_dataset->original_layout.column_definition[index].units), new_units);
4815 cp_str(&(SDDS_dataset->layout.column_definition[index].units), new_units);
4818 cp_str(&(SDDS_dataset->original_layout.column_definition[index].units), new_units);
4819 cp_str(&(SDDS_dataset->layout.column_definition[index].units), new_units);
4822 if (SDDS_dataset->pages_read == 0) {
4825 rawData = SDDS_dataset->data[index];
4828 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4829 ((
long double *)rawData)[i] *= factor;
4833 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4834 ((
double *)rawData)[i] *= factor;
4838 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4839 ((
float *)rawData)[i] *= factor;
4843 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4844 ((int32_t *)rawData)[i] *= factor;
4848 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4849 ((uint32_t *)rawData)[i] *= factor;
4853 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4854 ((int64_t *)rawData)[i] *= factor;
4858 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4859 ((uint64_t *)rawData)[i] *= factor;
4863 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4864 ((
short *)rawData)[i] *= factor;
4868 for (i = 0; i < SDDS_dataset->n_rows; i++) {
4869 ((
unsigned short *)rawData)[i] *= factor;
4905 int32_t index, type;
4909 if (new_units == NULL) {
4910 SDDS_SetError(
"new_units is NULL (SDDS_SetParameterUnitsConversion)");
4914 SDDS_SetError(
"Unable to get parameter--name is not recognized (SDDS_SetParameterUnitsConversion)");
4918 SDDS_SetError(
"Unable to get parameter--data type undefined (SDDS_SetParameterUnitsConversion)");
4921 if (SDDS_dataset->layout.parameter_definition[index].units != NULL) {
4922 if (strcmp(new_units, SDDS_dataset->layout.parameter_definition[index].units) != 0) {
4923 if ((old_units != NULL) && (strcmp(old_units, SDDS_dataset->layout.parameter_definition[index].units) != 0)) {
4924 SDDS_SetError(
"Unexpected units value found (SDDS_SetParameterUnitsConversion)");
4928 cp_str(&(SDDS_dataset->layout.parameter_definition[index].units), new_units);
4931 cp_str(&(SDDS_dataset->layout.parameter_definition[index].units), new_units);
4934 if (SDDS_dataset->pages_read == 0) {
4937 rawData = SDDS_dataset->parameter[index];
4940 *((
long double *)rawData) *= factor;
4943 *((
double *)rawData) *= factor;
4946 *((
float *)rawData) *= factor;
4949 *((int32_t *)rawData) *= factor;
4952 *((uint32_t *)rawData) *= factor;
4955 *((int64_t *)rawData) *= factor;
4958 *((uint64_t *)rawData) *= factor;
4961 *((
short *)rawData) *= factor;
4964 *((
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.