mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
StorageEntry: Make data public, remove accessors.
Also add id and seq_num fields.
This commit is contained in:
@@ -65,7 +65,7 @@ void Storage::SavePersistent(std::ostream& os) const {
|
||||
if (!entry.IsPersistent()) continue;
|
||||
|
||||
// type
|
||||
auto v = entry.value();
|
||||
auto v = entry.value;
|
||||
if (!v) continue;
|
||||
switch (v->type()) {
|
||||
case NT_BOOLEAN:
|
||||
@@ -313,9 +313,9 @@ bool Storage::LoadPersistent(
|
||||
case NT_BOOLEAN:
|
||||
// only true or false is accepted
|
||||
if (line == "true")
|
||||
entry.set_value(Value::MakeBoolean(true));
|
||||
entry.value = Value::MakeBoolean(true);
|
||||
else if (line == "false")
|
||||
entry.set_value(Value::MakeBoolean(false));
|
||||
entry.value = Value::MakeBoolean(false);
|
||||
else {
|
||||
if (warn)
|
||||
warn(line_num, "unrecognized boolean value, not 'true' or 'false'");
|
||||
@@ -332,7 +332,7 @@ bool Storage::LoadPersistent(
|
||||
if (warn) warn(line_num, "invalid double value");
|
||||
goto next_line;
|
||||
}
|
||||
entry.set_value(Value::MakeDouble(v));
|
||||
entry.value = Value::MakeDouble(v);
|
||||
break;
|
||||
}
|
||||
case NT_STRING: {
|
||||
@@ -347,12 +347,12 @@ bool Storage::LoadPersistent(
|
||||
goto next_line;
|
||||
}
|
||||
UnescapeString(str_tok, &str);
|
||||
entry.set_value(Value::MakeString(std::move(str)));
|
||||
entry.value = Value::MakeString(std::move(str));
|
||||
break;
|
||||
}
|
||||
case NT_RAW:
|
||||
Base64Decode(line, &str);
|
||||
entry.set_value(Value::MakeRaw(std::move(str)));
|
||||
entry.value = Value::MakeRaw(std::move(str));
|
||||
break;
|
||||
case NT_BOOLEAN_ARRAY: {
|
||||
llvm::StringRef elem_tok;
|
||||
@@ -372,7 +372,7 @@ bool Storage::LoadPersistent(
|
||||
}
|
||||
}
|
||||
|
||||
entry.set_value(Value::MakeBooleanArray(std::move(boolean_array)));
|
||||
entry.value = Value::MakeBooleanArray(std::move(boolean_array));
|
||||
break;
|
||||
}
|
||||
case NT_DOUBLE_ARRAY: {
|
||||
@@ -393,7 +393,7 @@ bool Storage::LoadPersistent(
|
||||
double_array.push_back(v);
|
||||
}
|
||||
|
||||
entry.set_value(Value::MakeDoubleArray(std::move(double_array)));
|
||||
entry.value = Value::MakeDoubleArray(std::move(double_array));
|
||||
break;
|
||||
}
|
||||
case NT_STRING_ARRAY: {
|
||||
@@ -421,7 +421,7 @@ bool Storage::LoadPersistent(
|
||||
string_array.push_back(std::move(str));
|
||||
}
|
||||
|
||||
entry.set_value(Value::MakeStringArray(std::move(string_array)));
|
||||
entry.value = Value::MakeStringArray(std::move(string_array));
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
||||
@@ -15,27 +15,20 @@
|
||||
|
||||
#include "llvm/StringMap.h"
|
||||
#include "nt_Value.h"
|
||||
#include "SequenceNumber.h"
|
||||
|
||||
namespace nt {
|
||||
|
||||
class StorageEntry {
|
||||
public:
|
||||
StorageEntry() : m_flags(0) {}
|
||||
StorageEntry() : id(0xffff), flags(0) {}
|
||||
|
||||
std::shared_ptr<Value> value() const { return m_value; }
|
||||
void set_value(std::shared_ptr<Value> value) { m_value = value; }
|
||||
bool IsPersistent() const { return (flags & NT_PERSISTENT) != 0; }
|
||||
|
||||
unsigned int flags() const { return m_flags; }
|
||||
void set_flags(unsigned int flags) { m_flags = flags; }
|
||||
|
||||
bool IsPersistent() const { return (m_flags & NT_PERSISTENT) != 0; }
|
||||
|
||||
StorageEntry(const StorageEntry&) = delete;
|
||||
StorageEntry& operator=(const StorageEntry&) = delete;
|
||||
|
||||
private:
|
||||
std::shared_ptr<Value> m_value;
|
||||
unsigned int m_flags;
|
||||
std::shared_ptr<Value> value;
|
||||
unsigned int id;
|
||||
unsigned int flags;
|
||||
SequenceNumber seq_num;
|
||||
};
|
||||
|
||||
class Storage {
|
||||
|
||||
Reference in New Issue
Block a user