|
|
@ -87,7 +87,7 @@ Value::Value(const std::initializer_list<Value>& values) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool isObject = std::all_of(values.begin(), values.end(), [](const Value& value) { |
|
|
|
bool isObject = std::all_of(values.begin(), values.end(), [](const Value& value) { |
|
|
|
return value.type() == Type::Array |
|
|
|
return value.type() == Type::Array |
|
|
|
&& value.m_value.asArray->size() == 2 |
|
|
|
&& value.size() == 2 |
|
|
|
&& value[0].m_type == Type::String; |
|
|
|
&& value[0].m_type == Type::String; |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
@ -186,6 +186,26 @@ const Value& Value::operator[](const std::string& key) const |
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------
|
|
|
|
// ------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
size_t Value::size() const |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
switch (m_type) { |
|
|
|
|
|
|
|
case Type::Null: |
|
|
|
|
|
|
|
return 0; |
|
|
|
|
|
|
|
case Type::Bool: |
|
|
|
|
|
|
|
case Type::Number: |
|
|
|
|
|
|
|
case Type::String: |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
case Type::Array: |
|
|
|
|
|
|
|
return m_value.asArray->size(); |
|
|
|
|
|
|
|
case Type::Object: |
|
|
|
|
|
|
|
return m_value.asObject->size(); |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
return 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// ------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
void Value::create() |
|
|
|
void Value::create() |
|
|
|
{ |
|
|
|
{ |
|
|
|
switch (m_type) { |
|
|
|
switch (m_type) { |
|
|
|