Nyx Node
Loading...
Searching...
No Matches
json_boolean.c
1/* NyxNode
2 * Author: Jérôme ODIER <jerome.odier@lpsc.in2p3.fr>
3 * SPDX-License-Identifier: GPL-2.0-only (Mongoose backend) or GPL-3.0+
4 */
5
6/*--------------------------------------------------------------------------------------------------------------------*/
7
8#include "../nyx_node_internal.h"
9
10/*--------------------------------------------------------------------------------------------------------------------*/
11
12nyx_boolean_t *nyx_boolean_new(void)
13{
14 /*----------------------------------------------------------------------------------------------------------------*/
15
17
18 /*----------------------------------------------------------------------------------------------------------------*/
19
20 object->base = NYX_OBJECT(NYX_TYPE_BOOLEAN);
21
22 /*----------------------------------------------------------------------------------------------------------------*/
23
24 object->value = false;
25
26 /*----------------------------------------------------------------------------------------------------------------*/
27
28 return object;
29}
30
31/*--------------------------------------------------------------------------------------------------------------------*/
32
33void nyx_boolean_free(nyx_boolean_t *object)
34{
35 nyx_memory_free(object);
36}
37
38/*--------------------------------------------------------------------------------------------------------------------*/
39
40bool nyx_boolean_get(const nyx_boolean_t *object)
41{
42 return object->value;
43}
44
45/*--------------------------------------------------------------------------------------------------------------------*/
46
47bool nyx_boolean_set(nyx_boolean_t *object, bool value)
48{
49 bool modified = \
50 object->value != value;
51 object->value = value;
52
53 return modified;
54}
55
56/*--------------------------------------------------------------------------------------------------------------------*/
57
58str_t nyx_boolean_to_string(const nyx_boolean_t *object)
59{
60 return nyx_bool_dup(object->value);
61}
62
63/*--------------------------------------------------------------------------------------------------------------------*/
__NYX_NULLABLE__ buff_t nyx_memory_alloc(__NYX_ZEROABLE__ size_t size)
Similar to libc malloc except that a memory overflow causes the node to stop.
__NYX_ZEROABLE__ size_t nyx_memory_free(__NYX_NULLABLE__ buff_t buff)
Similar to libc free except that it returns the amount of memory freed.
#define str_t
Alias for char *.
Definition nyx_node.h:70
@ NYX_TYPE_BOOLEAN
Boolean object.
Definition nyx_node.h:423
Struct describing a JSON boolean object.
Definition nyx_node.h:795
bool value
Boolean payload.
Definition nyx_node.h:798