Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
common
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alexander Lapshin
common
Commits
641aae96
Commit
641aae96
authored
May 25, 2019
by
Alexander Lapshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
1e8ac4e0
Changes
2
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
603 additions
and
18 deletions
+603
-18
json_functions.h
json/json_functions.h
+14
-18
json_functions.h.orig
json/json_functions.h.orig
+589
-0
No files found.
json/json_functions.h
View file @
641aae96
...
@@ -19,7 +19,7 @@ typedef rapidjson::Document jsondoc;
...
@@ -19,7 +19,7 @@ typedef rapidjson::Document jsondoc;
inline
bool
extract_value
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
bool
exist
,
bool
*
loaded
,
jsonval
::
ConstMemberIterator
&
result
)
inline
bool
extract_value
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
bool
exist
,
bool
*
loaded
,
jsonval
::
ConstMemberIterator
&
result
)
{
{
const
jsonval
::
ConstMemberIterator
itr
=
parent
.
FindMember
(
key
.
c_str
());
jsonval
::
ConstMemberIterator
itr
=
parent
.
FindMember
(
key
.
c_str
());
if
(
itr
==
parent
.
MemberEnd
()
&&
exist
)
{
if
(
itr
==
parent
.
MemberEnd
()
&&
exist
)
{
throw
Exp
()
<<
"error: element '"
<<
key
<<
"' not found"
;
throw
Exp
()
<<
"error: element '"
<<
key
<<
"' not found"
;
...
@@ -57,7 +57,7 @@ inline bool extract_value(const jsonval& parent, const std::string& key, bool ex
...
@@ -57,7 +57,7 @@ inline bool extract_value(const jsonval& parent, const std::string& key, bool ex
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
std
::
vector
<
std
::
string
>&
vec
,
bool
exist
=
true
,
bool
*
loaded
=
0
)
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
std
::
vector
<
std
::
string
>&
vec
,
bool
exist
=
true
,
bool
*
loaded
=
0
)
{
{
jsonval
::
ConstMemberIterator
itr
;
jsonval
::
ConstMemberIterator
itr
;
if
(
!
extract_value
(
parent
,
key
,
exist
,
loaded
,
itr
))
{
if
(
!
extract_value
(
parent
,
key
,
exist
,
loaded
,
itr
))
{
return
false
;
return
false
;
}
}
...
@@ -267,10 +267,6 @@ template <typename T, typename T2> void loadjson(const jsonval& parent, std::map
...
@@ -267,10 +267,6 @@ template <typename T, typename T2> void loadjson(const jsonval& parent, std::map
}
}
}
}
if
(
!
ok
)
{
throw
Exp
()
<<
"json parse error "
<<
filename
<<
", code: "
<<
ok
.
Code
()
<<
", offset: "
<<
ok
.
Offset
();
}
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
double
&
value
,
bool
exist
=
true
,
bool
*
loaded
=
0
)
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
double
&
value
,
bool
exist
=
true
,
bool
*
loaded
=
0
)
{
{
jsonval
::
ConstMemberIterator
itr
;
jsonval
::
ConstMemberIterator
itr
;
...
@@ -528,7 +524,7 @@ static void flushjson(const jsondoc& outroot, const std::string& outputfile, boo
...
@@ -528,7 +524,7 @@ static void flushjson(const jsondoc& outroot, const std::string& outputfile, boo
if
(
pretty
)
{
if
(
pretty
)
{
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
StringBuffer
buffer
;
rapidjson
::
PrettyWriter
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
rapidjson
::
PrettyWriter
<
rapidjson
::
StringBuffer
>
writer
(
buffer
);
if
(
!
outroot
.
Accept
(
writer
))
{
if
(
!
outroot
.
Accept
(
writer
))
{
throw
Exp
()
<<
"json write fail"
;
throw
Exp
()
<<
"json write fail"
;
}
}
std
::
cout
<<
buffer
.
GetString
();
std
::
cout
<<
buffer
.
GetString
();
...
...
json/json_functions.h.orig
0 → 100644
View file @
641aae96
This diff is collapsed.
Click to expand it.
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