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
00713907
Commit
00713907
authored
Feb 20, 2020
by
Alexander Lapshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
.
parent
b7f35dc1
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
33 additions
and
0 deletions
+33
-0
json_functions.h
json/json_functions.h
+33
-0
No files found.
json/json_functions.h
View file @
00713907
...
...
@@ -364,6 +364,39 @@ static bool loadjson(const jsonval& parent, const std::string& key, int& value,
return
true
;
}
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
size_t
&
value
,
const
bool
exist
=
true
,
bool
*
loaded
=
nullptr
)
{
jsonval
::
ConstMemberIterator
itr
;
if
(
!
extract_value
(
parent
,
key
,
exist
,
loaded
,
itr
))
{
return
false
;
}
const
jsonval
&
a
=
itr
->
value
;
if
(
a
.
IsNumber
())
{
value
=
a
.
GetInt
();
}
else
if
(
a
.
IsString
())
{
std
::
string
str
=
a
.
GetString
();
if
(
str
.
empty
()
&&
!
exist
)
{
if
(
loaded
)
{
*
loaded
=
false
;
}
return
false
;
}
if
(
!
Converter
::
ToNumber
(
str
,
value
))
{
throw
(
Exp
()
<<
"bad value format '"
<<
str
<<
"'"
<<
" in container '"
);
}
}
else
{
throw
(
Exp
()
<<
"element '"
<<
key
<<
"'"
<<
" has unexpected format '"
);
}
return
true
;
}
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
bool
&
value
,
const
bool
exist
=
true
,
bool
*
loaded
=
nullptr
)
{
jsonval
::
ConstMemberIterator
itr
;
...
...
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