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
4a71dc6d
Commit
4a71dc6d
authored
Sep 04, 2014
by
Kosta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reunified `ParseKey`, `ParseString`, and `ParseStringOrKey` again
parent
25f4892a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
28 deletions
+14
-28
reader.h
include/rapidjson/reader.h
+14
-28
No files found.
include/rapidjson/reader.h
View file @
4a71dc6d
...
...
@@ -473,7 +473,7 @@ private:
if
(
is
.
Peek
()
!=
'"'
)
RAPIDJSON_PARSE_ERROR
(
kParseErrorObjectMissName
,
is
.
Tell
());
Parse
Key
<
parseFlags
>
(
is
,
handler
);
Parse
String
<
parseFlags
>
(
is
,
handler
,
true
);
RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID
;
SkipWhitespace
(
is
);
...
...
@@ -578,7 +578,7 @@ private:
RAPIDJSON_PARSE_ERROR
(
kParseErrorValueInvalid
,
is
.
Tell
()
-
1
);
}
// Helper function to parse four hexidecimal digits in \uXXXX in ParseString
OrKey
().
// Helper function to parse four hexidecimal digits in \uXXXX in ParseString().
template
<
typename
InputStream
>
unsigned
ParseHex4
(
InputStream
&
is
)
{
unsigned
codepoint
=
0
;
...
...
@@ -618,47 +618,33 @@ private:
};
// Parse string and generate String event. Different code paths for kParseInsituFlag.
template
<
unsigned
parseFlags
,
bool
isKey
,
typename
InputStream
,
typename
Handler
>
void
ParseString
OrKey
(
InputStream
&
is
,
Handler
&
handler
)
{
template
<
unsigned
parseFlags
,
typename
InputStream
,
typename
Handler
>
void
ParseString
(
InputStream
&
is
,
Handler
&
handler
,
bool
isKey
=
false
)
{
internal
::
StreamLocalCopy
<
InputStream
>
copy
(
is
);
InputStream
&
s
(
copy
.
s
);
const
typename
TargetEncoding
::
Ch
*
str
=
NULL
;
SizeType
len
=
0
;
if
(
parseFlags
&
kParseInsituFlag
)
{
typename
InputStream
::
Ch
*
head
=
s
.
PutBegin
();
ParseStringToStream
<
parseFlags
,
SourceEncoding
,
SourceEncoding
>
(
s
,
s
);
RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID
;
size_t
length
=
s
.
PutEnd
(
head
)
-
1
;
RAPIDJSON_ASSERT
(
length
<=
0xFFFFFFFF
);
if
(
isKey
)
{
if
(
!
handler
.
Key
((
typename
TargetEncoding
::
Ch
*
)
head
,
SizeType
(
length
),
false
))
RAPIDJSON_PARSE_ERROR
(
kParseErrorTermination
,
s
.
Tell
());
}
else
{
if
(
!
handler
.
String
((
typename
TargetEncoding
::
Ch
*
)
head
,
SizeType
(
length
),
false
))
RAPIDJSON_PARSE_ERROR
(
kParseErrorTermination
,
s
.
Tell
());
}
str
=
(
const
typename
TargetEncoding
::
Ch
*
)
head
;
len
=
SizeType
(
length
);
}
else
{
StackStream
stackStream
(
stack_
);
ParseStringToStream
<
parseFlags
,
SourceEncoding
,
TargetEncoding
>
(
s
,
stackStream
);
RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID
;
if
(
isKey
)
{
if
(
!
handler
.
Key
(
stack_
.
template
Pop
<
typename
TargetEncoding
::
Ch
>
(
stackStream
.
length_
),
stackStream
.
length_
-
1
,
true
))
RAPIDJSON_PARSE_ERROR
(
kParseErrorTermination
,
s
.
Tell
());
}
else
{
if
(
!
handler
.
String
(
stack_
.
template
Pop
<
typename
TargetEncoding
::
Ch
>
(
stackStream
.
length_
),
stackStream
.
length_
-
1
,
true
))
RAPIDJSON_PARSE_ERROR
(
kParseErrorTermination
,
s
.
Tell
());
}
str
=
stack_
.
template
Pop
<
typename
TargetEncoding
::
Ch
>
(
stackStream
.
length_
);
len
=
stackStream
.
length_
-
1
;
}
}
template
<
unsigned
parseFlags
,
typename
InputStream
,
typename
Handler
>
void
ParseKey
(
InputStream
&
is
,
Handler
&
handler
)
{
return
ParseStringOrKey
<
parseFlags
,
true
>
(
is
,
handler
);
}
template
<
unsigned
parseFlags
,
typename
InputStream
,
typename
Handler
>
void
ParseString
(
InputStream
&
is
,
Handler
&
handler
)
{
return
ParseStringOrKey
<
parseFlags
,
false
>
(
is
,
handler
);
if
(
!
(
isKey
?
handler
.
Key
(
str
,
len
,
false
)
:
handler
.
String
(
str
,
len
,
false
)))
RAPIDJSON_PARSE_ERROR
(
kParseErrorTermination
,
s
.
Tell
());
}
// Parse string to an output is
...
...
@@ -1216,7 +1202,7 @@ private:
}
case
IterativeParsingMemberKeyState
:
Parse
Key
<
parseFlags
>
(
is
,
handler
);
Parse
String
<
parseFlags
>
(
is
,
handler
,
true
);
if
(
HasParseError
())
return
IterativeParsingErrorState
;
else
...
...
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