libcbor  0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
Functions
common.c File Reference
#include "cbor/common.h"
#include "arrays.h"
#include "bytestrings.h"
#include "data.h"
#include "floats_ctrls.h"
#include "ints.h"
#include "maps.h"
#include "strings.h"
#include "tags.h"

Go to the source code of this file.

Functions

bool cbor_isa_uint (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
bool cbor_isa_negint (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
bool cbor_isa_bytestring (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
bool cbor_isa_string (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
bool cbor_isa_array (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
bool cbor_isa_map (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
bool cbor_isa_tag (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
bool cbor_isa_float_ctrl (const cbor_item_t *item)
 Does the item have the appropriate major type? More...
 
cbor_type cbor_typeof (const cbor_item_t *item)
 Get the type of the item. More...
 
bool cbor_is_int (const cbor_item_t *item)
 Is the item an integer, either positive or negative? More...
 
bool cbor_is_bool (const cbor_item_t *item)
 Is the item an a boolean? More...
 
bool cbor_is_null (const cbor_item_t *item)
 Does this item represent null More...
 
bool cbor_is_undef (const cbor_item_t *item)
 Does this item represent undefined More...
 
bool cbor_is_float (const cbor_item_t *item)
 Is the item an a floating point number? More...
 
cbor_item_tcbor_incref (cbor_item_t *item)
 Increases the reference count by one. More...
 
void cbor_decref (cbor_item_t **item_ref)
 Decreases the reference count by one, deallocating the item if needed. More...
 
void cbor_intermediate_decref (cbor_item_t *item)
 Decreases the reference count by one, deallocating the item if needed. More...
 
size_t cbor_refcount (const cbor_item_t *item)
 Get the reference count. More...
 
cbor_item_tcbor_move (cbor_item_t *item)
 Provides CPP-like move construct. More...
 

Function Documentation

§ cbor_decref()

void cbor_decref ( cbor_item_t **  item)

Decreases the reference count by one, deallocating the item if needed.

In case the item is deallocated, the reference count of any dependent items is adjusted accordingly in a recursive manner.

Parameters
item[take]the item. Set to NULL if deallocated

Definition at line 99 of file common.c.

§ cbor_incref()

cbor_item_t* cbor_incref ( cbor_item_t item)

Increases the reference count by one.

No dependent items are affected.

Parameters
item[incref]item the item
Returns
the input reference

Definition at line 93 of file common.c.

§ cbor_intermediate_decref()

void cbor_intermediate_decref ( cbor_item_t item)

Decreases the reference count by one, deallocating the item if needed.

Convenience wrapper for cbor_decref when its set-to-null behavior is not needed

Parameters
item[take]the item

Definition at line 174 of file common.c.

§ cbor_is_bool()

bool cbor_is_bool ( const cbor_item_t item)

Is the item an a boolean?

Parameters
item[borrow]the item
Returns
Is the item a boolean?

Definition at line 71 of file common.c.

§ cbor_is_float()

bool cbor_is_float ( const cbor_item_t item)

Is the item an a floating point number?

Parameters
item[borrow]the item
Returns
Is the item a floating point number?

Definition at line 87 of file common.c.

§ cbor_is_int()

bool cbor_is_int ( const cbor_item_t item)

Is the item an integer, either positive or negative?

Parameters
item[borrow]the item
Returns
Is the item an integer, either positive or negative?

Definition at line 65 of file common.c.

§ cbor_is_null()

bool cbor_is_null ( const cbor_item_t item)

Does this item represent null

embed:rst:leading-asterisk
* .. warning:: This is in no way related to the value of the pointer. Passing a null pointer will most likely result in a crash.
* 
Parameters
item[borrow]the item
Returns
Is the item (CBOR logical) null?

Definition at line 77 of file common.c.

§ cbor_is_undef()

bool cbor_is_undef ( const cbor_item_t item)

Does this item represent undefined

embed:rst:leading-asterisk
* .. warning:: Care must be taken to distinguish nulls and undefined values in C.
* 
Parameters
item[borrow]the item
Returns
Is the item (CBOR logical) undefined?

Definition at line 82 of file common.c.

§ cbor_isa_array()

bool cbor_isa_array ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item an CBOR_TYPE_ARRAY?

Definition at line 38 of file common.c.

§ cbor_isa_bytestring()

bool cbor_isa_bytestring ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item a CBOR_TYPE_BYTESTRING?

Definition at line 28 of file common.c.

§ cbor_isa_float_ctrl()

bool cbor_isa_float_ctrl ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item a CBOR_TYPE_FLOAT_CTRL?

Definition at line 53 of file common.c.

§ cbor_isa_map()

bool cbor_isa_map ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item a CBOR_TYPE_MAP?

Definition at line 43 of file common.c.

§ cbor_isa_negint()

bool cbor_isa_negint ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item a CBOR_TYPE_NEGINT?

Definition at line 23 of file common.c.

§ cbor_isa_string()

bool cbor_isa_string ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item a CBOR_TYPE_STRING?

Definition at line 33 of file common.c.

§ cbor_isa_tag()

bool cbor_isa_tag ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item a CBOR_TYPE_TAG?

Definition at line 48 of file common.c.

§ cbor_isa_uint()

bool cbor_isa_uint ( const cbor_item_t item)

Does the item have the appropriate major type?

Parameters
item[borrow]the item
Returns
Is the item an CBOR_TYPE_UINT?

Definition at line 18 of file common.c.

§ cbor_move()

cbor_item_t* cbor_move ( cbor_item_t item)

Provides CPP-like move construct.

Decreases the reference count by one, but does not deallocate the item even if its refcount reaches zero. This is useful for passing intermediate values to functions that increase reference count. Should only be used with functions that incref their arguments.

embed:rst:leading-asterisk
* .. warning:: If the item is moved without correctly increasing the reference count afterwards, the memory will be leaked.
* 
Parameters
item[take]the item
Returns
the item with reference count decreased by one

Definition at line 184 of file common.c.

§ cbor_refcount()

size_t cbor_refcount ( const cbor_item_t item)

Get the reference count.

embed:rst:leading-asterisk
* .. warning:: This does *not* account for transitive references.
* 
Parameters
item[borrow]the item
Returns
the reference count

Definition at line 179 of file common.c.

§ cbor_typeof()

cbor_type cbor_typeof ( const cbor_item_t item)

Get the type of the item.

Parameters
item[borrow]
Returns
The type

Definition at line 59 of file common.c.