2015-06-21 21:02:10 -07:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2018-01-01 17:29:13 -08:00
|
|
|
/* Copyright (c) FIRST 2015-2018. All Rights Reserved. */
|
2015-06-21 21:02:10 -07:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2017-08-19 23:08:27 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include <support/timestamp.h>
|
|
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
#include "Value_internal.h"
|
2017-08-19 23:08:27 -07:00
|
|
|
#include "networktables/NetworkTableValue.h"
|
2015-06-21 21:02:10 -07:00
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
using namespace nt;
|
2015-06-21 21:02:10 -07:00
|
|
|
|
2015-07-17 11:16:03 -07:00
|
|
|
Value::Value() {
|
|
|
|
|
m_val.type = NT_UNASSIGNED;
|
2016-07-27 00:39:38 -07:00
|
|
|
m_val.last_change = wpi::Now();
|
2015-07-17 11:16:03 -07:00
|
|
|
}
|
2015-06-21 21:02:10 -07:00
|
|
|
|
2017-08-19 23:08:27 -07:00
|
|
|
Value::Value(NT_Type type, uint64_t time, const private_init&) {
|
2015-07-16 21:44:37 -07:00
|
|
|
m_val.type = type;
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
if (time == 0)
|
|
|
|
|
m_val.last_change = wpi::Now();
|
|
|
|
|
else
|
|
|
|
|
m_val.last_change = time;
|
2015-07-16 21:44:37 -07:00
|
|
|
if (m_val.type == NT_BOOLEAN_ARRAY)
|
|
|
|
|
m_val.data.arr_boolean.arr = nullptr;
|
|
|
|
|
else if (m_val.type == NT_DOUBLE_ARRAY)
|
|
|
|
|
m_val.data.arr_double.arr = nullptr;
|
|
|
|
|
else if (m_val.type == NT_STRING_ARRAY)
|
|
|
|
|
m_val.data.arr_string.arr = nullptr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Value::~Value() {
|
|
|
|
|
if (m_val.type == NT_BOOLEAN_ARRAY)
|
|
|
|
|
delete[] m_val.data.arr_boolean.arr;
|
|
|
|
|
else if (m_val.type == NT_DOUBLE_ARRAY)
|
|
|
|
|
delete[] m_val.data.arr_double.arr;
|
|
|
|
|
else if (m_val.type == NT_STRING_ARRAY)
|
|
|
|
|
delete[] m_val.data.arr_string.arr;
|
|
|
|
|
}
|
2015-06-29 23:08:35 -07:00
|
|
|
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
std::shared_ptr<Value> Value::MakeBooleanArray(llvm::ArrayRef<int> value,
|
2017-08-19 23:08:27 -07:00
|
|
|
uint64_t time) {
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
auto val = std::make_shared<Value>(NT_BOOLEAN_ARRAY, time, private_init());
|
2015-07-16 21:44:37 -07:00
|
|
|
val->m_val.data.arr_boolean.arr = new int[value.size()];
|
|
|
|
|
val->m_val.data.arr_boolean.size = value.size();
|
|
|
|
|
std::copy(value.begin(), value.end(), val->m_val.data.arr_boolean.arr);
|
2015-07-16 01:38:27 -07:00
|
|
|
return val;
|
2015-06-29 23:08:35 -07:00
|
|
|
}
|
|
|
|
|
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
std::shared_ptr<Value> Value::MakeDoubleArray(llvm::ArrayRef<double> value,
|
2017-08-19 23:08:27 -07:00
|
|
|
uint64_t time) {
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
auto val = std::make_shared<Value>(NT_DOUBLE_ARRAY, time, private_init());
|
2015-07-16 21:44:37 -07:00
|
|
|
val->m_val.data.arr_double.arr = new double[value.size()];
|
|
|
|
|
val->m_val.data.arr_double.size = value.size();
|
|
|
|
|
std::copy(value.begin(), value.end(), val->m_val.data.arr_double.arr);
|
2015-07-16 01:38:27 -07:00
|
|
|
return val;
|
2015-07-12 23:13:43 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-19 23:08:27 -07:00
|
|
|
std::shared_ptr<Value> Value::MakeStringArray(llvm::ArrayRef<std::string> value,
|
|
|
|
|
uint64_t time) {
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
auto val = std::make_shared<Value>(NT_STRING_ARRAY, time, private_init());
|
2015-07-16 01:38:27 -07:00
|
|
|
val->m_string_array = value;
|
2015-07-16 21:44:37 -07:00
|
|
|
// point NT_Value to the contents in the vector.
|
|
|
|
|
val->m_val.data.arr_string.arr = new NT_String[value.size()];
|
2015-11-09 22:05:38 -08:00
|
|
|
val->m_val.data.arr_string.size = val->m_string_array.size();
|
2017-08-19 23:08:27 -07:00
|
|
|
for (size_t i = 0; i < value.size(); ++i) {
|
2015-07-16 21:44:37 -07:00
|
|
|
val->m_val.data.arr_string.arr[i].str = const_cast<char*>(value[i].c_str());
|
|
|
|
|
val->m_val.data.arr_string.arr[i].len = value[i].size();
|
|
|
|
|
}
|
2015-07-16 01:38:27 -07:00
|
|
|
return val;
|
2015-06-29 23:08:35 -07:00
|
|
|
}
|
|
|
|
|
|
2017-08-19 23:08:27 -07:00
|
|
|
std::shared_ptr<Value> Value::MakeStringArray(std::vector<std::string>&& value,
|
|
|
|
|
uint64_t time) {
|
Implement independent instances.
Previously, most of the classes were implemented as singletons so only one
instance was possible.
This change adds an instance handle-based API. In Java, this API is located
in a different package than the old API (edu.wpi.first.networktables).
Backwards compatibility with ITable and the old NetworkTable API is largely
maintained, but a handful of classes have moved to the new package in Java
(ConnectionInfo and PersistentException), and the old JNI has been completed
replaced.
Also:
- Move SetTeam implementation to Dispatcher.
- Consistently pass time through Java and C++ Value API.
- Rename nt_Value.h to NetworkTableValue.h for consistency with Java.
- Improve documentation
- Make C++ and Java APIs more consistent
- Document RPC functions and support RPC in Java.
- Add polling features for entry and connection listeners and use them to
move callback threads to Java level.
- Remove thread start and stop hooks (as polling is available).
- Make Notifiers, RpcServer, Dispatcher, and Storage mockable.
- Set NOTIFY_NEW on immediate entry notifications.
- Make GetTable("/") and GetTable("") equivalent.
- Generate local notification for flags update when loading persistent file.
And many unit test updates/changes:
- Use InitGoogleMock instead of InitGoogleTest in test main.
- Move test printers to TestPrinter.h/cpp.
- Provide printers for StringRef, EntryNotifier, and Handle.
- StorageTest: Check notifications.
- Add entry notifier unit tests.
- Storage: Add test for incoming entry assignment.
- Update connection listener tests.
- Add entry listener unit tests.
Fixes #11, #140, #189, #190, #192, #193, #221
2017-04-23 10:26:17 -07:00
|
|
|
auto val = std::make_shared<Value>(NT_STRING_ARRAY, time, private_init());
|
2015-07-16 01:38:27 -07:00
|
|
|
val->m_string_array = std::move(value);
|
|
|
|
|
value.clear();
|
2015-07-16 21:44:37 -07:00
|
|
|
// point NT_Value to the contents in the vector.
|
|
|
|
|
val->m_val.data.arr_string.arr = new NT_String[val->m_string_array.size()];
|
2015-11-09 22:05:38 -08:00
|
|
|
val->m_val.data.arr_string.size = val->m_string_array.size();
|
2017-08-19 23:08:27 -07:00
|
|
|
for (size_t i = 0; i < val->m_string_array.size(); ++i) {
|
2015-07-16 21:44:37 -07:00
|
|
|
val->m_val.data.arr_string.arr[i].str =
|
|
|
|
|
const_cast<char*>(val->m_string_array[i].c_str());
|
|
|
|
|
val->m_val.data.arr_string.arr[i].len = val->m_string_array[i].size();
|
|
|
|
|
}
|
2015-07-16 01:38:27 -07:00
|
|
|
return val;
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
void nt::ConvertToC(const Value& in, NT_Value* out) {
|
2015-08-22 19:31:53 -07:00
|
|
|
out->type = NT_UNASSIGNED;
|
2015-07-16 01:38:27 -07:00
|
|
|
switch (in.type()) {
|
|
|
|
|
case NT_UNASSIGNED:
|
|
|
|
|
return;
|
|
|
|
|
case NT_BOOLEAN:
|
|
|
|
|
out->data.v_boolean = in.GetBoolean() ? 1 : 0;
|
|
|
|
|
break;
|
|
|
|
|
case NT_DOUBLE:
|
|
|
|
|
out->data.v_double = in.GetDouble();
|
|
|
|
|
break;
|
|
|
|
|
case NT_STRING:
|
|
|
|
|
ConvertToC(in.GetString(), &out->data.v_string);
|
|
|
|
|
break;
|
|
|
|
|
case NT_RAW:
|
|
|
|
|
ConvertToC(in.GetRaw(), &out->data.v_raw);
|
|
|
|
|
break;
|
|
|
|
|
case NT_RPC:
|
|
|
|
|
ConvertToC(in.GetRpc(), &out->data.v_raw);
|
|
|
|
|
break;
|
|
|
|
|
case NT_BOOLEAN_ARRAY: {
|
|
|
|
|
auto v = in.GetBooleanArray();
|
|
|
|
|
out->data.arr_boolean.arr =
|
|
|
|
|
static_cast<int*>(std::malloc(v.size() * sizeof(int)));
|
|
|
|
|
out->data.arr_boolean.size = v.size();
|
|
|
|
|
std::copy(v.begin(), v.end(), out->data.arr_boolean.arr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NT_DOUBLE_ARRAY: {
|
|
|
|
|
auto v = in.GetDoubleArray();
|
|
|
|
|
out->data.arr_double.arr =
|
|
|
|
|
static_cast<double*>(std::malloc(v.size() * sizeof(double)));
|
|
|
|
|
out->data.arr_double.size = v.size();
|
|
|
|
|
std::copy(v.begin(), v.end(), out->data.arr_double.arr);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
case NT_STRING_ARRAY: {
|
|
|
|
|
auto v = in.GetStringArray();
|
|
|
|
|
out->data.arr_string.arr =
|
2016-11-03 21:03:45 -07:00
|
|
|
static_cast<NT_String*>(std::malloc(v.size() * sizeof(NT_String)));
|
2015-08-22 19:31:53 -07:00
|
|
|
for (size_t i = 0; i < v.size(); ++i)
|
2015-07-16 01:38:27 -07:00
|
|
|
ConvertToC(v[i], &out->data.arr_string.arr[i]);
|
|
|
|
|
out->data.arr_string.size = v.size();
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
default:
|
|
|
|
|
// assert(false && "unknown value type");
|
|
|
|
|
return;
|
2015-06-29 23:08:35 -07:00
|
|
|
}
|
2015-07-16 01:38:27 -07:00
|
|
|
out->type = in.type();
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
void nt::ConvertToC(llvm::StringRef in, NT_String* out) {
|
2015-07-16 01:38:27 -07:00
|
|
|
out->len = in.size();
|
2016-11-03 21:03:45 -07:00
|
|
|
out->str = static_cast<char*>(std::malloc(in.size() + 1));
|
2015-07-16 01:38:27 -07:00
|
|
|
std::memcpy(out->str, in.data(), in.size());
|
|
|
|
|
out->str[in.size()] = '\0';
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
std::shared_ptr<Value> nt::ConvertFromC(const NT_Value& value) {
|
2015-07-16 01:38:27 -07:00
|
|
|
switch (value.type) {
|
|
|
|
|
case NT_UNASSIGNED:
|
|
|
|
|
return nullptr;
|
|
|
|
|
case NT_BOOLEAN:
|
|
|
|
|
return Value::MakeBoolean(value.data.v_boolean != 0);
|
|
|
|
|
case NT_DOUBLE:
|
|
|
|
|
return Value::MakeDouble(value.data.v_double);
|
|
|
|
|
case NT_STRING:
|
|
|
|
|
return Value::MakeString(ConvertFromC(value.data.v_string));
|
|
|
|
|
case NT_RAW:
|
|
|
|
|
return Value::MakeRaw(ConvertFromC(value.data.v_raw));
|
|
|
|
|
case NT_RPC:
|
|
|
|
|
return Value::MakeRpc(ConvertFromC(value.data.v_raw));
|
|
|
|
|
case NT_BOOLEAN_ARRAY:
|
|
|
|
|
return Value::MakeBooleanArray(llvm::ArrayRef<int>(
|
|
|
|
|
value.data.arr_boolean.arr, value.data.arr_boolean.size));
|
|
|
|
|
case NT_DOUBLE_ARRAY:
|
|
|
|
|
return Value::MakeDoubleArray(llvm::ArrayRef<double>(
|
|
|
|
|
value.data.arr_double.arr, value.data.arr_double.size));
|
|
|
|
|
case NT_STRING_ARRAY: {
|
|
|
|
|
std::vector<std::string> v;
|
|
|
|
|
v.reserve(value.data.arr_string.size);
|
2016-11-03 21:03:45 -07:00
|
|
|
for (size_t i = 0; i < value.data.arr_string.size; ++i)
|
2015-07-16 01:38:27 -07:00
|
|
|
v.push_back(ConvertFromC(value.data.arr_string.arr[i]));
|
|
|
|
|
return Value::MakeStringArray(std::move(v));
|
2015-07-03 13:29:31 -07:00
|
|
|
}
|
2015-07-16 01:38:27 -07:00
|
|
|
default:
|
|
|
|
|
// assert(false && "unknown value type");
|
|
|
|
|
return nullptr;
|
2015-06-29 23:08:35 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-07-17 07:21:07 -07:00
|
|
|
bool nt::operator==(const Value& lhs, const Value& rhs) {
|
2015-06-28 21:52:06 -07:00
|
|
|
if (lhs.type() != rhs.type()) return false;
|
|
|
|
|
switch (lhs.type()) {
|
2015-06-21 21:02:10 -07:00
|
|
|
case NT_UNASSIGNED:
|
2015-06-25 22:57:43 -07:00
|
|
|
return true; // XXX: is this better being false instead?
|
2015-06-21 21:02:10 -07:00
|
|
|
case NT_BOOLEAN:
|
2015-07-16 21:44:37 -07:00
|
|
|
return lhs.m_val.data.v_boolean == rhs.m_val.data.v_boolean;
|
2015-06-21 21:02:10 -07:00
|
|
|
case NT_DOUBLE:
|
2015-07-16 21:44:37 -07:00
|
|
|
return lhs.m_val.data.v_double == rhs.m_val.data.v_double;
|
2015-06-21 21:02:10 -07:00
|
|
|
case NT_STRING:
|
|
|
|
|
case NT_RAW:
|
|
|
|
|
case NT_RPC:
|
2015-07-16 01:38:27 -07:00
|
|
|
return lhs.m_string == rhs.m_string;
|
2015-06-21 21:02:10 -07:00
|
|
|
case NT_BOOLEAN_ARRAY:
|
2015-07-16 21:44:37 -07:00
|
|
|
if (lhs.m_val.data.arr_boolean.size != rhs.m_val.data.arr_boolean.size)
|
|
|
|
|
return false;
|
|
|
|
|
return std::memcmp(lhs.m_val.data.arr_boolean.arr,
|
|
|
|
|
rhs.m_val.data.arr_boolean.arr,
|
|
|
|
|
lhs.m_val.data.arr_boolean.size *
|
|
|
|
|
sizeof(lhs.m_val.data.arr_boolean.arr[0])) == 0;
|
2015-06-21 21:02:10 -07:00
|
|
|
case NT_DOUBLE_ARRAY:
|
2015-07-16 21:44:37 -07:00
|
|
|
if (lhs.m_val.data.arr_double.size != rhs.m_val.data.arr_double.size)
|
|
|
|
|
return false;
|
|
|
|
|
return std::memcmp(lhs.m_val.data.arr_double.arr,
|
|
|
|
|
rhs.m_val.data.arr_double.arr,
|
|
|
|
|
lhs.m_val.data.arr_double.size *
|
|
|
|
|
sizeof(lhs.m_val.data.arr_double.arr[0])) == 0;
|
2015-07-16 01:38:27 -07:00
|
|
|
case NT_STRING_ARRAY:
|
|
|
|
|
return lhs.m_string_array == rhs.m_string_array;
|
2015-06-21 21:02:10 -07:00
|
|
|
default:
|
2015-06-25 22:57:43 -07:00
|
|
|
// assert(false && "unknown value type");
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2015-06-21 21:02:10 -07:00
|
|
|
}
|