knx
ETS configurable knx-stack
knx_value.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <cstdint>
4 #include <ctime>
5 
6 class KNXValue
7 {
8  public:
9  KNXValue(bool value);
10  KNXValue(uint8_t value);
11  KNXValue(uint16_t value);
12  KNXValue(uint32_t value);
13  KNXValue(uint64_t value);
14  KNXValue(int8_t value);
15  KNXValue(int16_t value);
16  KNXValue(int32_t value);
17  KNXValue(int64_t value);
18  KNXValue(double value);
19  KNXValue(const char* value);
20  KNXValue(struct tm value);
21  KNXValue(float value);
22 
23  operator bool() const;
24  operator uint8_t() const;
25  operator uint16_t() const;
26  operator uint32_t() const;
27  operator uint64_t() const;
28  operator int8_t() const;
29  operator int16_t() const;
30  operator int32_t() const;
31  operator int64_t() const;
32  operator double() const;
33  operator const char*() const;
34  operator struct tm() const;
35  operator float() const;
36 
37  KNXValue& operator=(const bool value);
38  KNXValue& operator=(const uint8_t value);
39  KNXValue& operator=(const uint16_t value);
40  KNXValue& operator=(const uint32_t value);
41  KNXValue& operator=(const uint64_t value);
42  KNXValue& operator=(const int8_t value);
43  KNXValue& operator=(const int16_t value);
44  KNXValue& operator=(const int32_t value);
45  KNXValue& operator=(const int64_t value);
46  KNXValue& operator=(const double value);
47  KNXValue& operator=(const char* value);
48  KNXValue& operator=(const struct tm value);
49  KNXValue& operator=(const float value);
50 
51  private:
52  bool boolValue() const;
53  uint8_t ucharValue() const;
54  uint16_t ushortValue() const;
55  uint32_t uintValue() const;
56  uint64_t ulongValue() const;
57  int8_t charValue() const;
58  int16_t shortValue() const;
59  int32_t intValue() const;
60  int64_t longValue() const;
61  double doubleValue() const;
62  const char* stringValue() const;
63  struct tm timeValue() const;
64 
65 
66  union Value
67  {
68  bool boolValue;
69  uint8_t ucharValue;
70  uint16_t ushortValue;
71  uint32_t uintValue;
72  uint64_t ulongValue;
73  int8_t charValue;
74  int16_t shortValue;
75  int32_t intValue;
76  int64_t longValue;
77  double doubleValue;
78  const char* stringValue;
79  struct tm timeValue;
80  };
81  enum ValueType
82  {
83  BoolType,
84  UCharType,
85  UShortType,
86  UIntType,
87  ULongType,
88  CharType,
89  ShortType,
90  IntType,
91  LongType,
92  DoubleType,
93  StringType,
94  TimeType,
95  };
96 
97  ValueType _type;
98  Value _value;
99 };
KNXValue & operator=(const bool value)
Definition: knx_value.cpp:139
KNXValue(bool value)
Definition: knx_value.cpp:7