OSSIA
Open Scenario System for Interactive Application
Value

Tools to create various kinds of values. More...

Detailed Description

Tools to create various kinds of values.

The ossia_value_to_... family of functions expect that the actual value type is the one requested; anything else is undefined behaviour. Hence, use this only when you are sure because this is unsafe.

In contrast, the ossia_value_convert_... functions will try to do a meaningful conversion to get the type requested, which is safe, but much slower.

In short:

ossia_value_t v = ossia_value_create_string("1.2");
const char* = ossia_value_to_float(v); // result undefined
float f1 = ossia_value_to_float(v); // result undefined
float f2 = ossia_value_convert_float(v); // ok, f2 == 1.2
float ossia_value_convert_float(ossia_value_t val)
Get the value as a float.
Definition: ossia_value.cpp:286
float ossia_value_to_float(ossia_value_t val)
Get the value if it is an float.
Definition: ossia_value.cpp:138
ossia_value_t ossia_value_create_string(const char *value)
Create a value of type string.
Definition: ossia_value.cpp:75
See also
ossia::value

Functions

OSSIA_EXPORT ossia_value_t ossia_value_create_impulse ()
 Create a value of type Impulse. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_int (int value)
 Create a value of type int. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_float (float value)
 Create a value of type float. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_2f (float v1, float v2)
 Create a value of type vec2f. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_3f (float v1, float v2, float v3)
 Create a value of type vec3f. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_4f (float v1, float v2, float v3, float v4)
 Create a value of type vec4f. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_bool (int value)
 Create a value of type bool. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_char (char value)
 Create a value of type char. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_string (const char *value)
 Create a value of type string. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_byte_array (const char *value, size_t size)
 Create a value of type string. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_list (const ossia_value_t *values, size_t size)
 Create a value of type list. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_in (const int *values, size_t size)
 Create a value of type list with only ints. More...
 
OSSIA_EXPORT ossia_value_t ossia_value_create_fn (const float *values, size_t size)
 Create a value of type list with only floats. More...
 
OSSIA_EXPORT void ossia_value_free (ossia_value_t value)
 Free the value. More...
 
OSSIA_EXPORT ossia_type ossia_value_get_type (ossia_value_t type)
 Get the type of a value. More...
 
OSSIA_EXPORT int ossia_value_to_int (ossia_value_t val)
 Get the value if it is an int. More...
 
OSSIA_EXPORT float ossia_value_to_float (ossia_value_t val)
 Get the value if it is an float. More...
 
OSSIA_EXPORT struct ossia_vec2f ossia_value_to_2f (ossia_value_t val)
 Get the value if it is a vec2f. More...
 
OSSIA_EXPORT struct ossia_vec3f ossia_value_to_3f (ossia_value_t val)
 Get the value if it is a vec3f. More...
 
OSSIA_EXPORT struct ossia_vec4f ossia_value_to_4f (ossia_value_t val)
 Get the value if it is a vec4f. More...
 
OSSIA_EXPORT int ossia_value_to_bool (ossia_value_t val)
 Get the value if it is an bool. More...
 
OSSIA_EXPORT void ossia_value_to_byte_array (ossia_value_t val, char **str, size_t *sz)
 Get the value if it is a byte array. More...
 
OSSIA_EXPORT const char * ossia_value_to_string (ossia_value_t val)
 Get the value if it is a null-terminated string. More...
 
OSSIA_EXPORT void ossia_value_to_list (ossia_value_t val_in, ossia_value_t **out, size_t *size)
 Get the value if it is a list. More...
 
OSSIA_EXPORT void ossia_value_free_list (ossia_value_t *out)
 Free an array of values.
 
OSSIA_EXPORT void ossia_value_to_fn (ossia_value_t val_in, float **out, size_t *size)
 Get the value if it is a list of floats. More...
 
OSSIA_EXPORT void ossia_value_free_fn (float *out)
 Free an array of float.
 
OSSIA_EXPORT void ossia_value_to_in (ossia_value_t val_in, int **out, size_t *size)
 Get the value if it is a list of ints. More...
 
OSSIA_EXPORT void ossia_value_free_in (int *out)
 Free an array of int.
 
OSSIA_EXPORT int ossia_value_convert_int (ossia_value_t val)
 Get the value as an int. More...
 
OSSIA_EXPORT float ossia_value_convert_float (ossia_value_t val)
 Get the value as a float. More...
 
OSSIA_EXPORT int ossia_value_convert_bool (ossia_value_t val)
 Get the value as a bool. More...
 
OSSIA_EXPORT char ossia_value_convert_char (ossia_value_t val)
 Get the value as a char. More...
 
OSSIA_EXPORT void ossia_value_convert_byte_array (ossia_value_t val, char **str, size_t *sz)
 Get the value as a byte array. More...
 
OSSIA_EXPORT void ossia_value_convert_list (ossia_value_t val_in, ossia_value_t **out, size_t *size)
 Get the value as a list. More...
 
OSSIA_EXPORT struct ossia_vec2f ossia_value_convert_2f (ossia_value_t val)
 Get the value as a vec2f. More...
 
OSSIA_EXPORT struct ossia_vec3f ossia_value_convert_3f (ossia_value_t val)
 Get the value as a vec3f. More...
 
OSSIA_EXPORT struct ossia_vec4f ossia_value_convert_4f (ossia_value_t val)
 Get the value as a vec4f. More...
 
OSSIA_EXPORT void ossia_string_free (char *)
 

Function Documentation

◆ ossia_value_create_impulse()

OSSIA_EXPORT ossia_value_t ossia_value_create_impulse ( )

Create a value of type Impulse.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_int()

OSSIA_EXPORT ossia_value_t ossia_value_create_int ( int  value)

Create a value of type int.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_float()

OSSIA_EXPORT ossia_value_t ossia_value_create_float ( float  value)

Create a value of type float.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_2f()

OSSIA_EXPORT ossia_value_t ossia_value_create_2f ( float  v1,
float  v2 
)

Create a value of type vec2f.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_3f()

OSSIA_EXPORT ossia_value_t ossia_value_create_3f ( float  v1,
float  v2,
float  v3 
)

Create a value of type vec3f.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_4f()

OSSIA_EXPORT ossia_value_t ossia_value_create_4f ( float  v1,
float  v2,
float  v3,
float  v4 
)

Create a value of type vec4f.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_bool()

OSSIA_EXPORT ossia_value_t ossia_value_create_bool ( int  value)

Create a value of type bool.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_char()

OSSIA_EXPORT ossia_value_t ossia_value_create_char ( char  value)

Create a value of type char.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_string()

OSSIA_EXPORT ossia_value_t ossia_value_create_string ( const char *  value)

Create a value of type string.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_byte_array()

OSSIA_EXPORT ossia_value_t ossia_value_create_byte_array ( const char *  value,
size_t  size 
)

Create a value of type string.

Note
Multithread guarantees: Data-Safe.
See also
ossia::value

◆ ossia_value_create_list()

OSSIA_EXPORT ossia_value_t ossia_value_create_list ( const ossia_value_t *  values,
size_t  size 
)

Create a value of type list.

Note
Multithread guarantees: Data-Safe.
The passed array will be copied
See also
ossia::value

◆ ossia_value_create_in()

OSSIA_EXPORT ossia_value_t ossia_value_create_in ( const int *  values,
size_t  size 
)

Create a value of type list with only ints.

Note
Multithread guarantees: Data-Safe.
The passed array will be copied
See also
ossia::value

◆ ossia_value_create_fn()

OSSIA_EXPORT ossia_value_t ossia_value_create_fn ( const float *  values,
size_t  size 
)

Create a value of type list with only floats.

Note
Multithread guarantees: Data-Safe.
The passed array will be copied
See also
ossia::value

◆ ossia_value_free()

OSSIA_EXPORT void ossia_value_free ( ossia_value_t  value)

Free the value.

Note
Multithread guarantees: MT-Safe.
See also
ossia::value

◆ ossia_value_get_type()

OSSIA_EXPORT ossia_type ossia_value_get_type ( ossia_value_t  type)

Get the type of a value.

Note
Multithread guarantees: Data-Safe.
See also
ossia_type

◆ ossia_value_to_int()

OSSIA_EXPORT int ossia_value_to_int ( ossia_value_t  val)

Get the value if it is an int.

Returns
Undefined if ossia_value_get_type(val) != INT_T
Note
Multithread guarantees: Data-Safe.

◆ ossia_value_to_float()

OSSIA_EXPORT float ossia_value_to_float ( ossia_value_t  val)

Get the value if it is an float.

Returns
Undefined if ossia_value_get_type(val) != FLOAT_T
Note
Multithread guarantees: Data-Safe.

◆ ossia_value_to_2f()

OSSIA_EXPORT struct ossia_vec2f ossia_value_to_2f ( ossia_value_t  val)

Get the value if it is a vec2f.

Returns
Undefined if ossia_value_get_type(val) != VEC2F_T
Note
Multithread guarantees: Data-Safe.

◆ ossia_value_to_3f()

OSSIA_EXPORT struct ossia_vec3f ossia_value_to_3f ( ossia_value_t  val)

Get the value if it is a vec3f.

Returns
Undefined if ossia_value_get_type(val) != VEC3F_T
Note
Multithread guarantees: Data-Safe.

◆ ossia_value_to_4f()

OSSIA_EXPORT struct ossia_vec4f ossia_value_to_4f ( ossia_value_t  val)

Get the value if it is a vec4f.

Returns
Undefined if ossia_value_get_type(val) != VEC4F_T
Note
Multithread guarantees: Data-Safe.

◆ ossia_value_to_bool()

OSSIA_EXPORT int ossia_value_to_bool ( ossia_value_t  val)

Get the value if it is an bool.

Returns
Undefined if ossia_value_get_type(val) != BOOL_T
Note
Multithread guarantees: Data-Safe.

◆ ossia_value_to_byte_array()

OSSIA_EXPORT void ossia_value_to_byte_array ( ossia_value_t  val,
char **  str,
size_t *  sz 
)

Get the value if it is a byte array.

Returns
Undefined if ossia_value_get_type(val) != STRING_T
Note
Multithread guarantees: Data-Safe.

Usage:

char* str;
size_t b;
void ossia_value_to_byte_array(ossia_value_t val, char **out, size_t *size)
Get the value if it is a byte array.
Definition: ossia_value.cpp:164
See also
ossia_string_free

◆ ossia_value_to_string()

OSSIA_EXPORT const char* ossia_value_to_string ( ossia_value_t  val)

Get the value if it is a null-terminated string.

Returns
Undefined if ossia_value_get_type(val) != STRING_T
Note
Multithread guarantees: Data-Safe.
See also
ossia_string_free

◆ ossia_value_to_list()

OSSIA_EXPORT void ossia_value_to_list ( ossia_value_t  val_in,
ossia_value_t **  out,
size_t *  size 
)

Get the value if it is a list.

Returns
Undefined if ossia_value_get_type(val) != LIST_T
Note
Multithread guarantees: Data-Safe.
See also
ossia_value_free_list

◆ ossia_value_to_fn()

OSSIA_EXPORT void ossia_value_to_fn ( ossia_value_t  val_in,
float **  out,
size_t *  size 
)

Get the value if it is a list of floats.

Returns
Undefined if ossia_value_get_type(val) != LIST_T or any of the values are not FLOAT_T.
Note
Multithread guarantees: Data-Safe.
See also
ossia_value_free_list

◆ ossia_value_to_in()

OSSIA_EXPORT void ossia_value_to_in ( ossia_value_t  val_in,
int **  out,
size_t *  size 
)

Get the value if it is a list of ints.

Returns
Undefined if ossia_value_get_type(val) != LIST_T or any of the values are not INT_T.
Note
Multithread guarantees: Data-Safe.
See also
ossia_value_free_list

◆ ossia_value_convert_int()

OSSIA_EXPORT int ossia_value_convert_int ( ossia_value_t  val)

Get the value as an int.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_float()

OSSIA_EXPORT float ossia_value_convert_float ( ossia_value_t  val)

Get the value as a float.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_bool()

OSSIA_EXPORT int ossia_value_convert_bool ( ossia_value_t  val)

Get the value as a bool.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_char()

OSSIA_EXPORT char ossia_value_convert_char ( ossia_value_t  val)

Get the value as a char.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_byte_array()

OSSIA_EXPORT void ossia_value_convert_byte_array ( ossia_value_t  val,
char **  str,
size_t *  sz 
)

Get the value as a byte array.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_list()

OSSIA_EXPORT void ossia_value_convert_list ( ossia_value_t  val_in,
ossia_value_t **  out,
size_t *  size 
)

Get the value as a list.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_2f()

OSSIA_EXPORT struct ossia_vec2f ossia_value_convert_2f ( ossia_value_t  val)

Get the value as a vec2f.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_3f()

OSSIA_EXPORT struct ossia_vec3f ossia_value_convert_3f ( ossia_value_t  val)

Get the value as a vec3f.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.

◆ ossia_value_convert_4f()

OSSIA_EXPORT struct ossia_vec4f ossia_value_convert_4f ( ossia_value_t  val)

Get the value as a vec4f.

This function will do a best-effort conversion.

Note
Multithread guarantees: Data-Safe.