mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-26 01:51:41 +00:00
Include .h from .inc/.inl files (NFC) (#3017)
This helps both IDEs and linting tools. Also add some missing braces.
This commit is contained in:
@@ -9,6 +9,8 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include "networktables/NetworkTableEntry.h"
|
||||
|
||||
namespace nt {
|
||||
|
||||
inline NetworkTableEntry::NetworkTableEntry() {}
|
||||
@@ -50,37 +52,42 @@ inline std::shared_ptr<Value> NetworkTableEntry::GetValue() const {
|
||||
|
||||
inline bool NetworkTableEntry::GetBoolean(bool defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_BOOLEAN)
|
||||
if (!value || value->type() != NT_BOOLEAN) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value->GetBoolean();
|
||||
}
|
||||
|
||||
inline double NetworkTableEntry::GetDouble(double defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_DOUBLE)
|
||||
if (!value || value->type() != NT_DOUBLE) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value->GetDouble();
|
||||
}
|
||||
|
||||
inline std::string NetworkTableEntry::GetString(StringRef defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_STRING)
|
||||
if (!value || value->type() != NT_STRING) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value->GetString();
|
||||
}
|
||||
|
||||
inline std::string NetworkTableEntry::GetRaw(StringRef defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_RAW)
|
||||
if (!value || value->type() != NT_RAW) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value->GetString();
|
||||
}
|
||||
|
||||
inline std::vector<int> NetworkTableEntry::GetBooleanArray(
|
||||
ArrayRef<int> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_BOOLEAN_ARRAY)
|
||||
if (!value || value->type() != NT_BOOLEAN_ARRAY) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value->GetBooleanArray();
|
||||
}
|
||||
|
||||
@@ -93,8 +100,9 @@ inline std::vector<int> NetworkTableEntry::GetBooleanArray(
|
||||
inline std::vector<double> NetworkTableEntry::GetDoubleArray(
|
||||
ArrayRef<double> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_DOUBLE_ARRAY)
|
||||
if (!value || value->type() != NT_DOUBLE_ARRAY) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value->GetDoubleArray();
|
||||
}
|
||||
|
||||
@@ -107,8 +115,9 @@ inline std::vector<double> NetworkTableEntry::GetDoubleArray(
|
||||
inline std::vector<std::string> NetworkTableEntry::GetStringArray(
|
||||
ArrayRef<std::string> defaultValue) const {
|
||||
auto value = GetEntryValue(m_handle);
|
||||
if (!value || value->type() != NT_STRING_ARRAY)
|
||||
if (!value || value->type() != NT_STRING_ARRAY) {
|
||||
return defaultValue;
|
||||
}
|
||||
return value->GetStringArray();
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
|
||||
#include "networktables/NetworkTableInstance.h"
|
||||
|
||||
namespace nt {
|
||||
|
||||
inline NetworkTableInstance::NetworkTableInstance() noexcept {}
|
||||
@@ -24,8 +26,9 @@ inline NetworkTableInstance NetworkTableInstance::Create() {
|
||||
}
|
||||
|
||||
inline void NetworkTableInstance::Destroy(NetworkTableInstance inst) {
|
||||
if (inst.m_handle != 0)
|
||||
if (inst.m_handle != 0) {
|
||||
DestroyInstance(inst.m_handle);
|
||||
}
|
||||
}
|
||||
|
||||
inline NT_Inst NetworkTableInstance::GetHandle() const {
|
||||
@@ -39,8 +42,9 @@ inline NetworkTableEntry NetworkTableInstance::GetEntry(const Twine& name) {
|
||||
inline std::vector<NetworkTableEntry> NetworkTableInstance::GetEntries(
|
||||
const Twine& prefix, unsigned int types) {
|
||||
std::vector<NetworkTableEntry> entries;
|
||||
for (auto entry : ::nt::GetEntries(m_handle, prefix, types))
|
||||
for (auto entry : ::nt::GetEntries(m_handle, prefix, types)) {
|
||||
entries.emplace_back(entry);
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "networktables/RpcCall.h"
|
||||
#include "ntcore_cpp.h"
|
||||
|
||||
namespace nt {
|
||||
@@ -18,8 +19,9 @@ inline RpcCall::RpcCall(RpcCall&& other) noexcept : RpcCall() {
|
||||
|
||||
inline RpcCall::~RpcCall() {
|
||||
// automatically cancel result if user didn't request it
|
||||
if (m_call != 0)
|
||||
if (m_call != 0) {
|
||||
CancelResult();
|
||||
}
|
||||
}
|
||||
|
||||
inline bool RpcCall::GetResult(std::string* result) {
|
||||
|
||||
Reference in New Issue
Block a user