libcbor 0.12.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Loading...
Searching...
No Matches
ints.c File Reference
#include "ints.h"

Go to the source code of this file.

Functions

cbor_int_width cbor_int_get_width (const cbor_item_t *item)
 Queries the integer width.
 
uint8_t cbor_get_uint8 (const cbor_item_t *item)
 Extracts the integer value.
 
uint16_t cbor_get_uint16 (const cbor_item_t *item)
 Extracts the integer value.
 
uint32_t cbor_get_uint32 (const cbor_item_t *item)
 Extracts the integer value.
 
uint64_t cbor_get_uint64 (const cbor_item_t *item)
 Extracts the integer value.
 
uint64_t cbor_get_int (const cbor_item_t *item)
 Extracts the integer value.
 
void cbor_set_uint8 (cbor_item_t *item, uint8_t value)
 Assigns the integer value.
 
void cbor_set_uint16 (cbor_item_t *item, uint16_t value)
 Assigns the integer value.
 
void cbor_set_uint32 (cbor_item_t *item, uint32_t value)
 Assigns the integer value.
 
void cbor_set_uint64 (cbor_item_t *item, uint64_t value)
 Assigns the integer value.
 
void cbor_mark_uint (cbor_item_t *item)
 Marks the integer item as a positive integer.
 
void cbor_mark_negint (cbor_item_t *item)
 Marks the integer item as a negative integer.
 
cbor_item_tcbor_new_int8 (void)
 Allocates new integer with 1B width.
 
cbor_item_tcbor_new_int16 (void)
 Allocates new integer with 2B width.
 
cbor_item_tcbor_new_int32 (void)
 Allocates new integer with 4B width.
 
cbor_item_tcbor_new_int64 (void)
 Allocates new integer with 8B width.
 
cbor_item_tcbor_build_uint8 (uint8_t value)
 Constructs a new positive integer.
 
cbor_item_tcbor_build_uint16 (uint16_t value)
 Constructs a new positive integer.
 
cbor_item_tcbor_build_uint32 (uint32_t value)
 Constructs a new positive integer.
 
cbor_item_tcbor_build_uint64 (uint64_t value)
 Constructs a new positive integer.
 
cbor_item_tcbor_build_negint8 (uint8_t value)
 Constructs a new negative integer.
 
cbor_item_tcbor_build_negint16 (uint16_t value)
 Constructs a new negative integer.
 
cbor_item_tcbor_build_negint32 (uint32_t value)
 Constructs a new negative integer.
 
cbor_item_tcbor_build_negint64 (uint64_t value)
 Constructs a new negative integer.
 

Function Documentation

◆ cbor_build_negint16()

cbor_item_t * cbor_build_negint16 ( uint16_t value)

Constructs a new negative integer.

Parameters
valuethe value to use
Returns
new negative integer or NULL on memory allocation failure

Definition at line 171 of file ints.c.

◆ cbor_build_negint32()

cbor_item_t * cbor_build_negint32 ( uint32_t value)

Constructs a new negative integer.

Parameters
valuethe value to use
Returns
new negative integer or NULL on memory allocation failure

Definition at line 179 of file ints.c.

◆ cbor_build_negint64()

cbor_item_t * cbor_build_negint64 ( uint64_t value)

Constructs a new negative integer.

Parameters
valuethe value to use
Returns
new negative integer or NULL on memory allocation failure

Definition at line 187 of file ints.c.

◆ cbor_build_negint8()

cbor_item_t * cbor_build_negint8 ( uint8_t value)

Constructs a new negative integer.

Parameters
valuethe value to use
Returns
new negative integer or NULL on memory allocation failure

Definition at line 163 of file ints.c.

◆ cbor_build_uint16()

cbor_item_t * cbor_build_uint16 ( uint16_t value)

Constructs a new positive integer.

Parameters
valuethe value to use
Returns
new positive integer or NULL on memory allocation failure

Definition at line 139 of file ints.c.

◆ cbor_build_uint32()

cbor_item_t * cbor_build_uint32 ( uint32_t value)

Constructs a new positive integer.

Parameters
valuethe value to use
Returns
new positive integer or NULL on memory allocation failure

Definition at line 147 of file ints.c.

◆ cbor_build_uint64()

cbor_item_t * cbor_build_uint64 ( uint64_t value)

Constructs a new positive integer.

Parameters
valuethe value to use
Returns
new positive integer or NULL on memory allocation failure

Definition at line 155 of file ints.c.

◆ cbor_build_uint8()

cbor_item_t * cbor_build_uint8 ( uint8_t value)

Constructs a new positive integer.

Parameters
valuethe value to use
Returns
new positive integer or NULL on memory allocation failure

Definition at line 131 of file ints.c.

◆ cbor_get_int()

uint64_t cbor_get_int ( const cbor_item_t * item)

Extracts the integer value.

Parameters
itempositive or negative integer
Returns
the value, extended to uint64_t

Definition at line 39 of file ints.c.

◆ cbor_get_uint16()

uint16_t cbor_get_uint16 ( const cbor_item_t * item)

Extracts the integer value.

Parameters
itempositive or negative integer
Returns
the value

Definition at line 21 of file ints.c.

◆ cbor_get_uint32()

uint32_t cbor_get_uint32 ( const cbor_item_t * item)

Extracts the integer value.

Parameters
itempositive or negative integer
Returns
the value

Definition at line 27 of file ints.c.

◆ cbor_get_uint64()

uint64_t cbor_get_uint64 ( const cbor_item_t * item)

Extracts the integer value.

Parameters
itempositive or negative integer
Returns
the value

Definition at line 33 of file ints.c.

◆ cbor_get_uint8()

uint8_t cbor_get_uint8 ( const cbor_item_t * item)

Extracts the integer value.

Parameters
itempositive or negative integer
Returns
the value

Definition at line 15 of file ints.c.

◆ cbor_int_get_width()

cbor_int_width cbor_int_get_width ( const cbor_item_t * item)

Queries the integer width.

Parameters
itempositive or negative integer item
Returns
the width

Definition at line 10 of file ints.c.

◆ cbor_mark_negint()

void cbor_mark_negint ( cbor_item_t * item)

Marks the integer item as a negative integer.

The data value is not changed

Parameters
itempositive or negative integer item

Definition at line 86 of file ints.c.

◆ cbor_mark_uint()

void cbor_mark_uint ( cbor_item_t * item)

Marks the integer item as a positive integer.

The data value is not changed

Parameters
itempositive or negative integer item

Definition at line 81 of file ints.c.

◆ cbor_new_int16()

cbor_item_t * cbor_new_int16 ( void )

Allocates new integer with 2B width.

The width cannot be changed once allocated

Returns
new positive integer or NULL on memory allocation failure. The value is not initialized

Definition at line 101 of file ints.c.

◆ cbor_new_int32()

cbor_item_t * cbor_new_int32 ( void )

Allocates new integer with 4B width.

The width cannot be changed once allocated

Returns
new positive integer or NULL on memory allocation failure. The value is not initialized

Definition at line 111 of file ints.c.

◆ cbor_new_int64()

cbor_item_t * cbor_new_int64 ( void )

Allocates new integer with 8B width.

The width cannot be changed once allocated

Returns
new positive integer or NULL on memory allocation failure. The value is not initialized

Definition at line 121 of file ints.c.

◆ cbor_new_int8()

cbor_item_t * cbor_new_int8 ( void )

Allocates new integer with 1B width.

The width cannot be changed once allocated

Returns
new positive integer or NULL on memory allocation failure. The value is not initialized

Definition at line 91 of file ints.c.

◆ cbor_set_uint16()

void cbor_set_uint16 ( cbor_item_t * item,
uint16_t value )

Assigns the integer value.

Parameters
itempositive or negative integer item
valuethe value to assign. For negative integer, the logical value is -value - 1

Definition at line 63 of file ints.c.

◆ cbor_set_uint32()

void cbor_set_uint32 ( cbor_item_t * item,
uint32_t value )

Assigns the integer value.

Parameters
itempositive or negative integer item
valuethe value to assign. For negative integer, the logical value is -value - 1

Definition at line 69 of file ints.c.

◆ cbor_set_uint64()

void cbor_set_uint64 ( cbor_item_t * item,
uint64_t value )

Assigns the integer value.

Parameters
itempositive or negative integer item
valuethe value to assign. For negative integer, the logical value is -value - 1

Definition at line 75 of file ints.c.

◆ cbor_set_uint8()

void cbor_set_uint8 ( cbor_item_t * item,
uint8_t value )

Assigns the integer value.

Parameters
itempositive or negative integer item
valuethe value to assign. For negative integer, the logical value is -value - 1

Definition at line 57 of file ints.c.