Skip to content

Commit ee1be9b

Browse files
committed
update cppjson source code
1 parent 3b0225f commit ee1be9b

File tree

10 files changed

+20
-60
lines changed

10 files changed

+20
-60
lines changed

cpp_json/JsonAPI/Json.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,8 @@ namespace JSON{
2828

2929
json & json::operator=(const json & rhs) noexcept{
3030
if(rhs == *this) return *this; //avoid self-assignment
31-
puts("++");
3231
json tmp(rhs);
3332
json_ptr.swap(tmp.json_ptr);
34-
puts("--");
3533
return *this;
3634
}
3735

@@ -82,16 +80,16 @@ namespace JSON{
8280
}
8381

8482

85-
string & json::get_string() const{
83+
const string & json::get_string() const{
8684
return json_ptr->get_string();
8785
}
8886
double json::get_number() const{
8987
return json_ptr->get_number();
9088
}
91-
arr & json::get_arr() const{
89+
const arr & json::get_arr() const{
9290
return json_ptr->get_arr();
9391
}
94-
mem & json::get_mem() const{
92+
const mem & json::get_mem() const{
9593
return json_ptr->get_mem();
9694
}
9795
bool json::get_bool() const{
@@ -141,7 +139,7 @@ namespace JSON{
141139
/** copy operators of Json_value **/
142140
Json_value::Json_value(): type(JSON::JSON_NULL){}
143141
Json_value::Json_value(double n): var(n), type(JSON::JSON_NUMBER){}
144-
Json_value::Json_value(const string & s): var(s), type(JSON::JSON_STRING){puts("copy");}
142+
Json_value::Json_value(const string & s): var(s), type(JSON::JSON_STRING){}
145143
Json_value::Json_value(bool b):var(b){
146144
if(!b) type = JSON_FALSE;
147145
else type = JSON_TRUE;
@@ -200,30 +198,30 @@ namespace JSON{
200198
return !(*this == rhs);
201199
}
202200

203-
Json_value::Json_value(string && s) noexcept: var(std::move(s)) , type(JSON::JSON_STRING){puts("move");}
201+
Json_value::Json_value(string && s) noexcept: var(std::move(s)) , type(JSON::JSON_STRING){}
204202
Json_value::Json_value(mem && m) noexcept: var(m), type(JSON::JSON_OBJECT){}
205203
Json_value::Json_value(arr && a) noexcept: var(a), type(JSON::JSON_ARRAY){}
206204

207205

208-
string & Json_value::get_string(){
206+
const string & Json_value::get_string() const{
209207
assert(type == JSON_STRING);
210208
return std::get<string>(this->var);
211209
}
212210

213-
double Json_value::get_number(){
211+
double Json_value::get_number() const{
214212
assert(type == JSON_NUMBER);
215213
return std::get<double>(this->var);
216214
}
217-
arr & Json_value::get_arr(){
215+
const arr & Json_value::get_arr() const{
218216
assert(type == JSON_ARRAY);
219217
return std::get<arr>(this->var);
220218
}
221-
mem & Json_value::get_mem(){
219+
const mem & Json_value::get_mem() const{
222220
assert(type == JSON_OBJECT);
223221
return std::get<mem>(this->var);
224222
}
225223

226-
bool Json_value::get_bool(){
224+
bool Json_value::get_bool() const{
227225
assert(type == JSON_TRUE || type == JSON_FALSE);
228226
return type == JSON_TRUE;
229227
}

cpp_json/JsonAPI/Json.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,11 @@ namespace JSON{
4949

5050
/** get functions**/
5151
JSON_TYPE get_type() const{return type;}
52-
string & get_string();
53-
double get_number();
54-
arr & get_arr();
55-
mem & get_mem();
56-
bool get_bool();
52+
const string & get_string() const;
53+
double get_number() const;
54+
const arr & get_arr() const;
55+
const mem & get_mem() const;
56+
bool get_bool() const;
5757

5858
/** set functions **/
5959
void set_string(string & s);
@@ -101,10 +101,10 @@ namespace JSON{
101101
/** get_value functions **/
102102

103103
bool get_bool() const;
104-
string & get_string() const;
104+
const string & get_string() const;
105105
double get_number() const;
106-
arr & get_arr() const;
107-
mem & get_mem() const;
106+
const arr & get_arr() const;
107+
const mem & get_mem() const;
108108

109109
/** set_value functions **/
110110
void set_string(string & s);

cpp_json/cmake-build-debug/CMakeFiles/Progress/2

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp_json/cmake-build-debug/CMakeFiles/Progress/count.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

cpp_json/cmake-build-debug/CMakeFiles/cpp_json.dir/CXX.includecache

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -26,39 +26,3 @@ memory
2626
cerrno
2727
-
2828

29-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonparser.cpp
30-
Jsonparser.h
31-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonparser.h
32-
exception
33-
-
34-
35-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonparser.h
36-
stack.h
37-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/stack.h
38-
Json.h
39-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Json.h
40-
41-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonstringifier.cpp
42-
Jsonstringifier.h
43-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonstringifier.h
44-
45-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonstringifier.h
46-
stack.h
47-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/stack.h
48-
Json.h
49-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Json.h
50-
51-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/stack.cpp
52-
stack.h
53-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/stack.h
54-
55-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/stack.h
56-
Json.h
57-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Json.h
58-
59-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/main.cpp
60-
JsonAPI/Jsonparser.h
61-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonparser.h
62-
JsonAPI/Jsonstringifier.h
63-
/Users/wocaibujiaoquanmei/iCloud 云盘(归档)/GitHub/cppjson/cpp_json/JsonAPI/Jsonstringifier.h
64-
Binary file not shown.
Binary file not shown.
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Start testing: Dec 17 09:58 CST
1+
Start testing: Dec 17 10:18 CST
22
----------------------------------------------------------
3-
End testing: Dec 17 09:58 CST
3+
End testing: Dec 17 10:18 CST

cpp_json/cmake-build-debug/cpp_json

-3.98 KB
Binary file not shown.

0 commit comments

Comments
 (0)