SDDSlib
Loading...
Searching...
No Matches
SDDStypes.h
Go to the documentation of this file.
1/**
2 * @file SDDStypes.h
3 * @brief SDDS Data Types Definitions
4 *
5 * This header file defines the various data types used in the SDDS (Self Describing Data Sets)
6 * library. It includes type identifiers, type classification macros, and validation utilities
7 * to ensure correct data handling within the SDDS framework.
8 *
9 * @copyright
10 * - (c) 2002 The University of Chicago, as Operator of Argonne National Laboratory.
11 * - (c) 2002 The Regents of the University of California, as Operator of Los Alamos National Laboratory.
12 *
13 * @license This file is distributed under the terms of the Software License Agreement
14 * found in the file LICENSE included with this distribution.
15 *
16 * @authors
17 * M. Borland,
18 * C. Saunders,
19 * R. Soliday,
20 * H. Shang
21 *
22 */
23
24#ifndef _SDDSTYPES_
25#define _SDDSTYPES_ 1
26
27/**
28 * @def SDDS_LONGDOUBLE
29 * @brief Identifier for the `long double` data type.
30 */
31#define SDDS_LONGDOUBLE 1
32
33/**
34 * @def SDDS_DOUBLE
35 * @brief Identifier for the `double` data type.
36 */
37#define SDDS_DOUBLE 2
38
39/**
40 * @def SDDS_FLOAT
41 * @brief Identifier for the `float` data type.
42 */
43#define SDDS_FLOAT 3
44
45/**
46 * @def SDDS_LONG64
47 * @brief Identifier for the signed 64-bit integer data type.
48 */
49#define SDDS_LONG64 4
50
51/**
52 * @def SDDS_ULONG64
53 * @brief Identifier for the unsigned 64-bit integer data type.
54 */
55#define SDDS_ULONG64 5
56
57/**
58 * @def SDDS_LONG
59 * @brief Identifier for the signed 32-bit integer data type.
60 */
61#define SDDS_LONG 6
62
63/**
64 * @def SDDS_ULONG
65 * @brief Identifier for the unsigned 32-bit integer data type.
66 */
67#define SDDS_ULONG 7
68
69/**
70 * @def SDDS_SHORT
71 * @brief Identifier for the signed short integer data type.
72 */
73#define SDDS_SHORT 8
74
75/**
76 * @def SDDS_USHORT
77 * @brief Identifier for the unsigned short integer data type.
78 */
79#define SDDS_USHORT 9
80
81/**
82 * @def SDDS_STRING
83 * @brief Identifier for the string data type.
84 */
85#define SDDS_STRING 10
86
87/**
88 * @def SDDS_CHARACTER
89 * @brief Identifier for the character data type.
90 */
91#define SDDS_CHARACTER 11
92
93/**
94 * @def SDDS_NUM_TYPES
95 * @brief Total number of defined SDDS data types.
96 */
97#define SDDS_NUM_TYPES 11
98
99/**
100 * @def SDDS_INTEGER_TYPE(type)
101 * @brief Checks if the given type identifier corresponds to an integer type.
102 *
103 * This macro evaluates to a non-zero value if the `type` is one of the defined integer types:
104 * `SDDS_LONG64`, `SDDS_ULONG64`, `SDDS_LONG`, `SDDS_ULONG`, `SDDS_SHORT`, or `SDDS_USHORT`.
105 *
106 * @param type The type identifier to check.
107 * @return Non-zero if `type` is an integer type, zero otherwise.
108 */
109#define SDDS_INTEGER_TYPE(type) \
110 (((type) == SDDS_LONG64) || ((type) == SDDS_ULONG64) || \
111 ((type) == SDDS_LONG) || ((type) == SDDS_ULONG) || \
112 ((type) == SDDS_SHORT) || ((type) == SDDS_USHORT))
113
114/**
115 * @def SDDS_FLOATING_TYPE(type)
116 * @brief Checks if the given type identifier corresponds to a floating-point type.
117 *
118 * This macro evaluates to a non-zero value if the `type` is one of the defined floating-point types:
119 * `SDDS_LONGDOUBLE`, `SDDS_DOUBLE`, or `SDDS_FLOAT`.
120 *
121 * @param type The type identifier to check.
122 * @return Non-zero if `type` is a floating-point type, zero otherwise.
123 */
124#define SDDS_FLOATING_TYPE(type) \
125 (((type) == SDDS_LONGDOUBLE) || ((type) == SDDS_DOUBLE) || \
126 ((type) == SDDS_FLOAT))
127
128/**
129 * @def SDDS_NUMERIC_TYPE(type)
130 * @brief Checks if the given type identifier corresponds to any numeric type.
131 *
132 * This macro evaluates to a non-zero value if the `type` is either an integer type
133 * (`SDDS_INTEGER_TYPE`) or a floating-point type (`SDDS_FLOATING_TYPE`).
134 *
135 * @param type The type identifier to check.
136 * @return Non-zero if `type` is a numeric type, zero otherwise.
137 */
138#define SDDS_NUMERIC_TYPE(type) (SDDS_INTEGER_TYPE(type) || SDDS_FLOATING_TYPE(type))
139
140/**
141 * @def SDDS_VALID_TYPE(type)
142 * @brief Validates whether the given type identifier is within the defined range of SDDS types.
143 *
144 * This macro checks if the `type` is between `1` and `SDDS_NUM_TYPES` inclusive.
145 *
146 * @param type The type identifier to validate.
147 * @return Non-zero if `type` is valid, zero otherwise.
148 */
149#define SDDS_VALID_TYPE(type) (((type) >= 1) && ((type) <= SDDS_NUM_TYPES))
150
151/**
152 * @def SDDS_ANY_NUMERIC_TYPE
153 * @brief Special identifier used by SDDS_Check*() routines to accept any numeric type.
154 *
155 * This value extends beyond the defined types to allow functions to accept any numeric type.
156 */
157#define SDDS_ANY_NUMERIC_TYPE (SDDS_NUM_TYPES + 1)
158
159/**
160 * @def SDDS_ANY_FLOATING_TYPE
161 * @brief Special identifier used by SDDS_Check*() routines to accept any floating-point type.
162 *
163 * This value extends beyond the defined types to allow functions to accept any floating-point type.
164 */
165#define SDDS_ANY_FLOATING_TYPE (SDDS_NUM_TYPES + 2)
166
167/**
168 * @def SDDS_ANY_INTEGER_TYPE
169 * @brief Special identifier used by SDDS_Check*() routines to accept any integer type.
170 *
171 * This value extends beyond the defined types to allow functions to accept any integer type.
172 */
173#define SDDS_ANY_INTEGER_TYPE (SDDS_NUM_TYPES + 3)
174
175/**
176 * @brief Indicates that the SDDS types have been defined.
177 *
178 * This macro serves as an include guard to prevent multiple inclusions of the `SDDStypes.h` header file.
179 */
180#endif /* _SDDSTYPES_ */