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
8a71425e
Commit
8a71425e
authored
Feb 26, 2021
by
Alexander Lapshin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
+ svalue<int>
parent
5c511f3e
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
38 additions
and
0 deletions
+38
-0
json_functions.h
json/json_functions.h
+38
-0
No files found.
json/json_functions.h
View file @
8a71425e
...
...
@@ -852,3 +852,41 @@ static bool loadjson(const jsonval& parent, const std::string& key, svalue<doubl
return
true
;
}
static
bool
loadjson
(
const
jsonval
&
parent
,
const
std
::
string
&
key
,
svalue
<
int
>&
value
,
const
bool
exist
=
true
)
{
jsonval
::
ConstMemberIterator
itr
;
bool
*
loaded
=
nullptr
;
if
(
!
extract_value
(
parent
,
key
,
exist
,
loaded
,
itr
))
{
return
false
;
}
const
jsonval
&
a
=
itr
->
value
;
if
(
a
.
IsInt
())
{
value
=
a
.
GetInt
();
}
else
if
(
a
.
IsString
())
{
const
std
::
string
str
=
a
.
GetString
();
if
(
str
.
empty
()
&&
!
exist
)
{
if
(
loaded
)
{
*
loaded
=
false
;
}
return
false
;
}
int
val
;
if
(
!
Converter
::
ToNumber
(
str
,
val
))
{
throw
(
Exp
()
<<
"bad value format '"
<<
str
<<
"'"
<<
" in container '"
);
}
value
=
val
;
}
else
{
throw
(
Exp
()
<<
"element '"
<<
key
<<
"'"
<<
" has unexpected format '"
);
}
return
true
;
}
\ No newline at end of file
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