mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +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:
@@ -264,6 +264,27 @@ public final class NetworkTable {
|
||||
return path;
|
||||
}
|
||||
|
||||
/**
|
||||
* Save table values to a file. The file format used is identical to
|
||||
* that used for SavePersistent.
|
||||
* @param filename filename
|
||||
* @throws PersistentException if error saving file
|
||||
*/
|
||||
public void saveEntries(String filename) throws PersistentException {
|
||||
inst.saveEntries(filename, pathWithSep);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load table values from a file. The file format used is identical to
|
||||
* that used for SavePersistent / LoadPersistent.
|
||||
* @param filename filename
|
||||
* @return List of warnings (errors result in an exception instead)
|
||||
* @throws PersistentException if error saving file
|
||||
*/
|
||||
public String[] loadEntries(String filename) throws PersistentException {
|
||||
return inst.loadEntries(filename, pathWithSep);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (o == this) {
|
||||
|
||||
@@ -935,6 +935,29 @@ public final class NetworkTableInstance {
|
||||
return NetworkTablesJNI.loadPersistent(m_handle, filename);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @throws PersistentException if error saving file
|
||||
*/
|
||||
public void saveEntries(String filename, String prefix) throws PersistentException {
|
||||
NetworkTablesJNI.saveEntries(m_handle, filename, prefix);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
* @return List of warnings (errors result in an exception instead)
|
||||
* @throws PersistentException if error saving file
|
||||
*/
|
||||
public String[] loadEntries(String filename, String prefix) throws PersistentException {
|
||||
return NetworkTablesJNI.loadEntries(m_handle, filename, prefix);
|
||||
}
|
||||
|
||||
private final ReentrantLock m_loggerLock = new ReentrantLock();
|
||||
private final Map<Integer, Consumer<LogMessage>> m_loggers = new HashMap<>();
|
||||
private Thread m_loggerThread;
|
||||
|
||||
@@ -169,6 +169,9 @@ public final class NetworkTablesJNI {
|
||||
public static native void savePersistent(int inst, String filename) throws PersistentException;
|
||||
public static native String[] loadPersistent(int inst, String filename) throws PersistentException; // returns warnings
|
||||
|
||||
public static native void saveEntries(int inst, String filename, String prefix) throws PersistentException;
|
||||
public static native String[] loadEntries(int inst, String filename, String prefix) throws PersistentException; // returns warnings
|
||||
|
||||
public static native long now();
|
||||
|
||||
public static native int createLoggerPoller(int inst);
|
||||
|
||||
Reference in New Issue
Block a user