35 return *(
float *) item->
data;
42 return *(
float *) item->
data;
49 return *(
double *) item->
data;
68 *((
float *) item->
data) = value;
75 *((
float *) item->
data) = value;
82 *((
double *) item->
data) = value;
115 .data = (
unsigned char *) item +
sizeof(
cbor_item_t),
117 .metadata = {.float_ctrl_metadata = {.width =
CBOR_FLOAT_16}}
127 .data = (
unsigned char *) item +
sizeof(
cbor_item_t),
129 .metadata = {.float_ctrl_metadata = {.width =
CBOR_FLOAT_32}}
139 .data = (
unsigned char *) item +
sizeof(
cbor_item_t),
141 .metadata = {.float_ctrl_metadata = {.width =
CBOR_FLOAT_64}}
struct cbor_item_t cbor_item_t
The item handle.
void cbor_set_float4(cbor_item_t *item, float value)
Assigns a float value.
void cbor_set_float2(cbor_item_t *item, float value)
Assigns a float value.
cbor_float_width
Possible widths of CBOR_TYPE_FLOAT_CTRL items.
double cbor_float_get_float(const cbor_item_t *item)
Get the float value represented as double.
union cbor_item_metadata metadata
Discriminated by type.
Internal use - ctrl and special values.
cbor_item_t * cbor_build_float2(float value)
Constructs a new float.
cbor_item_t * cbor_new_undef()
Constructs new under ctrl item.
cbor_item_t * cbor_build_ctrl(uint8_t value)
Constructs a ctrl item.
cbor_item_t * cbor_build_bool(bool value)
Constructs new boolean ctrl item.
cbor_type type
Major type discriminator.
7 - decimals and special values (true, false, nil, ...)
size_t refcount
Reference count - initialize to 0.
void cbor_set_ctrl(cbor_item_t *item, uint8_t value)
Assign a control value.
cbor_item_t * cbor_build_float4(float value)
Constructs a new float.
cbor_item_t * cbor_new_ctrl()
Constructs a new ctrl item.
cbor_item_t * cbor_new_float4()
Constructs a new float item.
bool cbor_is_float(const cbor_item_t *item)
Is the item an a floating point number?
float cbor_float_get_float4(const cbor_item_t *item)
Get a single precision float.
uint8_t cbor_ctrl_value(const cbor_item_t *item)
Reads the control value.
cbor_item_t * cbor_new_float8()
Constructs a new float item.
cbor_float_width cbor_float_get_width(const cbor_item_t *item)
Get the float width.
bool cbor_isa_float_ctrl(const cbor_item_t *item)
Does the item have the appropriate major type?
void cbor_set_float8(cbor_item_t *item, double value)
Assigns a float value.
float cbor_float_get_float2(const cbor_item_t *item)
Get a half precision float.
cbor_item_t * cbor_build_float8(double value)
Constructs a new float.
cbor_item_t * cbor_new_null()
Constructs new null ctrl item.
double cbor_float_get_float8(const cbor_item_t *item)
Get a double precision float.
bool cbor_is_bool(const cbor_item_t *item)
Is the item an a boolean?
cbor_item_t * cbor_new_float2()
Constructs a new float item.
bool cbor_ctrl_is_bool(const cbor_item_t *item)
Is this ctrl item a boolean?
unsigned char * data
Raw data block - interpretation depends on metadata.
bool cbor_float_ctrl_is_ctrl(const cbor_item_t *item)
Is this a ctrl value?