WPILibC++ 2024.3.2
nt::NetworkTable Class Referencefinal

A network table that knows its subtable path. More...

#include <networktables/NetworkTable.h>

Public Types

using TableEventListener = std::function< void(NetworkTable *table, std::string_view key, const Event &event)>
 Called when an event occurs on a topic in a NetworkTable. More...
 
using SubTableListener = std::function< void(NetworkTable *parent, std::string_view name, std::shared_ptr< NetworkTable > table)>
 Called when a new table is created within a NetworkTable. More...
 

Public Member Functions

 NetworkTable (NT_Inst inst, std::string_view path, const private_init &)
 Constructor. More...
 
 ~NetworkTable ()
 
NetworkTableInstance GetInstance () const
 Gets the instance for the table. More...
 
NetworkTableEntry GetEntry (std::string_view key) const
 Gets the entry for a subkey. More...
 
Topic GetTopic (std::string_view name) const
 Get (generic) topic. More...
 
BooleanTopic GetBooleanTopic (std::string_view name) const
 Get boolean topic. More...
 
IntegerTopic GetIntegerTopic (std::string_view name) const
 Get integer topic. More...
 
FloatTopic GetFloatTopic (std::string_view name) const
 Get float topic. More...
 
DoubleTopic GetDoubleTopic (std::string_view name) const
 Get double topic. More...
 
StringTopic GetStringTopic (std::string_view name) const
 Get String topic. More...
 
RawTopic GetRawTopic (std::string_view name) const
 Get raw topic. More...
 
BooleanArrayTopic GetBooleanArrayTopic (std::string_view name) const
 Get boolean[] topic. More...
 
IntegerArrayTopic GetIntegerArrayTopic (std::string_view name) const
 Get integer[] topic. More...
 
FloatArrayTopic GetFloatArrayTopic (std::string_view name) const
 Get float[] topic. More...
 
DoubleArrayTopic GetDoubleArrayTopic (std::string_view name) const
 Get double[] topic. More...
 
StringArrayTopic GetStringArrayTopic (std::string_view name) const
 Get String[] topic. More...
 
template<wpi::ProtobufSerializable T>
ProtobufTopic< T > GetProtobufTopic (std::string_view name) const
 Gets a protobuf serialized value topic. More...
 
template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
StructTopic< T, I... > GetStructTopic (std::string_view name, I... info) const
 Gets a raw struct serialized value topic. More...
 
template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
StructArrayTopic< T, I... > GetStructArrayTopic (std::string_view name, I... info) const
 Gets a raw struct serialized array topic. More...
 
std::shared_ptr< NetworkTableGetSubTable (std::string_view key) const
 Returns the table at the specified key. More...
 
bool ContainsKey (std::string_view key) const
 Determines whether the given key is in this table. More...
 
bool ContainsSubTable (std::string_view key) const
 Determines whether there exists a non-empty subtable for this key in this table. More...
 
std::vector< TopicInfoGetTopicInfo (int types=0) const
 Gets topic information for all keys in the table (not including sub-tables). More...
 
std::vector< TopicGetTopics (int types=0) const
 Gets all topics in the table (not including sub-tables). More...
 
std::vector< std::string > GetKeys (int types=0) const
 Gets all keys in the table (not including sub-tables). More...
 
std::vector< std::string > GetSubTables () const
 Gets the names of all subtables in the table. More...
 
void SetPersistent (std::string_view key)
 Makes a key's value persistent through program restarts. More...
 
void ClearPersistent (std::string_view key)
 Stop making a key's value persistent through program restarts. More...
 
bool IsPersistent (std::string_view key) const
 Returns whether the value is persistent through program restarts. More...
 
bool PutNumber (std::string_view key, double value)
 Put a number in the table. More...
 
bool SetDefaultNumber (std::string_view key, double defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
double GetNumber (std::string_view key, double defaultValue) const
 Gets the number associated with the given name. More...
 
bool PutString (std::string_view key, std::string_view value)
 Put a string in the table. More...
 
bool SetDefaultString (std::string_view key, std::string_view defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
std::string GetString (std::string_view key, std::string_view defaultValue) const
 Gets the string associated with the given name. More...
 
bool PutBoolean (std::string_view key, bool value)
 Put a boolean in the table. More...
 
bool SetDefaultBoolean (std::string_view key, bool defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
bool GetBoolean (std::string_view key, bool defaultValue) const
 Gets the boolean associated with the given name. More...
 
bool PutBooleanArray (std::string_view key, std::span< const int > value)
 Put a boolean array in the table. More...
 
bool SetDefaultBooleanArray (std::string_view key, std::span< const int > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
std::vector< int > GetBooleanArray (std::string_view key, std::span< const int > defaultValue) const
 Returns the boolean array the key maps to. More...
 
bool PutNumberArray (std::string_view key, std::span< const double > value)
 Put a number array in the table. More...
 
bool SetDefaultNumberArray (std::string_view key, std::span< const double > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
std::vector< double > GetNumberArray (std::string_view key, std::span< const double > defaultValue) const
 Returns the number array the key maps to. More...
 
bool PutStringArray (std::string_view key, std::span< const std::string > value)
 Put a string array in the table. More...
 
bool SetDefaultStringArray (std::string_view key, std::span< const std::string > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
std::vector< std::string > GetStringArray (std::string_view key, std::span< const std::string > defaultValue) const
 Returns the string array the key maps to. More...
 
bool PutRaw (std::string_view key, std::span< const uint8_t > value)
 Put a raw value (byte array) in the table. More...
 
bool SetDefaultRaw (std::string_view key, std::span< const uint8_t > defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
std::vector< uint8_t > GetRaw (std::string_view key, std::span< const uint8_t > defaultValue) const
 Returns the raw value (byte array) the key maps to. More...
 
bool PutValue (std::string_view key, const Value &value)
 Put a value in the table. More...
 
bool SetDefaultValue (std::string_view key, const Value &defaultValue)
 Gets the current value in the table, setting it if it does not exist. More...
 
Value GetValue (std::string_view key) const
 Gets the value associated with a key as an object. More...
 
std::string_view GetPath () const
 Gets the full path of this table. More...
 
NT_Listener AddListener (int eventMask, TableEventListener listener)
 Listen to topics only within this table. More...
 
NT_Listener AddListener (std::string_view key, int eventMask, TableEventListener listener)
 Listen to a single key. More...
 
NT_Listener AddSubTableListener (SubTableListener listener)
 Listen for sub-table creation. More...
 
void RemoveListener (NT_Listener listener)
 Remove a listener. More...
 

Static Public Member Functions

static std::string_view BasenameKey (std::string_view key)
 Gets the "base name" of a key. More...
 
static std::string NormalizeKey (std::string_view key, bool withLeadingSlash=true)
 Normalizes an network table key to contain no consecutive slashes and optionally start with a leading slash. More...
 
static std::string_view NormalizeKey (std::string_view key, wpi::SmallVectorImpl< char > &buf, bool withLeadingSlash=true)
 
static std::vector< std::string > GetHierarchy (std::string_view key)
 Gets a list of the names of all the super tables of a given key. More...
 

Static Public Attributes

static constexpr char PATH_SEPARATOR_CHAR = '/'
 The path separator for sub-tables and keys. More...
 

Friends

class NetworkTableInstance
 

Detailed Description

A network table that knows its subtable path.

Member Typedef Documentation

◆ SubTableListener

using nt::NetworkTable::SubTableListener = std::function<void(NetworkTable* parent, std::string_view name, std::shared_ptr<NetworkTable> table)>

Called when a new table is created within a NetworkTable.

Parameters
parentthe parent of the table
namethe name of the new table
tablethe new table

◆ TableEventListener

using nt::NetworkTable::TableEventListener = std::function<void( NetworkTable* table, std::string_view key, const Event& event)>

Called when an event occurs on a topic in a NetworkTable.

Parameters
tablethe table the topic exists in
keythe key associated with the topic that changed
eventthe event

Constructor & Destructor Documentation

◆ NetworkTable()

nt::NetworkTable::NetworkTable ( NT_Inst  inst,
std::string_view  path,
const private_init &   
)

Constructor.

Use NetworkTableInstance::GetTable() or GetSubTable() instead.

◆ ~NetworkTable()

nt::NetworkTable::~NetworkTable ( )

Member Function Documentation

◆ AddListener() [1/2]

NT_Listener nt::NetworkTable::AddListener ( int  eventMask,
TableEventListener  listener 
)

Listen to topics only within this table.

Parameters
eventMaskBitmask of EventFlags values
listenerlistener to add
Returns
Listener handle

◆ AddListener() [2/2]

NT_Listener nt::NetworkTable::AddListener ( std::string_view  key,
int  eventMask,
TableEventListener  listener 
)

Listen to a single key.

Parameters
keythe key name
eventMaskBitmask of EventFlags values
listenerlistener to add
Returns
Listener handle

◆ AddSubTableListener()

NT_Listener nt::NetworkTable::AddSubTableListener ( SubTableListener  listener)

Listen for sub-table creation.

This calls the listener once for each newly created sub-table. It immediately calls the listener for any existing sub-tables.

Parameters
listenerlistener to add
Returns
Listener handle

◆ BasenameKey()

static std::string_view nt::NetworkTable::BasenameKey ( std::string_view  key)
static

Gets the "base name" of a key.

For example, "/foo/bar" becomes "bar". If the key has a trailing slash, returns an empty string.

Parameters
keykey
Returns
base name

◆ ClearPersistent()

void nt::NetworkTable::ClearPersistent ( std::string_view  key)

Stop making a key's value persistent through program restarts.

The key cannot be null.

Parameters
keythe key name

◆ ContainsKey()

bool nt::NetworkTable::ContainsKey ( std::string_view  key) const

Determines whether the given key is in this table.

Parameters
keythe key to search for
Returns
true if the table as a value assigned to the given key

◆ ContainsSubTable()

bool nt::NetworkTable::ContainsSubTable ( std::string_view  key) const

Determines whether there exists a non-empty subtable for this key in this table.

Parameters
keythe key to search for
Returns
true if there is a subtable with the key which contains at least one key/subtable of its own

◆ GetBoolean()

bool nt::NetworkTable::GetBoolean ( std::string_view  key,
bool  defaultValue 
) const

Gets the boolean associated with the given name.

If the key does not exist or is of different type, it will return the default value.

Parameters
keythe key to look up
defaultValuethe value to be returned if no value is found
Returns
the value associated with the given key or the given default value if there is no value associated with the key

◆ GetBooleanArray()

std::vector< int > nt::NetworkTable::GetBooleanArray ( std::string_view  key,
std::span< const int >  defaultValue 
) const

Returns the boolean array the key maps to.

If the key does not exist or is of different type, it will return the default value.

Parameters
keythe key to look up
defaultValuethe value to be returned if no value is found
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.
The returned array is std::vector<int> instead of std::vector<bool> because std::vector<bool> is special-cased in C++. 0 is false, any non-zero value is true.

◆ GetBooleanArrayTopic()

BooleanArrayTopic nt::NetworkTable::GetBooleanArrayTopic ( std::string_view  name) const

Get boolean[] topic.

Parameters
nametopic name
Returns
BooleanArrayTopic

◆ GetBooleanTopic()

BooleanTopic nt::NetworkTable::GetBooleanTopic ( std::string_view  name) const

Get boolean topic.

Parameters
nametopic name
Returns
BooleanTopic

◆ GetDoubleArrayTopic()

DoubleArrayTopic nt::NetworkTable::GetDoubleArrayTopic ( std::string_view  name) const

Get double[] topic.

Parameters
nametopic name
Returns
DoubleArrayTopic

◆ GetDoubleTopic()

DoubleTopic nt::NetworkTable::GetDoubleTopic ( std::string_view  name) const

Get double topic.

Parameters
nametopic name
Returns
DoubleTopic

◆ GetEntry()

NetworkTableEntry nt::NetworkTable::GetEntry ( std::string_view  key) const

Gets the entry for a subkey.

Parameters
keythe key name
Returns
Network table entry.

◆ GetFloatArrayTopic()

FloatArrayTopic nt::NetworkTable::GetFloatArrayTopic ( std::string_view  name) const

Get float[] topic.

Parameters
nametopic name
Returns
FloatArrayTopic

◆ GetFloatTopic()

FloatTopic nt::NetworkTable::GetFloatTopic ( std::string_view  name) const

Get float topic.

Parameters
nametopic name
Returns
FloatTopic

◆ GetHierarchy()

static std::vector< std::string > nt::NetworkTable::GetHierarchy ( std::string_view  key)
static

Gets a list of the names of all the super tables of a given key.

For example, the key "/foo/bar/baz" has a hierarchy of "/", "/foo", "/foo/bar", and "/foo/bar/baz".

Parameters
keythe key
Returns
List of super tables

◆ GetInstance()

NetworkTableInstance nt::NetworkTable::GetInstance ( ) const

Gets the instance for the table.

Returns
Instance

◆ GetIntegerArrayTopic()

IntegerArrayTopic nt::NetworkTable::GetIntegerArrayTopic ( std::string_view  name) const

Get integer[] topic.

Parameters
nametopic name
Returns
IntegerArrayTopic

◆ GetIntegerTopic()

IntegerTopic nt::NetworkTable::GetIntegerTopic ( std::string_view  name) const

Get integer topic.

Parameters
nametopic name
Returns
IntegerTopic

◆ GetKeys()

std::vector< std::string > nt::NetworkTable::GetKeys ( int  types = 0) const

Gets all keys in the table (not including sub-tables).

Parameters
typesbitmask of types; 0 is treated as a "don't care".
Returns
keys currently in the table

◆ GetNumber()

double nt::NetworkTable::GetNumber ( std::string_view  key,
double  defaultValue 
) const

Gets the number associated with the given name.

Parameters
keythe key to look up
defaultValuethe value to be returned if no value is found
Returns
the value associated with the given key or the given default value if there is no value associated with the key

◆ GetNumberArray()

std::vector< double > nt::NetworkTable::GetNumberArray ( std::string_view  key,
std::span< const double >  defaultValue 
) const

Returns the number array the key maps to.

If the key does not exist or is of different type, it will return the default value.

Parameters
keythe key to look up
defaultValuethe value to be returned if no value is found
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

◆ GetPath()

std::string_view nt::NetworkTable::GetPath ( ) const

Gets the full path of this table.

Does not include the trailing "/".

Returns
The path (e.g "", "/foo").

◆ GetProtobufTopic()

ProtobufTopic< T > nt::NetworkTable::GetProtobufTopic ( std::string_view  name) const
inline

Gets a protobuf serialized value topic.

Parameters
nametopic name
Returns
Topic

◆ GetRaw()

std::vector< uint8_t > nt::NetworkTable::GetRaw ( std::string_view  key,
std::span< const uint8_t >  defaultValue 
) const

Returns the raw value (byte array) the key maps to.

If the key does not exist or is of different type, it will return the default value.

Parameters
keythe key to look up
defaultValuethe value to be returned if no value is found
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the raw contents. If the overhead of this is a concern, use GetValue() instead.

◆ GetRawTopic()

RawTopic nt::NetworkTable::GetRawTopic ( std::string_view  name) const

Get raw topic.

Parameters
nametopic name
Returns
BooleanArrayTopic

◆ GetString()

std::string nt::NetworkTable::GetString ( std::string_view  key,
std::string_view  defaultValue 
) const

Gets the string associated with the given name.

If the key does not exist or is of different type, it will return the default value.

Parameters
keythe key to look up
defaultValuethe value to be returned if no value is found
Returns
the value associated with the given key or the given default value if there is no value associated with the key

◆ GetStringArray()

std::vector< std::string > nt::NetworkTable::GetStringArray ( std::string_view  key,
std::span< const std::string >  defaultValue 
) const

Returns the string array the key maps to.

If the key does not exist or is of different type, it will return the default value.

Parameters
keythe key to look up
defaultValuethe value to be returned if no value is found
Returns
the value associated with the given key or the given default value if there is no value associated with the key
Note
This makes a copy of the array. If the overhead of this is a concern, use GetValue() instead.

◆ GetStringArrayTopic()

StringArrayTopic nt::NetworkTable::GetStringArrayTopic ( std::string_view  name) const

Get String[] topic.

Parameters
nametopic name
Returns
StringArrayTopic

◆ GetStringTopic()

StringTopic nt::NetworkTable::GetStringTopic ( std::string_view  name) const

Get String topic.

Parameters
nametopic name
Returns
StringTopic

◆ GetStructArrayTopic()

template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
StructArrayTopic< T, I... > nt::NetworkTable::GetStructArrayTopic ( std::string_view  name,
I...  info 
) const
inline

Gets a raw struct serialized array topic.

Parameters
nametopic name
infooptional struct type info
Returns
Topic

◆ GetStructTopic()

template<typename T , typename... I>
requires wpi::StructSerializable<T, I...>
StructTopic< T, I... > nt::NetworkTable::GetStructTopic ( std::string_view  name,
I...  info 
) const
inline

Gets a raw struct serialized value topic.

Parameters
nametopic name
infooptional struct type info
Returns
Topic

◆ GetSubTable()

std::shared_ptr< NetworkTable > nt::NetworkTable::GetSubTable ( std::string_view  key) const

Returns the table at the specified key.

If there is no table at the specified key, it will create a new table

Parameters
keythe key name
Returns
the networktable to be returned

◆ GetSubTables()

std::vector< std::string > nt::NetworkTable::GetSubTables ( ) const

Gets the names of all subtables in the table.

Returns
subtables currently in the table

◆ GetTopic()

Topic nt::NetworkTable::GetTopic ( std::string_view  name) const

Get (generic) topic.

Parameters
nametopic name
Returns
Topic

◆ GetTopicInfo()

std::vector< TopicInfo > nt::NetworkTable::GetTopicInfo ( int  types = 0) const

Gets topic information for all keys in the table (not including sub-tables).

Parameters
typesbitmask of types; 0 is treated as a "don't care".
Returns
topic information for keys currently in the table

◆ GetTopics()

std::vector< Topic > nt::NetworkTable::GetTopics ( int  types = 0) const

Gets all topics in the table (not including sub-tables).

Parameters
typesbitmask of types; 0 is treated as a "don't care".
Returns
topic for keys currently in the table

◆ GetValue()

Value nt::NetworkTable::GetValue ( std::string_view  key) const

Gets the value associated with a key as an object.

Parameters
keythe key of the value to look up
Returns
the value associated with the given key, or nullptr if the key does not exist

◆ IsPersistent()

bool nt::NetworkTable::IsPersistent ( std::string_view  key) const

Returns whether the value is persistent through program restarts.

The key cannot be null.

Parameters
keythe key name

◆ NormalizeKey() [1/2]

static std::string nt::NetworkTable::NormalizeKey ( std::string_view  key,
bool  withLeadingSlash = true 
)
static

Normalizes an network table key to contain no consecutive slashes and optionally start with a leading slash.

For example:


normalizeKey("/foo/bar", true)  == "/foo/bar"
normalizeKey("foo/bar", true)   == "/foo/bar"
normalizeKey("/foo/bar", false) == "foo/bar"
normalizeKey("foo//bar", false) == "foo/bar"
Parameters
keythe key to normalize
withLeadingSlashwhether or not the normalized key should begin with a leading slash
Returns
normalized key

◆ NormalizeKey() [2/2]

static std::string_view nt::NetworkTable::NormalizeKey ( std::string_view  key,
wpi::SmallVectorImpl< char > &  buf,
bool  withLeadingSlash = true 
)
static

◆ PutBoolean()

bool nt::NetworkTable::PutBoolean ( std::string_view  key,
bool  value 
)

Put a boolean in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type

◆ PutBooleanArray()

bool nt::NetworkTable::PutBooleanArray ( std::string_view  key,
std::span< const int >  value 
)

Put a boolean array in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type
Note
The array must be of int's rather than of bool's because std::vector<bool> is special-cased in C++. 0 is false, any non-zero value is true.

◆ PutNumber()

bool nt::NetworkTable::PutNumber ( std::string_view  key,
double  value 
)

Put a number in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type

◆ PutNumberArray()

bool nt::NetworkTable::PutNumberArray ( std::string_view  key,
std::span< const double >  value 
)

Put a number array in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type

◆ PutRaw()

bool nt::NetworkTable::PutRaw ( std::string_view  key,
std::span< const uint8_t >  value 
)

Put a raw value (byte array) in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type

◆ PutString()

bool nt::NetworkTable::PutString ( std::string_view  key,
std::string_view  value 
)

Put a string in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type

◆ PutStringArray()

bool nt::NetworkTable::PutStringArray ( std::string_view  key,
std::span< const std::string >  value 
)

Put a string array in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type

◆ PutValue()

bool nt::NetworkTable::PutValue ( std::string_view  key,
const Value value 
)

Put a value in the table.

Parameters
keythe key to be assigned to
valuethe value that will be assigned
Returns
False if the table key already exists with a different type

◆ RemoveListener()

void nt::NetworkTable::RemoveListener ( NT_Listener  listener)

Remove a listener.

Parameters
listenerlistener handle

◆ SetDefaultBoolean()

bool nt::NetworkTable::SetDefaultBoolean ( std::string_view  key,
bool  defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultBooleanArray()

bool nt::NetworkTable::SetDefaultBooleanArray ( std::string_view  key,
std::span< const int >  defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultNumber()

bool nt::NetworkTable::SetDefaultNumber ( std::string_view  key,
double  defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultNumberArray()

bool nt::NetworkTable::SetDefaultNumberArray ( std::string_view  key,
std::span< const double >  defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultRaw()

bool nt::NetworkTable::SetDefaultRaw ( std::string_view  key,
std::span< const uint8_t >  defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultString()

bool nt::NetworkTable::SetDefaultString ( std::string_view  key,
std::string_view  defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultStringArray()

bool nt::NetworkTable::SetDefaultStringArray ( std::string_view  key,
std::span< const std::string >  defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetDefaultValue()

bool nt::NetworkTable::SetDefaultValue ( std::string_view  key,
const Value defaultValue 
)

Gets the current value in the table, setting it if it does not exist.

Parameters
keythe key
defaultValuethe default value to set if key doesn't exist.
Returns
False if the table key exists with a different type

◆ SetPersistent()

void nt::NetworkTable::SetPersistent ( std::string_view  key)

Makes a key's value persistent through program restarts.

Parameters
keythe key to make persistent

Friends And Related Function Documentation

◆ NetworkTableInstance

friend class NetworkTableInstance
friend

Member Data Documentation

◆ PATH_SEPARATOR_CHAR

constexpr char nt::NetworkTable::PATH_SEPARATOR_CHAR = '/'
staticconstexpr

The path separator for sub-tables and keys.


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