10#include <initializer_list>
28 struct private_init {};
189 return m_val.
data.v_boolean != 0;
199 return m_val.
data.v_int;
209 return m_val.
data.v_float;
219 return m_val.
data.v_double;
229 return {m_val.
data.v_string.str, m_val.
data.v_string.len};
237 std::span<const uint8_t>
GetRaw()
const {
239 return {m_val.
data.v_raw.data, m_val.
data.v_raw.size};
249 return {m_val.
data.arr_boolean.arr, m_val.
data.arr_boolean.size};
259 return {m_val.
data.arr_int.arr, m_val.
data.arr_int.size};
269 return {m_val.
data.arr_float.arr, m_val.
data.arr_float.size};
279 return {m_val.
data.arr_double.arr, m_val.
data.arr_double.size};
289 return *
static_cast<std::vector<std::string>*
>(m_storage.get());
309 val.m_val.data.v_boolean =
value;
323 val.m_val.data.v_int =
value;
337 val.m_val.data.v_float =
value;
351 val.m_val.data.v_double =
value;
365 auto data = std::make_shared<std::string>(
value);
366 val.m_val.data.v_string.str =
const_cast<char*
>(
data->c_str());
367 val.m_val.data.v_string.len =
data->size();
368 val.m_storage = std::move(
data);
380 template <
typename T,
381 typename std::enable_if<std::is_same<T, std::string>::value>
::type>
384 auto data = std::make_shared<std::string>(std::forward(
value));
385 val.m_val.data.v_string.str =
const_cast<char*
>(
data->c_str());
386 val.m_val.data.v_string.len =
data->size();
387 val.m_storage = std::move(
data);
402 std::make_shared<std::vector<uint8_t>>(
value.begin(),
value.end());
403 val.m_val.data.v_raw.data =
const_cast<uint8_t*
>(
data->data());
404 val.m_val.data.v_raw.size =
data->size();
405 val.m_storage = std::move(
data);
417 template <
typename T,
typename std::enable_if<
421 auto data = std::make_shared<std::vector<uint8_t>>(std::forward(
value));
422 val.m_val.data.v_raw.data =
const_cast<uint8_t*
>(
data->data());
423 val.m_val.data.v_raw.size =
data->size();
424 val.m_storage = std::move(
data);
635 std::shared_ptr<void> m_storage;
A network table entry value.
Definition: NetworkTableValue.h:27
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:307
int64_t server_time() const
Get the creation time of the value, in server time.
Definition: NetworkTableValue.h:77
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:335
static Value MakeString(T &&value, int64_t time=0)
Creates a string entry value.
Definition: NetworkTableValue.h:382
static Value MakeFloatArray(std::initializer_list< float > value, int64_t time=0)
Creates a float array entry value.
Definition: NetworkTableValue.h:540
static Value MakeBooleanArray(std::initializer_list< int > value, int64_t time=0)
Creates a boolean array entry value.
Definition: NetworkTableValue.h:469
bool IsValid() const
Determine if entry value contains a value or is unassigned.
Definition: NetworkTableValue.h:96
bool IsBooleanArray() const
Determine if entry value contains a boolean array.
Definition: NetworkTableValue.h:145
std::span< const int64_t > GetIntegerArray() const
Get the entry's integer array value.
Definition: NetworkTableValue.h:257
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:138
static Value MakeRaw(std::span< const uint8_t > value, int64_t time=0)
Creates a raw entry value.
Definition: NetworkTableValue.h:399
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:152
bool IsDouble() const
Determine if entry value contains a double.
Definition: NetworkTableValue.h:124
NT_Type type() const
Get the data type.
Definition: NetworkTableValue.h:42
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:207
static Value MakeString(std::string_view value, int64_t time=0)
Creates a string entry value.
Definition: NetworkTableValue.h:363
std::span< const float > GetFloatArray() const
Get the entry's float array value.
Definition: NetworkTableValue.h:267
int64_t last_change() const
Get the creation time of the value, in local time.
Definition: NetworkTableValue.h:56
bool IsDoubleArray() const
Determine if entry value contains a double array.
Definition: NetworkTableValue.h:166
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:611
bool IsFloat() const
Determine if entry value contains a float.
Definition: NetworkTableValue.h:117
bool IsStringArray() const
Determine if entry value contains a string array.
Definition: NetworkTableValue.h:173
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:84
double GetDouble() const
Get the entry's double value.
Definition: NetworkTableValue.h:217
bool IsInteger() const
Determine if entry value contains an integer.
Definition: NetworkTableValue.h:110
const NT_Value & value() const
Get the data value stored.
Definition: NetworkTableValue.h:49
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.
std::span< const std::string > GetStringArray() const
Get the entry's string array value.
Definition: NetworkTableValue.h:287
static Value MakeDouble(double value, int64_t time=0)
Creates a double entry value.
Definition: NetworkTableValue.h:349
int64_t GetInteger() const
Get the entry's integer value.
Definition: NetworkTableValue.h:197
std::span< const double > GetDoubleArray() const
Get the entry's double array value.
Definition: NetworkTableValue.h:277
std::span< const uint8_t > GetRaw() const
Get the entry's raw value.
Definition: NetworkTableValue.h:237
bool IsBoolean() const
Determine if entry value contains a boolean.
Definition: NetworkTableValue.h:103
bool IsString() const
Determine if entry value contains a string.
Definition: NetworkTableValue.h:131
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:321
bool GetBoolean() const
Get the entry's boolean value.
Definition: NetworkTableValue.h:187
Value(NT_Type type, int64_t time, int64_t serverTime, const private_init &)
bool IsFloatArray() const
Determine if entry value contains a float array.
Definition: NetworkTableValue.h:159
static Value MakeRaw(T &&value, int64_t time=0)
Creates a raw entry value.
Definition: NetworkTableValue.h:419
std::string_view GetString() const
Get the entry's string value.
Definition: NetworkTableValue.h:227
std::span< const int > GetBooleanArray() const
Get the entry's boolean array value.
Definition: NetworkTableValue.h:247
static Value MakeBooleanArray(std::initializer_list< bool > value, int64_t time=0)
Creates a boolean array entry value.
Definition: NetworkTableValue.h:446
Value(NT_Type type, int64_t time, const private_init &)
static Value MakeDoubleArray(std::initializer_list< double > value, int64_t time=0)
Creates a double array entry value.
Definition: NetworkTableValue.h:575
void SetTime(int64_t time)
Set the local creation time of the value.
Definition: NetworkTableValue.h:70
static Value MakeIntegerArray(std::initializer_list< int64_t > value, int64_t time=0)
Creates an integer array entry value.
Definition: NetworkTableValue.h:505
int64_t time() const
Get the creation time of the value, in local time.
Definition: NetworkTableValue.h:63
basic_string_view< char > string_view
Definition: core.h:520
type
Definition: core.h:575
NT_Type
NetworkTables data types.
Definition: ntcore_c.h:49
@ NT_DOUBLE
Definition: ntcore_c.h:52
@ NT_BOOLEAN
Definition: ntcore_c.h:51
@ NT_DOUBLE_ARRAY
Definition: ntcore_c.h:56
@ NT_STRING
Definition: ntcore_c.h:53
@ NT_FLOAT_ARRAY
Definition: ntcore_c.h:62
@ NT_INTEGER
Definition: ntcore_c.h:59
@ NT_BOOLEAN_ARRAY
Definition: ntcore_c.h:55
@ NT_FLOAT
Definition: ntcore_c.h:60
@ NT_STRING_ARRAY
Definition: ntcore_c.h:57
@ NT_INTEGER_ARRAY
Definition: ntcore_c.h:61
@ NT_UNASSIGNED
Definition: ntcore_c.h:50
@ NT_RAW
Definition: ntcore_c.h:54
::int64_t int64_t
Definition: Meta.h:59
::uint8_t uint8_t
Definition: Meta.h:52
NetworkTables (ntcore) namespace.
Definition: ntcore_cpp.h:35
bool operator==(const Value &lhs, const Value &rhs)
NetworkTables Entry Value.
Definition: ntcore_c.h:144
enum NT_Type type
Definition: ntcore_c.h:145
int64_t last_change
Definition: ntcore_c.h:146
int64_t server_time
Definition: ntcore_c.h:147
uint8_t * data
Definition: ntcore_c.h:155
Definition: format.h:1544