Util: Add flexible constructor toJson() to Json::Value
This commit is contained in:
+19
-54
@@ -19,19 +19,9 @@
|
||||
|
||||
namespace Json {
|
||||
|
||||
Value::Value(const Value& other)
|
||||
Value::Value(std::nullptr_t)
|
||||
: Value(Type::Null)
|
||||
{
|
||||
copyFrom(other);
|
||||
}
|
||||
|
||||
Value& Value::operator=(const Value& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
clear();
|
||||
copyFrom(other);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
Value::Value(Type type)
|
||||
@@ -40,48 +30,6 @@ Value::Value(Type type)
|
||||
create();
|
||||
}
|
||||
|
||||
Value::Value(bool value)
|
||||
: m_type(Type::Bool)
|
||||
{
|
||||
m_value.asBool = value;
|
||||
}
|
||||
|
||||
Value::Value(int value)
|
||||
: m_type(Type::Number)
|
||||
{
|
||||
m_value.asDouble = value;
|
||||
}
|
||||
|
||||
Value::Value(double value)
|
||||
: m_type(Type::Number)
|
||||
{
|
||||
m_value.asDouble = value;
|
||||
}
|
||||
|
||||
Value::Value(const char* value)
|
||||
: m_type(Type::String)
|
||||
{
|
||||
m_value.asString = new std::string(value);
|
||||
}
|
||||
|
||||
Value::Value(const std::string& value)
|
||||
: m_type(Type::String)
|
||||
{
|
||||
m_value.asString = new std::string(value);
|
||||
}
|
||||
|
||||
Value::Value(const Array& value)
|
||||
: m_type(Type::Array)
|
||||
{
|
||||
m_value.asArray = new Array(value);
|
||||
}
|
||||
|
||||
Value::Value(const Object& value)
|
||||
: m_type(Type::Object)
|
||||
{
|
||||
m_value.asObject = new Object(value);
|
||||
}
|
||||
|
||||
Value::Value(const std::initializer_list<Value>& values)
|
||||
{
|
||||
bool isObject = std::all_of(values.begin(), values.end(), [](const Value& value) {
|
||||
@@ -105,6 +53,23 @@ Value::Value(const std::initializer_list<Value>& values)
|
||||
}
|
||||
}
|
||||
|
||||
// Copy constructor
|
||||
Value::Value(const Value& other)
|
||||
{
|
||||
copyFrom(other);
|
||||
}
|
||||
|
||||
// Assignment operator
|
||||
Value& Value::operator=(const Value& other)
|
||||
{
|
||||
if (this != &other) {
|
||||
clear();
|
||||
copyFrom(other);
|
||||
}
|
||||
|
||||
return *this;
|
||||
}
|
||||
|
||||
// ------------------------------------------
|
||||
|
||||
Value Value::parse(const std::string& input)
|
||||
|
||||
Reference in New Issue
Block a user