mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-23 01:21:42 +00:00
[ntcore] Remove "using wpi" from nt namespace
This removes the nt::ArrayRef, nt::StringRef, and nt::Twine aliases.
This commit is contained in:
@@ -18,9 +18,9 @@
|
||||
|
||||
using namespace nt;
|
||||
|
||||
void Dispatcher::StartServer(const Twine& persist_filename,
|
||||
void Dispatcher::StartServer(const wpi::Twine& persist_filename,
|
||||
const char* listen_address, unsigned int port) {
|
||||
std::string listen_address_copy(StringRef(listen_address).trim());
|
||||
std::string listen_address_copy(wpi::StringRef(listen_address).trim());
|
||||
DispatcherBase::StartServer(
|
||||
persist_filename,
|
||||
std::unique_ptr<wpi::NetworkAcceptor>(new wpi::TCPAcceptor(
|
||||
@@ -28,7 +28,7 @@ void Dispatcher::StartServer(const Twine& persist_filename,
|
||||
}
|
||||
|
||||
void Dispatcher::SetServer(const char* server_name, unsigned int port) {
|
||||
std::string server_name_copy(StringRef(server_name).trim());
|
||||
std::string server_name_copy(wpi::StringRef(server_name).trim());
|
||||
SetConnector([=]() -> std::unique_ptr<wpi::NetworkStream> {
|
||||
return wpi::TCPConnector::connect(server_name_copy.c_str(),
|
||||
static_cast<int>(port), m_logger, 1);
|
||||
@@ -36,7 +36,7 @@ void Dispatcher::SetServer(const char* server_name, unsigned int port) {
|
||||
}
|
||||
|
||||
void Dispatcher::SetServer(
|
||||
ArrayRef<std::pair<StringRef, unsigned int>> servers) {
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers) {
|
||||
wpi::SmallVector<std::pair<std::string, int>, 16> servers_copy;
|
||||
for (const auto& server : servers) {
|
||||
servers_copy.emplace_back(std::string{server.first.trim()},
|
||||
@@ -53,7 +53,7 @@ void Dispatcher::SetServer(
|
||||
}
|
||||
|
||||
void Dispatcher::SetServerTeam(unsigned int team, unsigned int port) {
|
||||
std::pair<StringRef, unsigned int> servers[5];
|
||||
std::pair<wpi::StringRef, unsigned int> servers[5];
|
||||
|
||||
// 10.te.am.2
|
||||
wpi::SmallString<32> fixed;
|
||||
@@ -95,7 +95,7 @@ void Dispatcher::SetServerTeam(unsigned int team, unsigned int port) {
|
||||
}
|
||||
|
||||
void Dispatcher::SetServerOverride(const char* server_name, unsigned int port) {
|
||||
std::string server_name_copy(StringRef(server_name).trim());
|
||||
std::string server_name_copy(wpi::StringRef(server_name).trim());
|
||||
SetConnectorOverride([=]() -> std::unique_ptr<wpi::NetworkStream> {
|
||||
return wpi::TCPConnector::connect(server_name_copy.c_str(),
|
||||
static_cast<int>(port), m_logger, 1);
|
||||
@@ -134,7 +134,7 @@ void DispatcherBase::StartLocal() {
|
||||
}
|
||||
|
||||
void DispatcherBase::StartServer(
|
||||
const Twine& persist_filename,
|
||||
const wpi::Twine& persist_filename,
|
||||
std::unique_ptr<wpi::NetworkAcceptor> acceptor) {
|
||||
{
|
||||
std::scoped_lock lock(m_user_mutex);
|
||||
@@ -230,7 +230,7 @@ void DispatcherBase::SetUpdateRate(double interval) {
|
||||
m_update_rate = static_cast<unsigned int>(interval * 1000);
|
||||
}
|
||||
|
||||
void DispatcherBase::SetIdentity(const Twine& name) {
|
||||
void DispatcherBase::SetIdentity(const wpi::Twine& name) {
|
||||
std::scoped_lock lock(m_user_mutex);
|
||||
m_identity = name.str();
|
||||
}
|
||||
|
||||
@@ -45,12 +45,12 @@ class DispatcherBase : public IDispatcher {
|
||||
|
||||
unsigned int GetNetworkMode() const;
|
||||
void StartLocal();
|
||||
void StartServer(const Twine& persist_filename,
|
||||
void StartServer(const wpi::Twine& persist_filename,
|
||||
std::unique_ptr<wpi::NetworkAcceptor> acceptor);
|
||||
void StartClient();
|
||||
void Stop();
|
||||
void SetUpdateRate(double interval);
|
||||
void SetIdentity(const Twine& name);
|
||||
void SetIdentity(const wpi::Twine& name);
|
||||
void Flush();
|
||||
std::vector<ConnectionInfo> GetConnections() const;
|
||||
bool IsConnected() const;
|
||||
@@ -132,11 +132,12 @@ class Dispatcher : public DispatcherBase {
|
||||
wpi::Logger& logger)
|
||||
: DispatcherBase(storage, notifier, logger) {}
|
||||
|
||||
void StartServer(const Twine& persist_filename, const char* listen_address,
|
||||
unsigned int port);
|
||||
void StartServer(const wpi::Twine& persist_filename,
|
||||
const char* listen_address, unsigned int port);
|
||||
|
||||
void SetServer(const char* server_name, unsigned int port);
|
||||
void SetServer(ArrayRef<std::pair<StringRef, unsigned int>> servers);
|
||||
void SetServer(
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers);
|
||||
void SetServerTeam(unsigned int team, unsigned int port);
|
||||
|
||||
void SetServerOverride(const char* server_name, unsigned int port);
|
||||
|
||||
@@ -59,7 +59,7 @@ bool impl::EntryNotifierThread::Matches(const EntryListenerData& listener,
|
||||
|
||||
unsigned int EntryNotifier::Add(
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
StringRef prefix, unsigned int flags) {
|
||||
wpi::StringRef prefix, unsigned int flags) {
|
||||
if ((flags & NT_NOTIFY_LOCAL) != 0) {
|
||||
m_local_notifiers = true;
|
||||
}
|
||||
@@ -93,7 +93,7 @@ unsigned int EntryNotifier::AddPolled(unsigned int poller_uid,
|
||||
return DoAdd(poller_uid, Handle(m_inst, local_id, Handle::kEntry), flags);
|
||||
}
|
||||
|
||||
void EntryNotifier::NotifyEntry(unsigned int local_id, StringRef name,
|
||||
void EntryNotifier::NotifyEntry(unsigned int local_id, wpi::StringRef name,
|
||||
std::shared_ptr<Value> value,
|
||||
unsigned int flags,
|
||||
unsigned int only_listener) {
|
||||
|
||||
@@ -29,13 +29,13 @@ struct EntryListenerData
|
||||
EntryListenerData() = default;
|
||||
EntryListenerData(
|
||||
std::function<void(const EntryNotification& event)> callback_,
|
||||
StringRef prefix_, unsigned int flags_)
|
||||
wpi::StringRef prefix_, unsigned int flags_)
|
||||
: CallbackListenerData(callback_), prefix(prefix_), flags(flags_) {}
|
||||
EntryListenerData(
|
||||
std::function<void(const EntryNotification& event)> callback_,
|
||||
NT_Entry entry_, unsigned int flags_)
|
||||
: CallbackListenerData(callback_), entry(entry_), flags(flags_) {}
|
||||
EntryListenerData(unsigned int poller_uid_, StringRef prefix_,
|
||||
EntryListenerData(unsigned int poller_uid_, wpi::StringRef prefix_,
|
||||
unsigned int flags_)
|
||||
: CallbackListenerData(poller_uid_), prefix(prefix_), flags(flags_) {}
|
||||
EntryListenerData(unsigned int poller_uid_, NT_Entry entry_,
|
||||
@@ -93,7 +93,7 @@ class EntryNotifier
|
||||
unsigned int AddPolled(unsigned int poller_uid, unsigned int local_id,
|
||||
unsigned int flags) override;
|
||||
|
||||
void NotifyEntry(unsigned int local_id, StringRef name,
|
||||
void NotifyEntry(unsigned int local_id, wpi::StringRef name,
|
||||
std::shared_ptr<Value> value, unsigned int flags,
|
||||
unsigned int only_listener = UINT_MAX) override;
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ class IEntryNotifier {
|
||||
virtual unsigned int AddPolled(unsigned int poller_uid, unsigned int local_id,
|
||||
unsigned int flags) = 0;
|
||||
|
||||
virtual void NotifyEntry(unsigned int local_id, StringRef name,
|
||||
virtual void NotifyEntry(unsigned int local_id, wpi::StringRef name,
|
||||
std::shared_ptr<Value> value, unsigned int flags,
|
||||
unsigned int only_listener = UINT_MAX) = 0;
|
||||
};
|
||||
|
||||
@@ -14,7 +14,7 @@ namespace nt {
|
||||
|
||||
class IRpcServer {
|
||||
public:
|
||||
typedef std::function<void(StringRef result)> SendResponseFunc;
|
||||
typedef std::function<void(wpi::StringRef result)> SendResponseFunc;
|
||||
|
||||
IRpcServer() = default;
|
||||
IRpcServer(const IRpcServer&) = delete;
|
||||
@@ -24,7 +24,7 @@ class IRpcServer {
|
||||
virtual void RemoveRpc(unsigned int rpc_uid) = 0;
|
||||
|
||||
virtual void ProcessRpc(unsigned int local_id, unsigned int call_uid,
|
||||
StringRef name, StringRef params,
|
||||
wpi::StringRef name, wpi::StringRef params,
|
||||
const ConnectionInfo& conn,
|
||||
SendResponseFunc send_response,
|
||||
unsigned int rpc_uid) = 0;
|
||||
|
||||
@@ -50,10 +50,10 @@ class IStorage {
|
||||
|
||||
// Filename-based save/load functions. Used both by periodic saves and
|
||||
// accessible directly via the user API.
|
||||
virtual const char* SavePersistent(const Twine& filename,
|
||||
virtual const char* SavePersistent(const wpi::Twine& filename,
|
||||
bool periodic) const = 0;
|
||||
virtual const char* LoadPersistent(
|
||||
const Twine& filename,
|
||||
const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn) = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -142,7 +142,7 @@ std::string NetworkConnection::remote_id() const {
|
||||
return m_remote_id;
|
||||
}
|
||||
|
||||
void NetworkConnection::set_remote_id(StringRef remote_id) {
|
||||
void NetworkConnection::set_remote_id(wpi::StringRef remote_id) {
|
||||
std::scoped_lock lock(m_remote_id_mutex);
|
||||
m_remote_id = remote_id;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ class NetworkConnection : public INetworkConnection {
|
||||
void set_state(State state) final;
|
||||
|
||||
std::string remote_id() const;
|
||||
void set_remote_id(StringRef remote_id);
|
||||
void set_remote_id(wpi::StringRef remote_id);
|
||||
|
||||
uint64_t last_update() const { return m_last_update; }
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ void RpcServer::RemoveRpc(unsigned int rpc_uid) {
|
||||
}
|
||||
|
||||
void RpcServer::ProcessRpc(unsigned int local_id, unsigned int call_uid,
|
||||
StringRef name, StringRef params,
|
||||
wpi::StringRef name, wpi::StringRef params,
|
||||
const ConnectionInfo& conn,
|
||||
SendResponseFunc send_response,
|
||||
unsigned int rpc_uid) {
|
||||
|
||||
@@ -22,8 +22,8 @@ namespace impl {
|
||||
typedef std::pair<unsigned int, unsigned int> RpcIdPair;
|
||||
|
||||
struct RpcNotifierData : public RpcAnswer {
|
||||
RpcNotifierData(NT_Entry entry_, NT_RpcCall call_, StringRef name_,
|
||||
StringRef params_, const ConnectionInfo& conn_,
|
||||
RpcNotifierData(NT_Entry entry_, NT_RpcCall call_, wpi::StringRef name_,
|
||||
wpi::StringRef params_, const ConnectionInfo& conn_,
|
||||
IRpcServer::SendResponseFunc send_response_)
|
||||
: RpcAnswer{entry_, call_, name_, params_, conn_},
|
||||
send_response{std::move(send_response_)} {}
|
||||
@@ -93,9 +93,9 @@ class RpcServer
|
||||
unsigned int AddPolled(unsigned int poller_uid);
|
||||
void RemoveRpc(unsigned int rpc_uid) override;
|
||||
|
||||
void ProcessRpc(unsigned int local_id, unsigned int call_uid, StringRef name,
|
||||
StringRef params, const ConnectionInfo& conn,
|
||||
SendResponseFunc send_response,
|
||||
void ProcessRpc(unsigned int local_id, unsigned int call_uid,
|
||||
wpi::StringRef name, wpi::StringRef params,
|
||||
const ConnectionInfo& conn, SendResponseFunc send_response,
|
||||
unsigned int rpc_uid) override;
|
||||
|
||||
bool PostRpcResponse(unsigned int local_id, unsigned int call_uid,
|
||||
|
||||
@@ -91,7 +91,7 @@ void Storage::ProcessIncomingEntryAssign(std::shared_ptr<Message> msg,
|
||||
INetworkConnection* conn) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
unsigned int id = msg->id();
|
||||
StringRef name = msg->str();
|
||||
wpi::StringRef name = msg->str();
|
||||
Entry* entry;
|
||||
bool may_need_update = false;
|
||||
SequenceNumber seq_num(msg->seq_num_uid());
|
||||
@@ -359,7 +359,7 @@ void Storage::ProcessIncomingExecuteRpc(
|
||||
unsigned int call_uid = msg->seq_num_uid();
|
||||
m_rpc_server.ProcessRpc(
|
||||
entry->local_id, call_uid, entry->name, msg->str(), conn_info,
|
||||
[=](StringRef result) {
|
||||
[=](wpi::StringRef result) {
|
||||
auto c = conn_weak.lock();
|
||||
if (c) {
|
||||
c->QueueOutgoing(Message::RpcResponse(id, call_uid, result));
|
||||
@@ -442,7 +442,7 @@ void Storage::ApplyInitialAssignments(
|
||||
}
|
||||
|
||||
SequenceNumber seq_num(msg->seq_num_uid());
|
||||
StringRef name = msg->str();
|
||||
wpi::StringRef name = msg->str();
|
||||
|
||||
Entry* entry = GetOrNew(name);
|
||||
entry->seq_num = seq_num;
|
||||
@@ -509,7 +509,7 @@ void Storage::ApplyInitialAssignments(
|
||||
}
|
||||
}
|
||||
|
||||
std::shared_ptr<Value> Storage::GetEntryValue(StringRef name) const {
|
||||
std::shared_ptr<Value> Storage::GetEntryValue(wpi::StringRef name) const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
auto i = m_entries.find(name);
|
||||
if (i == m_entries.end()) {
|
||||
@@ -526,7 +526,7 @@ std::shared_ptr<Value> Storage::GetEntryValue(unsigned int local_id) const {
|
||||
return m_localmap[local_id]->value;
|
||||
}
|
||||
|
||||
bool Storage::SetDefaultEntryValue(StringRef name,
|
||||
bool Storage::SetDefaultEntryValue(wpi::StringRef name,
|
||||
std::shared_ptr<Value> value) {
|
||||
if (name.empty()) {
|
||||
return false;
|
||||
@@ -566,7 +566,7 @@ bool Storage::SetDefaultEntryValue(unsigned int local_id,
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Storage::SetEntryValue(StringRef name, std::shared_ptr<Value> value) {
|
||||
bool Storage::SetEntryValue(wpi::StringRef name, std::shared_ptr<Value> value) {
|
||||
if (name.empty()) {
|
||||
return true;
|
||||
}
|
||||
@@ -664,7 +664,8 @@ void Storage::SetEntryValueImpl(Entry* entry, std::shared_ptr<Value> value,
|
||||
}
|
||||
}
|
||||
|
||||
void Storage::SetEntryTypeValue(StringRef name, std::shared_ptr<Value> value) {
|
||||
void Storage::SetEntryTypeValue(wpi::StringRef name,
|
||||
std::shared_ptr<Value> value) {
|
||||
if (name.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -694,7 +695,7 @@ void Storage::SetEntryTypeValue(unsigned int local_id,
|
||||
SetEntryValueImpl(entry, value, lock, true);
|
||||
}
|
||||
|
||||
void Storage::SetEntryFlags(StringRef name, unsigned int flags) {
|
||||
void Storage::SetEntryFlags(wpi::StringRef name, unsigned int flags) {
|
||||
if (name.empty()) {
|
||||
return;
|
||||
}
|
||||
@@ -746,7 +747,7 @@ void Storage::SetEntryFlagsImpl(Entry* entry, unsigned int flags,
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Storage::GetEntryFlags(StringRef name) const {
|
||||
unsigned int Storage::GetEntryFlags(wpi::StringRef name) const {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
auto i = m_entries.find(name);
|
||||
if (i == m_entries.end()) {
|
||||
@@ -763,7 +764,7 @@ unsigned int Storage::GetEntryFlags(unsigned int local_id) const {
|
||||
return m_localmap[local_id]->flags;
|
||||
}
|
||||
|
||||
void Storage::DeleteEntry(StringRef name) {
|
||||
void Storage::DeleteEntry(wpi::StringRef name) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
auto i = m_entries.find(name);
|
||||
if (i == m_entries.end()) {
|
||||
@@ -872,9 +873,9 @@ void Storage::DeleteAllEntries() {
|
||||
dispatcher->QueueOutgoing(Message::ClearEntries(), nullptr, nullptr);
|
||||
}
|
||||
|
||||
Storage::Entry* Storage::GetOrNew(const Twine& name) {
|
||||
Storage::Entry* Storage::GetOrNew(const wpi::Twine& name) {
|
||||
wpi::SmallString<128> nameBuf;
|
||||
StringRef nameStr = name.toStringRef(nameBuf);
|
||||
wpi::StringRef nameStr = name.toStringRef(nameBuf);
|
||||
auto& entry = m_entries[nameStr];
|
||||
if (!entry) {
|
||||
m_localmap.emplace_back(new Entry(nameStr));
|
||||
@@ -884,7 +885,7 @@ Storage::Entry* Storage::GetOrNew(const Twine& name) {
|
||||
return entry;
|
||||
}
|
||||
|
||||
unsigned int Storage::GetEntry(const Twine& name) {
|
||||
unsigned int Storage::GetEntry(const wpi::Twine& name) {
|
||||
if (name.isTriviallyEmpty() ||
|
||||
(name.isSingleStringRef() && name.getSingleStringRef().empty())) {
|
||||
return UINT_MAX;
|
||||
@@ -893,10 +894,10 @@ unsigned int Storage::GetEntry(const Twine& name) {
|
||||
return GetOrNew(name)->local_id;
|
||||
}
|
||||
|
||||
std::vector<unsigned int> Storage::GetEntries(const Twine& prefix,
|
||||
std::vector<unsigned int> Storage::GetEntries(const wpi::Twine& prefix,
|
||||
unsigned int types) {
|
||||
wpi::SmallString<128> prefixBuf;
|
||||
StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
std::vector<unsigned int> ids;
|
||||
for (auto& i : m_entries) {
|
||||
@@ -969,10 +970,10 @@ uint64_t Storage::GetEntryLastChange(unsigned int local_id) const {
|
||||
return entry->value->last_change();
|
||||
}
|
||||
|
||||
std::vector<EntryInfo> Storage::GetEntryInfo(int inst, const Twine& prefix,
|
||||
std::vector<EntryInfo> Storage::GetEntryInfo(int inst, const wpi::Twine& prefix,
|
||||
unsigned int types) {
|
||||
wpi::SmallString<128> prefixBuf;
|
||||
StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
std::vector<EntryInfo> infos;
|
||||
for (auto& i : m_entries) {
|
||||
@@ -996,11 +997,11 @@ std::vector<EntryInfo> Storage::GetEntryInfo(int inst, const Twine& prefix,
|
||||
}
|
||||
|
||||
unsigned int Storage::AddListener(
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int flags) const {
|
||||
wpi::SmallString<128> prefixBuf;
|
||||
StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
unsigned int uid = m_notifier.Add(callback, prefixStr, flags);
|
||||
// perform immediate notifications
|
||||
@@ -1036,10 +1037,10 @@ unsigned int Storage::AddListener(
|
||||
}
|
||||
|
||||
unsigned int Storage::AddPolledListener(unsigned int poller,
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
unsigned int flags) const {
|
||||
wpi::SmallString<128> prefixBuf;
|
||||
StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
unsigned int uid = m_notifier.AddPolled(poller, prefixStr, flags);
|
||||
// perform immediate notifications
|
||||
@@ -1110,11 +1111,11 @@ bool Storage::GetPersistentEntries(
|
||||
}
|
||||
|
||||
bool Storage::GetEntries(
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
std::vector<std::pair<std::string, std::shared_ptr<Value>>>* entries)
|
||||
const {
|
||||
wpi::SmallString<128> prefixBuf;
|
||||
StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
// copy values out of storage as quickly as possible so lock isn't held
|
||||
{
|
||||
std::scoped_lock lock(m_mutex);
|
||||
@@ -1138,7 +1139,7 @@ bool Storage::GetEntries(
|
||||
return true;
|
||||
}
|
||||
|
||||
void Storage::CreateRpc(unsigned int local_id, StringRef def,
|
||||
void Storage::CreateRpc(unsigned int local_id, wpi::StringRef def,
|
||||
unsigned int rpc_uid) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
if (local_id >= m_localmap.size()) {
|
||||
@@ -1183,7 +1184,7 @@ void Storage::CreateRpc(unsigned int local_id, StringRef def,
|
||||
}
|
||||
}
|
||||
|
||||
unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) {
|
||||
unsigned int Storage::CallRpc(unsigned int local_id, wpi::StringRef params) {
|
||||
std::unique_lock lock(m_mutex);
|
||||
if (local_id >= m_localmap.size()) {
|
||||
return 0;
|
||||
@@ -1201,7 +1202,7 @@ unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) {
|
||||
unsigned int call_uid = entry->rpc_call_uid;
|
||||
|
||||
auto msg = Message::ExecuteRpc(entry->id, call_uid, params);
|
||||
StringRef name{entry->name};
|
||||
wpi::StringRef name{entry->name};
|
||||
|
||||
if (m_server) {
|
||||
// RPCs are unlikely to be used locally on the server, but handle it
|
||||
@@ -1217,7 +1218,7 @@ unsigned int Storage::CallRpc(unsigned int local_id, StringRef params) {
|
||||
unsigned int call_uid = msg->seq_num_uid();
|
||||
m_rpc_server.ProcessRpc(
|
||||
local_id, call_uid, name, msg->str(), conn_info,
|
||||
[=](StringRef result) {
|
||||
[=](wpi::StringRef result) {
|
||||
std::scoped_lock lock(m_mutex);
|
||||
m_rpc_results.insert(
|
||||
std::make_pair(RpcIdPair{local_id, call_uid}, result));
|
||||
|
||||
@@ -72,35 +72,35 @@ class Storage : public IStorage {
|
||||
|
||||
// User functions. These are the actual implementations of the corresponding
|
||||
// user API functions in ntcore_cpp.
|
||||
std::shared_ptr<Value> GetEntryValue(StringRef name) const;
|
||||
std::shared_ptr<Value> GetEntryValue(wpi::StringRef name) const;
|
||||
std::shared_ptr<Value> GetEntryValue(unsigned int local_id) const;
|
||||
|
||||
bool SetDefaultEntryValue(StringRef name, std::shared_ptr<Value> value);
|
||||
bool SetDefaultEntryValue(wpi::StringRef name, std::shared_ptr<Value> value);
|
||||
bool SetDefaultEntryValue(unsigned int local_id,
|
||||
std::shared_ptr<Value> value);
|
||||
|
||||
bool SetEntryValue(StringRef name, std::shared_ptr<Value> value);
|
||||
bool SetEntryValue(wpi::StringRef name, std::shared_ptr<Value> value);
|
||||
bool SetEntryValue(unsigned int local_id, std::shared_ptr<Value> value);
|
||||
|
||||
void SetEntryTypeValue(StringRef name, std::shared_ptr<Value> value);
|
||||
void SetEntryTypeValue(wpi::StringRef name, std::shared_ptr<Value> value);
|
||||
void SetEntryTypeValue(unsigned int local_id, std::shared_ptr<Value> value);
|
||||
|
||||
void SetEntryFlags(StringRef name, unsigned int flags);
|
||||
void SetEntryFlags(wpi::StringRef name, unsigned int flags);
|
||||
void SetEntryFlags(unsigned int local_id, unsigned int flags);
|
||||
|
||||
unsigned int GetEntryFlags(StringRef name) const;
|
||||
unsigned int GetEntryFlags(wpi::StringRef name) const;
|
||||
unsigned int GetEntryFlags(unsigned int local_id) const;
|
||||
|
||||
void DeleteEntry(StringRef name);
|
||||
void DeleteEntry(wpi::StringRef name);
|
||||
void DeleteEntry(unsigned int local_id);
|
||||
|
||||
void DeleteAllEntries();
|
||||
|
||||
std::vector<EntryInfo> GetEntryInfo(int inst, const Twine& prefix,
|
||||
std::vector<EntryInfo> GetEntryInfo(int inst, const wpi::Twine& prefix,
|
||||
unsigned int types);
|
||||
|
||||
unsigned int AddListener(
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int flags) const;
|
||||
unsigned int AddListener(
|
||||
@@ -108,14 +108,16 @@ class Storage : public IStorage {
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int flags) const;
|
||||
|
||||
unsigned int AddPolledListener(unsigned int poller_uid, const Twine& prefix,
|
||||
unsigned int AddPolledListener(unsigned int poller_uid,
|
||||
const wpi::Twine& prefix,
|
||||
unsigned int flags) const;
|
||||
unsigned int AddPolledListener(unsigned int poller_uid, unsigned int local_id,
|
||||
unsigned int flags) const;
|
||||
|
||||
// Index-only
|
||||
unsigned int GetEntry(const Twine& name);
|
||||
std::vector<unsigned int> GetEntries(const Twine& prefix, unsigned int types);
|
||||
unsigned int GetEntry(const wpi::Twine& name);
|
||||
std::vector<unsigned int> GetEntries(const wpi::Twine& prefix,
|
||||
unsigned int types);
|
||||
EntryInfo GetEntryInfo(int inst, unsigned int local_id) const;
|
||||
std::string GetEntryName(unsigned int local_id) const;
|
||||
NT_Type GetEntryType(unsigned int local_id) const;
|
||||
@@ -123,29 +125,32 @@ class Storage : public IStorage {
|
||||
|
||||
// Filename-based save/load functions. Used both by periodic saves and
|
||||
// accessible directly via the user API.
|
||||
const char* SavePersistent(const Twine& filename,
|
||||
const char* SavePersistent(const wpi::Twine& filename,
|
||||
bool periodic) const override;
|
||||
const char* LoadPersistent(
|
||||
const Twine& filename,
|
||||
const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn) override;
|
||||
|
||||
const char* SaveEntries(const Twine& filename, const Twine& prefix) const;
|
||||
const char* SaveEntries(const wpi::Twine& filename,
|
||||
const wpi::Twine& prefix) const;
|
||||
const char* LoadEntries(
|
||||
const Twine& filename, const Twine& prefix,
|
||||
const wpi::Twine& filename, const wpi::Twine& prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
// Stream-based save/load functions (exposed for testing purposes). These
|
||||
// implement the guts of the filename-based functions.
|
||||
void SavePersistent(wpi::raw_ostream& os, bool periodic) const;
|
||||
bool LoadEntries(wpi::raw_istream& is, const Twine& prefix, bool persistent,
|
||||
bool LoadEntries(wpi::raw_istream& is, const wpi::Twine& prefix,
|
||||
bool persistent,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
void SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const;
|
||||
void SaveEntries(wpi::raw_ostream& os, const wpi::Twine& prefix) const;
|
||||
|
||||
// RPC configuration needs to come through here as RPC definitions are
|
||||
// actually special Storage value types.
|
||||
void CreateRpc(unsigned int local_id, StringRef def, unsigned int rpc_uid);
|
||||
unsigned int CallRpc(unsigned int local_id, StringRef params);
|
||||
void CreateRpc(unsigned int local_id, wpi::StringRef def,
|
||||
unsigned int rpc_uid);
|
||||
unsigned int CallRpc(unsigned int local_id, wpi::StringRef params);
|
||||
bool GetRpcResult(unsigned int local_id, unsigned int call_uid,
|
||||
std::string* result);
|
||||
bool GetRpcResult(unsigned int local_id, unsigned int call_uid,
|
||||
@@ -237,7 +242,7 @@ class Storage : public IStorage {
|
||||
bool periodic,
|
||||
std::vector<std::pair<std::string, std::shared_ptr<Value>>>* entries)
|
||||
const;
|
||||
bool GetEntries(const Twine& prefix,
|
||||
bool GetEntries(const wpi::Twine& prefix,
|
||||
std::vector<std::pair<std::string, std::shared_ptr<Value>>>*
|
||||
entries) const;
|
||||
void SetEntryValueImpl(Entry* entry, std::shared_ptr<Value> value,
|
||||
@@ -251,7 +256,7 @@ class Storage : public IStorage {
|
||||
template <typename F>
|
||||
void DeleteAllEntriesImpl(bool local, F should_delete);
|
||||
void DeleteAllEntriesImpl(bool local);
|
||||
Entry* GetOrNew(const Twine& name);
|
||||
Entry* GetOrNew(const wpi::Twine& name);
|
||||
};
|
||||
|
||||
} // namespace nt
|
||||
|
||||
@@ -27,7 +27,7 @@ class LoadPersistentImpl {
|
||||
LoadPersistentImpl(wpi::raw_istream& is, WarnFunc warn)
|
||||
: m_is(is), m_warn(std::move(warn)) {}
|
||||
|
||||
bool Load(StringRef prefix, std::vector<Entry>* entries);
|
||||
bool Load(wpi::StringRef prefix, std::vector<Entry>* entries);
|
||||
|
||||
private:
|
||||
bool ReadLine();
|
||||
@@ -138,7 +138,8 @@ static wpi::StringRef UnescapeString(wpi::StringRef source,
|
||||
return wpi::StringRef{buf.data(), buf.size()};
|
||||
}
|
||||
|
||||
bool LoadPersistentImpl::Load(StringRef prefix, std::vector<Entry>* entries) {
|
||||
bool LoadPersistentImpl::Load(wpi::StringRef prefix,
|
||||
std::vector<Entry>* entries) {
|
||||
if (!ReadHeader()) {
|
||||
return false; // header
|
||||
}
|
||||
@@ -373,10 +374,10 @@ std::shared_ptr<Value> LoadPersistentImpl::ReadStringArrayValue() {
|
||||
}
|
||||
|
||||
bool Storage::LoadEntries(
|
||||
wpi::raw_istream& is, const Twine& prefix, bool persistent,
|
||||
wpi::raw_istream& is, const wpi::Twine& prefix, bool persistent,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
wpi::SmallString<128> prefixBuf;
|
||||
StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
wpi::StringRef prefixStr = prefix.toStringRef(prefixBuf);
|
||||
|
||||
// entries to add
|
||||
std::vector<LoadPersistentImpl::Entry> entries;
|
||||
@@ -456,7 +457,7 @@ bool Storage::LoadEntries(
|
||||
}
|
||||
|
||||
const char* Storage::LoadPersistent(
|
||||
const Twine& filename,
|
||||
const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
std::error_code ec;
|
||||
wpi::raw_fd_istream is(filename, ec);
|
||||
@@ -470,7 +471,7 @@ const char* Storage::LoadPersistent(
|
||||
}
|
||||
|
||||
const char* Storage::LoadEntries(
|
||||
const Twine& filename, const Twine& prefix,
|
||||
const wpi::Twine& filename, const wpi::Twine& prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
std::error_code ec;
|
||||
wpi::raw_fd_istream is(filename, ec);
|
||||
|
||||
@@ -190,7 +190,7 @@ void Storage::SavePersistent(wpi::raw_ostream& os, bool periodic) const {
|
||||
SavePersistentImpl(os).Save(entries);
|
||||
}
|
||||
|
||||
const char* Storage::SavePersistent(const Twine& filename,
|
||||
const char* Storage::SavePersistent(const wpi::Twine& filename,
|
||||
bool periodic) const {
|
||||
wpi::SmallString<128> fn;
|
||||
filename.toVector(fn);
|
||||
@@ -240,7 +240,8 @@ done:
|
||||
return err;
|
||||
}
|
||||
|
||||
void Storage::SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const {
|
||||
void Storage::SaveEntries(wpi::raw_ostream& os,
|
||||
const wpi::Twine& prefix) const {
|
||||
std::vector<SavePersistentImpl::Entry> entries;
|
||||
if (!GetEntries(prefix, &entries)) {
|
||||
return;
|
||||
@@ -248,8 +249,8 @@ void Storage::SaveEntries(wpi::raw_ostream& os, const Twine& prefix) const {
|
||||
SavePersistentImpl(os).Save(entries);
|
||||
}
|
||||
|
||||
const char* Storage::SaveEntries(const Twine& filename,
|
||||
const Twine& prefix) const {
|
||||
const char* Storage::SaveEntries(const wpi::Twine& filename,
|
||||
const wpi::Twine& prefix) const {
|
||||
wpi::SmallString<128> fn;
|
||||
filename.toVector(fn);
|
||||
wpi::SmallString<128> tmp = fn;
|
||||
|
||||
@@ -1549,7 +1549,7 @@ Java_edu_wpi_first_networktables_NetworkTablesJNI_startClient__I_3Ljava_lang_Str
|
||||
}
|
||||
|
||||
std::vector<std::string> names;
|
||||
std::vector<std::pair<nt::StringRef, unsigned int>> servers;
|
||||
std::vector<std::pair<wpi::StringRef, unsigned int>> servers;
|
||||
names.reserve(len);
|
||||
servers.reserve(len);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@@ -1561,7 +1561,7 @@ Java_edu_wpi_first_networktables_NetworkTablesJNI_startClient__I_3Ljava_lang_Str
|
||||
}
|
||||
names.emplace_back(JStringRef{env, elem}.str());
|
||||
servers.emplace_back(
|
||||
std::make_pair(nt::StringRef(names.back()), portInts[i]));
|
||||
std::make_pair(wpi::StringRef(names.back()), portInts[i]));
|
||||
}
|
||||
env->ReleaseIntArrayElements(ports, portInts, JNI_ABORT);
|
||||
nt::StartClient(inst, servers);
|
||||
@@ -1636,7 +1636,7 @@ Java_edu_wpi_first_networktables_NetworkTablesJNI_setServer__I_3Ljava_lang_Strin
|
||||
}
|
||||
|
||||
std::vector<std::string> names;
|
||||
std::vector<std::pair<nt::StringRef, unsigned int>> servers;
|
||||
std::vector<std::pair<wpi::StringRef, unsigned int>> servers;
|
||||
names.reserve(len);
|
||||
servers.reserve(len);
|
||||
for (int i = 0; i < len; ++i) {
|
||||
@@ -1648,7 +1648,7 @@ Java_edu_wpi_first_networktables_NetworkTablesJNI_setServer__I_3Ljava_lang_Strin
|
||||
}
|
||||
names.emplace_back(JStringRef{env, elem}.str());
|
||||
servers.emplace_back(
|
||||
std::make_pair(nt::StringRef(names.back()), portInts[i]));
|
||||
std::make_pair(wpi::StringRef(names.back()), portInts[i]));
|
||||
}
|
||||
env->ReleaseIntArrayElements(ports, portInts, JNI_ABORT);
|
||||
nt::SetServer(inst, servers);
|
||||
|
||||
@@ -15,31 +15,31 @@
|
||||
|
||||
using namespace nt;
|
||||
|
||||
StringRef NetworkTable::BasenameKey(StringRef key) {
|
||||
wpi::StringRef NetworkTable::BasenameKey(wpi::StringRef key) {
|
||||
size_t slash = key.rfind(PATH_SEPARATOR_CHAR);
|
||||
if (slash == StringRef::npos) {
|
||||
if (slash == wpi::StringRef::npos) {
|
||||
return key;
|
||||
}
|
||||
return key.substr(slash + 1);
|
||||
}
|
||||
|
||||
std::string NetworkTable::NormalizeKey(const Twine& key,
|
||||
std::string NetworkTable::NormalizeKey(const wpi::Twine& key,
|
||||
bool withLeadingSlash) {
|
||||
wpi::SmallString<128> buf;
|
||||
return NormalizeKey(key, buf, withLeadingSlash);
|
||||
}
|
||||
|
||||
StringRef NetworkTable::NormalizeKey(const Twine& key,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
bool withLeadingSlash) {
|
||||
wpi::StringRef NetworkTable::NormalizeKey(const wpi::Twine& key,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
bool withLeadingSlash) {
|
||||
buf.clear();
|
||||
if (withLeadingSlash) {
|
||||
buf.push_back(PATH_SEPARATOR_CHAR);
|
||||
}
|
||||
// for each path element, add it with a slash following
|
||||
wpi::SmallString<128> keyBuf;
|
||||
StringRef keyStr = key.toStringRef(keyBuf);
|
||||
wpi::SmallVector<StringRef, 16> parts;
|
||||
wpi::StringRef keyStr = key.toStringRef(keyBuf);
|
||||
wpi::SmallVector<wpi::StringRef, 16> parts;
|
||||
keyStr.split(parts, PATH_SEPARATOR_CHAR, -1, false);
|
||||
for (auto i = parts.begin(); i != parts.end(); ++i) {
|
||||
buf.append(i->begin(), i->end());
|
||||
@@ -49,17 +49,17 @@ StringRef NetworkTable::NormalizeKey(const Twine& key,
|
||||
if (!keyStr.empty() && keyStr.back() != PATH_SEPARATOR_CHAR) {
|
||||
buf.pop_back();
|
||||
}
|
||||
return StringRef(buf.data(), buf.size());
|
||||
return wpi::StringRef(buf.data(), buf.size());
|
||||
}
|
||||
|
||||
std::vector<std::string> NetworkTable::GetHierarchy(const Twine& key) {
|
||||
std::vector<std::string> NetworkTable::GetHierarchy(const wpi::Twine& key) {
|
||||
std::vector<std::string> hierarchy;
|
||||
hierarchy.emplace_back(1, PATH_SEPARATOR_CHAR);
|
||||
// for each path element, add it to the end of what we built previously
|
||||
wpi::SmallString<128> keyBuf;
|
||||
StringRef keyStr = key.toStringRef(keyBuf);
|
||||
wpi::StringRef keyStr = key.toStringRef(keyBuf);
|
||||
wpi::SmallString<128> path;
|
||||
wpi::SmallVector<StringRef, 16> parts;
|
||||
wpi::SmallVector<wpi::StringRef, 16> parts;
|
||||
keyStr.split(parts, PATH_SEPARATOR_CHAR, -1, false);
|
||||
if (!parts.empty()) {
|
||||
for (auto i = parts.begin(); i != parts.end(); ++i) {
|
||||
@@ -76,7 +76,8 @@ std::vector<std::string> NetworkTable::GetHierarchy(const Twine& key) {
|
||||
return hierarchy;
|
||||
}
|
||||
|
||||
NetworkTable::NetworkTable(NT_Inst inst, const Twine& path, const private_init&)
|
||||
NetworkTable::NetworkTable(NT_Inst inst, const wpi::Twine& path,
|
||||
const private_init&)
|
||||
: m_inst(inst), m_path(path.str()) {}
|
||||
|
||||
NetworkTable::~NetworkTable() {
|
||||
@@ -89,13 +90,14 @@ NetworkTableInstance NetworkTable::GetInstance() const {
|
||||
return NetworkTableInstance{m_inst};
|
||||
}
|
||||
|
||||
NetworkTableEntry NetworkTable::GetEntry(const Twine& key) const {
|
||||
NetworkTableEntry NetworkTable::GetEntry(const wpi::Twine& key) const {
|
||||
wpi::SmallString<128> keyBuf;
|
||||
StringRef keyStr = key.toStringRef(keyBuf);
|
||||
wpi::StringRef keyStr = key.toStringRef(keyBuf);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
NT_Entry& entry = m_entries[keyStr];
|
||||
if (entry == 0) {
|
||||
entry = nt::GetEntry(m_inst, m_path + Twine(PATH_SEPARATOR_CHAR) + keyStr);
|
||||
entry =
|
||||
nt::GetEntry(m_inst, m_path + wpi::Twine(PATH_SEPARATOR_CHAR) + keyStr);
|
||||
}
|
||||
return NetworkTableEntry{entry};
|
||||
}
|
||||
@@ -104,10 +106,10 @@ NT_EntryListener NetworkTable::AddEntryListener(TableEntryListener listener,
|
||||
unsigned int flags) const {
|
||||
size_t prefix_len = m_path.size() + 1;
|
||||
return nt::AddEntryListener(
|
||||
m_inst, m_path + Twine(PATH_SEPARATOR_CHAR),
|
||||
m_inst, m_path + wpi::Twine(PATH_SEPARATOR_CHAR),
|
||||
[=](const EntryNotification& event) {
|
||||
StringRef relative_key = event.name.substr(prefix_len);
|
||||
if (relative_key.find(PATH_SEPARATOR_CHAR) != StringRef::npos) {
|
||||
wpi::StringRef relative_key = event.name.substr(prefix_len);
|
||||
if (relative_key.find(PATH_SEPARATOR_CHAR) != wpi::StringRef::npos) {
|
||||
return;
|
||||
}
|
||||
listener(const_cast<NetworkTable*>(this), relative_key,
|
||||
@@ -116,7 +118,7 @@ NT_EntryListener NetworkTable::AddEntryListener(TableEntryListener listener,
|
||||
flags);
|
||||
}
|
||||
|
||||
NT_EntryListener NetworkTable::AddEntryListener(const Twine& key,
|
||||
NT_EntryListener NetworkTable::AddEntryListener(const wpi::Twine& key,
|
||||
TableEntryListener listener,
|
||||
unsigned int flags) const {
|
||||
size_t prefix_len = m_path.size() + 1;
|
||||
@@ -147,14 +149,14 @@ NT_EntryListener NetworkTable::AddSubTableListener(TableListener listener,
|
||||
flags |= NT_NOTIFY_LOCAL;
|
||||
}
|
||||
NT_EntryListener id = nt::AddEntryListener(
|
||||
m_inst, m_path + Twine(PATH_SEPARATOR_CHAR),
|
||||
m_inst, m_path + wpi::Twine(PATH_SEPARATOR_CHAR),
|
||||
[=](const EntryNotification& event) {
|
||||
StringRef relative_key = event.name.substr(prefix_len);
|
||||
wpi::StringRef relative_key = event.name.substr(prefix_len);
|
||||
auto end_sub_table = relative_key.find(PATH_SEPARATOR_CHAR);
|
||||
if (end_sub_table == StringRef::npos) {
|
||||
if (end_sub_table == wpi::StringRef::npos) {
|
||||
return;
|
||||
}
|
||||
StringRef sub_table_key = relative_key.substr(0, end_sub_table);
|
||||
wpi::StringRef sub_table_key = relative_key.substr(0, end_sub_table);
|
||||
if (notified_tables->find(sub_table_key) == notified_tables->end()) {
|
||||
return;
|
||||
}
|
||||
@@ -174,12 +176,12 @@ void NetworkTable::RemoveTableListener(NT_EntryListener listener) {
|
||||
}
|
||||
|
||||
std::shared_ptr<NetworkTable> NetworkTable::GetSubTable(
|
||||
const Twine& key) const {
|
||||
const wpi::Twine& key) const {
|
||||
return std::make_shared<NetworkTable>(
|
||||
m_inst, m_path + Twine(PATH_SEPARATOR_CHAR) + key, private_init{});
|
||||
m_inst, m_path + wpi::Twine(PATH_SEPARATOR_CHAR) + key, private_init{});
|
||||
}
|
||||
|
||||
bool NetworkTable::ContainsKey(const Twine& key) const {
|
||||
bool NetworkTable::ContainsKey(const wpi::Twine& key) const {
|
||||
if (key.isTriviallyEmpty() ||
|
||||
(key.isSingleStringRef() && key.getSingleStringRef().empty())) {
|
||||
return false;
|
||||
@@ -187,10 +189,10 @@ bool NetworkTable::ContainsKey(const Twine& key) const {
|
||||
return GetEntry(key).Exists();
|
||||
}
|
||||
|
||||
bool NetworkTable::ContainsSubTable(const Twine& key) const {
|
||||
bool NetworkTable::ContainsSubTable(const wpi::Twine& key) const {
|
||||
return !GetEntryInfo(m_inst,
|
||||
m_path + Twine(PATH_SEPARATOR_CHAR) + key +
|
||||
Twine(PATH_SEPARATOR_CHAR),
|
||||
m_path + wpi::Twine(PATH_SEPARATOR_CHAR) + key +
|
||||
wpi::Twine(PATH_SEPARATOR_CHAR),
|
||||
0)
|
||||
.empty();
|
||||
}
|
||||
@@ -198,11 +200,12 @@ bool NetworkTable::ContainsSubTable(const Twine& key) const {
|
||||
std::vector<std::string> NetworkTable::GetKeys(int types) const {
|
||||
std::vector<std::string> keys;
|
||||
size_t prefix_len = m_path.size() + 1;
|
||||
auto infos = GetEntryInfo(m_inst, m_path + Twine(PATH_SEPARATOR_CHAR), types);
|
||||
auto infos =
|
||||
GetEntryInfo(m_inst, m_path + wpi::Twine(PATH_SEPARATOR_CHAR), types);
|
||||
std::scoped_lock lock(m_mutex);
|
||||
for (auto& info : infos) {
|
||||
auto relative_key = StringRef(info.name).substr(prefix_len);
|
||||
if (relative_key.find(PATH_SEPARATOR_CHAR) != StringRef::npos) {
|
||||
auto relative_key = wpi::StringRef(info.name).substr(prefix_len);
|
||||
if (relative_key.find(PATH_SEPARATOR_CHAR) != wpi::StringRef::npos) {
|
||||
continue;
|
||||
}
|
||||
keys.push_back(relative_key);
|
||||
@@ -215,10 +218,10 @@ std::vector<std::string> NetworkTable::GetSubTables() const {
|
||||
std::vector<std::string> keys;
|
||||
size_t prefix_len = m_path.size() + 1;
|
||||
for (auto& entry :
|
||||
GetEntryInfo(m_inst, m_path + Twine(PATH_SEPARATOR_CHAR), 0)) {
|
||||
auto relative_key = StringRef(entry.name).substr(prefix_len);
|
||||
GetEntryInfo(m_inst, m_path + wpi::Twine(PATH_SEPARATOR_CHAR), 0)) {
|
||||
auto relative_key = wpi::StringRef(entry.name).substr(prefix_len);
|
||||
size_t end_subtable = relative_key.find(PATH_SEPARATOR_CHAR);
|
||||
if (end_subtable == StringRef::npos) {
|
||||
if (end_subtable == wpi::StringRef::npos) {
|
||||
continue;
|
||||
}
|
||||
keys.push_back(relative_key.substr(0, end_subtable));
|
||||
@@ -226,149 +229,157 @@ std::vector<std::string> NetworkTable::GetSubTables() const {
|
||||
return keys;
|
||||
}
|
||||
|
||||
void NetworkTable::SetPersistent(StringRef key) {
|
||||
void NetworkTable::SetPersistent(wpi::StringRef key) {
|
||||
GetEntry(key).SetPersistent();
|
||||
}
|
||||
|
||||
void NetworkTable::ClearPersistent(StringRef key) {
|
||||
void NetworkTable::ClearPersistent(wpi::StringRef key) {
|
||||
GetEntry(key).ClearPersistent();
|
||||
}
|
||||
|
||||
bool NetworkTable::IsPersistent(StringRef key) const {
|
||||
bool NetworkTable::IsPersistent(wpi::StringRef key) const {
|
||||
return GetEntry(key).IsPersistent();
|
||||
}
|
||||
|
||||
void NetworkTable::SetFlags(StringRef key, unsigned int flags) {
|
||||
void NetworkTable::SetFlags(wpi::StringRef key, unsigned int flags) {
|
||||
GetEntry(key).SetFlags(flags);
|
||||
}
|
||||
|
||||
void NetworkTable::ClearFlags(StringRef key, unsigned int flags) {
|
||||
void NetworkTable::ClearFlags(wpi::StringRef key, unsigned int flags) {
|
||||
GetEntry(key).ClearFlags(flags);
|
||||
}
|
||||
|
||||
unsigned int NetworkTable::GetFlags(StringRef key) const {
|
||||
unsigned int NetworkTable::GetFlags(wpi::StringRef key) const {
|
||||
return GetEntry(key).GetFlags();
|
||||
}
|
||||
|
||||
void NetworkTable::Delete(const Twine& key) {
|
||||
void NetworkTable::Delete(const wpi::Twine& key) {
|
||||
GetEntry(key).Delete();
|
||||
}
|
||||
|
||||
bool NetworkTable::PutNumber(StringRef key, double value) {
|
||||
bool NetworkTable::PutNumber(wpi::StringRef key, double value) {
|
||||
return GetEntry(key).SetDouble(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultNumber(StringRef key, double defaultValue) {
|
||||
bool NetworkTable::SetDefaultNumber(wpi::StringRef key, double defaultValue) {
|
||||
return GetEntry(key).SetDefaultDouble(defaultValue);
|
||||
}
|
||||
|
||||
double NetworkTable::GetNumber(StringRef key, double defaultValue) const {
|
||||
double NetworkTable::GetNumber(wpi::StringRef key, double defaultValue) const {
|
||||
return GetEntry(key).GetDouble(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::PutString(StringRef key, StringRef value) {
|
||||
bool NetworkTable::PutString(wpi::StringRef key, wpi::StringRef value) {
|
||||
return GetEntry(key).SetString(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultString(StringRef key, StringRef defaultValue) {
|
||||
bool NetworkTable::SetDefaultString(wpi::StringRef key,
|
||||
wpi::StringRef defaultValue) {
|
||||
return GetEntry(key).SetDefaultString(defaultValue);
|
||||
}
|
||||
|
||||
std::string NetworkTable::GetString(StringRef key,
|
||||
StringRef defaultValue) const {
|
||||
std::string NetworkTable::GetString(wpi::StringRef key,
|
||||
wpi::StringRef defaultValue) const {
|
||||
return GetEntry(key).GetString(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::PutBoolean(StringRef key, bool value) {
|
||||
bool NetworkTable::PutBoolean(wpi::StringRef key, bool value) {
|
||||
return GetEntry(key).SetBoolean(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultBoolean(StringRef key, bool defaultValue) {
|
||||
bool NetworkTable::SetDefaultBoolean(wpi::StringRef key, bool defaultValue) {
|
||||
return GetEntry(key).SetDefaultBoolean(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::GetBoolean(StringRef key, bool defaultValue) const {
|
||||
bool NetworkTable::GetBoolean(wpi::StringRef key, bool defaultValue) const {
|
||||
return GetEntry(key).GetBoolean(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::PutBooleanArray(StringRef key, ArrayRef<int> value) {
|
||||
bool NetworkTable::PutBooleanArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<int> value) {
|
||||
return GetEntry(key).SetBooleanArray(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultBooleanArray(StringRef key,
|
||||
ArrayRef<int> defaultValue) {
|
||||
bool NetworkTable::SetDefaultBooleanArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<int> defaultValue) {
|
||||
return GetEntry(key).SetDefaultBooleanArray(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<int> NetworkTable::GetBooleanArray(
|
||||
StringRef key, ArrayRef<int> defaultValue) const {
|
||||
wpi::StringRef key, wpi::ArrayRef<int> defaultValue) const {
|
||||
return GetEntry(key).GetBooleanArray(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::PutNumberArray(StringRef key, ArrayRef<double> value) {
|
||||
bool NetworkTable::PutNumberArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<double> value) {
|
||||
return GetEntry(key).SetDoubleArray(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultNumberArray(StringRef key,
|
||||
ArrayRef<double> defaultValue) {
|
||||
bool NetworkTable::SetDefaultNumberArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<double> defaultValue) {
|
||||
return GetEntry(key).SetDefaultDoubleArray(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<double> NetworkTable::GetNumberArray(
|
||||
StringRef key, ArrayRef<double> defaultValue) const {
|
||||
wpi::StringRef key, wpi::ArrayRef<double> defaultValue) const {
|
||||
return GetEntry(key).GetDoubleArray(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::PutStringArray(StringRef key, ArrayRef<std::string> value) {
|
||||
bool NetworkTable::PutStringArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<std::string> value) {
|
||||
return GetEntry(key).SetStringArray(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultStringArray(StringRef key,
|
||||
ArrayRef<std::string> defaultValue) {
|
||||
bool NetworkTable::SetDefaultStringArray(
|
||||
wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue) {
|
||||
return GetEntry(key).SetDefaultStringArray(defaultValue);
|
||||
}
|
||||
|
||||
std::vector<std::string> NetworkTable::GetStringArray(
|
||||
StringRef key, ArrayRef<std::string> defaultValue) const {
|
||||
wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue) const {
|
||||
return GetEntry(key).GetStringArray(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::PutRaw(StringRef key, StringRef value) {
|
||||
bool NetworkTable::PutRaw(wpi::StringRef key, wpi::StringRef value) {
|
||||
return GetEntry(key).SetRaw(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultRaw(StringRef key, StringRef defaultValue) {
|
||||
bool NetworkTable::SetDefaultRaw(wpi::StringRef key,
|
||||
wpi::StringRef defaultValue) {
|
||||
return GetEntry(key).SetDefaultRaw(defaultValue);
|
||||
}
|
||||
|
||||
std::string NetworkTable::GetRaw(StringRef key, StringRef defaultValue) const {
|
||||
std::string NetworkTable::GetRaw(wpi::StringRef key,
|
||||
wpi::StringRef defaultValue) const {
|
||||
return GetEntry(key).GetRaw(defaultValue);
|
||||
}
|
||||
|
||||
bool NetworkTable::PutValue(const Twine& key, std::shared_ptr<Value> value) {
|
||||
bool NetworkTable::PutValue(const wpi::Twine& key,
|
||||
std::shared_ptr<Value> value) {
|
||||
return GetEntry(key).SetValue(value);
|
||||
}
|
||||
|
||||
bool NetworkTable::SetDefaultValue(const Twine& key,
|
||||
bool NetworkTable::SetDefaultValue(const wpi::Twine& key,
|
||||
std::shared_ptr<Value> defaultValue) {
|
||||
return GetEntry(key).SetDefaultValue(defaultValue);
|
||||
}
|
||||
|
||||
std::shared_ptr<Value> NetworkTable::GetValue(const Twine& key) const {
|
||||
std::shared_ptr<Value> NetworkTable::GetValue(const wpi::Twine& key) const {
|
||||
return GetEntry(key).GetValue();
|
||||
}
|
||||
|
||||
StringRef NetworkTable::GetPath() const {
|
||||
wpi::StringRef NetworkTable::GetPath() const {
|
||||
return m_path;
|
||||
}
|
||||
|
||||
const char* NetworkTable::SaveEntries(const Twine& filename) const {
|
||||
return nt::SaveEntries(m_inst, filename, m_path + Twine(PATH_SEPARATOR_CHAR));
|
||||
const char* NetworkTable::SaveEntries(const wpi::Twine& filename) const {
|
||||
return nt::SaveEntries(m_inst, filename,
|
||||
m_path + wpi::Twine(PATH_SEPARATOR_CHAR));
|
||||
}
|
||||
|
||||
const char* NetworkTable::LoadEntries(
|
||||
const Twine& filename,
|
||||
const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
return nt::LoadEntries(m_inst, filename, m_path + Twine(PATH_SEPARATOR_CHAR),
|
||||
warn);
|
||||
return nt::LoadEntries(m_inst, filename,
|
||||
m_path + wpi::Twine(PATH_SEPARATOR_CHAR), warn);
|
||||
}
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
using namespace nt;
|
||||
|
||||
std::shared_ptr<NetworkTable> NetworkTableInstance::GetTable(
|
||||
const Twine& key) const {
|
||||
StringRef simple;
|
||||
const wpi::Twine& key) const {
|
||||
wpi::StringRef simple;
|
||||
bool isSimple = key.isSingleStringRef();
|
||||
if (isSimple) {
|
||||
simple = key.getSingleStringRef();
|
||||
@@ -23,23 +23,23 @@ std::shared_ptr<NetworkTable> NetworkTableInstance::GetTable(
|
||||
NetworkTable::private_init{});
|
||||
} else {
|
||||
return std::make_shared<NetworkTable>(
|
||||
m_handle, Twine(NetworkTable::PATH_SEPARATOR_CHAR) + key,
|
||||
m_handle, wpi::Twine(NetworkTable::PATH_SEPARATOR_CHAR) + key,
|
||||
NetworkTable::private_init{});
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkTableInstance::StartClient(ArrayRef<StringRef> servers,
|
||||
void NetworkTableInstance::StartClient(wpi::ArrayRef<wpi::StringRef> servers,
|
||||
unsigned int port) {
|
||||
wpi::SmallVector<std::pair<StringRef, unsigned int>, 8> server_ports;
|
||||
wpi::SmallVector<std::pair<wpi::StringRef, unsigned int>, 8> server_ports;
|
||||
for (const auto& server : servers) {
|
||||
server_ports.emplace_back(std::make_pair(server, port));
|
||||
}
|
||||
StartClient(server_ports);
|
||||
}
|
||||
|
||||
void NetworkTableInstance::SetServer(ArrayRef<StringRef> servers,
|
||||
void NetworkTableInstance::SetServer(wpi::ArrayRef<wpi::StringRef> servers,
|
||||
unsigned int port) {
|
||||
wpi::SmallVector<std::pair<StringRef, unsigned int>, 8> server_ports;
|
||||
wpi::SmallVector<std::pair<wpi::StringRef, unsigned int>, 8> server_ports;
|
||||
for (const auto& server : servers) {
|
||||
server_ports.emplace_back(std::make_pair(server, port));
|
||||
}
|
||||
@@ -47,7 +47,7 @@ void NetworkTableInstance::SetServer(ArrayRef<StringRef> servers,
|
||||
}
|
||||
|
||||
NT_EntryListener NetworkTableInstance::AddEntryListener(
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int flags) const {
|
||||
return ::nt::AddEntryListener(m_handle, prefix, callback, flags);
|
||||
|
||||
@@ -192,12 +192,12 @@ NT_Inst NT_GetInstanceFromHandle(NT_Handle handle) {
|
||||
*/
|
||||
|
||||
NT_Entry NT_GetEntry(NT_Inst inst, const char* name, size_t name_len) {
|
||||
return nt::GetEntry(inst, StringRef(name, name_len));
|
||||
return nt::GetEntry(inst, wpi::StringRef(name, name_len));
|
||||
}
|
||||
|
||||
NT_Entry* NT_GetEntries(NT_Inst inst, const char* prefix, size_t prefix_len,
|
||||
unsigned int types, size_t* count) {
|
||||
auto info_v = nt::GetEntries(inst, StringRef(prefix, prefix_len), types);
|
||||
auto info_v = nt::GetEntries(inst, wpi::StringRef(prefix, prefix_len), types);
|
||||
*count = info_v.size();
|
||||
if (info_v.size() == 0) {
|
||||
return nullptr;
|
||||
@@ -266,7 +266,8 @@ void NT_DeleteAllEntries(NT_Inst inst) {
|
||||
struct NT_EntryInfo* NT_GetEntryInfo(NT_Inst inst, const char* prefix,
|
||||
size_t prefix_len, unsigned int types,
|
||||
size_t* count) {
|
||||
auto info_v = nt::GetEntryInfo(inst, StringRef(prefix, prefix_len), types);
|
||||
auto info_v =
|
||||
nt::GetEntryInfo(inst, wpi::StringRef(prefix, prefix_len), types);
|
||||
return ConvertToC<NT_EntryInfo>(info_v, count);
|
||||
}
|
||||
|
||||
@@ -288,7 +289,7 @@ NT_EntryListener NT_AddEntryListener(NT_Inst inst, const char* prefix,
|
||||
NT_EntryListenerCallback callback,
|
||||
unsigned int flags) {
|
||||
return nt::AddEntryListener(
|
||||
inst, StringRef(prefix, prefix_len),
|
||||
inst, wpi::StringRef(prefix, prefix_len),
|
||||
[=](const EntryNotification& event) {
|
||||
NT_EntryNotification c_event;
|
||||
ConvertToC(event, &c_event);
|
||||
@@ -324,7 +325,7 @@ NT_EntryListener NT_AddPolledEntryListener(NT_EntryListenerPoller poller,
|
||||
const char* prefix,
|
||||
size_t prefix_len,
|
||||
unsigned int flags) {
|
||||
return nt::AddPolledEntryListener(poller, StringRef(prefix, prefix_len),
|
||||
return nt::AddPolledEntryListener(poller, wpi::StringRef(prefix, prefix_len),
|
||||
flags);
|
||||
}
|
||||
|
||||
@@ -421,12 +422,13 @@ NT_Bool NT_WaitForConnectionListenerQueue(NT_Inst inst, double timeout) {
|
||||
|
||||
void NT_CreateRpc(NT_Entry entry, const char* def, size_t def_len, void* data,
|
||||
NT_RpcCallback callback) {
|
||||
nt::CreateRpc(entry, StringRef(def, def_len), [=](const RpcAnswer& answer) {
|
||||
NT_RpcAnswer answer_c;
|
||||
ConvertToC(answer, &answer_c);
|
||||
callback(data, &answer_c);
|
||||
NT_DisposeRpcAnswer(&answer_c);
|
||||
});
|
||||
nt::CreateRpc(entry, wpi::StringRef(def, def_len),
|
||||
[=](const RpcAnswer& answer) {
|
||||
NT_RpcAnswer answer_c;
|
||||
ConvertToC(answer, &answer_c);
|
||||
callback(data, &answer_c);
|
||||
NT_DisposeRpcAnswer(&answer_c);
|
||||
});
|
||||
}
|
||||
|
||||
NT_RpcCallPoller NT_CreateRpcCallPoller(NT_Inst inst) {
|
||||
@@ -439,7 +441,7 @@ void NT_DestroyRpcCallPoller(NT_RpcCallPoller poller) {
|
||||
|
||||
void NT_CreatePolledRpc(NT_Entry entry, const char* def, size_t def_len,
|
||||
NT_RpcCallPoller poller) {
|
||||
nt::CreatePolledRpc(entry, StringRef(def, def_len), poller);
|
||||
nt::CreatePolledRpc(entry, wpi::StringRef(def, def_len), poller);
|
||||
}
|
||||
|
||||
NT_RpcAnswer* NT_PollRpc(NT_RpcCallPoller poller, size_t* len) {
|
||||
@@ -465,11 +467,11 @@ NT_Bool NT_WaitForRpcCallQueue(NT_Inst inst, double timeout) {
|
||||
|
||||
NT_Bool NT_PostRpcResponse(NT_Entry entry, NT_RpcCall call, const char* result,
|
||||
size_t result_len) {
|
||||
return nt::PostRpcResponse(entry, call, StringRef(result, result_len));
|
||||
return nt::PostRpcResponse(entry, call, wpi::StringRef(result, result_len));
|
||||
}
|
||||
|
||||
NT_RpcCall NT_CallRpc(NT_Entry entry, const char* params, size_t params_len) {
|
||||
return nt::CallRpc(entry, StringRef(params, params_len));
|
||||
return nt::CallRpc(entry, wpi::StringRef(params, params_len));
|
||||
}
|
||||
|
||||
char* NT_GetRpcResult(NT_Entry entry, NT_RpcCall call, size_t* result_len) {
|
||||
@@ -520,7 +522,7 @@ char* NT_PackRpcDefinition(const NT_RpcDefinition* def, size_t* packed_len) {
|
||||
NT_Bool NT_UnpackRpcDefinition(const char* packed, size_t packed_len,
|
||||
NT_RpcDefinition* def) {
|
||||
nt::RpcDefinition def_v;
|
||||
if (!nt::UnpackRpcDefinition(StringRef(packed, packed_len), &def_v)) {
|
||||
if (!nt::UnpackRpcDefinition(wpi::StringRef(packed, packed_len), &def_v)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -550,8 +552,8 @@ char* NT_PackRpcValues(const NT_Value** values, size_t values_len,
|
||||
|
||||
NT_Value** NT_UnpackRpcValues(const char* packed, size_t packed_len,
|
||||
const NT_Type* types, size_t types_len) {
|
||||
auto values_v = nt::UnpackRpcValues(StringRef(packed, packed_len),
|
||||
ArrayRef<NT_Type>(types, types_len));
|
||||
auto values_v = nt::UnpackRpcValues(wpi::StringRef(packed, packed_len),
|
||||
wpi::ArrayRef<NT_Type>(types, types_len));
|
||||
if (values_v.size() == 0) {
|
||||
return nullptr;
|
||||
}
|
||||
@@ -571,7 +573,7 @@ NT_Value** NT_UnpackRpcValues(const char* packed, size_t packed_len,
|
||||
*/
|
||||
|
||||
void NT_SetNetworkIdentity(NT_Inst inst, const char* name, size_t name_len) {
|
||||
nt::SetNetworkIdentity(inst, StringRef(name, name_len));
|
||||
nt::SetNetworkIdentity(inst, wpi::StringRef(name, name_len));
|
||||
}
|
||||
|
||||
unsigned int NT_GetNetworkMode(NT_Inst inst) {
|
||||
@@ -605,7 +607,7 @@ void NT_StartClient(NT_Inst inst, const char* server_name, unsigned int port) {
|
||||
|
||||
void NT_StartClientMulti(NT_Inst inst, size_t count, const char** server_names,
|
||||
const unsigned int* ports) {
|
||||
std::vector<std::pair<StringRef, unsigned int>> servers;
|
||||
std::vector<std::pair<wpi::StringRef, unsigned int>> servers;
|
||||
servers.reserve(count);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
servers.emplace_back(std::make_pair(server_names[i], ports[i]));
|
||||
@@ -627,7 +629,7 @@ void NT_SetServer(NT_Inst inst, const char* server_name, unsigned int port) {
|
||||
|
||||
void NT_SetServerMulti(NT_Inst inst, size_t count, const char** server_names,
|
||||
const unsigned int* ports) {
|
||||
std::vector<std::pair<StringRef, unsigned int>> servers;
|
||||
std::vector<std::pair<wpi::StringRef, unsigned int>> servers;
|
||||
servers.reserve(count);
|
||||
for (size_t i = 0; i < count; ++i) {
|
||||
servers.emplace_back(std::make_pair(server_names[i], ports[i]));
|
||||
@@ -679,13 +681,14 @@ const char* NT_LoadPersistent(NT_Inst inst, const char* filename,
|
||||
|
||||
const char* NT_SaveEntries(NT_Inst inst, const char* filename,
|
||||
const char* prefix, size_t prefix_len) {
|
||||
return nt::SaveEntries(inst, filename, StringRef(prefix, prefix_len));
|
||||
return nt::SaveEntries(inst, filename, wpi::StringRef(prefix, prefix_len));
|
||||
}
|
||||
|
||||
const char* NT_LoadEntries(NT_Inst inst, const char* filename,
|
||||
const char* prefix, size_t prefix_len,
|
||||
void (*warn)(size_t line, const char* msg)) {
|
||||
return nt::LoadEntries(inst, filename, StringRef(prefix, prefix_len), warn);
|
||||
return nt::LoadEntries(inst, filename, wpi::StringRef(prefix, prefix_len),
|
||||
warn);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -951,23 +954,24 @@ NT_Bool NT_SetEntryBoolean(NT_Entry entry, uint64_t time, NT_Bool v_boolean,
|
||||
NT_Bool NT_SetEntryString(NT_Entry entry, uint64_t time, const char* str,
|
||||
size_t str_len, NT_Bool force) {
|
||||
if (force != 0) {
|
||||
nt::SetEntryTypeValue(entry,
|
||||
Value::MakeString(StringRef(str, str_len), time));
|
||||
nt::SetEntryTypeValue(
|
||||
entry, Value::MakeString(wpi::StringRef(str, str_len), time));
|
||||
return 1;
|
||||
} else {
|
||||
return nt::SetEntryValue(entry,
|
||||
Value::MakeString(StringRef(str, str_len), time));
|
||||
return nt::SetEntryValue(
|
||||
entry, Value::MakeString(wpi::StringRef(str, str_len), time));
|
||||
}
|
||||
}
|
||||
|
||||
NT_Bool NT_SetEntryRaw(NT_Entry entry, uint64_t time, const char* raw,
|
||||
size_t raw_len, NT_Bool force) {
|
||||
if (force != 0) {
|
||||
nt::SetEntryTypeValue(entry, Value::MakeRaw(StringRef(raw, raw_len), time));
|
||||
nt::SetEntryTypeValue(entry,
|
||||
Value::MakeRaw(wpi::StringRef(raw, raw_len), time));
|
||||
return 1;
|
||||
} else {
|
||||
return nt::SetEntryValue(entry,
|
||||
Value::MakeRaw(StringRef(raw, raw_len), time));
|
||||
return nt::SetEntryValue(
|
||||
entry, Value::MakeRaw(wpi::StringRef(raw, raw_len), time));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1128,13 +1132,14 @@ NT_Bool NT_SetDefaultEntryString(NT_Entry entry, uint64_t time,
|
||||
const char* default_value,
|
||||
size_t default_len) {
|
||||
return nt::SetDefaultEntryValue(
|
||||
entry, Value::MakeString(StringRef(default_value, default_len), time));
|
||||
entry,
|
||||
Value::MakeString(wpi::StringRef(default_value, default_len), time));
|
||||
}
|
||||
|
||||
NT_Bool NT_SetDefaultEntryRaw(NT_Entry entry, uint64_t time,
|
||||
const char* default_value, size_t default_len) {
|
||||
return nt::SetDefaultEntryValue(
|
||||
entry, Value::MakeRaw(StringRef(default_value, default_len), time));
|
||||
entry, Value::MakeRaw(wpi::StringRef(default_value, default_len), time));
|
||||
}
|
||||
|
||||
NT_Bool NT_SetDefaultEntryBooleanArray(NT_Entry entry, uint64_t time,
|
||||
|
||||
@@ -53,7 +53,7 @@ NT_Inst GetInstanceFromHandle(NT_Handle handle) {
|
||||
* Table Functions
|
||||
*/
|
||||
|
||||
NT_Entry GetEntry(NT_Inst inst, const Twine& name) {
|
||||
NT_Entry GetEntry(NT_Inst inst, const wpi::Twine& name) {
|
||||
int i = Handle{inst}.GetTypedInst(Handle::kInstance);
|
||||
auto ii = InstanceImpl::Get(i);
|
||||
if (!ii) {
|
||||
@@ -67,7 +67,7 @@ NT_Entry GetEntry(NT_Inst inst, const Twine& name) {
|
||||
return Handle(i, id, Handle::kEntry);
|
||||
}
|
||||
|
||||
std::vector<NT_Entry> GetEntries(NT_Inst inst, const Twine& prefix,
|
||||
std::vector<NT_Entry> GetEntries(NT_Inst inst, const wpi::Twine& prefix,
|
||||
unsigned int types) {
|
||||
int i = Handle{inst}.GetTypedInst(Handle::kInstance);
|
||||
auto ii = InstanceImpl::Get(i);
|
||||
@@ -203,7 +203,7 @@ void DeleteAllEntries(NT_Inst inst) {
|
||||
ii->storage.DeleteAllEntries();
|
||||
}
|
||||
|
||||
std::vector<EntryInfo> GetEntryInfo(NT_Inst inst, const Twine& prefix,
|
||||
std::vector<EntryInfo> GetEntryInfo(NT_Inst inst, const wpi::Twine& prefix,
|
||||
unsigned int types) {
|
||||
int i = Handle{inst}.GetTypedInst(Handle::kInstance);
|
||||
auto ii = InstanceImpl::Get(i);
|
||||
@@ -236,7 +236,7 @@ EntryInfo GetEntryInfo(NT_Entry entry) {
|
||||
*/
|
||||
|
||||
NT_EntryListener AddEntryListener(
|
||||
NT_Inst inst, const Twine& prefix,
|
||||
NT_Inst inst, const wpi::Twine& prefix,
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int flags) {
|
||||
int i = Handle{inst}.GetTypedInst(Handle::kInstance);
|
||||
@@ -288,7 +288,7 @@ void DestroyEntryListenerPoller(NT_EntryListenerPoller poller) {
|
||||
}
|
||||
|
||||
NT_EntryListener AddPolledEntryListener(NT_EntryListenerPoller poller,
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
unsigned int flags) {
|
||||
Handle handle{poller};
|
||||
int id = handle.GetTypedIndex(Handle::kEntryListenerPoller);
|
||||
@@ -494,7 +494,7 @@ bool WaitForConnectionListenerQueue(NT_Inst inst, double timeout) {
|
||||
* Remote Procedure Call Functions
|
||||
*/
|
||||
|
||||
void CreateRpc(NT_Entry entry, StringRef def,
|
||||
void CreateRpc(NT_Entry entry, wpi::StringRef def,
|
||||
std::function<void(const RpcAnswer& answer)> callback) {
|
||||
Handle handle{entry};
|
||||
int id = handle.GetTypedIndex(Handle::kEntry);
|
||||
@@ -535,7 +535,8 @@ void DestroyRpcCallPoller(NT_RpcCallPoller poller) {
|
||||
ii->rpc_server.RemovePoller(id);
|
||||
}
|
||||
|
||||
void CreatePolledRpc(NT_Entry entry, StringRef def, NT_RpcCallPoller poller) {
|
||||
void CreatePolledRpc(NT_Entry entry, wpi::StringRef def,
|
||||
NT_RpcCallPoller poller) {
|
||||
Handle handle{entry};
|
||||
int id = handle.GetTypedIndex(Handle::kEntry);
|
||||
auto ii = InstanceImpl::Get(handle.GetInst());
|
||||
@@ -607,7 +608,7 @@ bool WaitForRpcCallQueue(NT_Inst inst, double timeout) {
|
||||
return ii->rpc_server.WaitForQueue(timeout);
|
||||
}
|
||||
|
||||
bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, StringRef result) {
|
||||
bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, wpi::StringRef result) {
|
||||
Handle handle{entry};
|
||||
int id = handle.GetTypedIndex(Handle::kEntry);
|
||||
auto ii = InstanceImpl::Get(handle.GetInst());
|
||||
@@ -627,7 +628,7 @@ bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, StringRef result) {
|
||||
return ii->rpc_server.PostRpcResponse(id, call_uid, result);
|
||||
}
|
||||
|
||||
NT_RpcCall CallRpc(NT_Entry entry, StringRef params) {
|
||||
NT_RpcCall CallRpc(NT_Entry entry, wpi::StringRef params) {
|
||||
Handle handle{entry};
|
||||
int id = handle.GetTypedIndex(Handle::kEntry);
|
||||
int i = handle.GetInst();
|
||||
@@ -736,7 +737,7 @@ std::string PackRpcDefinition(const RpcDefinition& def) {
|
||||
return enc.ToStringRef();
|
||||
}
|
||||
|
||||
bool UnpackRpcDefinition(StringRef packed, RpcDefinition* def) {
|
||||
bool UnpackRpcDefinition(wpi::StringRef packed, RpcDefinition* def) {
|
||||
wpi::raw_mem_istream is(packed.data(), packed.size());
|
||||
wpi::Logger logger;
|
||||
WireDecoder dec(is, 0x0300, logger);
|
||||
@@ -791,7 +792,7 @@ bool UnpackRpcDefinition(StringRef packed, RpcDefinition* def) {
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string PackRpcValues(ArrayRef<std::shared_ptr<Value>> values) {
|
||||
std::string PackRpcValues(wpi::ArrayRef<std::shared_ptr<Value>> values) {
|
||||
WireEncoder enc(0x0300);
|
||||
for (auto& value : values) {
|
||||
enc.WriteValue(*value);
|
||||
@@ -799,8 +800,8 @@ std::string PackRpcValues(ArrayRef<std::shared_ptr<Value>> values) {
|
||||
return enc.ToStringRef();
|
||||
}
|
||||
|
||||
std::vector<std::shared_ptr<Value>> UnpackRpcValues(StringRef packed,
|
||||
ArrayRef<NT_Type> types) {
|
||||
std::vector<std::shared_ptr<Value>> UnpackRpcValues(
|
||||
wpi::StringRef packed, wpi::ArrayRef<NT_Type> types) {
|
||||
wpi::raw_mem_istream is(packed.data(), packed.size());
|
||||
wpi::Logger logger;
|
||||
WireDecoder dec(is, 0x0300, logger);
|
||||
@@ -823,7 +824,7 @@ uint64_t Now() {
|
||||
* Client/Server Functions
|
||||
*/
|
||||
|
||||
void SetNetworkIdentity(NT_Inst inst, const Twine& name) {
|
||||
void SetNetworkIdentity(NT_Inst inst, const wpi::Twine& name) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
return;
|
||||
@@ -859,7 +860,7 @@ void StopLocal(NT_Inst inst) {
|
||||
ii->dispatcher.Stop();
|
||||
}
|
||||
|
||||
void StartServer(NT_Inst inst, const Twine& persist_filename,
|
||||
void StartServer(NT_Inst inst, const wpi::Twine& persist_filename,
|
||||
const char* listen_address, unsigned int port) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
@@ -897,8 +898,9 @@ void StartClient(NT_Inst inst, const char* server_name, unsigned int port) {
|
||||
ii->dispatcher.StartClient();
|
||||
}
|
||||
|
||||
void StartClient(NT_Inst inst,
|
||||
ArrayRef<std::pair<StringRef, unsigned int>> servers) {
|
||||
void StartClient(
|
||||
NT_Inst inst,
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
return;
|
||||
@@ -937,7 +939,7 @@ void SetServer(NT_Inst inst, const char* server_name, unsigned int port) {
|
||||
}
|
||||
|
||||
void SetServer(NT_Inst inst,
|
||||
ArrayRef<std::pair<StringRef, unsigned int>> servers) {
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
return;
|
||||
@@ -1013,7 +1015,7 @@ bool IsConnected(NT_Inst inst) {
|
||||
* Persistent Functions
|
||||
*/
|
||||
|
||||
const char* SavePersistent(NT_Inst inst, const Twine& filename) {
|
||||
const char* SavePersistent(NT_Inst inst, const wpi::Twine& filename) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
return "invalid instance handle";
|
||||
@@ -1023,7 +1025,7 @@ const char* SavePersistent(NT_Inst inst, const Twine& filename) {
|
||||
}
|
||||
|
||||
const char* LoadPersistent(
|
||||
NT_Inst inst, const Twine& filename,
|
||||
NT_Inst inst, const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
@@ -1033,8 +1035,8 @@ const char* LoadPersistent(
|
||||
return ii->storage.LoadPersistent(filename, warn);
|
||||
}
|
||||
|
||||
const char* SaveEntries(NT_Inst inst, const Twine& filename,
|
||||
const Twine& prefix) {
|
||||
const char* SaveEntries(NT_Inst inst, const wpi::Twine& filename,
|
||||
const wpi::Twine& prefix) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
return "invalid instance handle";
|
||||
@@ -1044,7 +1046,7 @@ const char* SaveEntries(NT_Inst inst, const Twine& filename,
|
||||
}
|
||||
|
||||
const char* LoadEntries(
|
||||
NT_Inst inst, const Twine& filename, const Twine& prefix,
|
||||
NT_Inst inst, const wpi::Twine& filename, const wpi::Twine& prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
auto ii = InstanceImpl::Get(Handle{inst}.GetTypedInst(Handle::kInstance));
|
||||
if (!ii) {
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
|
||||
namespace nt {
|
||||
|
||||
using wpi::ArrayRef;
|
||||
using wpi::StringRef;
|
||||
using wpi::Twine;
|
||||
|
||||
class NetworkTableInstance;
|
||||
|
||||
/**
|
||||
@@ -58,7 +54,7 @@ class NetworkTable final {
|
||||
* @param key key
|
||||
* @return base name
|
||||
*/
|
||||
static StringRef BasenameKey(StringRef key);
|
||||
static wpi::StringRef BasenameKey(wpi::StringRef key);
|
||||
|
||||
/**
|
||||
* Normalizes an network table key to contain no consecutive slashes and
|
||||
@@ -76,12 +72,12 @@ class NetworkTable final {
|
||||
* with a leading slash
|
||||
* @return normalized key
|
||||
*/
|
||||
static std::string NormalizeKey(const Twine& key,
|
||||
static std::string NormalizeKey(const wpi::Twine& key,
|
||||
bool withLeadingSlash = true);
|
||||
|
||||
static StringRef NormalizeKey(const Twine& key,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
bool withLeadingSlash = true);
|
||||
static wpi::StringRef NormalizeKey(const wpi::Twine& key,
|
||||
wpi::SmallVectorImpl<char>& buf,
|
||||
bool withLeadingSlash = true);
|
||||
|
||||
/**
|
||||
* Gets a list of the names of all the super tables of a given key. For
|
||||
@@ -91,13 +87,13 @@ class NetworkTable final {
|
||||
* @param key the key
|
||||
* @return List of super tables
|
||||
*/
|
||||
static std::vector<std::string> GetHierarchy(const Twine& key);
|
||||
static std::vector<std::string> GetHierarchy(const wpi::Twine& key);
|
||||
|
||||
/**
|
||||
* Constructor. Use NetworkTableInstance::GetTable() or GetSubTable()
|
||||
* instead.
|
||||
*/
|
||||
NetworkTable(NT_Inst inst, const Twine& path, const private_init&);
|
||||
NetworkTable(NT_Inst inst, const wpi::Twine& path, const private_init&);
|
||||
virtual ~NetworkTable();
|
||||
|
||||
/**
|
||||
@@ -118,7 +114,7 @@ class NetworkTable final {
|
||||
* @param key the key name
|
||||
* @return Network table entry.
|
||||
*/
|
||||
NetworkTableEntry GetEntry(const Twine& key) const;
|
||||
NetworkTableEntry GetEntry(const wpi::Twine& key) const;
|
||||
|
||||
/**
|
||||
* Listen to keys only within this table.
|
||||
@@ -138,7 +134,7 @@ class NetworkTable final {
|
||||
* @param flags EntryListenerFlags bitmask
|
||||
* @return Listener handle
|
||||
*/
|
||||
NT_EntryListener AddEntryListener(const Twine& key,
|
||||
NT_EntryListener AddEntryListener(const wpi::Twine& key,
|
||||
TableEntryListener listener,
|
||||
unsigned int flags) const;
|
||||
|
||||
@@ -175,7 +171,7 @@ class NetworkTable final {
|
||||
* @param key the key name
|
||||
* @return the networktable to be returned
|
||||
*/
|
||||
std::shared_ptr<NetworkTable> GetSubTable(const Twine& key) const;
|
||||
std::shared_ptr<NetworkTable> GetSubTable(const wpi::Twine& key) const;
|
||||
|
||||
/**
|
||||
* Determines whether the given key is in this table.
|
||||
@@ -183,7 +179,7 @@ class NetworkTable final {
|
||||
* @param key the key to search for
|
||||
* @return true if the table as a value assigned to the given key
|
||||
*/
|
||||
bool ContainsKey(const Twine& key) const;
|
||||
bool ContainsKey(const wpi::Twine& key) const;
|
||||
|
||||
/**
|
||||
* Determines whether there exists a non-empty subtable for this key
|
||||
@@ -193,7 +189,7 @@ class NetworkTable final {
|
||||
* @return true if there is a subtable with the key which contains at least
|
||||
* one key/subtable of its own
|
||||
*/
|
||||
bool ContainsSubTable(const Twine& key) const;
|
||||
bool ContainsSubTable(const wpi::Twine& key) const;
|
||||
|
||||
/**
|
||||
* Gets all keys in the table (not including sub-tables).
|
||||
@@ -215,7 +211,7 @@ class NetworkTable final {
|
||||
*
|
||||
* @param key the key to make persistent
|
||||
*/
|
||||
void SetPersistent(StringRef key);
|
||||
void SetPersistent(wpi::StringRef key);
|
||||
|
||||
/**
|
||||
* Stop making a key's value persistent through program restarts.
|
||||
@@ -223,7 +219,7 @@ class NetworkTable final {
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
void ClearPersistent(StringRef key);
|
||||
void ClearPersistent(wpi::StringRef key);
|
||||
|
||||
/**
|
||||
* Returns whether the value is persistent through program restarts.
|
||||
@@ -231,7 +227,7 @@ class NetworkTable final {
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
bool IsPersistent(StringRef key) const;
|
||||
bool IsPersistent(wpi::StringRef key) const;
|
||||
|
||||
/**
|
||||
* Sets flags on the specified key in this table. The key can
|
||||
@@ -240,7 +236,7 @@ class NetworkTable final {
|
||||
* @param key the key name
|
||||
* @param flags the flags to set (bitmask)
|
||||
*/
|
||||
void SetFlags(StringRef key, unsigned int flags);
|
||||
void SetFlags(wpi::StringRef key, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Clears flags on the specified key in this table. The key can
|
||||
@@ -249,7 +245,7 @@ class NetworkTable final {
|
||||
* @param key the key name
|
||||
* @param flags the flags to clear (bitmask)
|
||||
*/
|
||||
void ClearFlags(StringRef key, unsigned int flags);
|
||||
void ClearFlags(wpi::StringRef key, unsigned int flags);
|
||||
|
||||
/**
|
||||
* Returns the flags for the specified key.
|
||||
@@ -257,14 +253,14 @@ class NetworkTable final {
|
||||
* @param key the key name
|
||||
* @return the flags, or 0 if the key is not defined
|
||||
*/
|
||||
unsigned int GetFlags(StringRef key) const;
|
||||
unsigned int GetFlags(wpi::StringRef key) const;
|
||||
|
||||
/**
|
||||
* Deletes the specified key in this table.
|
||||
*
|
||||
* @param key the key name
|
||||
*/
|
||||
void Delete(const Twine& key);
|
||||
void Delete(const wpi::Twine& key);
|
||||
|
||||
/**
|
||||
* Put a number in the table
|
||||
@@ -273,7 +269,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutNumber(StringRef key, double value);
|
||||
bool PutNumber(wpi::StringRef key, double value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -282,7 +278,7 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultNumber(StringRef key, double defaultValue);
|
||||
bool SetDefaultNumber(wpi::StringRef key, double defaultValue);
|
||||
|
||||
/**
|
||||
* Gets the number associated with the given name.
|
||||
@@ -292,7 +288,7 @@ class NetworkTable final {
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
double GetNumber(StringRef key, double defaultValue) const;
|
||||
double GetNumber(wpi::StringRef key, double defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a string in the table
|
||||
@@ -301,7 +297,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutString(StringRef key, StringRef value);
|
||||
bool PutString(wpi::StringRef key, wpi::StringRef value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -310,7 +306,7 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultString(StringRef key, StringRef defaultValue);
|
||||
bool SetDefaultString(wpi::StringRef key, wpi::StringRef defaultValue);
|
||||
|
||||
/**
|
||||
* Gets the string associated with the given name. If the key does not
|
||||
@@ -321,7 +317,7 @@ class NetworkTable final {
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
std::string GetString(StringRef key, StringRef defaultValue) const;
|
||||
std::string GetString(wpi::StringRef key, wpi::StringRef defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a boolean in the table
|
||||
@@ -330,7 +326,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutBoolean(StringRef key, bool value);
|
||||
bool PutBoolean(wpi::StringRef key, bool value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -339,7 +335,7 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultBoolean(StringRef key, bool defaultValue);
|
||||
bool SetDefaultBoolean(wpi::StringRef key, bool defaultValue);
|
||||
|
||||
/**
|
||||
* Gets the boolean associated with the given name. If the key does not
|
||||
@@ -350,7 +346,7 @@ class NetworkTable final {
|
||||
* @return the value associated with the given key or the given default value
|
||||
* if there is no value associated with the key
|
||||
*/
|
||||
bool GetBoolean(StringRef key, bool defaultValue) const;
|
||||
bool GetBoolean(wpi::StringRef key, bool defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a boolean array in the table
|
||||
@@ -363,7 +359,7 @@ class NetworkTable final {
|
||||
* std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
bool PutBooleanArray(StringRef key, ArrayRef<int> value);
|
||||
bool PutBooleanArray(wpi::StringRef key, wpi::ArrayRef<int> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -372,7 +368,8 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultBooleanArray(StringRef key, ArrayRef<int> defaultValue);
|
||||
bool SetDefaultBooleanArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<int> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the boolean array the key maps to. If the key does not exist or is
|
||||
@@ -390,8 +387,8 @@ class NetworkTable final {
|
||||
* because std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
std::vector<int> GetBooleanArray(StringRef key,
|
||||
ArrayRef<int> defaultValue) const;
|
||||
std::vector<int> GetBooleanArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<int> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a number array in the table
|
||||
@@ -400,7 +397,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutNumberArray(StringRef key, ArrayRef<double> value);
|
||||
bool PutNumberArray(wpi::StringRef key, wpi::ArrayRef<double> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -409,7 +406,8 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultNumberArray(StringRef key, ArrayRef<double> defaultValue);
|
||||
bool SetDefaultNumberArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<double> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the number array the key maps to. If the key does not exist or is
|
||||
@@ -423,8 +421,8 @@ class NetworkTable final {
|
||||
* @note This makes a copy of the array. If the overhead of this is a
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<double> GetNumberArray(StringRef key,
|
||||
ArrayRef<double> defaultValue) const;
|
||||
std::vector<double> GetNumberArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<double> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a string array in the table
|
||||
@@ -433,7 +431,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutStringArray(StringRef key, ArrayRef<std::string> value);
|
||||
bool PutStringArray(wpi::StringRef key, wpi::ArrayRef<std::string> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -442,7 +440,8 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @returns False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultStringArray(StringRef key, ArrayRef<std::string> defaultValue);
|
||||
bool SetDefaultStringArray(wpi::StringRef key,
|
||||
wpi::ArrayRef<std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the string array the key maps to. If the key does not exist or is
|
||||
@@ -457,7 +456,7 @@ class NetworkTable final {
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<std::string> GetStringArray(
|
||||
StringRef key, ArrayRef<std::string> defaultValue) const;
|
||||
wpi::StringRef key, wpi::ArrayRef<std::string> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a raw value (byte array) in the table
|
||||
@@ -466,7 +465,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutRaw(StringRef key, StringRef value);
|
||||
bool PutRaw(wpi::StringRef key, wpi::StringRef value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -475,7 +474,7 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultRaw(StringRef key, StringRef defaultValue);
|
||||
bool SetDefaultRaw(wpi::StringRef key, wpi::StringRef defaultValue);
|
||||
|
||||
/**
|
||||
* Returns the raw value (byte array) the key maps to. If the key does not
|
||||
@@ -489,7 +488,7 @@ class NetworkTable final {
|
||||
* @note This makes a copy of the raw contents. If the overhead of this is a
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::string GetRaw(StringRef key, StringRef defaultValue) const;
|
||||
std::string GetRaw(wpi::StringRef key, wpi::StringRef defaultValue) const;
|
||||
|
||||
/**
|
||||
* Put a value in the table
|
||||
@@ -498,7 +497,7 @@ class NetworkTable final {
|
||||
* @param value the value that will be assigned
|
||||
* @return False if the table key already exists with a different type
|
||||
*/
|
||||
bool PutValue(const Twine& key, std::shared_ptr<Value> value);
|
||||
bool PutValue(const wpi::Twine& key, std::shared_ptr<Value> value);
|
||||
|
||||
/**
|
||||
* Gets the current value in the table, setting it if it does not exist.
|
||||
@@ -507,7 +506,8 @@ class NetworkTable final {
|
||||
* @param defaultValue the default value to set if key doesn't exist.
|
||||
* @return False if the table key exists with a different type
|
||||
*/
|
||||
bool SetDefaultValue(const Twine& key, std::shared_ptr<Value> defaultValue);
|
||||
bool SetDefaultValue(const wpi::Twine& key,
|
||||
std::shared_ptr<Value> defaultValue);
|
||||
|
||||
/**
|
||||
* Gets the value associated with a key as an object
|
||||
@@ -516,14 +516,14 @@ class NetworkTable final {
|
||||
* @return the value associated with the given key, or nullptr if the key
|
||||
* does not exist
|
||||
*/
|
||||
std::shared_ptr<Value> GetValue(const Twine& key) const;
|
||||
std::shared_ptr<Value> GetValue(const wpi::Twine& key) const;
|
||||
|
||||
/**
|
||||
* Gets the full path of this table. Does not include the trailing "/".
|
||||
*
|
||||
* @return The path (e.g "", "/foo").
|
||||
*/
|
||||
StringRef GetPath() const;
|
||||
wpi::StringRef GetPath() const;
|
||||
|
||||
/**
|
||||
* Save table values to a file. The file format used is identical to
|
||||
@@ -532,7 +532,7 @@ class NetworkTable final {
|
||||
* @param filename filename
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* SaveEntries(const Twine& filename) const;
|
||||
const char* SaveEntries(const wpi::Twine& filename) const;
|
||||
|
||||
/**
|
||||
* Load table values from a file. The file format used is identical to
|
||||
@@ -543,7 +543,7 @@ class NetworkTable final {
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* LoadEntries(
|
||||
const Twine& filename,
|
||||
const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
};
|
||||
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
|
||||
namespace nt {
|
||||
|
||||
using wpi::ArrayRef;
|
||||
using wpi::StringRef;
|
||||
using wpi::Twine;
|
||||
|
||||
class NetworkTableInstance;
|
||||
|
||||
/**
|
||||
@@ -147,7 +143,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the entry's value or the given default value
|
||||
*/
|
||||
std::string GetString(StringRef defaultValue) const;
|
||||
std::string GetString(wpi::StringRef defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a raw. If the entry does not exist or is of
|
||||
@@ -156,7 +152,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the value to be returned if no value is found
|
||||
* @return the entry's value or the given default value
|
||||
*/
|
||||
std::string GetRaw(StringRef defaultValue) const;
|
||||
std::string GetRaw(wpi::StringRef defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a boolean array. If the entry does not exist
|
||||
@@ -172,7 +168,7 @@ class NetworkTableEntry final {
|
||||
* because std::vector<bool> is special-cased in C++. 0 is false, any
|
||||
* non-zero value is true.
|
||||
*/
|
||||
std::vector<int> GetBooleanArray(ArrayRef<int> defaultValue) const;
|
||||
std::vector<int> GetBooleanArray(wpi::ArrayRef<int> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a boolean array. If the entry does not exist
|
||||
@@ -201,7 +197,7 @@ class NetworkTableEntry final {
|
||||
* @note This makes a copy of the array. If the overhead of this is a
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<double> GetDoubleArray(ArrayRef<double> defaultValue) const;
|
||||
std::vector<double> GetDoubleArray(wpi::ArrayRef<double> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a double array. If the entry does not exist
|
||||
@@ -227,7 +223,7 @@ class NetworkTableEntry final {
|
||||
* concern, use GetValue() instead.
|
||||
*/
|
||||
std::vector<std::string> GetStringArray(
|
||||
ArrayRef<std::string> defaultValue) const;
|
||||
wpi::ArrayRef<std::string> defaultValue) const;
|
||||
|
||||
/**
|
||||
* Gets the entry's value as a string array. If the entry does not exist
|
||||
@@ -272,7 +268,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultString(const Twine& defaultValue);
|
||||
bool SetDefaultString(const wpi::Twine& defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -280,7 +276,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultRaw(StringRef defaultValue);
|
||||
bool SetDefaultRaw(wpi::StringRef defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -288,7 +284,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultBooleanArray(ArrayRef<int> defaultValue);
|
||||
bool SetDefaultBooleanArray(wpi::ArrayRef<int> defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -304,7 +300,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultDoubleArray(ArrayRef<double> defaultValue);
|
||||
bool SetDefaultDoubleArray(wpi::ArrayRef<double> defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -320,7 +316,7 @@ class NetworkTableEntry final {
|
||||
* @param defaultValue the default value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDefaultStringArray(ArrayRef<std::string> defaultValue);
|
||||
bool SetDefaultStringArray(wpi::ArrayRef<std::string> defaultValue);
|
||||
|
||||
/**
|
||||
* Sets the entry's value if it does not exist.
|
||||
@@ -360,7 +356,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetString(const Twine& value);
|
||||
bool SetString(const wpi::Twine& value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -368,7 +364,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetRaw(StringRef value);
|
||||
bool SetRaw(wpi::StringRef value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -376,7 +372,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetBooleanArray(ArrayRef<bool> value);
|
||||
bool SetBooleanArray(wpi::ArrayRef<bool> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -392,7 +388,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetBooleanArray(ArrayRef<int> value);
|
||||
bool SetBooleanArray(wpi::ArrayRef<int> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -408,7 +404,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetDoubleArray(ArrayRef<double> value);
|
||||
bool SetDoubleArray(wpi::ArrayRef<double> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -424,7 +420,7 @@ class NetworkTableEntry final {
|
||||
* @param value the value to set
|
||||
* @return False if the entry exists with a different type
|
||||
*/
|
||||
bool SetStringArray(ArrayRef<std::string> value);
|
||||
bool SetStringArray(wpi::ArrayRef<std::string> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value.
|
||||
@@ -464,7 +460,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetString(const Twine& value);
|
||||
void ForceSetString(const wpi::Twine& value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -472,7 +468,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetRaw(StringRef value);
|
||||
void ForceSetRaw(wpi::StringRef value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -480,7 +476,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetBooleanArray(ArrayRef<bool> value);
|
||||
void ForceSetBooleanArray(wpi::ArrayRef<bool> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -496,7 +492,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetBooleanArray(ArrayRef<int> value);
|
||||
void ForceSetBooleanArray(wpi::ArrayRef<int> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -512,7 +508,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetDoubleArray(ArrayRef<double> value);
|
||||
void ForceSetDoubleArray(wpi::ArrayRef<double> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -528,7 +524,7 @@ class NetworkTableEntry final {
|
||||
*
|
||||
* @param value the value to set
|
||||
*/
|
||||
void ForceSetStringArray(ArrayRef<std::string> value);
|
||||
void ForceSetStringArray(wpi::ArrayRef<std::string> value);
|
||||
|
||||
/**
|
||||
* Sets the entry's value. If the value is of different type, the type is
|
||||
@@ -600,7 +596,7 @@ class NetworkTableEntry final {
|
||||
* @param params parameter
|
||||
* @return RPC call object.
|
||||
*/
|
||||
RpcCall CallRpc(StringRef params);
|
||||
RpcCall CallRpc(wpi::StringRef params);
|
||||
|
||||
/**
|
||||
* Add a listener for changes to this entry.
|
||||
|
||||
@@ -66,7 +66,8 @@ inline double NetworkTableEntry::GetDouble(double defaultValue) const {
|
||||
return value->GetDouble();
|
||||
}
|
||||
|
||||
inline std::string NetworkTableEntry::GetString(StringRef defaultValue) const {
|
||||
inline std::string NetworkTableEntry::GetString(
|
||||
wpi::StringRef defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_STRING) {
|
||||
return defaultValue;
|
||||
@@ -74,7 +75,8 @@ inline std::string NetworkTableEntry::GetString(StringRef defaultValue) const {
|
||||
return value->GetString();
|
||||
}
|
||||
|
||||
inline std::string NetworkTableEntry::GetRaw(StringRef defaultValue) const {
|
||||
inline std::string NetworkTableEntry::GetRaw(
|
||||
wpi::StringRef defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_RAW) {
|
||||
return defaultValue;
|
||||
@@ -83,7 +85,7 @@ inline std::string NetworkTableEntry::GetRaw(StringRef defaultValue) const {
|
||||
}
|
||||
|
||||
inline std::vector<int> NetworkTableEntry::GetBooleanArray(
|
||||
ArrayRef<int> defaultValue) const {
|
||||
wpi::ArrayRef<int> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_BOOLEAN_ARRAY) {
|
||||
return defaultValue;
|
||||
@@ -98,7 +100,7 @@ inline std::vector<int> NetworkTableEntry::GetBooleanArray(
|
||||
}
|
||||
|
||||
inline std::vector<double> NetworkTableEntry::GetDoubleArray(
|
||||
ArrayRef<double> defaultValue) const {
|
||||
wpi::ArrayRef<double> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_DOUBLE_ARRAY) {
|
||||
return defaultValue;
|
||||
@@ -113,7 +115,7 @@ inline std::vector<double> NetworkTableEntry::GetDoubleArray(
|
||||
}
|
||||
|
||||
inline std::vector<std::string> NetworkTableEntry::GetStringArray(
|
||||
ArrayRef<std::string> defaultValue) const {
|
||||
wpi::ArrayRef<std::string> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_STRING_ARRAY) {
|
||||
return defaultValue;
|
||||
@@ -139,16 +141,17 @@ inline bool NetworkTableEntry::SetDefaultDouble(double defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeDouble(defaultValue));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultString(const Twine& defaultValue) {
|
||||
inline bool NetworkTableEntry::SetDefaultString(
|
||||
const wpi::Twine& defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeString(defaultValue));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultRaw(StringRef defaultValue) {
|
||||
inline bool NetworkTableEntry::SetDefaultRaw(wpi::StringRef defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeRaw(defaultValue));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultBooleanArray(
|
||||
ArrayRef<int> defaultValue) {
|
||||
wpi::ArrayRef<int> defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeBooleanArray(defaultValue));
|
||||
}
|
||||
|
||||
@@ -158,7 +161,7 @@ inline bool NetworkTableEntry::SetDefaultBooleanArray(
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultDoubleArray(
|
||||
ArrayRef<double> defaultValue) {
|
||||
wpi::ArrayRef<double> defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeDoubleArray(defaultValue));
|
||||
}
|
||||
|
||||
@@ -168,7 +171,7 @@ inline bool NetworkTableEntry::SetDefaultDoubleArray(
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDefaultStringArray(
|
||||
ArrayRef<std::string> defaultValue) {
|
||||
wpi::ArrayRef<std::string> defaultValue) {
|
||||
return SetDefaultEntryValue(m_handle, Value::MakeStringArray(defaultValue));
|
||||
}
|
||||
|
||||
@@ -189,15 +192,15 @@ inline bool NetworkTableEntry::SetDouble(double value) {
|
||||
return SetEntryValue(m_handle, Value::MakeDouble(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetString(const Twine& value) {
|
||||
inline bool NetworkTableEntry::SetString(const wpi::Twine& value) {
|
||||
return SetEntryValue(m_handle, Value::MakeString(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetRaw(StringRef value) {
|
||||
inline bool NetworkTableEntry::SetRaw(wpi::StringRef value) {
|
||||
return SetEntryValue(m_handle, Value::MakeRaw(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetBooleanArray(ArrayRef<bool> value) {
|
||||
inline bool NetworkTableEntry::SetBooleanArray(wpi::ArrayRef<bool> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -206,7 +209,7 @@ inline bool NetworkTableEntry::SetBooleanArray(
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetBooleanArray(ArrayRef<int> value) {
|
||||
inline bool NetworkTableEntry::SetBooleanArray(wpi::ArrayRef<int> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -215,7 +218,7 @@ inline bool NetworkTableEntry::SetBooleanArray(
|
||||
return SetEntryValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetDoubleArray(ArrayRef<double> value) {
|
||||
inline bool NetworkTableEntry::SetDoubleArray(wpi::ArrayRef<double> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeDoubleArray(value));
|
||||
}
|
||||
|
||||
@@ -224,7 +227,8 @@ inline bool NetworkTableEntry::SetDoubleArray(
|
||||
return SetEntryValue(m_handle, Value::MakeDoubleArray(value));
|
||||
}
|
||||
|
||||
inline bool NetworkTableEntry::SetStringArray(ArrayRef<std::string> value) {
|
||||
inline bool NetworkTableEntry::SetStringArray(
|
||||
wpi::ArrayRef<std::string> value) {
|
||||
return SetEntryValue(m_handle, Value::MakeStringArray(value));
|
||||
}
|
||||
|
||||
@@ -245,15 +249,15 @@ inline void NetworkTableEntry::ForceSetDouble(double value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeDouble(value));
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetString(const Twine& value) {
|
||||
inline void NetworkTableEntry::ForceSetString(const wpi::Twine& value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeString(value));
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetRaw(StringRef value) {
|
||||
inline void NetworkTableEntry::ForceSetRaw(wpi::StringRef value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeRaw(value));
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(ArrayRef<bool> value) {
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(wpi::ArrayRef<bool> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -262,7 +266,7 @@ inline void NetworkTableEntry::ForceSetBooleanArray(
|
||||
SetEntryTypeValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(ArrayRef<int> value) {
|
||||
inline void NetworkTableEntry::ForceSetBooleanArray(wpi::ArrayRef<int> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
@@ -271,7 +275,8 @@ inline void NetworkTableEntry::ForceSetBooleanArray(
|
||||
SetEntryTypeValue(m_handle, Value::MakeBooleanArray(value));
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetDoubleArray(ArrayRef<double> value) {
|
||||
inline void NetworkTableEntry::ForceSetDoubleArray(
|
||||
wpi::ArrayRef<double> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeDoubleArray(value));
|
||||
}
|
||||
|
||||
@@ -281,7 +286,7 @@ inline void NetworkTableEntry::ForceSetDoubleArray(
|
||||
}
|
||||
|
||||
inline void NetworkTableEntry::ForceSetStringArray(
|
||||
ArrayRef<std::string> value) {
|
||||
wpi::ArrayRef<std::string> value) {
|
||||
SetEntryTypeValue(m_handle, Value::MakeStringArray(value));
|
||||
}
|
||||
|
||||
@@ -316,10 +321,10 @@ inline void NetworkTableEntry::Delete() {
|
||||
|
||||
inline void NetworkTableEntry::CreateRpc(
|
||||
std::function<void(const RpcAnswer& answer)> callback) {
|
||||
::nt::CreateRpc(m_handle, StringRef("\0", 1), callback);
|
||||
::nt::CreateRpc(m_handle, wpi::StringRef("\0", 1), callback);
|
||||
}
|
||||
|
||||
inline RpcCall NetworkTableEntry::CallRpc(StringRef params) {
|
||||
inline RpcCall NetworkTableEntry::CallRpc(wpi::StringRef params) {
|
||||
return RpcCall{m_handle, ::nt::CallRpc(m_handle, params)};
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,6 @@
|
||||
|
||||
namespace nt {
|
||||
|
||||
using wpi::ArrayRef;
|
||||
using wpi::StringRef;
|
||||
using wpi::Twine;
|
||||
|
||||
/**
|
||||
* NetworkTables Instance.
|
||||
*
|
||||
@@ -135,7 +131,7 @@ class NetworkTableInstance final {
|
||||
* @param name Key
|
||||
* @return Network table entry.
|
||||
*/
|
||||
NetworkTableEntry GetEntry(const Twine& name);
|
||||
NetworkTableEntry GetEntry(const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Get entries starting with the given prefix.
|
||||
@@ -148,7 +144,7 @@ class NetworkTableInstance final {
|
||||
* @param types bitmask of types; 0 is treated as a "don't care"
|
||||
* @return Array of entries.
|
||||
*/
|
||||
std::vector<NetworkTableEntry> GetEntries(const Twine& prefix,
|
||||
std::vector<NetworkTableEntry> GetEntries(const wpi::Twine& prefix,
|
||||
unsigned int types);
|
||||
|
||||
/**
|
||||
@@ -162,7 +158,7 @@ class NetworkTableInstance final {
|
||||
* @param types bitmask of types; 0 is treated as a "don't care"
|
||||
* @return Array of entry information.
|
||||
*/
|
||||
std::vector<EntryInfo> GetEntryInfo(const Twine& prefix,
|
||||
std::vector<EntryInfo> GetEntryInfo(const wpi::Twine& prefix,
|
||||
unsigned int types) const;
|
||||
|
||||
/**
|
||||
@@ -171,7 +167,7 @@ class NetworkTableInstance final {
|
||||
* @param key the key name
|
||||
* @return The network table
|
||||
*/
|
||||
std::shared_ptr<NetworkTable> GetTable(const Twine& key) const;
|
||||
std::shared_ptr<NetworkTable> GetTable(const wpi::Twine& key) const;
|
||||
|
||||
/**
|
||||
* Deletes ALL keys in ALL subtables (except persistent values).
|
||||
@@ -193,7 +189,7 @@ class NetworkTableInstance final {
|
||||
* @return Listener handle
|
||||
*/
|
||||
NT_EntryListener AddEntryListener(
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int flags) const;
|
||||
|
||||
@@ -287,7 +283,7 @@ class NetworkTableInstance final {
|
||||
*
|
||||
* @param name identity to advertise
|
||||
*/
|
||||
void SetNetworkIdentity(const Twine& name);
|
||||
void SetNetworkIdentity(const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Get the current network mode.
|
||||
@@ -318,7 +314,7 @@ class NetworkTableInstance final {
|
||||
* address (UTF-8 string, null terminated)
|
||||
* @param port port to communicate over
|
||||
*/
|
||||
void StartServer(const Twine& persist_filename = "networktables.ini",
|
||||
void StartServer(const wpi::Twine& persist_filename = "networktables.ini",
|
||||
const char* listen_address = "",
|
||||
unsigned int port = kDefaultPort);
|
||||
|
||||
@@ -346,7 +342,8 @@ class NetworkTableInstance final {
|
||||
*
|
||||
* @param servers array of server name and port pairs
|
||||
*/
|
||||
void StartClient(ArrayRef<std::pair<StringRef, unsigned int>> servers);
|
||||
void StartClient(
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Starts a client using the specified servers and port. The
|
||||
@@ -355,7 +352,7 @@ class NetworkTableInstance final {
|
||||
* @param servers array of server names
|
||||
* @param port port to communicate over
|
||||
*/
|
||||
void StartClient(ArrayRef<StringRef> servers,
|
||||
void StartClient(wpi::ArrayRef<wpi::StringRef> servers,
|
||||
unsigned int port = kDefaultPort);
|
||||
|
||||
/**
|
||||
@@ -386,7 +383,8 @@ class NetworkTableInstance final {
|
||||
*
|
||||
* @param servers array of server name and port pairs
|
||||
*/
|
||||
void SetServer(ArrayRef<std::pair<StringRef, unsigned int>> servers);
|
||||
void SetServer(
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Sets server addresses and port for client (without restarting client).
|
||||
@@ -395,7 +393,8 @@ class NetworkTableInstance final {
|
||||
* @param servers array of server names
|
||||
* @param port port to communicate over
|
||||
*/
|
||||
void SetServer(ArrayRef<StringRef> servers, unsigned int port = kDefaultPort);
|
||||
void SetServer(wpi::ArrayRef<wpi::StringRef> servers,
|
||||
unsigned int port = kDefaultPort);
|
||||
|
||||
/**
|
||||
* Sets server addresses and port for client (without restarting client).
|
||||
@@ -466,7 +465,7 @@ class NetworkTableInstance final {
|
||||
* @param filename filename
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* SavePersistent(const Twine& filename) const;
|
||||
const char* SavePersistent(const wpi::Twine& filename) const;
|
||||
|
||||
/**
|
||||
* Load persistent values from a file. The server automatically does this
|
||||
@@ -478,7 +477,7 @@ class NetworkTableInstance final {
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* LoadPersistent(
|
||||
const Twine& filename,
|
||||
const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
/**
|
||||
@@ -489,7 +488,8 @@ class NetworkTableInstance final {
|
||||
* @param prefix save only keys starting with this prefix
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* SaveEntries(const Twine& filename, const Twine& prefix) const;
|
||||
const char* SaveEntries(const wpi::Twine& filename,
|
||||
const wpi::Twine& prefix) const;
|
||||
|
||||
/**
|
||||
* Load table values from a file. The file format used is identical to
|
||||
@@ -501,7 +501,7 @@ class NetworkTableInstance final {
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* LoadEntries(
|
||||
const Twine& filename, const Twine& prefix,
|
||||
const wpi::Twine& filename, const wpi::Twine& prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -35,12 +35,13 @@ inline NT_Inst NetworkTableInstance::GetHandle() const {
|
||||
return m_handle;
|
||||
}
|
||||
|
||||
inline NetworkTableEntry NetworkTableInstance::GetEntry(const Twine& name) {
|
||||
inline NetworkTableEntry NetworkTableInstance::GetEntry(
|
||||
const wpi::Twine& name) {
|
||||
return NetworkTableEntry{::nt::GetEntry(m_handle, name)};
|
||||
}
|
||||
|
||||
inline std::vector<NetworkTableEntry> NetworkTableInstance::GetEntries(
|
||||
const Twine& prefix, unsigned int types) {
|
||||
const wpi::Twine& prefix, unsigned int types) {
|
||||
std::vector<NetworkTableEntry> entries;
|
||||
for (auto entry : ::nt::GetEntries(m_handle, prefix, types)) {
|
||||
entries.emplace_back(entry);
|
||||
@@ -49,7 +50,7 @@ inline std::vector<NetworkTableEntry> NetworkTableInstance::GetEntries(
|
||||
}
|
||||
|
||||
inline std::vector<EntryInfo> NetworkTableInstance::GetEntryInfo(
|
||||
const Twine& prefix, unsigned int types) const {
|
||||
const wpi::Twine& prefix, unsigned int types) const {
|
||||
return ::nt::GetEntryInfo(m_handle, prefix, types);
|
||||
}
|
||||
|
||||
@@ -80,7 +81,7 @@ inline bool NetworkTableInstance::WaitForRpcCallQueue(double timeout) {
|
||||
return ::nt::WaitForRpcCallQueue(m_handle, timeout);
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::SetNetworkIdentity(const Twine& name) {
|
||||
inline void NetworkTableInstance::SetNetworkIdentity(const wpi::Twine& name) {
|
||||
::nt::SetNetworkIdentity(m_handle, name);
|
||||
}
|
||||
|
||||
@@ -96,9 +97,9 @@ inline void NetworkTableInstance::StopLocal() {
|
||||
::nt::StopLocal(m_handle);
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::StartServer(const Twine& persist_filename,
|
||||
const char* listen_address,
|
||||
unsigned int port) {
|
||||
inline void NetworkTableInstance::StartServer(
|
||||
const wpi::Twine& persist_filename, const char* listen_address,
|
||||
unsigned int port) {
|
||||
::nt::StartServer(m_handle, persist_filename, listen_address, port);
|
||||
}
|
||||
|
||||
@@ -116,7 +117,7 @@ inline void NetworkTableInstance::StartClient(const char* server_name,
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::StartClient(
|
||||
ArrayRef<std::pair<StringRef, unsigned int>> servers) {
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers) {
|
||||
::nt::StartClient(m_handle, servers);
|
||||
}
|
||||
|
||||
@@ -135,7 +136,7 @@ inline void NetworkTableInstance::SetServer(const char* server_name,
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::SetServer(
|
||||
ArrayRef<std::pair<StringRef, unsigned int>> servers) {
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers) {
|
||||
::nt::SetServer(m_handle, servers);
|
||||
}
|
||||
|
||||
@@ -170,23 +171,23 @@ inline bool NetworkTableInstance::IsConnected() const {
|
||||
}
|
||||
|
||||
inline const char* NetworkTableInstance::SavePersistent(
|
||||
const Twine& filename) const {
|
||||
const wpi::Twine& filename) const {
|
||||
return ::nt::SavePersistent(m_handle, filename);
|
||||
}
|
||||
|
||||
inline const char* NetworkTableInstance::LoadPersistent(
|
||||
const Twine& filename,
|
||||
const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
return ::nt::LoadPersistent(m_handle, filename, warn);
|
||||
}
|
||||
|
||||
inline const char* NetworkTableInstance::SaveEntries(
|
||||
const Twine& filename, const Twine& prefix) const {
|
||||
const wpi::Twine& filename, const wpi::Twine& prefix) const {
|
||||
return ::nt::SaveEntries(m_handle, filename, prefix);
|
||||
}
|
||||
|
||||
inline const char* NetworkTableInstance::LoadEntries(
|
||||
const Twine& filename, const Twine& prefix,
|
||||
const wpi::Twine& filename, const wpi::Twine& prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn) {
|
||||
return ::nt::LoadEntries(m_handle, filename, prefix, warn);
|
||||
}
|
||||
|
||||
@@ -23,10 +23,6 @@
|
||||
|
||||
namespace nt {
|
||||
|
||||
using wpi::ArrayRef;
|
||||
using wpi::StringRef;
|
||||
using wpi::Twine;
|
||||
|
||||
/**
|
||||
* A network table entry value.
|
||||
* @ingroup ntcore_cpp_api
|
||||
@@ -167,7 +163,7 @@ class Value final {
|
||||
*
|
||||
* @return The string value.
|
||||
*/
|
||||
StringRef GetString() const {
|
||||
wpi::StringRef GetString() const {
|
||||
assert(m_val.type == NT_STRING);
|
||||
return m_string;
|
||||
}
|
||||
@@ -177,7 +173,7 @@ class Value final {
|
||||
*
|
||||
* @return The raw value.
|
||||
*/
|
||||
StringRef GetRaw() const {
|
||||
wpi::StringRef GetRaw() const {
|
||||
assert(m_val.type == NT_RAW);
|
||||
return m_string;
|
||||
}
|
||||
@@ -187,7 +183,7 @@ class Value final {
|
||||
*
|
||||
* @return The rpc definition value.
|
||||
*/
|
||||
StringRef GetRpc() const {
|
||||
wpi::StringRef GetRpc() const {
|
||||
assert(m_val.type == NT_RPC);
|
||||
return m_string;
|
||||
}
|
||||
@@ -197,10 +193,10 @@ class Value final {
|
||||
*
|
||||
* @return The boolean array value.
|
||||
*/
|
||||
ArrayRef<int> GetBooleanArray() const {
|
||||
wpi::ArrayRef<int> GetBooleanArray() const {
|
||||
assert(m_val.type == NT_BOOLEAN_ARRAY);
|
||||
return ArrayRef<int>(m_val.data.arr_boolean.arr,
|
||||
m_val.data.arr_boolean.size);
|
||||
return wpi::ArrayRef<int>(m_val.data.arr_boolean.arr,
|
||||
m_val.data.arr_boolean.size);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,10 +204,10 @@ class Value final {
|
||||
*
|
||||
* @return The double array value.
|
||||
*/
|
||||
ArrayRef<double> GetDoubleArray() const {
|
||||
wpi::ArrayRef<double> GetDoubleArray() const {
|
||||
assert(m_val.type == NT_DOUBLE_ARRAY);
|
||||
return ArrayRef<double>(m_val.data.arr_double.arr,
|
||||
m_val.data.arr_double.size);
|
||||
return wpi::ArrayRef<double>(m_val.data.arr_double.arr,
|
||||
m_val.data.arr_double.size);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,7 +215,7 @@ class Value final {
|
||||
*
|
||||
* @return The string array value.
|
||||
*/
|
||||
ArrayRef<std::string> GetStringArray() const {
|
||||
wpi::ArrayRef<std::string> GetStringArray() const {
|
||||
assert(m_val.type == NT_STRING_ARRAY);
|
||||
return m_string_array;
|
||||
}
|
||||
@@ -267,7 +263,7 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeString(const Twine& value,
|
||||
static std::shared_ptr<Value> MakeString(const wpi::Twine& value,
|
||||
uint64_t time = 0) {
|
||||
auto val = std::make_shared<Value>(NT_STRING, time, private_init());
|
||||
val->m_string = value.str();
|
||||
@@ -302,7 +298,8 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeRaw(StringRef value, uint64_t time = 0) {
|
||||
static std::shared_ptr<Value> MakeRaw(wpi::StringRef value,
|
||||
uint64_t time = 0) {
|
||||
auto val = std::make_shared<Value>(NT_RAW, time, private_init());
|
||||
val->m_string = value;
|
||||
val->m_val.data.v_raw.str = const_cast<char*>(val->m_string.c_str());
|
||||
@@ -336,7 +333,8 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeRpc(StringRef value, uint64_t time = 0) {
|
||||
static std::shared_ptr<Value> MakeRpc(wpi::StringRef value,
|
||||
uint64_t time = 0) {
|
||||
auto val = std::make_shared<Value>(NT_RPC, time, private_init());
|
||||
val->m_string = value;
|
||||
val->m_val.data.v_raw.str = const_cast<char*>(val->m_string.c_str());
|
||||
@@ -369,7 +367,7 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeBooleanArray(ArrayRef<bool> value,
|
||||
static std::shared_ptr<Value> MakeBooleanArray(wpi::ArrayRef<bool> value,
|
||||
uint64_t time = 0);
|
||||
|
||||
/**
|
||||
@@ -394,7 +392,7 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeBooleanArray(ArrayRef<int> value,
|
||||
static std::shared_ptr<Value> MakeBooleanArray(wpi::ArrayRef<int> value,
|
||||
uint64_t time = 0);
|
||||
|
||||
/**
|
||||
@@ -419,7 +417,7 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeDoubleArray(ArrayRef<double> value,
|
||||
static std::shared_ptr<Value> MakeDoubleArray(wpi::ArrayRef<double> value,
|
||||
uint64_t time = 0);
|
||||
|
||||
/**
|
||||
@@ -443,8 +441,8 @@ class Value final {
|
||||
* time)
|
||||
* @return The entry value
|
||||
*/
|
||||
static std::shared_ptr<Value> MakeStringArray(ArrayRef<std::string> value,
|
||||
uint64_t time = 0);
|
||||
static std::shared_ptr<Value> MakeStringArray(
|
||||
wpi::ArrayRef<std::string> value, uint64_t time = 0);
|
||||
|
||||
/**
|
||||
* Creates a string array entry value.
|
||||
|
||||
@@ -16,8 +16,6 @@ class NetworkTable;
|
||||
class NetworkTableEntry;
|
||||
class Value;
|
||||
|
||||
using wpi::StringRef;
|
||||
|
||||
/**
|
||||
* A listener that listens to changes in values in a NetworkTable.
|
||||
*
|
||||
@@ -32,7 +30,7 @@ using wpi::StringRef;
|
||||
*
|
||||
* @ingroup ntcore_cpp_api
|
||||
*/
|
||||
typedef std::function<void(NetworkTable* table, StringRef name,
|
||||
typedef std::function<void(NetworkTable* table, wpi::StringRef name,
|
||||
NetworkTableEntry entry,
|
||||
std::shared_ptr<Value> value, int flags)>
|
||||
TableEntryListener;
|
||||
|
||||
@@ -14,8 +14,6 @@ namespace nt {
|
||||
|
||||
class NetworkTable;
|
||||
|
||||
using wpi::StringRef;
|
||||
|
||||
/**
|
||||
* A listener that listens to new sub-tables in a NetworkTable.
|
||||
*
|
||||
@@ -27,7 +25,7 @@ using wpi::StringRef;
|
||||
*
|
||||
* @ingroup ntcore_cpp_api
|
||||
*/
|
||||
typedef std::function<void(NetworkTable* parent, StringRef name,
|
||||
typedef std::function<void(NetworkTable* parent, wpi::StringRef name,
|
||||
std::shared_ptr<NetworkTable> table)>
|
||||
TableListener;
|
||||
|
||||
|
||||
@@ -32,10 +32,6 @@ namespace nt {
|
||||
* @{
|
||||
*/
|
||||
|
||||
using wpi::ArrayRef;
|
||||
using wpi::StringRef;
|
||||
using wpi::Twine;
|
||||
|
||||
/** NetworkTables Entry Information */
|
||||
struct EntryInfo {
|
||||
/** Entry handle */
|
||||
@@ -102,7 +98,7 @@ struct ConnectionInfo {
|
||||
/** NetworkTables RPC Version 1 Definition Parameter */
|
||||
struct RpcParamDef {
|
||||
RpcParamDef() = default;
|
||||
RpcParamDef(StringRef name_, std::shared_ptr<Value> def_value_)
|
||||
RpcParamDef(wpi::StringRef name_, std::shared_ptr<Value> def_value_)
|
||||
: name(name_), def_value(std::move(def_value_)) {}
|
||||
|
||||
std::string name;
|
||||
@@ -112,7 +108,8 @@ struct RpcParamDef {
|
||||
/** NetworkTables RPC Version 1 Definition Result */
|
||||
struct RpcResultDef {
|
||||
RpcResultDef() = default;
|
||||
RpcResultDef(StringRef name_, NT_Type type_) : name(name_), type(type_) {}
|
||||
RpcResultDef(wpi::StringRef name_, NT_Type type_)
|
||||
: name(name_), type(type_) {}
|
||||
|
||||
std::string name;
|
||||
NT_Type type;
|
||||
@@ -130,8 +127,8 @@ struct RpcDefinition {
|
||||
class RpcAnswer {
|
||||
public:
|
||||
RpcAnswer() = default;
|
||||
RpcAnswer(NT_Entry entry_, NT_RpcCall call_, StringRef name_,
|
||||
StringRef params_, ConnectionInfo conn_)
|
||||
RpcAnswer(NT_Entry entry_, NT_RpcCall call_, wpi::StringRef name_,
|
||||
wpi::StringRef params_, ConnectionInfo conn_)
|
||||
: entry(entry_),
|
||||
call(call_),
|
||||
name(name_),
|
||||
@@ -164,7 +161,7 @@ class RpcAnswer {
|
||||
* @param result result raw data that will be provided to remote caller
|
||||
* @return True if posting the response is valid, otherwise false
|
||||
*/
|
||||
bool PostResponse(StringRef result) const;
|
||||
bool PostResponse(wpi::StringRef result) const;
|
||||
|
||||
friend void swap(RpcAnswer& first, RpcAnswer& second) {
|
||||
using std::swap;
|
||||
@@ -181,7 +178,7 @@ class EntryNotification {
|
||||
public:
|
||||
EntryNotification() = default;
|
||||
EntryNotification(NT_EntryListener listener_, NT_Entry entry_,
|
||||
StringRef name_, std::shared_ptr<Value> value_,
|
||||
wpi::StringRef name_, std::shared_ptr<Value> value_,
|
||||
unsigned int flags_)
|
||||
: listener(listener_),
|
||||
entry(entry_),
|
||||
@@ -248,7 +245,7 @@ class LogMessage {
|
||||
public:
|
||||
LogMessage() = default;
|
||||
LogMessage(NT_Logger logger_, unsigned int level_, const char* filename_,
|
||||
unsigned int line_, StringRef message_)
|
||||
unsigned int line_, wpi::StringRef message_)
|
||||
: logger(logger_),
|
||||
level(level_),
|
||||
filename(filename_),
|
||||
@@ -330,7 +327,7 @@ NT_Inst GetInstanceFromHandle(NT_Handle handle);
|
||||
* @param name entry name (UTF-8 string)
|
||||
* @return entry handle
|
||||
*/
|
||||
NT_Entry GetEntry(NT_Inst inst, const Twine& name);
|
||||
NT_Entry GetEntry(NT_Inst inst, const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Get Entry Handles.
|
||||
@@ -346,7 +343,7 @@ NT_Entry GetEntry(NT_Inst inst, const Twine& name);
|
||||
* as a "don't care"
|
||||
* @return Array of entry handles.
|
||||
*/
|
||||
std::vector<NT_Entry> GetEntries(NT_Inst inst, const Twine& prefix,
|
||||
std::vector<NT_Entry> GetEntries(NT_Inst inst, const wpi::Twine& prefix,
|
||||
unsigned int types);
|
||||
|
||||
/**
|
||||
@@ -487,7 +484,7 @@ void DeleteAllEntries(NT_Inst inst);
|
||||
* as a "don't care"
|
||||
* @return Array of entry information.
|
||||
*/
|
||||
std::vector<EntryInfo> GetEntryInfo(NT_Inst inst, const Twine& prefix,
|
||||
std::vector<EntryInfo> GetEntryInfo(NT_Inst inst, const wpi::Twine& prefix,
|
||||
unsigned int types);
|
||||
|
||||
/**
|
||||
@@ -519,7 +516,7 @@ EntryInfo GetEntryInfo(NT_Entry entry);
|
||||
* @param flags update flags; for example, NT_NOTIFY_NEW if the key
|
||||
* did not previously exist
|
||||
*/
|
||||
typedef std::function<void(NT_EntryListener entry_listener, StringRef name,
|
||||
typedef std::function<void(NT_EntryListener entry_listener, wpi::StringRef name,
|
||||
std::shared_ptr<Value> value, unsigned int flags)>
|
||||
EntryListenerCallback;
|
||||
|
||||
@@ -533,7 +530,7 @@ typedef std::function<void(NT_EntryListener entry_listener, StringRef name,
|
||||
* @return Listener handle
|
||||
*/
|
||||
NT_EntryListener AddEntryListener(
|
||||
NT_Inst inst, const Twine& prefix,
|
||||
NT_Inst inst, const wpi::Twine& prefix,
|
||||
std::function<void(const EntryNotification& event)> callback,
|
||||
unsigned int flags);
|
||||
|
||||
@@ -581,7 +578,7 @@ void DestroyEntryListenerPoller(NT_EntryListenerPoller poller);
|
||||
* @return Listener handle
|
||||
*/
|
||||
NT_EntryListener AddPolledEntryListener(NT_EntryListenerPoller poller,
|
||||
const Twine& prefix,
|
||||
const wpi::Twine& prefix,
|
||||
unsigned int flags);
|
||||
|
||||
/**
|
||||
@@ -790,7 +787,7 @@ bool WaitForConnectionListenerQueue(NT_Inst inst, double timeout);
|
||||
* @param callback callback function; note the callback function must call
|
||||
* PostRpcResponse() to provide a response to the call
|
||||
*/
|
||||
void CreateRpc(NT_Entry entry, StringRef def,
|
||||
void CreateRpc(NT_Entry entry, wpi::StringRef def,
|
||||
std::function<void(const RpcAnswer& answer)> callback);
|
||||
|
||||
/**
|
||||
@@ -823,7 +820,8 @@ void DestroyRpcCallPoller(NT_RpcCallPoller poller);
|
||||
* @param def RPC definition
|
||||
* @param poller poller handle
|
||||
*/
|
||||
void CreatePolledRpc(NT_Entry entry, StringRef def, NT_RpcCallPoller poller);
|
||||
void CreatePolledRpc(NT_Entry entry, wpi::StringRef def,
|
||||
NT_RpcCallPoller poller);
|
||||
|
||||
/**
|
||||
* Get the next incoming RPC call. This blocks until the next incoming RPC
|
||||
@@ -886,7 +884,7 @@ bool WaitForRpcCallQueue(NT_Inst inst, double timeout);
|
||||
* @param result result raw data that will be provided to remote caller
|
||||
* @return true if the response was posted, otherwise false
|
||||
*/
|
||||
bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, StringRef result);
|
||||
bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, wpi::StringRef result);
|
||||
|
||||
/**
|
||||
* Call a RPC function. May be used on either the client or server.
|
||||
@@ -899,7 +897,7 @@ bool PostRpcResponse(NT_Entry entry, NT_RpcCall call, StringRef result);
|
||||
* @return RPC call handle (for use with GetRpcResult() or
|
||||
* CancelRpcResult()).
|
||||
*/
|
||||
NT_RpcCall CallRpc(NT_Entry entry, StringRef params);
|
||||
NT_RpcCall CallRpc(NT_Entry entry, wpi::StringRef params);
|
||||
|
||||
/**
|
||||
* Get the result (return value) of a RPC call. This function blocks until
|
||||
@@ -950,7 +948,7 @@ std::string PackRpcDefinition(const RpcDefinition& def);
|
||||
* @param def RPC version 1 definition (output)
|
||||
* @return True if successfully unpacked, false otherwise.
|
||||
*/
|
||||
bool UnpackRpcDefinition(StringRef packed, RpcDefinition* def);
|
||||
bool UnpackRpcDefinition(wpi::StringRef packed, RpcDefinition* def);
|
||||
|
||||
/**
|
||||
* Pack RPC values as required for RPC version 1 definition messages.
|
||||
@@ -958,7 +956,7 @@ bool UnpackRpcDefinition(StringRef packed, RpcDefinition* def);
|
||||
* @param values array of values to pack
|
||||
* @return Raw packed bytes.
|
||||
*/
|
||||
std::string PackRpcValues(ArrayRef<std::shared_ptr<Value>> values);
|
||||
std::string PackRpcValues(wpi::ArrayRef<std::shared_ptr<Value>> values);
|
||||
|
||||
/**
|
||||
* Unpack RPC values as required for RPC version 1 definition messages.
|
||||
@@ -967,8 +965,8 @@ std::string PackRpcValues(ArrayRef<std::shared_ptr<Value>> values);
|
||||
* @param types array of data types (as provided in the RPC definition)
|
||||
* @return Array of values.
|
||||
*/
|
||||
std::vector<std::shared_ptr<Value>> UnpackRpcValues(StringRef packed,
|
||||
ArrayRef<NT_Type> types);
|
||||
std::vector<std::shared_ptr<Value>> UnpackRpcValues(
|
||||
wpi::StringRef packed, wpi::ArrayRef<NT_Type> types);
|
||||
|
||||
/** @} */
|
||||
|
||||
@@ -985,7 +983,7 @@ std::vector<std::shared_ptr<Value>> UnpackRpcValues(StringRef packed,
|
||||
* @param inst instance handle
|
||||
* @param name identity to advertise
|
||||
*/
|
||||
void SetNetworkIdentity(NT_Inst inst, const Twine& name);
|
||||
void SetNetworkIdentity(NT_Inst inst, const wpi::Twine& name);
|
||||
|
||||
/**
|
||||
* Get the current network mode.
|
||||
@@ -1018,7 +1016,7 @@ void StopLocal(NT_Inst inst);
|
||||
* address. (UTF-8 string, null terminated)
|
||||
* @param port port to communicate over.
|
||||
*/
|
||||
void StartServer(NT_Inst inst, const Twine& persist_filename,
|
||||
void StartServer(NT_Inst inst, const wpi::Twine& persist_filename,
|
||||
const char* listen_address, unsigned int port);
|
||||
|
||||
/**
|
||||
@@ -1051,8 +1049,9 @@ void StartClient(NT_Inst inst, const char* server_name, unsigned int port);
|
||||
* @param inst instance handle
|
||||
* @param servers array of server name and port pairs
|
||||
*/
|
||||
void StartClient(NT_Inst inst,
|
||||
ArrayRef<std::pair<StringRef, unsigned int>> servers);
|
||||
void StartClient(
|
||||
NT_Inst inst,
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Starts a client using commonly known robot addresses for the specified
|
||||
@@ -1088,7 +1087,7 @@ void SetServer(NT_Inst inst, const char* server_name, unsigned int port);
|
||||
* @param servers array of server name and port pairs
|
||||
*/
|
||||
void SetServer(NT_Inst inst,
|
||||
ArrayRef<std::pair<StringRef, unsigned int>> servers);
|
||||
wpi::ArrayRef<std::pair<wpi::StringRef, unsigned int>> servers);
|
||||
|
||||
/**
|
||||
* Sets server addresses and port for client (without restarting client).
|
||||
@@ -1174,7 +1173,7 @@ bool IsConnected(NT_Inst inst);
|
||||
* @param filename filename
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* SavePersistent(NT_Inst inst, const Twine& filename);
|
||||
const char* SavePersistent(NT_Inst inst, const wpi::Twine& filename);
|
||||
|
||||
/**
|
||||
* Load persistent values from a file. The server automatically does this
|
||||
@@ -1187,7 +1186,7 @@ const char* SavePersistent(NT_Inst inst, const Twine& filename);
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* LoadPersistent(
|
||||
NT_Inst inst, const Twine& filename,
|
||||
NT_Inst inst, const wpi::Twine& filename,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
/**
|
||||
@@ -1199,8 +1198,8 @@ const char* LoadPersistent(
|
||||
* @param prefix save only keys starting with this prefix
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* SaveEntries(NT_Inst inst, const Twine& filename,
|
||||
const Twine& prefix);
|
||||
const char* SaveEntries(NT_Inst inst, const wpi::Twine& filename,
|
||||
const wpi::Twine& prefix);
|
||||
|
||||
/**
|
||||
* Load table values from a file. The file format used is identical to
|
||||
@@ -1212,8 +1211,8 @@ const char* SaveEntries(NT_Inst inst, const Twine& filename,
|
||||
* @param warn callback function for warnings
|
||||
* @return error string, or nullptr if successful
|
||||
*/
|
||||
const char* LoadEntries(NT_Inst inst, const Twine& filename,
|
||||
const Twine& prefix,
|
||||
const char* LoadEntries(NT_Inst inst, const wpi::Twine& filename,
|
||||
const wpi::Twine& prefix,
|
||||
std::function<void(size_t line, const char* msg)> warn);
|
||||
|
||||
/** @} */
|
||||
@@ -1340,7 +1339,7 @@ bool WaitForLoggerQueue(NT_Inst inst, double timeout);
|
||||
/** @} */
|
||||
/** @} */
|
||||
|
||||
inline bool RpcAnswer::PostResponse(StringRef result) const {
|
||||
inline bool RpcAnswer::PostResponse(wpi::StringRef result) const {
|
||||
auto ret = PostRpcResponse(entry, call, result);
|
||||
call = 0;
|
||||
return ret;
|
||||
|
||||
@@ -245,7 +245,7 @@ TEST_F(EntryNotifierTest, PollPrefixBasic) {
|
||||
int g4count = 0;
|
||||
for (const auto& result : results) {
|
||||
SCOPED_TRACE(::testing::PrintToString(result));
|
||||
EXPECT_TRUE(StringRef(result.name).startswith("/foo"));
|
||||
EXPECT_TRUE(wpi::StringRef(result.name).startswith("/foo"));
|
||||
EXPECT_THAT(result.value, ValueEq(Value::MakeDouble(1)));
|
||||
EXPECT_EQ(Handle{result.entry}.GetType(), Handle::kEntry);
|
||||
EXPECT_EQ(Handle{result.entry}.GetInst(), 1);
|
||||
|
||||
@@ -30,7 +30,7 @@ class MockEntryNotifier : public IEntryNotifier {
|
||||
unsigned int(unsigned int poller_uid, unsigned int local_id,
|
||||
unsigned int flags));
|
||||
MOCK_METHOD5(NotifyEntry,
|
||||
void(unsigned int local_id, StringRef name,
|
||||
void(unsigned int local_id, wpi::StringRef name,
|
||||
std::shared_ptr<Value> value, unsigned int flags,
|
||||
unsigned int only_listener));
|
||||
};
|
||||
|
||||
@@ -16,7 +16,7 @@ class MockRpcServer : public IRpcServer {
|
||||
MOCK_METHOD1(RemoveRpc, void(unsigned int rpc_uid));
|
||||
MOCK_METHOD7(ProcessRpc,
|
||||
void(unsigned int local_id, unsigned int call_uid,
|
||||
StringRef name, StringRef params,
|
||||
wpi::StringRef name, wpi::StringRef params,
|
||||
const ConnectionInfo& conn, SendResponseFunc send_response,
|
||||
unsigned int rpc_uid));
|
||||
};
|
||||
|
||||
@@ -19,6 +19,7 @@ using ::testing::_;
|
||||
using ::testing::AnyNumber;
|
||||
using ::testing::IsNull;
|
||||
using ::testing::Return;
|
||||
using wpi::StringRef;
|
||||
|
||||
namespace nt {
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ class StorageTest {
|
||||
Storage::EntriesMap& entries() { return storage.m_entries; }
|
||||
Storage::IdMap& idmap() { return storage.m_idmap; }
|
||||
|
||||
Storage::Entry* GetEntry(StringRef name) {
|
||||
Storage::Entry* GetEntry(wpi::StringRef name) {
|
||||
auto i = storage.m_entries.find(name);
|
||||
return i == storage.m_entries.end() ? &tmp_entry : i->getValue();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user