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
e70494bc
Commit
e70494bc
authored
Sep 04, 2014
by
Kosta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix for `Reader::ParseString()` implementation plus some minor code cleanups and additions
parent
4a71dc6d
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
12 deletions
+14
-12
capitalize.cpp
example/capitalize/capitalize.cpp
+1
-2
simplereader.cpp
example/simplereader/simplereader.cpp
+5
-2
prettywriter.h
include/rapidjson/prettywriter.h
+1
-0
reader.h
include/rapidjson/reader.h
+6
-8
writer.h
include/rapidjson/writer.h
+1
-0
No files found.
example/capitalize/capitalize.cpp
View file @
e70494bc
...
...
@@ -14,7 +14,7 @@
using
namespace
rapidjson
;
template
<
typename
OutputHandler
>
struct
CapitalizeFilter
{
struct
CapitalizeFilter
:
public
BaseReaderHandler
<
UTF8
<>
,
OutputHandler
>
{
CapitalizeFilter
(
OutputHandler
&
out
)
:
out_
(
out
),
buffer_
()
{}
bool
Null
()
{
return
out_
.
Null
();
}
...
...
@@ -31,7 +31,6 @@ struct CapitalizeFilter {
return
out_
.
String
(
&
buffer_
.
front
(),
length
,
true
);
// true = output handler need to copy the string
}
bool
StartObject
()
{
return
out_
.
StartObject
();
}
bool
Key
(
const
char
*
str
,
SizeType
length
,
bool
copy
)
{
return
String
(
str
,
length
,
copy
);
}
bool
EndObject
(
SizeType
memberCount
)
{
return
out_
.
EndObject
(
memberCount
);
}
bool
StartArray
()
{
return
out_
.
StartArray
();
}
bool
EndArray
(
SizeType
elementCount
)
{
return
out_
.
EndArray
(
elementCount
);
}
...
...
example/simplereader/simplereader.cpp
View file @
e70494bc
...
...
@@ -4,7 +4,7 @@
using
namespace
rapidjson
;
using
namespace
std
;
struct
MyHandler
{
struct
MyHandler
:
public
BaseReaderHandler
<
UTF8
<>
,
MyHandler
>
{
bool
Null
()
{
cout
<<
"Null()"
<<
endl
;
return
true
;
}
bool
Bool
(
bool
b
)
{
cout
<<
"Bool("
<<
boolalpha
<<
b
<<
")"
<<
endl
;
return
true
;
}
bool
Int
(
int
i
)
{
cout
<<
"Int("
<<
i
<<
")"
<<
endl
;
return
true
;
}
...
...
@@ -17,7 +17,10 @@ struct MyHandler {
return
true
;
}
bool
StartObject
()
{
cout
<<
"StartObject()"
<<
endl
;
return
true
;
}
bool
Key
(
const
char
*
str
,
SizeType
length
,
bool
copy
)
{
return
String
(
str
,
length
,
copy
);
}
bool
Key
(
const
char
*
str
,
SizeType
length
,
bool
copy
)
{
cout
<<
"Key("
<<
str
<<
", "
<<
length
<<
", "
<<
boolalpha
<<
copy
<<
")"
<<
endl
;
return
true
;
}
bool
EndObject
(
SizeType
memberCount
)
{
cout
<<
"EndObject("
<<
memberCount
<<
")"
<<
endl
;
return
true
;
}
bool
StartArray
()
{
cout
<<
"StartArray()"
<<
endl
;
return
true
;
}
bool
EndArray
(
SizeType
elementCount
)
{
cout
<<
"EndArray("
<<
elementCount
<<
")"
<<
endl
;
return
true
;
}
...
...
include/rapidjson/prettywriter.h
View file @
e70494bc
...
...
@@ -137,6 +137,7 @@ public:
//! Simpler but slower overload.
bool
String
(
const
Ch
*
str
)
{
return
String
(
str
,
internal
::
StrLen
(
str
));
}
bool
Key
(
const
Ch
*
str
)
{
return
Key
(
str
,
internal
::
StrLen
(
str
));
}
//@}
protected
:
...
...
include/rapidjson/reader.h
View file @
e70494bc
...
...
@@ -623,27 +623,25 @@ private:
internal
::
StreamLocalCopy
<
InputStream
>
copy
(
is
);
InputStream
&
s
(
copy
.
s
);
const
typename
TargetEncoding
::
Ch
*
str
=
NULL
;
SizeType
len
=
0
;
bool
success
=
false
;
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
);
str
=
(
const
typename
TargetEncoding
::
Ch
*
)
head
;
len
=
SizeType
(
length
);
const
typename
TargetEncoding
::
Ch
*
const
str
=
(
const
typename
TargetEncoding
::
Ch
*
)
head
;
success
=
(
isKey
?
handler
.
Key
(
str
,
SizeType
(
length
),
false
)
:
handler
.
String
(
str
,
SizeType
(
length
),
false
)
);
}
else
{
StackStream
stackStream
(
stack_
);
ParseStringToStream
<
parseFlags
,
SourceEncoding
,
TargetEncoding
>
(
s
,
stackStream
);
RAPIDJSON_PARSE_ERROR_EARLY_RETURN_VOID
;
str
=
stack_
.
template
Pop
<
typename
TargetEncoding
::
Ch
>
(
stackStream
.
length_
);
len
=
stackStream
.
length_
-
1
;
const
typename
TargetEncoding
::
Ch
*
const
str
=
stack_
.
template
Pop
<
typename
TargetEncoding
::
Ch
>
(
stackStream
.
length_
);
success
=
(
isKey
?
handler
.
Key
(
str
,
stackStream
.
length_
-
1
,
false
)
:
handler
.
String
(
str
,
stackStream
.
length_
-
1
,
false
))
;
}
if
(
!
(
isKey
?
handler
.
Key
(
str
,
len
,
false
)
:
handler
.
String
(
str
,
len
,
false
))
)
if
(
!
success
)
RAPIDJSON_PARSE_ERROR
(
kParseErrorTermination
,
s
.
Tell
());
}
...
...
include/rapidjson/writer.h
View file @
e70494bc
...
...
@@ -167,6 +167,7 @@ public:
//! Simpler but slower overload.
bool
String
(
const
Ch
*
str
)
{
return
String
(
str
,
internal
::
StrLen
(
str
));
}
bool
Key
(
const
Ch
*
str
)
{
return
Key
(
str
,
internal
::
StrLen
(
str
));
}
//@}
...
...
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