MCPcopy Create free account
hub / github.com/MonaSolutions/MonaServer / JSONReader

Method JSONReader

MonaCore/sources/JSONReader.cpp:30–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28
29
30JSONReader::JSONReader(PacketReader& packet,const PoolBuffers& poolBuffers) : _pos(packet.position()),_pBuffer(poolBuffers),DataReader(packet),_isValid(false) {
31
32 // check first '[' and last ']' or '{ and '}'
33
34 const UInt8* cur = current();
35 if (!cur)
36 return;
37 bool isArray(*cur=='[');
38 if (!isArray && *cur != '{')
39 return;
40
41 packet.next();
42 _pos = packet.position();
43
44 if (!(cur = current()))
45 return;
46
47 const UInt8* end(cur + packet.available());
48
49 while (end-- > cur) {
50 if (!isspace(*end)) {
51 if (isArray) {
52 if (*end == ']') {
53 _isValid = true;
54 packet.shrink(end-cur);
55 }
56 } else if (*end == '}') {
57 _isValid = true;
58 packet.shrink(end-cur);
59 }
60 return;
61 }
62 }
63}
64
65
66UInt8 JSONReader::followingType() {

Callers

nothing calls this directly

Calls 5

isspaceFunction · 0.85
positionMethod · 0.80
shrinkMethod · 0.80
nextMethod · 0.45
availableMethod · 0.45

Tested by

no test coverage detected