libcbor  0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Functions
floats_ctrls.c File Reference
#include "floats_ctrls.h"
#include "assert.h"
#include <math.h>

Go to the source code of this file.

Functions

cbor_float_width cbor_float_get_width (const cbor_item_t *item)
 Get the float width. More...
 
uint8_t cbor_ctrl_value (const cbor_item_t *item)
 Reads the control value. More...
 
bool cbor_float_ctrl_is_ctrl (const cbor_item_t *item)
 Is this a ctrl value? More...
 
float cbor_float_get_float2 (const cbor_item_t *item)
 Get a half precision float. More...
 
float cbor_float_get_float4 (const cbor_item_t *item)
 Get a single precision float. More...
 
double cbor_float_get_float8 (const cbor_item_t *item)
 Get a double precision float. More...
 
double cbor_float_get_float (const cbor_item_t *item)
 Get the float value represented as double. More...
 
void cbor_set_float2 (cbor_item_t *item, float value)
 Assigns a float value. More...
 
void cbor_set_float4 (cbor_item_t *item, float value)
 Assigns a float value. More...
 
void cbor_set_float8 (cbor_item_t *item, double value)
 Assigns a float value. More...
 
void cbor_set_ctrl (cbor_item_t *item, uint8_t value)
 Assign a control value. More...
 
bool cbor_ctrl_is_bool (const cbor_item_t *item)
 Is this ctrl item a boolean? More...
 
cbor_item_tcbor_new_ctrl ()
 Constructs a new ctrl item. More...
 
cbor_item_tcbor_new_float2 ()
 Constructs a new float item. More...
 
cbor_item_tcbor_new_float4 ()
 Constructs a new float item. More...
 
cbor_item_tcbor_new_float8 ()
 Constructs a new float item. More...
 
cbor_item_tcbor_new_null ()
 Constructs new null ctrl item. More...
 
cbor_item_tcbor_new_undef ()
 Constructs new under ctrl item. More...
 
cbor_item_tcbor_build_bool (bool value)
 Constructs new boolean ctrl item. More...
 
cbor_item_tcbor_build_float2 (float value)
 Constructs a new float. More...
 
cbor_item_tcbor_build_float4 (float value)
 Constructs a new float. More...
 
cbor_item_tcbor_build_float8 (double value)
 Constructs a new float. More...
 
cbor_item_tcbor_build_ctrl (uint8_t value)
 Constructs a ctrl item. More...
 

Function Documentation

§ cbor_build_bool()

cbor_item_t* cbor_build_bool ( bool  value)

Constructs new boolean ctrl item.

Parameters
valueThe value to use
Returns
new boolen ctrl item

Definition at line 160 of file floats_ctrls.c.

§ cbor_build_ctrl()

cbor_item_t* cbor_build_ctrl ( uint8_t  value)

Constructs a ctrl item.

Parameters
valuethe value to use
Returns
new ctrl item

Definition at line 186 of file floats_ctrls.c.

§ cbor_build_float2()

cbor_item_t* cbor_build_float2 ( float  value)

Constructs a new float.

Parameters
valuethe value to use
Returns
new float

Definition at line 165 of file floats_ctrls.c.

§ cbor_build_float4()

cbor_item_t* cbor_build_float4 ( float  value)

Constructs a new float.

Parameters
valuethe value to use
Returns
new float

Definition at line 172 of file floats_ctrls.c.

§ cbor_build_float8()

cbor_item_t* cbor_build_float8 ( double  value)

Constructs a new float.

Parameters
valuethe value to use
Returns
new float

Definition at line 179 of file floats_ctrls.c.

§ cbor_ctrl_is_bool()

bool cbor_ctrl_is_bool ( const cbor_item_t item)

Is this ctrl item a boolean?

Parameters
item[borrow]A ctrl item
Returns
Is this ctrl item a boolean?

Definition at line 92 of file floats_ctrls.c.

§ cbor_ctrl_value()

uint8_t cbor_ctrl_value ( const cbor_item_t item)

Reads the control value.

Parameters
item[borrow]A ctrl item
Returns
the simple value

Definition at line 18 of file floats_ctrls.c.

§ cbor_float_ctrl_is_ctrl()

bool cbor_float_ctrl_is_ctrl ( const cbor_item_t item)

Is this a ctrl value?

Parameters
item[borrow]A float or ctrl item
Returns
Is this a ctrl value?

Definition at line 25 of file floats_ctrls.c.

§ cbor_float_get_float()

double cbor_float_get_float ( const cbor_item_t item)

Get the float value represented as double.

Can be used regardless of the width.

Parameters

Definition at line 52 of file floats_ctrls.c.

§ cbor_float_get_float2()

float cbor_float_get_float2 ( const cbor_item_t item)

Get a half precision float.

The item must have the corresponding width

Parameters

Definition at line 31 of file floats_ctrls.c.

§ cbor_float_get_float4()

float cbor_float_get_float4 ( const cbor_item_t item)

Get a single precision float.

The item must have the corresponding width

Parameters

Definition at line 38 of file floats_ctrls.c.

§ cbor_float_get_float8()

double cbor_float_get_float8 ( const cbor_item_t item)

Get a double precision float.

The item must have the corresponding width

Parameters

Definition at line 45 of file floats_ctrls.c.

§ cbor_float_get_width()

cbor_float_width cbor_float_get_width ( const cbor_item_t item)

Get the float width.

Parameters
item[borrow]A float or ctrl item
Returns
The width.

Definition at line 12 of file floats_ctrls.c.

§ cbor_new_ctrl()

cbor_item_t* cbor_new_ctrl ( )

Constructs a new ctrl item.

The width cannot be changed once the item is created

Returns
new 1B ctrl

Definition at line 98 of file floats_ctrls.c.

§ cbor_new_float2()

cbor_item_t* cbor_new_float2 ( )

Constructs a new float item.

The width cannot be changed once the item is created

Returns
new 2B float

Definition at line 110 of file floats_ctrls.c.

§ cbor_new_float4()

cbor_item_t* cbor_new_float4 ( )

Constructs a new float item.

The width cannot be changed once the item is created

Returns
new 4B float

Definition at line 122 of file floats_ctrls.c.

§ cbor_new_float8()

cbor_item_t* cbor_new_float8 ( )

Constructs a new float item.

The width cannot be changed once the item is created

Returns
new 8B float

Definition at line 134 of file floats_ctrls.c.

§ cbor_new_null()

cbor_item_t* cbor_new_null ( )

Constructs new null ctrl item.

Returns
new null ctrl item

Definition at line 146 of file floats_ctrls.c.

§ cbor_new_undef()

cbor_item_t* cbor_new_undef ( )

Constructs new under ctrl item.

Returns
new under ctrl item

Definition at line 153 of file floats_ctrls.c.

§ cbor_set_ctrl()

void cbor_set_ctrl ( cbor_item_t item,
uint8_t  value 
)

Assign a control value.

embed:rst:leading-asterisk
* .. warning:: It is possible to produce an invalid CBOR value by assigning a invalid value using this mechanism. Please consult the standard before use.
* 
Parameters
item[borrow]A ctrl item
valueThe simple value to assign. Please consult the standard for allowed values

Definition at line 85 of file floats_ctrls.c.

§ cbor_set_float2()

void cbor_set_float2 ( cbor_item_t item,
float  value 
)

Assigns a float value.

Parameters
item[borrow]A half precision float
valueThe value to assign

Definition at line 64 of file floats_ctrls.c.

§ cbor_set_float4()

void cbor_set_float4 ( cbor_item_t item,
float  value 
)

Assigns a float value.

Parameters
item[borrow]A single precision float
valueThe value to assign

Definition at line 71 of file floats_ctrls.c.

§ cbor_set_float8()

void cbor_set_float8 ( cbor_item_t item,
double  value 
)

Assigns a float value.

Parameters
item[borrow]A double precision float
valueThe value to assign

Definition at line 78 of file floats_ctrls.c.