WPILibC++ 2024.3.1
nt::Value Class Referencefinal

A network table entry value. More...

#include <networktables/NetworkTableValue.h>

Public Member Functions

 Value ()
 
 Value (NT_Type type, size_t size, int64_t time, const private_init &)
 
 Value (NT_Type type, size_t size, int64_t time, int64_t serverTime, const private_init &)
 
 operator bool () const
 
NT_Type type () const
 Get the data type. More...
 
const NT_Valuevalue () const
 Get the data value stored. More...
 
int64_t last_change () const
 Get the creation time of the value, in local time. More...
 
int64_t time () const
 Get the creation time of the value, in local time. More...
 
size_t size () const
 Get the approximate in-memory size of the value in bytes. More...
 
void SetTime (int64_t time)
 Set the local creation time of the value. More...
 
int64_t server_time () const
 Get the creation time of the value, in server time. More...
 
void SetServerTime (int64_t time)
 Set the creation time of the value, in server time. More...
 
Type Checkers
bool IsValid () const
 Determine if entry value contains a value or is unassigned. More...
 
bool IsBoolean () const
 Determine if entry value contains a boolean. More...
 
bool IsInteger () const
 Determine if entry value contains an integer. More...
 
bool IsFloat () const
 Determine if entry value contains a float. More...
 
bool IsDouble () const
 Determine if entry value contains a double. More...
 
bool IsString () const
 Determine if entry value contains a string. More...
 
bool IsRaw () const
 Determine if entry value contains a raw. More...
 
bool IsBooleanArray () const
 Determine if entry value contains a boolean array. More...
 
bool IsIntegerArray () const
 Determine if entry value contains an integer array. More...
 
bool IsFloatArray () const
 Determine if entry value contains a float array. More...
 
bool IsDoubleArray () const
 Determine if entry value contains a double array. More...
 
bool IsStringArray () const
 Determine if entry value contains a string array. More...
 
Type-Safe Getters
bool GetBoolean () const
 Get the entry's boolean value. More...
 
int64_t GetInteger () const
 Get the entry's integer value. More...
 
float GetFloat () const
 Get the entry's float value. More...
 
double GetDouble () const
 Get the entry's double value. More...
 
std::string_view GetString () const
 Get the entry's string value. More...
 
std::span< const uint8_t > GetRaw () const
 Get the entry's raw value. More...
 
std::span< const int > GetBooleanArray () const
 Get the entry's boolean array value. More...
 
std::span< const int64_t > GetIntegerArray () const
 Get the entry's integer array value. More...
 
std::span< const float > GetFloatArray () const
 Get the entry's float array value. More...
 
std::span< const double > GetDoubleArray () const
 Get the entry's double array value. More...
 
std::span< const std::string > GetStringArray () const
 Get the entry's string array value. More...
 

Static Public Member Functions

Factory functions
static Value MakeBoolean (bool value, int64_t time=0)
 Creates a boolean entry value. More...
 
static Value MakeInteger (int64_t value, int64_t time=0)
 Creates an integer entry value. More...
 
static Value MakeFloat (float value, int64_t time=0)
 Creates a float entry value. More...
 
static Value MakeDouble (double value, int64_t time=0)
 Creates a double entry value. More...
 
static Value MakeString (std::string_view value, int64_t time=0)
 Creates a string entry value. More...
 
template<std::same_as< std::string > T>
static Value MakeString (T &&value, int64_t time=0)
 Creates a string entry value. More...
 
static Value MakeRaw (std::span< const uint8_t > value, int64_t time=0)
 Creates a raw entry value. More...
 
template<std::same_as< std::vector< uint8_t > > T>
static Value MakeRaw (T &&value, int64_t time=0)
 Creates a raw entry value. More...
 
static Value MakeBooleanArray (std::span< const bool > value, int64_t time=0)
 Creates a boolean array entry value. More...
 
static Value MakeBooleanArray (std::initializer_list< bool > value, int64_t time=0)
 Creates a boolean array entry value. More...
 
static Value MakeBooleanArray (std::span< const int > value, int64_t time=0)
 Creates a boolean array entry value. More...
 
static Value MakeBooleanArray (std::initializer_list< int > value, int64_t time=0)
 Creates a boolean array entry value. More...
 
static Value MakeBooleanArray (std::vector< int > &&value, int64_t time=0)
 Creates a boolean array entry value. More...
 
static Value MakeIntegerArray (std::span< const int64_t > value, int64_t time=0)
 Creates an integer array entry value. More...
 
static Value MakeIntegerArray (std::initializer_list< int64_t > value, int64_t time=0)
 Creates an integer array entry value. More...
 
static Value MakeIntegerArray (std::vector< int64_t > &&value, int64_t time=0)
 Creates an integer array entry value. More...
 
static Value MakeFloatArray (std::span< const float > value, int64_t time=0)
 Creates a float array entry value. More...
 
static Value MakeFloatArray (std::initializer_list< float > value, int64_t time=0)
 Creates a float array entry value. More...
 
static Value MakeFloatArray (std::vector< float > &&value, int64_t time=0)
 Creates a float array entry value. More...
 
static Value MakeDoubleArray (std::span< const double > value, int64_t time=0)
 Creates a double array entry value. More...
 
static Value MakeDoubleArray (std::initializer_list< double > value, int64_t time=0)
 Creates a double array entry value. More...
 
static Value MakeDoubleArray (std::vector< double > &&value, int64_t time=0)
 Creates a double array entry value. More...
 
static Value MakeStringArray (std::span< const std::string > value, int64_t time=0)
 Creates a string array entry value. More...
 
static Value MakeStringArray (std::initializer_list< std::string > value, int64_t time=0)
 Creates a string array entry value. More...
 
static Value MakeStringArray (std::vector< std::string > &&value, int64_t time=0)
 Creates a string array entry value. More...
 

Friends

bool operator== (const Value &lhs, const Value &rhs)
 

Detailed Description

A network table entry value.

Constructor & Destructor Documentation

◆ Value() [1/3]

nt::Value::Value ( )

◆ Value() [2/3]

nt::Value::Value ( NT_Type  type,
size_t  size,
int64_t  time,
const private_init &   
)

◆ Value() [3/3]

nt::Value::Value ( NT_Type  type,
size_t  size,
int64_t  time,
int64_t  serverTime,
const private_init &   
)

Member Function Documentation

◆ GetBoolean()

bool nt::Value::GetBoolean ( ) const
inline

Get the entry's boolean value.

Returns
The boolean value.

◆ GetBooleanArray()

std::span< const int > nt::Value::GetBooleanArray ( ) const
inline

Get the entry's boolean array value.

Returns
The boolean array value.

◆ GetDouble()

double nt::Value::GetDouble ( ) const
inline

Get the entry's double value.

Returns
The double value.

◆ GetDoubleArray()

std::span< const double > nt::Value::GetDoubleArray ( ) const
inline

Get the entry's double array value.

Returns
The double array value.

◆ GetFloat()

float nt::Value::GetFloat ( ) const
inline

Get the entry's float value.

Returns
The float value.

◆ GetFloatArray()

std::span< const float > nt::Value::GetFloatArray ( ) const
inline

Get the entry's float array value.

Returns
The float array value.

◆ GetInteger()

int64_t nt::Value::GetInteger ( ) const
inline

Get the entry's integer value.

Returns
The integer value.

◆ GetIntegerArray()

std::span< const int64_t > nt::Value::GetIntegerArray ( ) const
inline

Get the entry's integer array value.

Returns
The integer array value.

◆ GetRaw()

std::span< const uint8_t > nt::Value::GetRaw ( ) const
inline

Get the entry's raw value.

Returns
The raw value.

◆ GetString()

std::string_view nt::Value::GetString ( ) const
inline

Get the entry's string value.

Returns
The string value.

◆ GetStringArray()

std::span< const std::string > nt::Value::GetStringArray ( ) const
inline

Get the entry's string array value.

Returns
The string array value.

◆ IsBoolean()

bool nt::Value::IsBoolean ( ) const
inline

Determine if entry value contains a boolean.

Returns
True if the entry value is of boolean type.

◆ IsBooleanArray()

bool nt::Value::IsBooleanArray ( ) const
inline

Determine if entry value contains a boolean array.

Returns
True if the entry value is of boolean array type.

◆ IsDouble()

bool nt::Value::IsDouble ( ) const
inline

Determine if entry value contains a double.

Returns
True if the entry value is of double type.

◆ IsDoubleArray()

bool nt::Value::IsDoubleArray ( ) const
inline

Determine if entry value contains a double array.

Returns
True if the entry value is of double array type.

◆ IsFloat()

bool nt::Value::IsFloat ( ) const
inline

Determine if entry value contains a float.

Returns
True if the entry value is of float type.

◆ IsFloatArray()

bool nt::Value::IsFloatArray ( ) const
inline

Determine if entry value contains a float array.

Returns
True if the entry value is of float array type.

◆ IsInteger()

bool nt::Value::IsInteger ( ) const
inline

Determine if entry value contains an integer.

Returns
True if the entry value is of integer type.

◆ IsIntegerArray()

bool nt::Value::IsIntegerArray ( ) const
inline

Determine if entry value contains an integer array.

Returns
True if the entry value is of integer array type.

◆ IsRaw()

bool nt::Value::IsRaw ( ) const
inline

Determine if entry value contains a raw.

Returns
True if the entry value is of raw type.

◆ IsString()

bool nt::Value::IsString ( ) const
inline

Determine if entry value contains a string.

Returns
True if the entry value is of string type.

◆ IsStringArray()

bool nt::Value::IsStringArray ( ) const
inline

Determine if entry value contains a string array.

Returns
True if the entry value is of string array type.

◆ IsValid()

bool nt::Value::IsValid ( ) const
inline

Determine if entry value contains a value or is unassigned.

Returns
True if the entry value contains a value.

◆ last_change()

int64_t nt::Value::last_change ( ) const
inline

Get the creation time of the value, in local time.

Returns
The time, in the units returned by nt::Now().

◆ MakeBoolean()

static Value nt::Value::MakeBoolean ( bool  value,
int64_t  time = 0 
)
inlinestatic

Creates a boolean entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeBooleanArray() [1/5]

static Value nt::Value::MakeBooleanArray ( std::initializer_list< bool >  value,
int64_t  time = 0 
)
inlinestatic

Creates a boolean array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeBooleanArray() [2/5]

static Value nt::Value::MakeBooleanArray ( std::initializer_list< int >  value,
int64_t  time = 0 
)
inlinestatic

Creates a boolean array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeBooleanArray() [3/5]

static Value nt::Value::MakeBooleanArray ( std::span< const bool >  value,
int64_t  time = 0 
)
static

Creates a boolean array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeBooleanArray() [4/5]

static Value nt::Value::MakeBooleanArray ( std::span< const int >  value,
int64_t  time = 0 
)
static

Creates a boolean array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeBooleanArray() [5/5]

static Value nt::Value::MakeBooleanArray ( std::vector< int > &&  value,
int64_t  time = 0 
)
static

Creates a boolean array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value
Note
This function moves the values out of the vector.

◆ MakeDouble()

static Value nt::Value::MakeDouble ( double  value,
int64_t  time = 0 
)
inlinestatic

Creates a double entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeDoubleArray() [1/3]

static Value nt::Value::MakeDoubleArray ( std::initializer_list< double >  value,
int64_t  time = 0 
)
inlinestatic

Creates a double array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeDoubleArray() [2/3]

static Value nt::Value::MakeDoubleArray ( std::span< const double >  value,
int64_t  time = 0 
)
static

Creates a double array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeDoubleArray() [3/3]

static Value nt::Value::MakeDoubleArray ( std::vector< double > &&  value,
int64_t  time = 0 
)
static

Creates a double array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value
Note
This function moves the values out of the vector.

◆ MakeFloat()

static Value nt::Value::MakeFloat ( float  value,
int64_t  time = 0 
)
inlinestatic

Creates a float entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeFloatArray() [1/3]

static Value nt::Value::MakeFloatArray ( std::initializer_list< float >  value,
int64_t  time = 0 
)
inlinestatic

Creates a float array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeFloatArray() [2/3]

static Value nt::Value::MakeFloatArray ( std::span< const float >  value,
int64_t  time = 0 
)
static

Creates a float array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeFloatArray() [3/3]

static Value nt::Value::MakeFloatArray ( std::vector< float > &&  value,
int64_t  time = 0 
)
static

Creates a float array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value
Note
This function moves the values out of the vector.

◆ MakeInteger()

static Value nt::Value::MakeInteger ( int64_t  value,
int64_t  time = 0 
)
inlinestatic

Creates an integer entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeIntegerArray() [1/3]

static Value nt::Value::MakeIntegerArray ( std::initializer_list< int64_t >  value,
int64_t  time = 0 
)
inlinestatic

Creates an integer array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeIntegerArray() [2/3]

static Value nt::Value::MakeIntegerArray ( std::span< const int64_t >  value,
int64_t  time = 0 
)
static

Creates an integer array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeIntegerArray() [3/3]

static Value nt::Value::MakeIntegerArray ( std::vector< int64_t > &&  value,
int64_t  time = 0 
)
static

Creates an integer array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value
Note
This function moves the values out of the vector.

◆ MakeRaw() [1/2]

static Value nt::Value::MakeRaw ( std::span< const uint8_t >  value,
int64_t  time = 0 
)
inlinestatic

Creates a raw entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeRaw() [2/2]

template<std::same_as< std::vector< uint8_t > > T>
static Value nt::Value::MakeRaw ( T &&  value,
int64_t  time = 0 
)
inlinestatic

Creates a raw entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeString() [1/2]

static Value nt::Value::MakeString ( std::string_view  value,
int64_t  time = 0 
)
inlinestatic

Creates a string entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeString() [2/2]

template<std::same_as< std::string > T>
static Value nt::Value::MakeString ( T &&  value,
int64_t  time = 0 
)
inlinestatic

Creates a string entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeStringArray() [1/3]

static Value nt::Value::MakeStringArray ( std::initializer_list< std::string >  value,
int64_t  time = 0 
)
inlinestatic

Creates a string array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeStringArray() [2/3]

static Value nt::Value::MakeStringArray ( std::span< const std::string >  value,
int64_t  time = 0 
)
static

Creates a string array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value

◆ MakeStringArray() [3/3]

static Value nt::Value::MakeStringArray ( std::vector< std::string > &&  value,
int64_t  time = 0 
)
static

Creates a string array entry value.

Parameters
valuethe value
timeif nonzero, the creation time to use (instead of the current time)
Returns
The entry value
Note
This function moves the values out of the vector.

◆ operator bool()

nt::Value::operator bool ( ) const
inlineexplicit

◆ server_time()

int64_t nt::Value::server_time ( ) const
inline

Get the creation time of the value, in server time.

Returns
The server time.

◆ SetServerTime()

void nt::Value::SetServerTime ( int64_t  time)
inline

Set the creation time of the value, in server time.

Parameters
timeThe server time.

◆ SetTime()

void nt::Value::SetTime ( int64_t  time)
inline

Set the local creation time of the value.

Parameters
timeThe time.

◆ size()

size_t nt::Value::size ( ) const
inline

Get the approximate in-memory size of the value in bytes.

This is zero for values that do not require additional memory beyond the memory of the Value itself.

Returns
The size in bytes.

◆ time()

int64_t nt::Value::time ( ) const
inline

Get the creation time of the value, in local time.

Returns
The time, in the units returned by nt::Now().

◆ type()

NT_Type nt::Value::type ( ) const
inline

Get the data type.

Returns
The type.

◆ value()

const NT_Value & nt::Value::value ( ) const
inline

Get the data value stored.

Returns
The type.

Friends And Related Function Documentation

◆ operator==

bool operator== ( const Value lhs,
const Value rhs 
)
friend

The documentation for this class was generated from the following file: