WPILibC++ 2024.3.2
Value.h
Go to the documentation of this file.
1// Copyright (c) FIRST and other WPILib contributors.
2// Open Source Software; you can modify and/or share it under the terms of
3// the WPILib BSD license file in the root directory of this project.
4
5#pragma once
6
7#include "hal/Types.h"
8
9/** HAL data types. */
13 HAL_DOUBLE = 0x02,
14 HAL_ENUM = 0x04,
15 HAL_INT = 0x08,
16 HAL_LONG = 0x10,
17};
18
19/** HAL Entry Value. Note this is a typed union. */
20struct HAL_Value {
21 union {
23 int32_t v_enum;
24 int32_t v_int;
25 int64_t v_long;
26 double v_double;
29};
30
31#ifdef __cplusplus
32extern "C" {
33#endif
34
36 struct HAL_Value value;
37 value.type = HAL_BOOLEAN;
38 value.data.v_boolean = v;
39 return value;
40}
41
42inline struct HAL_Value HAL_MakeEnum(int v) {
43 struct HAL_Value value;
44 value.type = HAL_ENUM;
45 value.data.v_enum = v;
46 return value;
47}
48
49inline struct HAL_Value HAL_MakeInt(int v) {
50 struct HAL_Value value;
51 value.type = HAL_INT;
52 value.data.v_int = v;
53 return value;
54}
55
56inline struct HAL_Value HAL_MakeLong(int64_t v) {
57 struct HAL_Value value;
58 value.type = HAL_LONG;
59 value.data.v_long = v;
60 return value;
61}
62
63inline struct HAL_Value HAL_MakeDouble(double v) {
64 struct HAL_Value value;
65 value.type = HAL_DOUBLE;
66 value.data.v_double = v;
67 return value;
68}
69
70#ifdef __cplusplus
71} // extern "C"
72#endif
struct HAL_Value HAL_MakeBoolean(HAL_Bool v)
Definition: Value.h:35
struct HAL_Value HAL_MakeDouble(double v)
Definition: Value.h:63
struct HAL_Value HAL_MakeEnum(int v)
Definition: Value.h:42
struct HAL_Value HAL_MakeInt(int v)
Definition: Value.h:49
struct HAL_Value HAL_MakeLong(int64_t v)
Definition: Value.h:56
HAL_Type
HAL data types.
Definition: Value.h:10
@ HAL_DOUBLE
Definition: Value.h:13
@ HAL_LONG
Definition: Value.h:16
@ HAL_UNASSIGNED
Definition: Value.h:11
@ HAL_ENUM
Definition: Value.h:14
@ HAL_BOOLEAN
Definition: Value.h:12
@ HAL_INT
Definition: Value.h:15
int32_t HAL_Bool
Definition: Types.h:73
HAL Entry Value.
Definition: Value.h:20
double v_double
Definition: Value.h:26
int64_t v_long
Definition: Value.h:25
HAL_Bool v_boolean
Definition: Value.h:22
int32_t v_int
Definition: Value.h:24
enum HAL_Type type
Definition: Value.h:28
union HAL_Value::@0 data
int32_t v_enum
Definition: Value.h:23