RAVE
rave_value.h
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2Copyright (C) 2025 Swedish Meteorological and Hydrological Institute, SMHI,
3
4This file is part of RAVE.
5
6RAVE is free software: you can redistribute it and/or modify
7it under the terms of the GNU Lesser General Public License as published by
8the Free Software Foundation, either version 3 of the License, or
9(at your option) any later version.
10
11RAVE is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU Lesser General Public License for more details.
15
16You should have received a copy of the GNU Lesser General Public License
17along with RAVE. If not, see <http://www.gnu.org/licenses/>.
18------------------------------------------------------------------------*/
26#ifndef RAVE_VALUE_H
27#define RAVE_VALUE_H
28#include "rave_object.h"
30#include <stdarg.h>
31
43
48
53
60
66
72RaveValue_t* RaveValue_createString(const char* value);
73
79RaveValue_t* RaveValue_createStringFmt(const char* fmt, ...);
80
87int RaveValue_setString(RaveValue_t* self, const char* value);
88
95int RaveValue_getString(RaveValue_t* self, char** value);
96
102const char* RaveValue_toString(RaveValue_t* self);
103
110
116void RaveValue_setLong(RaveValue_t* self, long value);
117
124int RaveValue_getLong(RaveValue_t* self, long* value);
125
131long RaveValue_toLong(RaveValue_t* self);
132
133
140
146void RaveValue_setDouble(RaveValue_t* self, double value);
147
154int RaveValue_getDouble(RaveValue_t* self, double* value);
155
161double RaveValue_toDouble(RaveValue_t* self);
162
169
175 void RaveValue_setBoolean(RaveValue_t* self, int value);
176
183 int RaveValue_getBoolean(RaveValue_t* self, int* value);
184
191
198
204
211
218
225RaveValue_t* RaveValue_createStringArray(const char** value, int len);
226
234int RaveValue_setStringArray(RaveValue_t* self, const char** value, int len);
235
243int RaveValue_getStringArray(RaveValue_t* self, char*** value, int* len);
244
251
258RaveValue_t* RaveValue_createLongArray(long* value, int len);
259
267int RaveValue_setLongArray(RaveValue_t* self, long* value, int len);
268
276int RaveValue_getLongArray(RaveValue_t* self, long** value, int* len);
277
284
291RaveValue_t* RaveValue_createDoubleArray(double* value, int len);
292
300int RaveValue_setDoubleArray(RaveValue_t* self, double* value, int len);
301
309int RaveValue_getDoubleArray(RaveValue_t* self, double** value, int* len);
310
317
325
333
340
348int RaveValueHash_put(RaveValue_t* self, const char* key, RaveValue_t* value);
349
356 RaveValue_t* RaveValueHash_get(RaveValue_t* self, const char* key);
357
358
365
372int RaveValueHash_exists(RaveValue_t* self, const char* key);
373
379void RaveValueHash_remove(RaveValue_t* self, const char* key);
380
386
393
400
408
416
423
430int RaveValueList_add(RaveValue_t* self, RaveValue_t* value);
431
439int RaveValueList_insert(RaveValue_t* self, int index, RaveValue_t* value);
440
448RaveValue_t* RaveValueList_join(RaveValue_t* self, const char* sep);
449
456
463RaveValue_t* RaveValueList_get(RaveValue_t* self, int index);
464
470void RaveValueList_release(RaveValue_t* self, int index);
471
477
483char* RaveValue_toJSON(RaveValue_t* self);
484
490RaveValue_t* RaveValue_fromJSON(const char* json);
491
497RaveValue_t* RaveValue_loadJSON(const char* filename);
498
499#endif /* RAVE_VALUE_H */
500
struct _RaveList_t RaveList_t
Defines a list.
Definition rave_list.h:33
Generic implementation of an object that is used within rave.
struct _raveobjecttype RaveCoreObjectType
The rave object type definition.
RaveCoreObjectType RaveValue_TYPE
Type definition to use when creating a rave object.
Definition rave_value.c:1225
void RaveValueHash_clear(RaveValue_t *self)
If rave value is hash, then this provides same functionality as RaveObjectHashTable_clear.
Definition rave_value.c:823
void RaveValueList_release(RaveValue_t *self, int index)
If rave value is list, then this provides same functionality as RaveObjectList_release.
Definition rave_value.c:961
int RaveValue_setString(RaveValue_t *self, const char *value)
Sets a string value in self.
Definition rave_value.c:191
RaveValue_t * RaveValueHash_get(RaveValue_t *self, const char *key)
If rave value is hash, then this provides same functionality as RaveObjectHashTable_get.
Definition rave_value.c:779
int RaveValue_getString(RaveValue_t *self, char **value)
Returns the value as a string.
Definition rave_value.c:214
int RaveValue_getLongArray(RaveValue_t *self, long **value, int *len)
Returns the value as a long array.
Definition rave_value.c:545
int RaveValue_getList(RaveValue_t *self, RaveObjectList_t **rlist)
Returns the rave list if possible.
Definition rave_value.c:874
int RaveValueHash_size(RaveValue_t *self)
If rave value is hash, then this provides same functionality as RaveObjectHashTable_size.
Definition rave_value.c:793
RaveValue_t * RaveValue_createString(const char *value)
Creates a string rave value.
Definition rave_value.c:163
void RaveValue_setBoolean(RaveValue_t *self, int value)
Sets the value as a boolean.
Definition rave_value.c:318
int RaveValue_getHashTable(RaveValue_t *self, RaveObjectHashTable_t **table)
Returns the hash table if possible.
Definition rave_value.c:752
char * RaveValue_toJSON(RaveValue_t *self)
Translates self to a json representation.
Definition rave_value.c:1056
RaveValue_t * RaveValue_loadJSON(const char *filename)
Loads a JSON object from a file.
Definition rave_value.c:1207
RaveValue_t * RaveValue_createList(RaveObjectList_t *rlist)
Creates a rave value list.
Definition rave_value.c:841
RaveValue_Type RaveValue_type(RaveValue_t *self)
Returns the format for this attribute.
Definition rave_value.c:144
int RaveValueHash_exists(RaveValue_t *self, const char *key)
If rave value is hash, then this provides same functionality as RaveObjectHashTable_exists.
Definition rave_value.c:802
int RaveValue_setStringArray(RaveValue_t *self, const char **value, int len)
Sets the value as a simple 1-dimensional string array.
Definition rave_value.c:401
int RaveValue_isStringArray(RaveValue_t *self)
Returns if the rave value can be represented as a string array (list of strings only)
Definition rave_value.c:368
int RaveValue_toBoolean(RaveValue_t *self)
Returns the boolean value.
Definition rave_value.c:338
int RaveValue_getStringArray(RaveValue_t *self, char ***value, int *len)
Returns the value as a string array.
Definition rave_value.c:434
RaveList_t * RaveValueHash_keys(RaveValue_t *self)
If rave value is hash, then this provides same functionality as RaveObjectHashTable_keys.
Definition rave_value.c:831
const char * RaveValue_toString(RaveValue_t *self)
Returns the string value.
Definition rave_value.c:226
int RaveValueList_add(RaveValue_t *self, RaveValue_t *value)
If rave value is list, then this provides same functionality as RaveObjectList_add.
Definition rave_value.c:891
RaveValue_t * RaveValue_createLongArray(long *value, int len)
Creates a long array rave value.
Definition rave_value.c:506
RaveValue_t * RaveValueList_get(RaveValue_t *self, int index)
If rave value is list, then this provides same functionality as RaveObjectList_get.
Definition rave_value.c:952
void RaveValue_setLong(RaveValue_t *self, long value)
Sets the value as a long.
Definition rave_value.c:243
RaveValue_t * RaveValue_createNull()
Creates a null rave value.
Definition rave_value.c:344
RaveValue_t * RaveValue_createStringArray(const char **value, int len)
Creates a string array rave value.
Definition rave_value.c:390
int RaveValue_setHashTable(RaveValue_t *self, RaveObjectHashTable_t *table)
Sets the value as a hash table.
Definition rave_value.c:741
void RaveValueHash_remove(RaveValue_t *self, const char *key)
If rave value is hash, then this provides same functionality as RaveObjectHashTable_remove except tha...
Definition rave_value.c:814
int RaveValue_setLongArray(RaveValue_t *self, long *value, int len)
Sets the value as a simple 1-dimensional long array.
Definition rave_value.c:517
RaveObjectList_t * RaveValue_toList(RaveValue_t *self)
NOTE!
Definition rave_value.c:885
int RaveValue_setList(RaveValue_t *self, RaveObjectList_t *rlist)
Sets the value as a rave list.
Definition rave_value.c:862
RaveValue_t * RaveValue_createBoolean(int value)
Creates a boolean rave value.
Definition rave_value.c:307
int RaveValue_isLongArray(RaveValue_t *self)
Returns if the rave value can be represented as a long array (list of long only)
Definition rave_value.c:485
RaveValue_t * RaveValue_createStringFmt(const char *fmt,...)
Creates a string rave value from a varargs list.
Definition rave_value.c:174
RaveValue_t * RaveValueList_join(RaveValue_t *self, const char *sep)
Creates a rave value string from the list of strings and adds the separator between each entry.
Definition rave_value.c:911
RaveObjectHashTable_t * RaveValue_toHashTable(RaveValue_t *self)
NOTE!
Definition rave_value.c:763
int RaveValueList_insert(RaveValue_t *self, int index, RaveValue_t *value)
If rave value is list, then this provides same functionality as RaveObjectList_insert.
Definition rave_value.c:901
int RaveValue_getDouble(RaveValue_t *self, double *value)
Returns the value as a double.
Definition rave_value.c:289
int RaveValue_getLong(RaveValue_t *self, long *value)
Returns the value as a long.
Definition rave_value.c:251
struct _RaveValue_t RaveValue_t
Defines a rave value.
Definition rave_value.h:47
void RaveValue_reset(RaveValue_t *self)
Resets the value object.
Definition rave_value.c:150
long RaveValue_toLong(RaveValue_t *self)
Returns the long value.
Definition rave_value.c:263
RaveValue_t * RaveValue_createDoubleArray(double *value, int len)
Creates a double array rave value.
Definition rave_value.c:608
int RaveValueHash_put(RaveValue_t *self, const char *key, RaveValue_t *value)
If rave value is hash, then this provides same functionality as RaveObjectHashTable_put.
Definition rave_value.c:769
int RaveValue_isDoubleArray(RaveValue_t *self)
Returns if the rave value can be represented as a double array (list of double only)
Definition rave_value.c:587
RaveValue_t * RaveValue_createDouble(double value)
Creates a double rave value.
Definition rave_value.c:269
RaveValue_t * RaveValue_createLong(long value)
Creates a long rave value.
Definition rave_value.c:232
int RaveValue_isNull(RaveValue_t *self)
Returns if the value is null or not.
Definition rave_value.c:362
double RaveValue_toDouble(RaveValue_t *self)
Returns the double value.
Definition rave_value.c:301
RaveValue_Type
Definition rave_value.h:32
@ RaveValue_Type_String
String.
Definition rave_value.h:34
@ RaveValue_Type_Long
Long.
Definition rave_value.h:35
@ RaveValue_Type_Boolean
Boolean.
Definition rave_value.h:37
@ RaveValue_Type_Hashtable
Hash table.
Definition rave_value.h:40
@ RaveValue_Type_Data2D
2D array
Definition rave_value.h:39
@ RaveValue_Type_Undefined
Undefined.
Definition rave_value.h:33
@ RaveValue_Type_Null
Null.
Definition rave_value.h:38
@ RaveValue_Type_Double
Double.
Definition rave_value.h:36
int RaveValueList_size(RaveValue_t *self)
If rave value is list, then this provides same functionality as RaveObjectList_size.
Definition rave_value.c:943
RaveValue_t * RaveValue_fromJSON(const char *json)
Support function for translating a json structure to a rave value.
Definition rave_value.c:1185
int RaveValue_setDoubleArray(RaveValue_t *self, double *value, int len)
Sets the value as a simple 1-dimensional double array.
Definition rave_value.c:619
void RaveValue_setDouble(RaveValue_t *self, double value)
Sets the value as a double.
Definition rave_value.c:281
RaveValue_t * RaveValue_createHashTable(RaveObjectHashTable_t *hashtable)
Creates a rave value hash table.
Definition rave_value.c:693
int RaveValue_getBoolean(RaveValue_t *self, int *value)
Returns the value as a boolean.
Definition rave_value.c:326
int RaveValue_getDoubleArray(RaveValue_t *self, double **value, int *len)
Returns the value as a double array.
Definition rave_value.c:647
void RaveValueList_clear(RaveValue_t *self)
If rave value is list, then this provides same functionality as RaveObjectList_clear.
Definition rave_value.c:969
void RaveValue_setNull(RaveValue_t *self)
Sets the value as a null value.
Definition rave_value.c:355
Implementation of a rave object hashtable that maps between strings and rave core objects.
struct _RaveObjectHashTable_t RaveObjectHashTable_t
Defines a hash table.
Definition raveobject_hashtable.h:38
struct _RaveObjectList_t RaveObjectList_t
Defines a list.
Definition raveobject_list.h:38
Represents one scan in a volume.
Definition rave_value.c:47
RaveObjectHashTable_t * hashtable
the hash table
Definition rave_value.c:54