mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-07-02 02:51:42 +00:00
Add SaveEntries() and LoadEntries(). (#233)
These allow saving and loading non-persistent entries in the persistent file format.
This commit is contained in:
@@ -644,6 +644,25 @@ class NetworkTable final : public ITable {
|
||||
* @return The path (e.g "", "/foo").
|
||||
*/
|
||||
StringRef GetPath() const override;
|
||||
|
||||
/**
|
||||
* Save table values to a file. The file format used is identical to
|
||||
* that used for SavePersistent.
|
||||
* @param filename filename
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* SaveEntries(StringRef filename) const;
|
||||
|
||||
/**
|
||||
* Load table values from a file. The file format used is identical to
|
||||
* that used for SavePersistent / LoadPersistent.
|
||||
* @param filename filename
|
||||
* @param warn callback function for warnings
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* LoadEntries(
|
||||
StringRef filename,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
};
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
@@ -430,7 +430,7 @@ class NetworkTableInstance final {
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @defgroup PersistentFunctions Persistent Functions
|
||||
* @defgroup FileFunctions File Save/Load Functions
|
||||
* @{
|
||||
*/
|
||||
|
||||
@@ -455,6 +455,27 @@ class NetworkTableInstance final {
|
||||
StringRef filename,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
/**
|
||||
* Save table values to a file. The file format used is identical to
|
||||
* that used for SavePersistent.
|
||||
* @param filename filename
|
||||
* @param prefix save only keys starting with this prefix
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* SaveEntries(StringRef filename, StringRef prefix) const;
|
||||
|
||||
/**
|
||||
* Load table values from a file. The file format used is identical to
|
||||
* that used for SavePersistent / LoadPersistent.
|
||||
* @param filename filename
|
||||
* @param prefix load only keys starting with this prefix
|
||||
* @param warn callback function for warnings
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* LoadEntries(
|
||||
StringRef filename, StringRef prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
||||
@@ -157,6 +157,17 @@ inline const char* NetworkTableInstance::LoadPersistent(
|
||||
return ::nt::LoadPersistent(m_handle, filename, warn);
|
||||
}
|
||||
|
||||
inline const char* NetworkTableInstance::SaveEntries(
|
||||
StringRef filename, StringRef prefix) const {
|
||||
return ::nt::SaveEntries(m_handle, filename, prefix);
|
||||
}
|
||||
|
||||
inline const char* NetworkTableInstance::LoadEntries(
|
||||
StringRef filename, StringRef prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
return ::nt::LoadEntries(m_handle, filename, prefix, warn);
|
||||
}
|
||||
|
||||
inline NT_Logger NetworkTableInstance::AddLogger(
|
||||
std::function<void(const LogMessage& msg)> func, unsigned int min_level,
|
||||
unsigned int max_level) {
|
||||
|
||||
Reference in New Issue
Block a user