11#include <initializer_list>
24#pragma GCC diagnostic push
25#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
33 struct private_init {};
78 size_t size()
const {
return m_size; }
204 return m_val.
data.v_boolean != 0;
214 return m_val.
data.v_int;
224 return m_val.
data.v_float;
234 return m_val.
data.v_double;
244 return {m_val.
data.v_string.str, m_val.
data.v_string.len};
252 std::span<const uint8_t>
GetRaw()
const {
254 return {m_val.
data.v_raw.data, m_val.
data.v_raw.size};
264 return {m_val.
data.arr_boolean.arr, m_val.
data.arr_boolean.size};
274 return {m_val.
data.arr_int.arr, m_val.
data.arr_int.size};
284 return {m_val.
data.arr_float.arr, m_val.
data.arr_float.size};
294 return {m_val.
data.arr_double.arr, m_val.
data.arr_double.size};
304 return *
static_cast<std::vector<std::string>*
>(m_storage.get());
324 val.m_val.data.v_boolean =
value;
338 val.m_val.data.v_int =
value;
352 val.m_val.data.v_float =
value;
366 val.m_val.data.v_double =
value;
379 auto data = std::make_shared<std::string>(
value);
381 val.m_val.data.v_string.str =
const_cast<char*
>(data->c_str());
382 val.m_val.data.v_string.len = data->size();
383 val.m_storage = std::move(data);
395 template <std::same_as<std::
string> T>
397 auto data = std::make_shared<std::string>(std::forward<T>(
value));
399 val.m_val.data.v_string.str =
const_cast<char*
>(data->c_str());
400 val.m_val.data.v_string.len = data->size();
401 val.m_storage = std::move(data);
415 std::make_shared<std::vector<uint8_t>>(
value.begin(),
value.end());
417 val.m_val.data.v_raw.data =
const_cast<uint8_t*
>(data->data());
418 val.m_val.data.v_raw.size = data->size();
419 val.m_storage = std::move(data);
431 template <std::same_as<std::vector<u
int8_t>> T>
433 auto data = std::make_shared<std::vector<uint8_t>>(std::forward<T>(
value));
435 val.m_val.data.v_raw.data =
const_cast<uint8_t*
>(data->data());
436 val.m_val.data.v_raw.size = data->size();
437 val.m_storage = std::move(data);
648 std::shared_ptr<void> m_storage;
653#pragma GCC diagnostic pop
A network table entry value.
Definition: NetworkTableValue.h:32
static Value MakeStringArray(std::vector< std::string > &&value, int64_t time=0)
Creates a string array entry value.
static Value MakeBoolean(bool value, int64_t time=0)
Creates a boolean entry value.
Definition: NetworkTableValue.h:322
int64_t server_time() const
Get the creation time of the value, in server time.
Definition: NetworkTableValue.h:92
static Value MakeIntegerArray(std::vector< int64_t > &&value, int64_t time=0)
Creates an integer array entry value.
static Value MakeBooleanArray(std::vector< int > &&value, int64_t time=0)
Creates a boolean array entry value.
static Value MakeFloat(float value, int64_t time=0)
Creates a float entry value.
Definition: NetworkTableValue.h:350
static Value MakeString(T &&value, int64_t time=0)
Creates a string entry value.
Definition: NetworkTableValue.h:396
static Value MakeFloatArray(std::initializer_list< float > value, int64_t time=0)
Creates a float array entry value.
Definition: NetworkTableValue.h:553
static Value MakeBooleanArray(std::initializer_list< int > value, int64_t time=0)
Creates a boolean array entry value.
Definition: NetworkTableValue.h:482
bool IsValid() const
Determine if entry value contains a value or is unassigned.
Definition: NetworkTableValue.h:111
bool IsBooleanArray() const
Determine if entry value contains a boolean array.
Definition: NetworkTableValue.h:160
std::span< const int64_t > GetIntegerArray() const
Get the entry's integer array value.
Definition: NetworkTableValue.h:272
static Value MakeFloatArray(std::span< const float > value, int64_t time=0)
Creates a float array entry value.
bool IsRaw() const
Determine if entry value contains a raw.
Definition: NetworkTableValue.h:153
static Value MakeRaw(std::span< const uint8_t > value, int64_t time=0)
Creates a raw entry value.
Definition: NetworkTableValue.h:413
static Value MakeDoubleArray(std::vector< double > &&value, int64_t time=0)
Creates a double array entry value.
bool IsIntegerArray() const
Determine if entry value contains an integer array.
Definition: NetworkTableValue.h:167
bool IsDouble() const
Determine if entry value contains a double.
Definition: NetworkTableValue.h:139
NT_Type type() const
Get the data type.
Definition: NetworkTableValue.h:48
friend bool operator==(const Value &lhs, const Value &rhs)
static Value MakeIntegerArray(std::span< const int64_t > value, int64_t time=0)
Creates an integer array entry value.
float GetFloat() const
Get the entry's float value.
Definition: NetworkTableValue.h:222
static Value MakeString(std::string_view value, int64_t time=0)
Creates a string entry value.
Definition: NetworkTableValue.h:378
std::span< const float > GetFloatArray() const
Get the entry's float array value.
Definition: NetworkTableValue.h:282
int64_t last_change() const
Get the creation time of the value, in local time.
Definition: NetworkTableValue.h:62
bool IsDoubleArray() const
Determine if entry value contains a double array.
Definition: NetworkTableValue.h:181
static Value MakeBooleanArray(std::span< const int > value, int64_t time=0)
Creates a boolean array entry value.
static Value MakeStringArray(std::initializer_list< std::string > value, int64_t time=0)
Creates a string array entry value.
Definition: NetworkTableValue.h:624
bool IsFloat() const
Determine if entry value contains a float.
Definition: NetworkTableValue.h:132
static Value MakeRaw(T &&value, int64_t time=0)
Creates a raw entry value.
Definition: NetworkTableValue.h:432
bool IsStringArray() const
Determine if entry value contains a string array.
Definition: NetworkTableValue.h:188
static Value MakeDoubleArray(std::span< const double > value, int64_t time=0)
Creates a double array entry value.
void SetServerTime(int64_t time)
Set the creation time of the value, in server time.
Definition: NetworkTableValue.h:99
double GetDouble() const
Get the entry's double value.
Definition: NetworkTableValue.h:232
bool IsInteger() const
Determine if entry value contains an integer.
Definition: NetworkTableValue.h:125
const NT_Value & value() const
Get the data value stored.
Definition: NetworkTableValue.h:55
static Value MakeFloatArray(std::vector< float > &&value, int64_t time=0)
Creates a float array entry value.
static Value MakeStringArray(std::span< const std::string > value, int64_t time=0)
Creates a string array entry value.
Value(NT_Type type, size_t size, int64_t time, const private_init &)
std::span< const std::string > GetStringArray() const
Get the entry's string array value.
Definition: NetworkTableValue.h:302
static Value MakeDouble(double value, int64_t time=0)
Creates a double entry value.
Definition: NetworkTableValue.h:364
int64_t GetInteger() const
Get the entry's integer value.
Definition: NetworkTableValue.h:212
std::span< const double > GetDoubleArray() const
Get the entry's double array value.
Definition: NetworkTableValue.h:292
std::span< const uint8_t > GetRaw() const
Get the entry's raw value.
Definition: NetworkTableValue.h:252
bool IsBoolean() const
Determine if entry value contains a boolean.
Definition: NetworkTableValue.h:118
bool IsString() const
Determine if entry value contains a string.
Definition: NetworkTableValue.h:146
static Value MakeBooleanArray(std::span< const bool > value, int64_t time=0)
Creates a boolean array entry value.
static Value MakeInteger(int64_t value, int64_t time=0)
Creates an integer entry value.
Definition: NetworkTableValue.h:336
bool GetBoolean() const
Get the entry's boolean value.
Definition: NetworkTableValue.h:202
size_t size() const
Get the approximate in-memory size of the value in bytes.
Definition: NetworkTableValue.h:78
bool IsFloatArray() const
Determine if entry value contains a float array.
Definition: NetworkTableValue.h:174
Value(NT_Type type, size_t size, int64_t time, int64_t serverTime, const private_init &)
std::string_view GetString() const
Get the entry's string value.
Definition: NetworkTableValue.h:242
std::span< const int > GetBooleanArray() const
Get the entry's boolean array value.
Definition: NetworkTableValue.h:262
static Value MakeBooleanArray(std::initializer_list< bool > value, int64_t time=0)
Creates a boolean array entry value.
Definition: NetworkTableValue.h:459
static Value MakeDoubleArray(std::initializer_list< double > value, int64_t time=0)
Creates a double array entry value.
Definition: NetworkTableValue.h:588
void SetTime(int64_t time)
Set the local creation time of the value.
Definition: NetworkTableValue.h:85
static Value MakeIntegerArray(std::initializer_list< int64_t > value, int64_t time=0)
Creates an integer array entry value.
Definition: NetworkTableValue.h:518
int64_t time() const
Get the creation time of the value, in local time.
Definition: NetworkTableValue.h:69
basic_string_view< char > string_view
Definition: core.h:501
NT_Type
NetworkTables data types.
Definition: ntcore_c.h:51
@ NT_DOUBLE
Definition: ntcore_c.h:54
@ NT_BOOLEAN
Definition: ntcore_c.h:53
@ NT_DOUBLE_ARRAY
Definition: ntcore_c.h:58
@ NT_STRING
Definition: ntcore_c.h:55
@ NT_FLOAT_ARRAY
Definition: ntcore_c.h:64
@ NT_INTEGER
Definition: ntcore_c.h:61
@ NT_BOOLEAN_ARRAY
Definition: ntcore_c.h:57
@ NT_FLOAT
Definition: ntcore_c.h:62
@ NT_STRING_ARRAY
Definition: ntcore_c.h:59
@ NT_INTEGER_ARRAY
Definition: ntcore_c.h:63
@ NT_UNASSIGNED
Definition: ntcore_c.h:52
@ NT_RAW
Definition: ntcore_c.h:56
NetworkTables (ntcore) namespace.
Definition: ntcore_cpp.h:36
bool operator==(const Value &lhs, const Value &rhs)
NetworkTables Entry Value.
Definition: ntcore_c.h:150
enum NT_Type type
Definition: ntcore_c.h:151
int64_t last_change
Definition: ntcore_c.h:152
int64_t server_time
Definition: ntcore_c.h:153
uint8_t * data
Definition: ntcore_c.h:161