Nyx Node
Loading...
Searching...
No Matches
json_boolean.py
1# -*- coding: utf-8 -*-
2########################################################################################################################
3# NyxNode
4# Author: Jérôme ODIER <jerome.odier@lpsc.in2p3.fr>
5# SPDX-License-Identifier: GPL-3.0+
6########################################################################################################################
7
8from .. import bind
9from .. import obj
10
11########################################################################################################################
12
14 """!
15 @brief JSON boolean object.
16 """
17
18 ####################################################################################################################
19
20 def __init__(self, value: int | float | bool | None = None, ptr: int | None = None):
21 """!
22 @brief Allocates a new JSON boolean object or wraps one.
23
24 @param value Optional default value.
25 @param ptr Optional JSON boolean object pointer.
26 """
27
28 ################################################################################################################
29
30 if ptr is None:
31
32 ptr = bind.lib.nyx_boolean_new()
33
34 elif bind.lib.nyx_object_get_type(ptr) != bind.NyxObjectType.BOOLEAN:
35
36 raise TypeError('Not a pointer to a Nyx boolean object')
37
38 ################################################################################################################
39
40 super().__init__(ptr)
41
42 ################################################################################################################
43
44 if isinstance(value, (int, float, bool)):
45
46 self.value = bool(value)
47
48 ####################################################################################################################
49
50 @property
51 def value(self) -> bool:
52 """!
53 @brief Gets the value of this JSON boolean object.
54
55 @return The current value.
56 """
57
58 return bool(bind.lib.nyx_boolean_get(self.ptr))
59
60 ####################################################################################################################
61
62 @value.setter
63 def value(self, value: bool) -> bool:
64 """!
65 @brief Sets the value of this JSON boolean object.
66
67 @return @c True if the value was modified, @c False otherwise.
68 """
69
70 return bool(bind.lib.nyx_boolean_set(self.ptr, bool(value)))
71
72########################################################################################################################
73
74__all__ = ['NyxBoolean']
75
76########################################################################################################################
__init__(self, int|float|bool|None value=None, int|None ptr=None)
Allocates a new JSON boolean object or wraps one.
Base class for JSON Nyx objects.
Definition obj.py:44