libcbor  0.5.0
libcbor is a C library for parsing and generating CBOR, the general-purpose schema-less binary data format.
ints.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2014-2017 Pavel Kalvoda <me@pavelkalvoda.com>
3  *
4  * libcbor is free software; you can redistribute it and/or modify
5  * it under the terms of the MIT license. See LICENSE for details.
6  */
7 
8 #ifndef LIBCBOR_INTS_H
9 #define LIBCBOR_INTS_H
10 
11 #include "cbor/common.h"
12 
13 #ifdef __cplusplus
14 extern "C" {
15 #endif
16 
17 /*
18 * ============================================================================
19 * Integer (uints and negints) manipulation
20 * ============================================================================
21 */
22 
28 uint8_t cbor_get_uint8(const cbor_item_t *item);
29 
35 uint16_t cbor_get_uint16(const cbor_item_t *item);
36 
42 uint32_t cbor_get_uint32(const cbor_item_t *item);
43 
49 uint64_t cbor_get_uint64(const cbor_item_t *item);
50 
56 uint64_t cbor_get_int(const cbor_item_t *item);
57 
63 void cbor_set_uint8(cbor_item_t *item, uint8_t value);
64 
70 void cbor_set_uint16(cbor_item_t *item, uint16_t value);
71 
77 void cbor_set_uint32(cbor_item_t *item, uint32_t value);
78 
84 void cbor_set_uint64(cbor_item_t *item, uint64_t value);
85 
92 
99 void cbor_mark_uint(cbor_item_t *item);
100 
107 void cbor_mark_negint(cbor_item_t *item);
108 
116 
124 
132 
140 
146 cbor_item_t *cbor_build_uint8(uint8_t value);
147 
153 cbor_item_t *cbor_build_uint16(uint16_t value);
154 
160 cbor_item_t *cbor_build_uint32(uint32_t value);
161 
167 cbor_item_t *cbor_build_uint64(uint64_t value);
168 
174 cbor_item_t *cbor_build_negint8(uint8_t value);
175 
181 cbor_item_t *cbor_build_negint16(uint16_t value);
182 
188 cbor_item_t *cbor_build_negint32(uint32_t value);
189 
195 cbor_item_t *cbor_build_negint64(uint64_t value);
196 
197 
198 
199 #ifdef __cplusplus
200 }
201 #endif
202 
203 #endif //LIBCBOR_INTS_H
cbor_item_t * cbor_new_int32()
Allocates new integer with 4B width.
Definition: ints.c:121
void cbor_mark_uint(cbor_item_t *item)
Marks the integer item as a positive integer.
Definition: ints.c:85
cbor_int_width cbor_int_get_width(const cbor_item_t *item)
Queries the integer width.
Definition: ints.c:10
cbor_item_t * cbor_build_negint64(uint64_t value)
Constructs a new negative integer.
Definition: ints.c:201
cbor_item_t * cbor_new_int64()
Allocates new integer with 8B width.
Definition: ints.c:133
cbor_item_t * cbor_build_negint16(uint16_t value)
Constructs a new negative integer.
Definition: ints.c:185
uint16_t cbor_get_uint16(const cbor_item_t *item)
Extracts the integer value.
Definition: ints.c:23
cbor_item_t * cbor_build_negint32(uint32_t value)
Constructs a new negative integer.
Definition: ints.c:193
uint32_t cbor_get_uint32(const cbor_item_t *item)
Extracts the integer value.
Definition: ints.c:30
uint64_t cbor_get_int(const cbor_item_t *item)
Extracts the integer value.
Definition: ints.c:44
void cbor_mark_negint(cbor_item_t *item)
Marks the integer item as a negative integer.
Definition: ints.c:91
void cbor_set_uint8(cbor_item_t *item, uint8_t value)
Assigns the integer value.
Definition: ints.c:56
cbor_item_t * cbor_build_uint64(uint64_t value)
Constructs a new positive integer.
Definition: ints.c:169
cbor_int_width
Possible widths of CBOR_TYPE_UINT items.
Definition: data.h:46
uint64_t cbor_get_uint64(const cbor_item_t *item)
Extracts the integer value.
Definition: ints.c:37
cbor_item_t * cbor_build_uint32(uint32_t value)
Constructs a new positive integer.
Definition: ints.c:161
void cbor_set_uint16(cbor_item_t *item, uint16_t value)
Assigns the integer value.
Definition: ints.c:63
void cbor_set_uint32(cbor_item_t *item, uint32_t value)
Assigns the integer value.
Definition: ints.c:71
cbor_item_t * cbor_new_int16()
Allocates new integer with 2B width.
Definition: ints.c:109
cbor_item_t * cbor_new_int8()
Allocates new integer with 1B width.
Definition: ints.c:97
void cbor_set_uint64(cbor_item_t *item, uint64_t value)
Assigns the integer value.
Definition: ints.c:78
cbor_item_t * cbor_build_uint16(uint16_t value)
Constructs a new positive integer.
Definition: ints.c:153
The item handle.
Definition: data.h:149
cbor_item_t * cbor_build_negint8(uint8_t value)
Constructs a new negative integer.
Definition: ints.c:177
cbor_item_t * cbor_build_uint8(uint8_t value)
Constructs a new positive integer.
Definition: ints.c:145
uint8_t cbor_get_uint8(const cbor_item_t *item)
Extracts the integer value.
Definition: ints.c:16