2018-04-12 23:54:58 -07:00
|
|
|
#ifndef LIBABACUS_VALUE_H
|
|
|
|
#define LIBABACUS_VALUE_H
|
|
|
|
|
2018-04-17 15:49:09 -07:00
|
|
|
#include "refcount.h"
|
2018-04-21 14:09:01 -07:00
|
|
|
#include "result.h"
|
2018-04-12 23:54:58 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
* A struct that represents a value.
|
|
|
|
*/
|
|
|
|
struct libab_value_s {
|
|
|
|
/**
|
|
|
|
* The type of the value.
|
|
|
|
*/
|
|
|
|
libab_ref type;
|
|
|
|
/**
|
|
|
|
* The data that is specific to this value.
|
|
|
|
*/
|
|
|
|
void* data;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct libab_value_s libab_value;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initializes a new value with the given allocated memory for the data,
|
|
|
|
* and the given type.
|
|
|
|
* @param data the data for this value. It is freed when the value is released
|
|
|
|
* according to the free function of the base type.
|
|
|
|
* @param type the type of this value.
|
|
|
|
*/
|
|
|
|
void libab_value_init(libab_value* value, void* data, libab_ref* type);
|
|
|
|
/**
|
|
|
|
* Frees the given value.
|
|
|
|
* @param value the value to free.
|
|
|
|
*/
|
|
|
|
void libab_value_free(libab_value* value);
|
|
|
|
|
|
|
|
#endif
|