Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
f0c108b5
Commit
f0c108b5
authored
Mar 13, 2017
by
John Stiles
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove all switch
parent
6723e329
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
43 deletions
+27
-43
lookaheadparser.cpp
example/lookaheadparser/lookaheadparser.cpp
+27
-43
No files found.
example/lookaheadparser/lookaheadparser.cpp
View file @
f0c108b5
...
...
@@ -58,6 +58,7 @@ protected:
protected
:
enum
LookaheadParsingState
{
kInit
,
kError
,
kHasNull
,
kHasBool
,
...
...
@@ -78,7 +79,7 @@ protected:
static
const
int
parseFlags
=
kParseDefaultFlags
|
kParseInsituFlag
;
};
LookaheadParserHandler
::
LookaheadParserHandler
(
char
*
str
)
:
v_
(),
ss_
(
str
)
{
LookaheadParserHandler
::
LookaheadParserHandler
(
char
*
str
)
:
v_
(),
s
t_
(
kInit
),
r_
(),
s
s_
(
str
)
{
r_
.
IterativeParseInit
();
ParseNext
();
}
...
...
@@ -145,12 +146,12 @@ const char* LookaheadParser::NextObjectKey() {
return
result
;
}
if
(
st_
=
=
kExitingObject
)
{
ParseNext
()
;
if
(
st_
!
=
kExitingObject
)
{
st_
=
kError
;
return
0
;
}
st_
=
kError
;
ParseNext
()
;
return
0
;
}
...
...
@@ -180,7 +181,7 @@ int LookaheadParser::GetInt() {
}
double
LookaheadParser
::
GetDouble
()
{
if
(
st_
!=
kHasNumber
||
!
v_
.
IsNumber
()
)
{
if
(
st_
!=
kHasNumber
)
{
st_
=
kError
;
return
0.
;
}
...
...
@@ -223,27 +224,16 @@ const char* LookaheadParser::GetString() {
void
LookaheadParser
::
SkipOut
(
int
depth
)
{
do
{
switch
(
st_
)
{
case
kEnteringArray
:
case
kEnteringObject
:
++
depth
;
break
;
case
kExitingArray
:
case
kExitingObject
:
--
depth
;
break
;
case
kError
:
return
;
case
kHasNull
:
case
kHasBool
:
case
kHasNumber
:
case
kHasString
:
case
kHasKey
:
break
;
if
(
st_
==
kEnteringArray
||
st_
==
kEnteringObject
)
{
++
depth
;
}
else
if
(
st_
==
kExitingArray
||
st_
==
kExitingObject
)
{
--
depth
;
}
else
if
(
st_
==
kError
)
{
return
;
}
ParseNext
();
}
while
(
depth
>
0
);
...
...
@@ -270,25 +260,19 @@ Value* LookaheadParser::PeekValue() {
}
int
LookaheadParser
::
PeekType
()
{
switch
(
st_
)
{
case
kHasNull
:
case
kHasBool
:
case
kHasNumber
:
case
kHasString
:
case
kHasKey
:
return
v_
.
GetType
();
case
kEnteringArray
:
return
kArrayType
;
case
kEnteringObject
:
return
kObjectType
;
case
kExitingArray
:
case
kExitingObject
:
case
kError
:
return
-
1
;
if
(
st_
>=
kHasNull
&&
st_
<=
kHasKey
)
{
return
v_
.
GetType
();
}
if
(
st_
==
kEnteringArray
)
{
return
kArrayType
;
}
if
(
st_
==
kEnteringObject
)
{
return
kObjectType
;
}
return
-
1
;
}
//-------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment