|
@@ -63,7 +63,7 @@ public:
|
|
|
assign(v, sizeof(T) * value.size(), typeid(T *).hash_code());
|
|
|
}
|
|
|
|
|
|
- Value(const std::vector <bool> &value)
|
|
|
+ Value(const std::vector<bool> &value)
|
|
|
{
|
|
|
size_t size = sizeof(bool) * value.size();
|
|
|
|
|
@@ -98,9 +98,19 @@ public:
|
|
|
delete[] _content;
|
|
|
}
|
|
|
|
|
|
- bool empty() const
|
|
|
+ bool is_null() const
|
|
|
{ return _content == nullptr; }
|
|
|
|
|
|
+ template<typename Z>
|
|
|
+ bool is_type() const
|
|
|
+ { return _type_id == typeid(Z).hash_code(); }
|
|
|
+
|
|
|
+ bool operator==(const Value &other) const
|
|
|
+ {
|
|
|
+ return _type_id == other._type_id and _size == other._size
|
|
|
+ and std::memcmp(_content, other._content, _size) == 0;
|
|
|
+ }
|
|
|
+
|
|
|
template<typename T>
|
|
|
void operator()(T &value) const
|
|
|
{
|
|
@@ -129,10 +139,6 @@ public:
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- template<typename Z>
|
|
|
- bool is_type() const
|
|
|
- { return _type_id == typeid(Z).hash_code(); }
|
|
|
-
|
|
|
Value &operator=(const Value &value)
|
|
|
{
|
|
|
if (_content != nullptr) {
|
|
@@ -159,7 +165,7 @@ public:
|
|
|
|
|
|
std::string to_string() const
|
|
|
{
|
|
|
- if (empty()) {
|
|
|
+ if (is_null()) {
|
|
|
return "<null>";
|
|
|
} else if (is_type<double>()) {
|
|
|
double v;
|