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
d0188462
Commit
d0188462
authored
Dec 05, 2018
by
seky
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removed std::string and receiving const Value in printIt
parent
c9060b4a
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
13 deletions
+9
-13
sortkeys.cpp
example/sortkeys/sortkeys.cpp
+9
-13
No files found.
example/sortkeys/sortkeys.cpp
View file @
d0188462
#define RAPIDJSON_HAS_STDSTRING 1
#include "rapidjson/document.h"
#include "rapidjson/filewritestream.h"
#include <rapidjson/prettywriter.h>
#include <rapidjson/stringbuffer.h>
#include <algorithm>
#include <iostream>
...
...
@@ -9,26 +8,23 @@
using
namespace
rapidjson
;
using
namespace
std
;
void
printIt
(
Document
&
doc
)
void
printIt
(
const
Value
&
doc
)
{
string
output
;
StringBuffer
buffer
;
PrettyWriter
<
StringBuffer
>
writer
(
buffer
);
char
writeBuffer
[
65536
]
;
FileWriteStream
os
(
stdout
,
writeBuffer
,
sizeof
(
writeBuffer
))
;
PrettyWriter
<
FileWriteStream
>
writer
(
os
);
doc
.
Accept
(
writer
);
output
=
buffer
.
GetString
();
cout
<<
output
<<
endl
;
cout
<<
endl
;
}
struct
Value
NameComparator
struct
NameComparator
{
bool
operator
()(
const
GenericMember
<
UTF8
<>
,
MemoryPoolAllocator
<>>
&
lhs
,
const
GenericMember
<
UTF8
<>
,
MemoryPoolAllocator
<>>
&
rhs
)
const
{
string
lhss
=
string
(
lhs
.
name
.
GetString
());
string
rhss
=
string
(
rhs
.
name
.
GetString
());
return
lhss
<
rhss
;
return
(
strcmp
(
lhs
.
name
.
GetString
(),
rhs
.
name
.
GetString
())
<
0
);
}
};
...
...
@@ -55,7 +51,7 @@ int main()
}
**/
std
::
sort
(
d
.
MemberBegin
(),
d
.
MemberEnd
(),
Value
NameComparator
());
std
::
sort
(
d
.
MemberBegin
(),
d
.
MemberEnd
(),
NameComparator
());
printIt
(
d
);
/**
...
...
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