RAVE
rave_value.h File Reference

A value object that can represent standard types like int, double, . More...

#include "rave_object.h"
#include "raveobject_hashtable.h"
#include <stdarg.h>

Go to the source code of this file.

Typedefs

typedef enum RaveValue_Type RaveValue_Type
 
typedef struct _RaveValue_t RaveValue_t
 Defines a rave value.
 

Enumerations

enum  RaveValue_Type {
  RaveValue_Type_Undefined = -1 , RaveValue_Type_String = 0 , RaveValue_Type_Long = 1 , RaveValue_Type_Double = 2 ,
  RaveValue_Type_StringArray = 3 , RaveValue_Type_LongArray = 4 , RaveValue_Type_DoubleArray = 5 , RaveValue_Type_Data2D = 6 ,
  RaveValue_Type_Hashtable = 7
}
 

Functions

RaveValue_Type RaveValue_type (RaveValue_t *self)
 Returns the format for this attribute.
 
void RaveValue_reset (RaveValue_t *self)
 Resets the value object.
 
RaveValue_tRaveValue_createString (const char *value)
 Creates a string rave value.
 
int RaveValue_setString (RaveValue_t *self, const char *value)
 Sets a string value in self.
 
int RaveValue_getString (RaveValue_t *self, char **value)
 Returns the value as a string.
 
const char * RaveValue_toString (RaveValue_t *self)
 Returns the string value.
 
RaveValue_tRaveValue_createLong (long value)
 Creates a long rave value.
 
void RaveValue_setLong (RaveValue_t *self, long value)
 Sets the value as a long.
 
int RaveValue_getLong (RaveValue_t *self, long *value)
 Returns the value as a long.
 
long RaveValue_toLong (RaveValue_t *self)
 Returns the long value.
 
RaveValue_tRaveValue_createDouble (double value)
 Creates a double rave value.
 
void RaveValue_setDouble (RaveValue_t *self, double value)
 Sets the value as a double.
 
int RaveValue_getDouble (RaveValue_t *self, double *value)
 Returns the value as a double.
 
double RaveValue_toDouble (RaveValue_t *self)
 Returns the double value.
 
RaveValue_tRaveValue_createStringArray (const char **value, int len)
 Creates a string array rave value.
 
int RaveValue_setStringArray (RaveValue_t *self, const char **value, int len)
 Sets the value as a simple 1-dimensional double array.
 
int RaveValue_getStringArray (RaveValue_t *self, char ***value, int *len)
 Returns the value as a string array.
 
RaveValue_tRaveValue_createLongArray (long *value, int len)
 Creates a long array rave value.
 
int RaveValue_setLongArray (RaveValue_t *self, long *value, int len)
 Sets the value as a simple 1-dimensional long array.
 
int RaveValue_getLongArray (RaveValue_t *self, long **value, int *len)
 Returns the value as a long array.
 
RaveValue_tRaveValue_createDoubleArray (double *value, int len)
 Creates a double array rave value.
 
int RaveValue_setDoubleArray (RaveValue_t *self, double *value, int len)
 Sets the value as a simple 1-dimensional double array.
 
int RaveValue_getDoubleArray (RaveValue_t *self, double **value, int *len)
 Returns the value as a double array.
 
int RaveValue_setHashTable (RaveValue_t *self, RaveObjectHashTable_t *table)
 Sets the value as a hash table.
 
int RaveValue_getHashTable (RaveValue_t *self, RaveObjectHashTable_t **table)
 Returns the hash table if possible.
 
RaveObjectHashTable_tRaveValue_toHashTable (RaveValue_t *self)
 NOTE!
 

Variables

RaveCoreObjectType RaveValue_TYPE
 Type definition to use when creating a rave object.
 

Detailed Description

A value object that can represent standard types like int, double, .

. It can also contain arrays, lists and hashtables This object supports RAVE_OBJECT_CLONE.

Author
Anders Henja (Swedish Meteorological and Hydrological Institute, SMHI)
Date
2025-02-14

Typedef Documentation

◆ RaveValue_t

typedef struct _RaveValue_t RaveValue_t

Defines a rave value.

Enumeration Type Documentation

◆ RaveValue_Type

Enumerator
RaveValue_Type_Undefined 

Undefined.

RaveValue_Type_String 

String.

RaveValue_Type_Long 

Long.

RaveValue_Type_Double 

Double.

RaveValue_Type_StringArray 

Simple 1-dimensional array of strings.

RaveValue_Type_LongArray 

Simple 1-dimensional array of longs.

RaveValue_Type_DoubleArray 

Simple 1-dimensional array of doubles.

RaveValue_Type_Data2D 

2D array

RaveValue_Type_Hashtable 

Hash table.

Function Documentation

◆ RaveValue_createDouble()

RaveValue_t * RaveValue_createDouble ( double value)

Creates a double rave value.

Parameters
[in]value- the double
Returns
the value on success otherwise NULL

◆ RaveValue_createDoubleArray()

RaveValue_t * RaveValue_createDoubleArray ( double * value,
int len )

Creates a double array rave value.

Parameters
[in]value- the double array
[in]len- the length of the array
Returns
the value on success otherwise NULL

◆ RaveValue_createLong()

RaveValue_t * RaveValue_createLong ( long value)

Creates a long rave value.

Parameters
[in]value- the long
Returns
the value on success otherwise NULL

◆ RaveValue_createLongArray()

RaveValue_t * RaveValue_createLongArray ( long * value,
int len )

Creates a long array rave value.

Parameters
[in]value- the long array
[in]len- the length of the array
Returns
the value on success otherwise NULL

◆ RaveValue_createString()

RaveValue_t * RaveValue_createString ( const char * value)

Creates a string rave value.

Parameters
[in]value- the string
Returns
the value on success otherwise NULL

◆ RaveValue_createStringArray()

RaveValue_t * RaveValue_createStringArray ( const char ** value,
int len )

Creates a string array rave value.

Parameters
[in]value- the string array
[in]len- the length of the array
Returns
the value on success otherwise NULL

◆ RaveValue_getDouble()

int RaveValue_getDouble ( RaveValue_t * self,
double * value )

Returns the value as a double.

Parameters
[in]self- self
[out]value- the double value
Returns
1 on success or 0 if format of the data not is a double

◆ RaveValue_getDoubleArray()

int RaveValue_getDoubleArray ( RaveValue_t * self,
double ** value,
int * len )

Returns the value as a double array.

Parameters
[in]self- self
[out]value- the internal double array, DO NOT RELEASE memory
[out]len- the number of values in the array
Returns
1 on success or 0 if format of the data not is a double array

◆ RaveValue_getHashTable()

int RaveValue_getHashTable ( RaveValue_t * self,
RaveObjectHashTable_t ** table )

Returns the hash table if possible.

Parameters
[in]self
[out]table- a reference to the hash table
Returns
1 if value is a hash table otherwise 0

◆ RaveValue_getLong()

int RaveValue_getLong ( RaveValue_t * self,
long * value )

Returns the value as a long.

Parameters
[in]self- self
[out]value- the long value
Returns
1 on success or 0 if format of the data not is a long

◆ RaveValue_getLongArray()

int RaveValue_getLongArray ( RaveValue_t * self,
long ** value,
int * len )

Returns the value as a long array.

Parameters
[in]self- self
[out]value- the internal long array, DO NOT RELEASE memory
[out]len- the number of values in the array
Returns
1 on success or 0 if format of the data not is a long array

◆ RaveValue_getString()

int RaveValue_getString ( RaveValue_t * self,
char ** value )

Returns the value as a string.

Parameters
[in]self- self
[out]value- the internal 0-terminated string, DO NOT RELEASE memory
Returns
1 on success or 0 if format of the data not is a string

◆ RaveValue_getStringArray()

int RaveValue_getStringArray ( RaveValue_t * self,
char *** value,
int * len )

Returns the value as a string array.

Parameters
[in]self- self
[out]value- the internal string array, DO NOT RELEASE memory
[out]len- the number of values in the array
Returns
1 on success or 0 if format of the data not is a double array

◆ RaveValue_reset()

void RaveValue_reset ( RaveValue_t * self)

Resets the value object.

Parameters
[in]self- self

◆ RaveValue_setDouble()

void RaveValue_setDouble ( RaveValue_t * self,
double value )

Sets the value as a double.

Parameters
[in]self- self
[in]value- the value

◆ RaveValue_setDoubleArray()

int RaveValue_setDoubleArray ( RaveValue_t * self,
double * value,
int len )

Sets the value as a simple 1-dimensional double array.

Parameters
[in]self- self
[in]value- the value
[in]len- the number of doubles in the array
Returns
1 on success otherwise 0

◆ RaveValue_setHashTable()

int RaveValue_setHashTable ( RaveValue_t * self,
RaveObjectHashTable_t * table )

Sets the value as a hash table.

Parameters
[in]self- self
[in]table- the object hash table.
Returns
1 on success or 0 if not settable

◆ RaveValue_setLong()

void RaveValue_setLong ( RaveValue_t * self,
long value )

Sets the value as a long.

Parameters
[in]self- self
[in]value- the value

◆ RaveValue_setLongArray()

int RaveValue_setLongArray ( RaveValue_t * self,
long * value,
int len )

Sets the value as a simple 1-dimensional long array.

Parameters
[in]self- self
[in]value- the value
[in]len- the number of longs in the array
Returns
1 on success otherwise 0

◆ RaveValue_setString()

int RaveValue_setString ( RaveValue_t * self,
const char * value )

Sets a string value in self.

Parameters
[in]self- self
[in]value- the value
Returns
1 on success otherwise 0

◆ RaveValue_setStringArray()

int RaveValue_setStringArray ( RaveValue_t * self,
const char ** value,
int len )

Sets the value as a simple 1-dimensional double array.

Parameters
[in]self- self
[in]value- the value
[in]len- the number of doubles in the array
Returns
1 on success otherwise 0

◆ RaveValue_toDouble()

double RaveValue_toDouble ( RaveValue_t * self)

Returns the double value.

NOTE! It up to user to ensure that value actually is a double otherwise behavior will be undefined.

Parameters
[in]self- self
Returns
the double value or -

◆ RaveValue_toHashTable()

RaveObjectHashTable_t * RaveValue_toHashTable ( RaveValue_t * self)

NOTE!

It up to user to ensure that value actually is a hash table otherwise behavior will be undefined.

Parameters
[in]self- self
Returns
the hash table or NULL

◆ RaveValue_toLong()

long RaveValue_toLong ( RaveValue_t * self)

Returns the long value.

NOTE! It up to user to ensure that value actually is a long otherwise behavior will be undefined.

Parameters
[in]self- self
Returns
the long value or 0

◆ RaveValue_toString()

const char * RaveValue_toString ( RaveValue_t * self)

Returns the string value.

NOTE! It up to user to ensure that value actually is a string otherwise behavior will be undefined.

Parameters
[in]self- self
Returns
the string value or NULL

◆ RaveValue_type()

RaveValue_Type RaveValue_type ( RaveValue_t * self)

Returns the format for this attribute.

Parameters
[in]self- self
Returns
the format

Variable Documentation

◆ RaveValue_TYPE

RaveCoreObjectType RaveValue_TYPE
extern

Type definition to use when creating a rave object.