11#include <initializer_list>
27#pragma GCC diagnostic push
28#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
36 struct private_init {};
56 m_val.
data.arr_boolean.arr =
nullptr;
59 m_val.
data.arr_int.arr =
nullptr;
62 m_val.
data.arr_float.arr =
nullptr;
65 m_val.
data.arr_double.arr =
nullptr;
68 m_val.
data.arr_string.arr =
nullptr;
112 size_t size()
const {
return m_size; }
238 return m_val.
data.v_boolean != 0;
248 return m_val.
data.v_int;
258 return m_val.
data.v_float;
268 return m_val.
data.v_double;
278 return {m_val.
data.v_string.str, m_val.
data.v_string.len};
286 std::span<const uint8_t>
GetRaw()
const {
288 return {m_val.
data.v_raw.data, m_val.
data.v_raw.size};
298 return {m_val.
data.arr_boolean.arr, m_val.
data.arr_boolean.size};
308 return {m_val.
data.arr_int.arr, m_val.
data.arr_int.size};
318 return {m_val.
data.arr_float.arr, m_val.
data.arr_float.size};
328 return {m_val.
data.arr_double.arr, m_val.
data.arr_double.size};
338 return *
static_cast<std::vector<std::string>*
>(m_storage.get());
413 auto data = std::make_shared<std::string>(
value);
415 val.m_val.
data.v_string.str =
const_cast<char*
>(data->c_str());
416 val.m_val.data.v_string.len = data->size();
417 val.m_storage = std::move(data);
429 template <std::same_as<std::
string> T>
431 auto data = std::make_shared<std::string>(std::forward<T>(
value));
433 val.m_val.
data.v_string.str =
const_cast<char*
>(data->c_str());
434 val.m_val.data.v_string.len = data->size();
435 val.m_storage = std::move(data);
449 std::make_shared<std::vector<uint8_t>>(
value.begin(),
value.end());
451 val.m_val.
data.v_raw.data =
const_cast<uint8_t*
>(data->data());
452 val.m_val.data.v_raw.size = data->size();
453 val.m_storage = std::move(data);
465 template <std::same_as<std::vector<u
int8_t>> T>
467 auto data = std::make_shared<std::vector<uint8_t>>(std::forward<T>(
value));
469 val.m_val.
data.v_raw.data =
const_cast<uint8_t*
>(data->data());
470 val.m_val.data.v_raw.size = data->size();
471 val.m_storage = std::move(data);
682 std::shared_ptr<void> m_storage;
687#pragma GCC diagnostic pop
A network table entry value.
Definition NetworkTableValue.h:35
static Value MakeStringArray(std::vector< std::string > &&value, int64_t time=0)
Creates a string array entry value.
Value()
Definition NetworkTableValue.h:39
static Value MakeBoolean(bool value, int64_t time=0)
Creates a boolean entry value.
Definition NetworkTableValue.h:356
int64_t server_time() const
Get the creation time of the value, in server time.
Definition NetworkTableValue.h:126
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:384
static Value MakeString(T &&value, int64_t time=0)
Creates a string entry value.
Definition NetworkTableValue.h:430
static Value MakeFloatArray(std::initializer_list< float > value, int64_t time=0)
Creates a float array entry value.
Definition NetworkTableValue.h:587
static Value MakeBooleanArray(std::initializer_list< int > value, int64_t time=0)
Creates a boolean array entry value.
Definition NetworkTableValue.h:516
bool IsValid() const
Determine if entry value contains a value or is unassigned.
Definition NetworkTableValue.h:145
bool IsBooleanArray() const
Determine if entry value contains a boolean array.
Definition NetworkTableValue.h:194
std::span< const int64_t > GetIntegerArray() const
Get the entry's integer array value.
Definition NetworkTableValue.h:306
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:187
static Value MakeRaw(std::span< const uint8_t > value, int64_t time=0)
Creates a raw entry value.
Definition NetworkTableValue.h:447
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:201
bool IsDouble() const
Determine if entry value contains a double.
Definition NetworkTableValue.h:173
NT_Type type() const
Get the data type.
Definition NetworkTableValue.h:82
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:256
static Value MakeString(std::string_view value, int64_t time=0)
Creates a string entry value.
Definition NetworkTableValue.h:412
std::span< const float > GetFloatArray() const
Get the entry's float array value.
Definition NetworkTableValue.h:316
int64_t last_change() const
Get the creation time of the value, in local time.
Definition NetworkTableValue.h:96
bool IsDoubleArray() const
Determine if entry value contains a double array.
Definition NetworkTableValue.h:215
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:658
bool IsFloat() const
Determine if entry value contains a float.
Definition NetworkTableValue.h:166
static Value MakeRaw(T &&value, int64_t time=0)
Creates a raw entry value.
Definition NetworkTableValue.h:466
bool IsStringArray() const
Determine if entry value contains a string array.
Definition NetworkTableValue.h:222
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:133
double GetDouble() const
Get the entry's double value.
Definition NetworkTableValue.h:266
bool IsInteger() const
Determine if entry value contains an integer.
Definition NetworkTableValue.h:159
const NT_Value & value() const
Get the data value stored.
Definition NetworkTableValue.h:89
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 &)
Definition NetworkTableValue.h:45
std::span< const std::string > GetStringArray() const
Get the entry's string array value.
Definition NetworkTableValue.h:336
static Value MakeDouble(double value, int64_t time=0)
Creates a double entry value.
Definition NetworkTableValue.h:398
int64_t GetInteger() const
Get the entry's integer value.
Definition NetworkTableValue.h:246
std::span< const double > GetDoubleArray() const
Get the entry's double array value.
Definition NetworkTableValue.h:326
std::span< const uint8_t > GetRaw() const
Get the entry's raw value.
Definition NetworkTableValue.h:286
bool IsBoolean() const
Determine if entry value contains a boolean.
Definition NetworkTableValue.h:152
bool IsString() const
Determine if entry value contains a string.
Definition NetworkTableValue.h:180
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:370
bool GetBoolean() const
Get the entry's boolean value.
Definition NetworkTableValue.h:236
size_t size() const
Get the approximate in-memory size of the value in bytes.
Definition NetworkTableValue.h:112
bool IsFloatArray() const
Determine if entry value contains a float array.
Definition NetworkTableValue.h:208
Value(NT_Type type, size_t size, int64_t time, int64_t serverTime, const private_init &)
Definition NetworkTableValue.h:48
std::string_view GetString() const
Get the entry's string value.
Definition NetworkTableValue.h:276
std::span< const int > GetBooleanArray() const
Get the entry's boolean array value.
Definition NetworkTableValue.h:296
static Value MakeBooleanArray(std::initializer_list< bool > value, int64_t time=0)
Creates a boolean array entry value.
Definition NetworkTableValue.h:493
static Value MakeDoubleArray(std::initializer_list< double > value, int64_t time=0)
Creates a double array entry value.
Definition NetworkTableValue.h:622
void SetTime(int64_t time)
Set the local creation time of the value.
Definition NetworkTableValue.h:119
static Value MakeIntegerArray(std::initializer_list< int64_t > value, int64_t time=0)
Creates an integer array entry value.
Definition NetworkTableValue.h:552
int64_t time() const
Get the creation time of the value, in local time.
Definition NetworkTableValue.h:103
NT_Type
NetworkTables data types.
Definition ntcore_c.h:53
@ NT_DOUBLE
Definition ntcore_c.h:56
@ NT_BOOLEAN
Definition ntcore_c.h:55
@ NT_DOUBLE_ARRAY
Definition ntcore_c.h:60
@ NT_STRING
Definition ntcore_c.h:57
@ NT_FLOAT_ARRAY
Definition ntcore_c.h:66
@ NT_INTEGER
Definition ntcore_c.h:63
@ NT_BOOLEAN_ARRAY
Definition ntcore_c.h:59
@ NT_FLOAT
Definition ntcore_c.h:64
@ NT_STRING_ARRAY
Definition ntcore_c.h:61
@ NT_INTEGER_ARRAY
Definition ntcore_c.h:65
@ NT_UNASSIGNED
Definition ntcore_c.h:54
@ NT_RAW
Definition ntcore_c.h:58
int64_t Now()
Returns monotonic current time in 1 us increments.
NetworkTables (ntcore) namespace.
Definition ntcore_cpp.h:36
bool operator==(const Value &lhs, const Value &rhs)
NetworkTables Entry Value.
Definition ntcore_c.h:135
enum NT_Type type
Definition ntcore_c.h:136
int64_t last_change
Definition ntcore_c.h:137
int64_t server_time
Definition ntcore_c.h:138
uint8_t * data
Definition ntcore_c.h:146