SDDSlib
Loading...
Searching...
No Matches
SDDS_data.c
Go to the documentation of this file.
1/**
2 * @file SDDS_data.c
3 * @brief Defines global data arrays used by SDDS (Self Describing Data Sets) routines.
4 *
5 * This file declares and initializes global data arrays utilized by the SDDS library's
6 * various routines. These arrays include data mode identifiers, type names and sizes,
7 * command names, and field information structures for descriptions, data modes,
8 * arrays, columns, parameters, associates, and includes.
9 *
10 * @copyright
11 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
12 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
13 *
14 * @license
15 * This file is distributed under the terms of the Software License Agreement
16 * found in the file LICENSE included with this distribution.
17 *
18 * @authors
19 * M. Borland,
20 * C. Saunders,
21 * R. Soliday
22 */
23
24#include "SDDS.h"
25#include "SDDS_internal.h"
26
27/**
28 * @brief Array of supported data modes.
29 *
30 * Contains the string representations of the different data modes supported by SDDS,
31 * such as "binary" and "ascii".
32 */
33char *SDDS_data_mode[SDDS_NUM_DATA_MODES] = {
34 "binary",
35 "ascii"
36};
37
38/**
39 * @brief Array of supported data type names.
40 *
41 * Lists the string names corresponding to each data type supported by SDDS.
42 */
44 "longdouble",
45 "double",
46 "float",
47 "long64",
48 "ulong64",
49 "long",
50 "ulong",
51 "short",
52 "ushort",
53 "string",
54 "character"
55};
56
57/**
58 * @brief Array of sizes for each supported data type.
59 *
60 * Stores the size in bytes for each data type defined in SDDS_TYPE.
61 */
63 sizeof(long double),
64 sizeof(double),
65 sizeof(float),
66 sizeof(int64_t),
67 sizeof(uint64_t),
68 sizeof(int32_t),
69 sizeof(uint32_t),
70 sizeof(short),
71 sizeof(unsigned short),
72 sizeof(char *),
73 sizeof(char)
74};
75
76/**
77 * @brief Array of supported SDDS command names.
78 *
79 * Lists the command strings that can be used within SDDS files to define structure and data.
80 */
81char *SDDS_command[SDDS_NUM_COMMANDS] = {
82 "description",
83 "column",
84 "parameter",
85 "associate",
86 "data",
87 "include",
88 "array",
89};
90
91/*
92 * Field name and type information:
93 * This section defines the mapping between field names and their corresponding
94 * offsets and types within various SDDS structures. This approach duplicates
95 * some aspects of the namelist description structures but offers easier usage
96 * and decouples the routines from the namelist implementation.
97 * Eventually, this information may replace the namelist routines entirely.
98 */
99#include <stddef.h>
100
101/**
102 * @brief Field information for SDDS layout descriptions.
103 *
104 * Maps each description field name to its offset within the SDDS_LAYOUT structure,
105 * along with the corresponding data type and any associated enumeration pairs.
106 */
108 {"text", offsetof(SDDS_LAYOUT, description), SDDS_STRING, NULL},
109 {"contents", offsetof(SDDS_LAYOUT, contents), SDDS_STRING, NULL},
110};
111
112/**
113 * @brief Enumeration pairs for data modes.
114 *
115 * Associates string representations of data modes with their corresponding SDDS enumeration values.
116 */
118 {"binary", SDDS_BINARY},
119 {"ascii", SDDS_ASCII},
120 {NULL, 0},
121};
122
123/**
124 * @brief Enumeration pairs for data endianness.
125 *
126 * Associates string representations of endianness with their corresponding SDDS enumeration values.
127 */
129 {"big", SDDS_BIGENDIAN},
130 {"little", SDDS_LITTLEENDIAN},
131 {NULL, 0},
132};
133
134/**
135 * @brief Enumeration pairs for data types.
136 *
137 * Associates string representations of data types with their corresponding SDDS enumeration values.
138 */
140 {"longdouble", SDDS_LONGDOUBLE},
141 {"double", SDDS_DOUBLE},
142 {"float", SDDS_FLOAT},
143 {"long64", SDDS_LONG64},
144 {"ulong64", SDDS_ULONG64},
145 {"long", SDDS_LONG},
146 {"ulong", SDDS_ULONG},
147 {"short", SDDS_SHORT},
148 {"ushort", SDDS_USHORT},
149 {"string", SDDS_STRING},
150 {"character", SDDS_CHARACTER},
151 {NULL, 0}};
152
153/**
154 * @brief Field information for data mode settings.
155 *
156 * Maps each data mode field name to its offset within the DATA_MODE structure,
157 * along with the corresponding data type and any associated enumeration pairs.
158 */
160 {"mode", offsetof(DATA_MODE, mode), SDDS_LONG, dataModeEnumPair},
161 {"lines_per_row", offsetof(DATA_MODE, lines_per_row), SDDS_LONG, NULL},
162 {"no_row_counts", offsetof(DATA_MODE, no_row_counts), SDDS_LONG, NULL},
163 {"fixed_row_count", offsetof(DATA_MODE, fixed_row_count), SDDS_LONG, NULL},
164 {"additional_header_lines", offsetof(DATA_MODE, additional_header_lines), SDDS_LONG, NULL},
165 {"column_major_order", offsetof(DATA_MODE, column_major), SDDS_SHORT, NULL},
166 {"endian", offsetof(DATA_MODE, endian), SDDS_LONG, dataEndianEnumPair},
167};
168
169/**
170 * @brief Field information for array definitions.
171 *
172 * Maps each array field name to its offset within the ARRAY_DEFINITION structure,
173 * along with the corresponding data type and any associated enumeration pairs.
174 */
176 {"name", offsetof(ARRAY_DEFINITION, name), SDDS_STRING, NULL},
177 {"symbol", offsetof(ARRAY_DEFINITION, symbol), SDDS_STRING, NULL},
178 {"units", offsetof(ARRAY_DEFINITION, units), SDDS_STRING, NULL},
179 {"description", offsetof(ARRAY_DEFINITION, description), SDDS_STRING, NULL},
180 {"format_string", offsetof(ARRAY_DEFINITION, format_string), SDDS_STRING, NULL},
181 {"group_name", offsetof(ARRAY_DEFINITION, group_name), SDDS_STRING, NULL},
182 {"type", offsetof(ARRAY_DEFINITION, type), SDDS_LONG, typeEnumPair},
183 {"field_length", offsetof(ARRAY_DEFINITION, field_length), SDDS_LONG, NULL},
184 {"dimensions", offsetof(ARRAY_DEFINITION, dimensions), SDDS_LONG, NULL},
185};
186
187/**
188 * @brief Field information for column definitions.
189 *
190 * Maps each column field name to its offset within the COLUMN_DEFINITION structure,
191 * along with the corresponding data type and any associated enumeration pairs.
192 */
194 {"name", offsetof(COLUMN_DEFINITION, name), SDDS_STRING},
195 {"symbol", offsetof(COLUMN_DEFINITION, symbol), SDDS_STRING},
196 {"units", offsetof(COLUMN_DEFINITION, units), SDDS_STRING},
197 {"description", offsetof(COLUMN_DEFINITION, description), SDDS_STRING},
198 {"format_string", offsetof(COLUMN_DEFINITION, format_string), SDDS_STRING},
199 {"type", offsetof(COLUMN_DEFINITION, type), SDDS_LONG, typeEnumPair},
200 {"field_length", offsetof(COLUMN_DEFINITION, field_length), SDDS_LONG},
201};
202
203/**
204 * @brief Field information for parameter definitions.
205 *
206 * Maps each parameter field name to its offset within the PARAMETER_DEFINITION structure,
207 * along with the corresponding data type and any associated enumeration pairs.
208 */
210 {"name", offsetof(PARAMETER_DEFINITION, name), SDDS_STRING},
211 {"symbol", offsetof(PARAMETER_DEFINITION, symbol), SDDS_STRING},
212 {"units", offsetof(PARAMETER_DEFINITION, units), SDDS_STRING},
213 {"description", offsetof(PARAMETER_DEFINITION, description), SDDS_STRING},
214 {"format_string", offsetof(PARAMETER_DEFINITION, format_string), SDDS_STRING},
215 {"type", offsetof(PARAMETER_DEFINITION, type), SDDS_LONG, typeEnumPair},
216 {"fixed_value", offsetof(PARAMETER_DEFINITION, fixed_value), SDDS_STRING},
217};
218
219/**
220 * @brief Field information for associate definitions.
221 *
222 * Maps each associate field name to its offset within the ASSOCIATE_DEFINITION structure,
223 * along with the corresponding data type and any associated enumeration pairs.
224 */
226 {"name", offsetof(ASSOCIATE_DEFINITION, name), SDDS_STRING},
227 {"filename", offsetof(ASSOCIATE_DEFINITION, filename), SDDS_STRING},
228 {"path", offsetof(ASSOCIATE_DEFINITION, path), SDDS_STRING},
229 {"description", offsetof(ASSOCIATE_DEFINITION, description), SDDS_STRING},
230 {"contents", offsetof(ASSOCIATE_DEFINITION, contents), SDDS_STRING},
231 {"sdds", offsetof(ASSOCIATE_DEFINITION, sdds), SDDS_LONG},
232};
233
234/**
235 * @brief Field information for include directives.
236 *
237 * Maps each include field name to its offset within the INCLUDE_DEFINITION structure,
238 * along with the corresponding data type.
239 */
241 {"filename", 0, SDDS_STRING},
242};
SDDS (Self Describing Data Set) Data Types Definitions and Function Prototypes.
SDDS_FIELD_INFORMATION SDDS_AssociateFieldInformation[SDDS_ASSOCIATE_FIELDS]
Field information for associate definitions.
Definition SDDS_data.c:225
SDDS_FIELD_INFORMATION SDDS_ArrayFieldInformation[SDDS_ARRAY_FIELDS]
Field information for array definitions.
Definition SDDS_data.c:175
SDDS_ENUM_PAIR dataModeEnumPair[3]
Enumeration pairs for data modes.
Definition SDDS_data.c:117
SDDS_FIELD_INFORMATION SDDS_ColumnFieldInformation[SDDS_COLUMN_FIELDS]
Field information for column definitions.
Definition SDDS_data.c:193
int32_t SDDS_type_size[SDDS_NUM_TYPES]
Array of sizes for each supported data type.
Definition SDDS_data.c:62
SDDS_FIELD_INFORMATION SDDS_DescriptionFieldInformation[SDDS_DESCRIPTION_FIELDS]
Field information for SDDS layout descriptions.
Definition SDDS_data.c:107
SDDS_FIELD_INFORMATION SDDS_ParameterFieldInformation[SDDS_PARAMETER_FIELDS]
Field information for parameter definitions.
Definition SDDS_data.c:209
SDDS_FIELD_INFORMATION SDDS_IncludeFieldInformation[SDDS_INCLUDE_FIELDS]
Field information for include directives.
Definition SDDS_data.c:240
SDDS_ENUM_PAIR typeEnumPair[SDDS_NUM_TYPES+1]
Enumeration pairs for data types.
Definition SDDS_data.c:139
char * SDDS_data_mode[SDDS_NUM_DATA_MODES]
Array of supported data modes.
Definition SDDS_data.c:33
char * SDDS_command[SDDS_NUM_COMMANDS]
Array of supported SDDS command names.
Definition SDDS_data.c:81
SDDS_FIELD_INFORMATION SDDS_DataFieldInformation[SDDS_DATA_FIELDS]
Field information for data mode settings.
Definition SDDS_data.c:159
char * SDDS_type_name[SDDS_NUM_TYPES]
Array of supported data type names.
Definition SDDS_data.c:43
SDDS_ENUM_PAIR dataEndianEnumPair[3]
Enumeration pairs for data endianness.
Definition SDDS_data.c:128
Internal definitions and function declarations for SDDS with LZMA support.
#define SDDS_NUM_TYPES
Total number of defined SDDS data types.
Definition SDDStypes.h:97
#define SDDS_ULONG
Identifier for the unsigned 32-bit integer data type.
Definition SDDStypes.h:67
#define SDDS_FLOAT
Identifier for the float data type.
Definition SDDStypes.h:43
#define SDDS_STRING
Identifier for the string data type.
Definition SDDStypes.h:85
#define SDDS_ULONG64
Identifier for the unsigned 64-bit integer data type.
Definition SDDStypes.h:55
#define SDDS_LONG
Identifier for the signed 32-bit integer data type.
Definition SDDStypes.h:61
#define SDDS_SHORT
Identifier for the signed short integer data type.
Definition SDDStypes.h:73
#define SDDS_CHARACTER
Identifier for the character data type.
Definition SDDStypes.h:91
#define SDDS_USHORT
Identifier for the unsigned short integer data type.
Definition SDDStypes.h:79
#define SDDS_DOUBLE
Identifier for the double data type.
Definition SDDStypes.h:37
#define SDDS_LONGDOUBLE
Identifier for the long double data type.
Definition SDDStypes.h:31
#define SDDS_LONG64
Identifier for the signed 64-bit integer data type.
Definition SDDStypes.h:49