Serialbox  2.2.0
Data serialization library and tools for C/C++, Python and Fortran
Metainfo.h
1 /*===-- serialbox-c/Metainfo.h ------------------------------------------------------*- C++ -*-===*\
2  *
3  * S E R I A L B O X
4  *
5  * This file is distributed under terms of BSD license.
6  * See LICENSE.txt for more information
7  *
8  *===------------------------------------------------------------------------------------------===//
9  *
10  *! \file
11  *! This file contains the C implementation of the Metainfo.
12  *
13 \*===------------------------------------------------------------------------------------------===*/
14 
15 #ifndef SERIALBOX_C_METAINFO_H
16 #define SERIALBOX_C_METAINFO_H
17 
18 #include "serialbox-c/Api.h"
19 #include "serialbox-c/Array.h"
20 #include "serialbox-c/Type.h"
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
34 /*===------------------------------------------------------------------------------------------===*\
35  * Construction & Destruction
36 \*===------------------------------------------------------------------------------------------===*/
37 
43 SERIALBOX_API serialboxMetainfo_t* serialboxMetainfoCreate(void);
44 
51 SERIALBOX_API serialboxMetainfo_t*
53 
59 SERIALBOX_API void serialboxMetainfoDestroy(serialboxMetainfo_t* metaInfo);
60 
61 /*===------------------------------------------------------------------------------------------===*\
62  * Utility
63 \*===------------------------------------------------------------------------------------------===*/
64 
71 SERIALBOX_API int serialboxMetainfoGetSize(const serialboxMetainfo_t* metaInfo);
78 SERIALBOX_API int serialboxMetainfoIsEmpty(const serialboxMetainfo_t* metaInfo);
79 
86 SERIALBOX_API void serialboxMetainfoClear(serialboxMetainfo_t* metaInfo);
87 
95 SERIALBOX_API int serialboxMetainfoEqual(const serialboxMetainfo_t* m1,
96  const serialboxMetainfo_t* m2);
97 
105 SERIALBOX_API int serialboxMetainfoHasKey(const serialboxMetainfo_t* metaInfo, const char* key);
106 
114 SERIALBOX_API enum serialboxTypeID
115 serialboxMetainfoGetTypeIDOfKey(const serialboxMetainfo_t* metaInfo, const char* key);
116 
126 SERIALBOX_API char* serialboxMetainfoToString(const serialboxMetainfo_t* metaInfo);
127 
136 SERIALBOX_API typedef struct {
137  char** keys;
138  int* types;
139  int len;
141 
150 SERIALBOX_API serialboxMetainfoElementInfo_t*
152 
159 
168 SERIALBOX_API int serialboxMetainfoDeleteKey(serialboxMetainfo_t* metaInfo, const char* key);
169 
170 /*===------------------------------------------------------------------------------------------===*\
171  * Add meta-information
172 \*===------------------------------------------------------------------------------------------===*/
173 
186 SERIALBOX_API int serialboxMetainfoAddBoolean(serialboxMetainfo_t* metaInfo, const char* key,
187  serialboxBoolean_t value);
188 SERIALBOX_API int serialboxMetainfoAddInt32(serialboxMetainfo_t* metaInfo, const char* key,
189  serialboxInt32_t value);
190 SERIALBOX_API int serialboxMetainfoAddInt64(serialboxMetainfo_t* metaInfo, const char* key,
191  serialboxInt64_t value);
192 SERIALBOX_API int serialboxMetainfoAddFloat32(serialboxMetainfo_t* metaInfo, const char* key,
193  serialboxFloat32_t value);
194 SERIALBOX_API int serialboxMetainfoAddFloat64(serialboxMetainfo_t* metaInfo, const char* key,
195  serialboxFloat64_t value);
196 SERIALBOX_API int serialboxMetainfoAddString(serialboxMetainfo_t* metaInfo, const char* key,
197  const char* value);
212 SERIALBOX_API int serialboxMetainfoAddArrayOfBoolean(serialboxMetainfo_t* metaInfo, const char* key,
213  const serialboxArrayOfBoolean_t* array);
214 SERIALBOX_API int serialboxMetainfoAddArrayOfInt32(serialboxMetainfo_t* metaInfo, const char* key,
215  const serialboxArrayOfInt32_t* array);
216 SERIALBOX_API int serialboxMetainfoAddArrayOfInt64(serialboxMetainfo_t* metaInfo, const char* key,
217  const serialboxArrayOfInt64_t* array);
218 SERIALBOX_API int serialboxMetainfoAddArrayOfFloat32(serialboxMetainfo_t* metaInfo, const char* key,
219  const serialboxArrayOfFloat32_t* array);
220 SERIALBOX_API int serialboxMetainfoAddArrayOfFloat64(serialboxMetainfo_t* metaInfo, const char* key,
221  const serialboxArrayOfFloat64_t* array);
222 SERIALBOX_API int serialboxMetainfoAddArrayOfString(serialboxMetainfo_t* metaInfo, const char* key,
223  const serialboxArrayOfString_t* array);
226 /*===------------------------------------------------------------------------------------------===*\
227  * Query meta-information
228 \*===------------------------------------------------------------------------------------------===*/
229 
248  const char* key);
249 SERIALBOX_API serialboxInt32_t serialboxMetainfoGetInt32(const serialboxMetainfo_t* metaInfo,
250  const char* key);
251 SERIALBOX_API serialboxInt64_t serialboxMetainfoGetInt64(const serialboxMetainfo_t* metaInfo,
252  const char* key);
253 SERIALBOX_API serialboxFloat32_t serialboxMetainfoGetFloat32(const serialboxMetainfo_t* metaInfo,
254  const char* key);
255 SERIALBOX_API serialboxFloat64_t serialboxMetainfoGetFloat64(const serialboxMetainfo_t* metaInfo,
256  const char* key);
257 SERIALBOX_API serialboxString_t serialboxMetainfoGetString(const serialboxMetainfo_t* metaInfo,
258  const char* key);
277 SERIALBOX_API serialboxArrayOfBoolean_t*
278 serialboxMetainfoGetArrayOfBoolean(const serialboxMetainfo_t* metaInfo, const char* key);
279 
280 SERIALBOX_API serialboxArrayOfInt32_t*
281 serialboxMetainfoGetArrayOfInt32(const serialboxMetainfo_t* metaInfo, const char* key);
282 
283 SERIALBOX_API serialboxArrayOfInt64_t*
284 serialboxMetainfoGetArrayOfInt64(const serialboxMetainfo_t* metaInfo, const char* key);
285 
286 SERIALBOX_API serialboxArrayOfFloat32_t*
287 serialboxMetainfoGetArrayOfFloat32(const serialboxMetainfo_t* metaInfo, const char* key);
288 
289 SERIALBOX_API serialboxArrayOfFloat64_t*
290 serialboxMetainfoGetArrayOfFloat64(const serialboxMetainfo_t* metaInfo, const char* key);
291 
292 SERIALBOX_API serialboxArrayOfString_t*
293 serialboxMetainfoGetArrayOfString(const serialboxMetainfo_t* metaInfo, const char* key);
298 #ifdef __cplusplus
299 }
300 #endif
301 
302 #endif
Array of booleans.
Definition: Array.h:40
SERIALBOX_API int serialboxMetainfoDeleteKey(serialboxMetainfo_t *metaInfo, const char *key)
Delete element given by key
Definition: Metainfo.cpp:148
SERIALBOX_API serialboxMetainfo_t * serialboxMetainfoCreateFromMetainfo(const serialboxMetainfo_t *other)
Copy construct the meta-information.
Definition: Metainfo.cpp:38
SERIALBOX_API typedef int serialboxBoolean_t
Boolean type of serialbox.
Definition: Type.h:41
SERIALBOX_API void serialboxMetainfoDestroyElementInfo(serialboxMetainfoElementInfo_t *elementInfo)
Destroy the element-information and deallocate all memory.
Definition: Metainfo.cpp:133
SERIALBOX_API typedef int64_t serialboxInt64_t
64-bit integral type of serialbox
Definition: Type.h:51
SERIALBOX_API int serialboxMetainfoAddArrayOfBoolean(serialboxMetainfo_t *metaInfo, const char *key, const serialboxArrayOfBoolean_t *array)
Add a new element in the form key=[array] to the meta-information.
SERIALBOX_API int serialboxMetainfoHasKey(const serialboxMetainfo_t *metaInfo, const char *key)
Check if and element with key key exists.
Definition: Metainfo.cpp:86
SERIALBOX_API typedef int32_t serialboxInt32_t
32-bit integral type of serialbox
Definition: Type.h:46
SERIALBOX_API void serialboxMetainfoDestroy(serialboxMetainfo_t *metaInfo)
Destroy the meta-information and deallocate all memory.
Definition: Metainfo.cpp:52
SERIALBOX_API serialboxBoolean_t serialboxMetainfoGetBoolean(const serialboxMetainfo_t *metaInfo, const char *key)
Convert value of element with key key to type T (where T is given by the suffix of thefunction...
SERIALBOX_API int serialboxMetainfoGetSize(const serialboxMetainfo_t *metaInfo)
Get number of elemenets in the meta-information.
Definition: Metainfo.cpp:65
SERIALBOX_API serialboxArrayOfBoolean_t * serialboxMetainfoGetArrayOfBoolean(const serialboxMetainfo_t *metaInfo, const char *key)
Convert value of element with key key to a newly allocated array array of type T
Refrence to a Metainfo.
Definition: Type.h:91
Array of strings.
Definition: Array.h:80
SERIALBOX_API enum serialboxTypeID serialboxMetainfoGetTypeIDOfKey(const serialboxMetainfo_t *metaInfo, const char *key)
Get TypeID of element with key key
Definition: Metainfo.cpp:91
SERIALBOX_API typedef char * serialboxString_t
String type of serialbox.
Definition: Type.h:66
Data-structure to query the info of the elements (keys and corresponding types) in the meta-informati...
Definition: Metainfo.h:136
SERIALBOX_API void serialboxMetainfoClear(serialboxMetainfo_t *metaInfo)
All the elements in the Metainfo are dropped: their destructors are called, and they are removed from...
Definition: Metainfo.cpp:75
SERIALBOX_API typedef float serialboxFloat32_t
32-bit floating point type of serialbox (float)
Definition: Type.h:56
SERIALBOX_API int serialboxMetainfoEqual(const serialboxMetainfo_t *m1, const serialboxMetainfo_t *m2)
Check if Metainfo m1 is equal to Metainfo m2
Definition: Metainfo.cpp:80
SERIALBOX_API typedef double serialboxFloat64_t
64-bit floating point type of serialbox (double)
Definition: Type.h:61
Array of 32-bit integers.
Definition: Array.h:48
SERIALBOX_API int serialboxMetainfoIsEmpty(const serialboxMetainfo_t *metaInfo)
Check if meta information is empty.
Definition: Metainfo.cpp:70
SERIALBOX_API char * serialboxMetainfoToString(const serialboxMetainfo_t *metaInfo)
Convert to string.
Definition: Metainfo.cpp:103
Array of 32-bit floating point numbers (float)
Definition: Array.h:64
Array of 64-bit floating point numbers (double)
Definition: Array.h:72
Array of 64-bit integers.
Definition: Array.h:56
SERIALBOX_API int serialboxMetainfoAddBoolean(serialboxMetainfo_t *metaInfo, const char *key, serialboxBoolean_t value)
Add a new element in the form key=value pair to the meta-information.
SERIALBOX_API serialboxMetainfoElementInfo_t * serialboxMetainfoCreateElementInfo(const serialboxMetainfo_t *metaInfo)
Allocate and intialize the element-info.
Definition: Metainfo.cpp:111
serialboxTypeID
Type-id of types recognized by serialbox.
Definition: Type.h:116
SERIALBOX_API serialboxMetainfo_t * serialboxMetainfoCreate(void)
Construct an empty meta-information.
Definition: Metainfo.cpp:25