Added shallow copy constructors for Json_Array and Json_Object && Added a float type constructor for Json_Value && Fixed the incorrect indentation issue when pretty-printing an empty Json_Array.
This commit is contained in:
parent
e80d14d347
commit
ce6f9646c4
@ -54,6 +54,8 @@ public:
|
|||||||
// 列表构造
|
// 列表构造
|
||||||
Json_Arry(std::initializer_list<Json_Value> init_list) : private_element_list(init_list) {};
|
Json_Arry(std::initializer_list<Json_Value> init_list) : private_element_list(init_list) {};
|
||||||
Json_Arry(std::vector<Json_Value> init_list) : private_element_list(init_list) {};
|
Json_Arry(std::vector<Json_Value> init_list) : private_element_list(init_list) {};
|
||||||
|
// 浅拷贝构造
|
||||||
|
Json_Arry(const Json_Arry &temp);
|
||||||
|
|
||||||
// 深拷贝
|
// 深拷贝
|
||||||
Json_Arry &operator=(const Json_Arry &another);
|
Json_Arry &operator=(const Json_Arry &another);
|
||||||
@ -101,6 +103,7 @@ public:
|
|||||||
Json_Value(int64_t num_integer);
|
Json_Value(int64_t num_integer);
|
||||||
Json_Value(int num_integer) : Json_Value((int64_t)num_integer) {};
|
Json_Value(int num_integer) : Json_Value((int64_t)num_integer) {};
|
||||||
Json_Value(double num_float);
|
Json_Value(double num_float);
|
||||||
|
Json_Value(float num_float) : Json_Value((double)num_float) {};
|
||||||
Json_Value(bool boolean);
|
Json_Value(bool boolean);
|
||||||
// 浅拷贝构造
|
// 浅拷贝构造
|
||||||
Json_Value(const Json_Value &temp);
|
Json_Value(const Json_Value &temp);
|
||||||
@ -165,6 +168,8 @@ public:
|
|||||||
// 列表构造
|
// 列表构造
|
||||||
Json_Object(std::initializer_list<Json_Pair> init_list) : private_element_list(init_list) {};
|
Json_Object(std::initializer_list<Json_Pair> init_list) : private_element_list(init_list) {};
|
||||||
Json_Object(std::vector<Json_Pair> init_list) : private_element_list(init_list) {};
|
Json_Object(std::vector<Json_Pair> init_list) : private_element_list(init_list) {};
|
||||||
|
// 浅拷贝构造
|
||||||
|
Json_Object(const Json_Object &temp);
|
||||||
|
|
||||||
// 深拷贝
|
// 深拷贝
|
||||||
Json_Object &operator=(const Json_Object &another);
|
Json_Object &operator=(const Json_Object &another);
|
||||||
|
|||||||
@ -786,7 +786,7 @@ std::string Json_Export(const char *path_to_file, Json_Value value, bool enable_
|
|||||||
fprintf(pFile, "\r\n");
|
fprintf(pFile, "\r\n");
|
||||||
}
|
}
|
||||||
// 尾部缩进
|
// 尾部缩进
|
||||||
if (enable_pretty_print && (!value.isNull()))
|
if (enable_pretty_print && (!arry.isNull()))
|
||||||
for (size_t count = 0; count < depth; count++)
|
for (size_t count = 0; count < depth; count++)
|
||||||
fprintf(pFile, " ");
|
fprintf(pFile, " ");
|
||||||
|
|
||||||
@ -1041,6 +1041,13 @@ bool Json_Pair::isNull() const
|
|||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
||||||
|
// 浅拷贝构造
|
||||||
|
Json_Arry::Json_Arry(const Json_Arry &temp)
|
||||||
|
{
|
||||||
|
// 执行深拷贝
|
||||||
|
*this = temp;
|
||||||
|
}
|
||||||
|
|
||||||
// 深拷贝
|
// 深拷贝
|
||||||
Json_Arry &Json_Arry::operator=(const Json_Arry &another)
|
Json_Arry &Json_Arry::operator=(const Json_Arry &another)
|
||||||
{
|
{
|
||||||
@ -1075,6 +1082,13 @@ bool Json_Arry::isNull(void) const
|
|||||||
|
|
||||||
// =================================================================================================
|
// =================================================================================================
|
||||||
|
|
||||||
|
// 浅拷贝构造
|
||||||
|
Json_Object::Json_Object(const Json_Object &temp)
|
||||||
|
{
|
||||||
|
// 执行深拷贝
|
||||||
|
*this = temp;
|
||||||
|
}
|
||||||
|
|
||||||
// 深拷贝
|
// 深拷贝
|
||||||
Json_Object &Json_Object::operator=(const Json_Object &another)
|
Json_Object &Json_Object::operator=(const Json_Object &another)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user