Electroneum
Toggle main menu visibility
Loading...
Searching...
No Matches
simplereader.cpp
Go to the documentation of this file.
1
#include "
rapidjson/reader.h
"
2
#include <iostream>
3
4
using namespace
rapidjson
;
5
using namespace
std
;
6
7
struct
MyHandler
{
8
bool
Null
() { cout <<
"Null()"
<< endl;
return
true
; }
9
bool
Bool
(
bool
b) { cout <<
"Bool("
<< boolalpha << b <<
")"
<< endl;
return
true
; }
10
bool
Int
(
int
i) { cout <<
"Int("
<< i <<
")"
<< endl;
return
true
; }
11
bool
Uint
(
unsigned
u) { cout <<
"Uint("
<< u <<
")"
<< endl;
return
true
; }
12
bool
Int64
(
int64_t
i) { cout <<
"Int64("
<< i <<
")"
<< endl;
return
true
; }
13
bool
Uint64
(
uint64_t
u) { cout <<
"Uint64("
<< u <<
")"
<< endl;
return
true
; }
14
bool
Double
(
double
d) { cout <<
"Double("
<< d <<
")"
<< endl;
return
true
; }
15
bool
RawNumber
(
const
char
* str,
SizeType
length,
bool
copy) {
16
cout <<
"Number("
<< str <<
", "
<< length <<
", "
<< boolalpha << copy <<
")"
<< endl;
17
return
true
;
18
}
19
bool
String
(
const
char
* str,
SizeType
length,
bool
copy) {
20
cout <<
"String("
<< str <<
", "
<< length <<
", "
<< boolalpha << copy <<
")"
<< endl;
21
return
true
;
22
}
23
bool
StartObject
() { cout <<
"StartObject()"
<< endl;
return
true
; }
24
bool
Key
(
const
char
* str,
SizeType
length,
bool
copy) {
25
cout <<
"Key("
<< str <<
", "
<< length <<
", "
<< boolalpha << copy <<
")"
<< endl;
26
return
true
;
27
}
28
bool
EndObject
(
SizeType
memberCount) { cout <<
"EndObject("
<< memberCount <<
")"
<< endl;
return
true
; }
29
bool
StartArray
() { cout <<
"StartArray()"
<< endl;
return
true
; }
30
bool
EndArray
(
SizeType
elementCount) { cout <<
"EndArray("
<< elementCount <<
")"
<< endl;
return
true
; }
31
};
32
33
int
main
() {
34
const
char
json
[] =
" { \"hello\" : \"world\", \"t\" : true , \"f\" : false, \"n\": null, \"i\":123, \"pi\": 3.1416, \"a\":[1, 2, 3, 4] } "
;
35
36
MyHandler
handler;
37
Reader
reader;
38
StringStream
ss(
json
);
39
reader.
Parse
(ss, handler);
40
41
return
0;
42
}
GenericReader::Parse
ParseResult Parse(InputStream &is, Handler &handler)
Parse JSON text.
Definition
reader.h:557
StringStream
GenericStringStream< UTF8< char > > StringStream
Definition
fwd.h:49
Reader
GenericReader< UTF8< char >, UTF8< char >, CrtAllocator > Reader
Definition
fwd.h:90
rapidjson
main RapidJSON namespace
std
STL namespace.
SizeType
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.).
Definition
rapidjson.h:389
reader.h
main
int main()
Definition
simplereader.cpp:33
int64_t
signed __int64 int64_t
Definition
stdint.h:135
uint64_t
unsigned __int64 uint64_t
Definition
stdint.h:136
MyHandler
Definition
simplepullreader.cpp:15
MyHandler::String
bool String(const char *str, SizeType length, bool copy)
Definition
simplereader.cpp:19
MyHandler::StartArray
bool StartArray()
Definition
simplereader.cpp:29
MyHandler::Bool
bool Bool(bool b)
Definition
simplereader.cpp:9
MyHandler::RawNumber
bool RawNumber(const char *str, SizeType length, bool copy)
Definition
simplereader.cpp:15
MyHandler::EndObject
bool EndObject(SizeType memberCount)
Definition
simplereader.cpp:28
MyHandler::Uint
bool Uint(unsigned u)
Definition
simplereader.cpp:11
MyHandler::Int64
bool Int64(int64_t i)
Definition
simplereader.cpp:12
MyHandler::Double
bool Double(double d)
Definition
simplereader.cpp:14
MyHandler::Null
bool Null()
Definition
simplereader.cpp:8
MyHandler::EndArray
bool EndArray(SizeType elementCount)
Definition
simplereader.cpp:30
MyHandler::Uint64
bool Uint64(uint64_t u)
Definition
simplereader.cpp:13
MyHandler::Int
bool Int(int i)
Definition
simplereader.cpp:10
MyHandler::Key
bool Key(const char *str, SizeType length, bool copy)
Definition
simplereader.cpp:24
MyHandler::StartObject
bool StartObject()
Definition
simplereader.cpp:23
json
rapidjson::Document json
Definition
transport.cpp:49
external
rapidjson
example
simplereader
simplereader.cpp
Generated on
for Electroneum by
1.17.0