Electroneum
LookaheadParser Class Reference
Inheritance diagram for LookaheadParser:
Collaboration diagram for LookaheadParser:

Public Member Functions

 LookaheadParser (char *str)
 
bool EnterObject ()
 
bool EnterArray ()
 
const char * NextObjectKey ()
 
bool NextArrayValue ()
 
int GetInt ()
 
double GetDouble ()
 
const char * GetString ()
 
bool GetBool ()
 
void GetNull ()
 
void SkipObject ()
 
void SkipArray ()
 
void SkipValue ()
 
Value * PeekValue ()
 
int PeekType ()
 
bool IsValid ()
 

Protected Member Functions

void SkipOut (int depth)
 
- Protected Member Functions inherited from LookaheadParserHandler
 LookaheadParserHandler (char *str)
 
void ParseNext ()
 
bool Null ()
 
bool Bool (bool b)
 
bool Int (int i)
 
bool Uint (unsigned u)
 
bool Int64 (int64_t i)
 
bool Uint64 (uint64_t u)
 
bool Double (double d)
 
bool RawNumber (const char *, SizeType, bool)
 
bool String (const char *str, SizeType length, bool)
 
bool StartObject ()
 
bool Key (const char *str, SizeType length, bool)
 
bool EndObject (SizeType)
 
bool StartArray ()
 
bool EndArray (SizeType)
 

Additional Inherited Members

- Protected Types inherited from LookaheadParserHandler
enum  LookaheadParsingState {
  kInit , kError , kHasNull , kHasBool ,
  kHasNumber , kHasString , kHasKey , kEnteringObject ,
  kExitingObject , kEnteringArray , kExitingArray
}
 
- Protected Attributes inherited from LookaheadParserHandler
Value v_
 
LookaheadParsingState st_
 
Reader r_
 
InsituStringStream ss_
 
- Static Protected Attributes inherited from LookaheadParserHandler
static const int parseFlags = kParseDefaultFlags | kParseInsituFlag
 

Detailed Description

Definition at line 101 of file lookaheadparser.cpp.

Constructor & Destructor Documentation

◆ LookaheadParser()

LookaheadParser::LookaheadParser ( char *  str)
inline

Definition at line 103 of file lookaheadparser.cpp.

103 : LookaheadParserHandler(str) {}

Member Function Documentation

◆ EnterArray()

bool LookaheadParser::EnterArray ( )

Definition at line 137 of file lookaheadparser.cpp.

137  {
138  if (st_ != kEnteringArray) {
139  st_ = kError;
140  return false;
141  }
142 
143  ParseNext();
144  return true;
145 }
LookaheadParsingState st_
Here is the call graph for this function:
Here is the caller graph for this function:

◆ EnterObject()

bool LookaheadParser::EnterObject ( )

Definition at line 127 of file lookaheadparser.cpp.

127  {
128  if (st_ != kEnteringObject) {
129  st_ = kError;
130  return false;
131  }
132 
133  ParseNext();
134  return true;
135 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetBool()

bool LookaheadParser::GetBool ( )

Definition at line 199 of file lookaheadparser.cpp.

199  {
200  if (st_ != kHasBool) {
201  st_ = kError;
202  return false;
203  }
204 
205  bool result = v_.GetBool();
206  ParseNext();
207  return result;
208 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetDouble()

double LookaheadParser::GetDouble ( )

Definition at line 188 of file lookaheadparser.cpp.

188  {
189  if (st_ != kHasNumber) {
190  st_ = kError;
191  return 0.;
192  }
193 
194  double result = v_.GetDouble();
195  ParseNext();
196  return result;
197 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetInt()

int LookaheadParser::GetInt ( )

Definition at line 177 of file lookaheadparser.cpp.

177  {
178  if (st_ != kHasNumber || !v_.IsInt()) {
179  st_ = kError;
180  return 0;
181  }
182 
183  int result = v_.GetInt();
184  ParseNext();
185  return result;
186 }
Here is the call graph for this function:

◆ GetNull()

void LookaheadParser::GetNull ( )

Definition at line 210 of file lookaheadparser.cpp.

210  {
211  if (st_ != kHasNull) {
212  st_ = kError;
213  return;
214  }
215 
216  ParseNext();
217 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetString()

const char * LookaheadParser::GetString ( )

Definition at line 219 of file lookaheadparser.cpp.

219  {
220  if (st_ != kHasString) {
221  st_ = kError;
222  return 0;
223  }
224 
225  const char* result = v_.GetString();
226  ParseNext();
227  return result;
228 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsValid()

bool LookaheadParser::IsValid ( )
inline

Definition at line 121 of file lookaheadparser.cpp.

121 { return st_ != kError; }

◆ NextArrayValue()

bool LookaheadParser::NextArrayValue ( )

Definition at line 163 of file lookaheadparser.cpp.

163  {
164  if (st_ == kExitingArray) {
165  ParseNext();
166  return false;
167  }
168 
169  if (st_ == kError || st_ == kExitingObject || st_ == kHasKey) {
170  st_ = kError;
171  return false;
172  }
173 
174  return true;
175 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ NextObjectKey()

const char * LookaheadParser::NextObjectKey ( )

Definition at line 147 of file lookaheadparser.cpp.

147  {
148  if (st_ == kHasKey) {
149  const char* result = v_.GetString();
150  ParseNext();
151  return result;
152  }
153 
154  if (st_ != kExitingObject) {
155  st_ = kError;
156  return 0;
157  }
158 
159  ParseNext();
160  return 0;
161 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ PeekType()

int LookaheadParser::PeekType ( )

Definition at line 267 of file lookaheadparser.cpp.

267  {
268  if (st_ >= kHasNull && st_ <= kHasKey) {
269  return v_.GetType();
270  }
271 
272  if (st_ == kEnteringArray) {
273  return kArrayType;
274  }
275 
276  if (st_ == kEnteringObject) {
277  return kObjectType;
278  }
279 
280  return -1;
281 }
@ kObjectType
object
Definition: rapidjson.h:624
@ kArrayType
array
Definition: rapidjson.h:625
Here is the caller graph for this function:

◆ PeekValue()

Value * LookaheadParser::PeekValue ( )

Definition at line 259 of file lookaheadparser.cpp.

259  {
260  if (st_ >= kHasNull && st_ <= kHasKey) {
261  return &v_;
262  }
263 
264  return 0;
265 }

◆ SkipArray()

void LookaheadParser::SkipArray ( )

Definition at line 251 of file lookaheadparser.cpp.

251  {
252  SkipOut(1);
253 }
void SkipOut(int depth)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ SkipObject()

void LookaheadParser::SkipObject ( )

Definition at line 255 of file lookaheadparser.cpp.

255  {
256  SkipOut(1);
257 }
Here is the call graph for this function:

◆ SkipOut()

void LookaheadParser::SkipOut ( int  depth)
protected

Definition at line 230 of file lookaheadparser.cpp.

230  {
231  do {
232  if (st_ == kEnteringArray || st_ == kEnteringObject) {
233  ++depth;
234  }
235  else if (st_ == kExitingArray || st_ == kExitingObject) {
236  --depth;
237  }
238  else if (st_ == kError) {
239  return;
240  }
241 
242  ParseNext();
243  }
244  while (depth > 0);
245 }
Here is the caller graph for this function:

◆ SkipValue()

void LookaheadParser::SkipValue ( )

Definition at line 247 of file lookaheadparser.cpp.

247  {
248  SkipOut(0);
249 }
Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: