Skip to content

Commit 4232e40

Browse files
StilesCrisisStilesCrisis
authored andcommitted
Clean up example code
1 parent d84d5fe commit 4232e40

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

example/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ set(EXAMPLES
1818
serialize
1919
simpledom
2020
simplereader
21+
simplepullreader
2122
simplewriter
2223
tutorial)
2324

example/simplepullreader/simplepullreader.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,19 @@ struct MyHandler {
99
std::string data;
1010

1111
bool Null() { type = "Null"; data.clear(); return true; }
12-
bool Bool(bool b) { type = "Bool"; data = b? "true": "false"; return true; }
13-
bool Int(int i) { type = "Int"; data = std::to_string(i); return true; }
14-
bool Uint(unsigned u) { type = "Uint"; data = std::to_string(u); return true; }
15-
bool Int64(int64_t i) { type = "Int64"; data = std::to_string(i); return true; }
16-
bool Uint64(uint64_t u) { type = "Uint64"; data = std::to_string(u); return true; }
17-
bool Double(double d) { type = "Double"; data = std::to_string(d); return true; }
18-
bool RawNumber(const char* str, SizeType length, bool) { type = "Number"; data = std::string(str, length); return true; }
19-
bool String(const char* str, SizeType length, bool) { type = "String" data = std::string(str, length); return true; }
12+
bool Bool(bool b) { type = "Bool:"; data = b? "true": "false"; return true; }
13+
bool Int(int i) { type = "Int:"; data = std::to_string(i); return true; }
14+
bool Uint(unsigned u) { type = "Uint:"; data = std::to_string(u); return true; }
15+
bool Int64(int64_t i) { type = "Int64:"; data = std::to_string(i); return true; }
16+
bool Uint64(uint64_t u) { type = "Uint64:"; data = std::to_string(u); return true; }
17+
bool Double(double d) { type = "Double:"; data = std::to_string(d); return true; }
18+
bool RawNumber(const char* str, SizeType length, bool) { type = "Number:"; data = std::string(str, length); return true; }
19+
bool String(const char* str, SizeType length, bool) { type = "String:"; data = std::string(str, length); return true; }
2020
bool StartObject() { type = "StartObject"; data.clear(); return true; }
21-
bool Key(const char* str, SizeType length, bool) { type = "Key" data = std::string(str, length); return true; }
22-
bool EndObject(SizeType memberCount) { type = "EndObject"; data = std::to_string(memberCount); return true; }
21+
bool Key(const char* str, SizeType length, bool) { type = "Key:"; data = std::string(str, length); return true; }
22+
bool EndObject(SizeType memberCount) { type = "EndObject:"; data = std::to_string(memberCount); return true; }
2323
bool StartArray() { type = "StartArray"; data.clear(); return true; }
24-
bool EndArray(SizeType elementCount) { type = "EndArray"; data = std::to_string(elementCount); return true; }
24+
bool EndArray(SizeType elementCount) { type = "EndArray:"; data = std::to_string(elementCount); return true; }
2525
};
2626

2727
int main() {
@@ -33,7 +33,7 @@ int main() {
3333
reader.IterativeParseInit();
3434
while (!reader.IterativeParseComplete()) {
3535
reader.IterativeParseNext<kParseDefaultFlags>(ss, handler);
36-
cout << handler.type << ": " << handler.data << endl;
36+
cout << handler.type << handler.data << endl;
3737
}
3838

3939
return 0;

0 commit comments

Comments
 (0)