WPILibC++  2020.3.2-60-g3011ebe
Value.h
1 /*----------------------------------------------------------------------------*/
2 /* Copyright (c) 2017-2019 FIRST. All Rights Reserved. */
3 /* Open Source Software - may be modified and shared by FRC teams. The code */
4 /* must be accompanied by the FIRST BSD license file in the root directory of */
5 /* the project. */
6 /*----------------------------------------------------------------------------*/
7 
8 #pragma once
9 
10 #include "hal/Types.h"
11 
13 enum HAL_Type {
14  HAL_UNASSIGNED = 0,
15  HAL_BOOLEAN = 0x01,
16  HAL_DOUBLE = 0x02,
17  HAL_ENUM = 0x04,
18  HAL_INT = 0x08,
19  HAL_LONG = 0x10,
20 };
21 
23 struct HAL_Value {
24  union {
25  HAL_Bool v_boolean;
26  int32_t v_enum;
27  int32_t v_int;
28  int64_t v_long;
29  double v_double;
30  } data;
31  enum HAL_Type type;
32 };
33 
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37 
38 inline struct HAL_Value HAL_MakeBoolean(HAL_Bool v) {
39  struct HAL_Value value;
40  value.type = HAL_BOOLEAN;
41  value.data.v_boolean = v;
42  return value;
43 }
44 
45 inline struct HAL_Value HAL_MakeEnum(int v) {
46  struct HAL_Value value;
47  value.type = HAL_ENUM;
48  value.data.v_enum = v;
49  return value;
50 }
51 
52 inline struct HAL_Value HAL_MakeInt(int v) {
53  struct HAL_Value value;
54  value.type = HAL_INT;
55  value.data.v_int = v;
56  return value;
57 }
58 
59 inline struct HAL_Value HAL_MakeLong(int64_t v) {
60  struct HAL_Value value;
61  value.type = HAL_LONG;
62  value.data.v_long = v;
63  return value;
64 }
65 
66 inline struct HAL_Value HAL_MakeDouble(double v) {
67  struct HAL_Value value;
68  value.type = HAL_DOUBLE;
69  value.data.v_double = v;
70  return value;
71 }
72 
73 #ifdef __cplusplus
74 } // extern "C"
75 #endif
HAL_Value
HAL Entry Value.
Definition: Value.h:23