Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
GitCode
Cataclysm DDA
提交
710e3ea6
C
Cataclysm DDA
项目概览
GitCode
/
Cataclysm DDA
通知
6
Star
6383
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
C
Cataclysm DDA
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
710e3ea6
编写于
12月 23, 2021
作者:
A
akrieger
提交者:
Andrew Krieger
1月 14, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove a bunch of unnecessary JsonObject copying
上级
380414c9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
57 addition
and
57 deletion
+57
-57
src/assign.h
src/assign.h
+57
-57
未找到文件。
src/assign.h
浏览文件 @
710e3ea6
...
...
@@ -58,8 +58,7 @@ bool assign( const JsonObject &jo, const std::string &name, T &val, bool strict
double
scalar
;
// Object via which to report errors which differs for proportional/relative values
JsonObject
err
=
jo
;
err
.
allow_omitted_members
();
const
JsonObject
*
err
=
&
jo
;
JsonObject
relative
=
jo
.
get_object
(
"relative"
);
relative
.
allow_omitted_members
();
JsonObject
proportional
=
jo
.
get_object
(
"proportional"
);
...
...
@@ -68,14 +67,14 @@ bool assign( const JsonObject &jo, const std::string &name, T &val, bool strict
// Do not require strict parsing for relative and proportional values as rules
// such as +10% are well-formed independent of whether they affect base value
if
(
relative
.
read
(
name
,
out
)
)
{
err
=
relative
;
err
=
&
relative
;
strict
=
false
;
out
+=
val
;
}
else
if
(
proportional
.
read
(
name
,
scalar
)
)
{
err
=
proportional
;
err
=
&
proportional
;
if
(
scalar
<=
0
||
scalar
==
1
)
{
err
.
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
err
->
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
}
strict
=
false
;
out
=
val
*
scalar
;
...
...
@@ -85,11 +84,12 @@ bool assign( const JsonObject &jo, const std::string &name, T &val, bool strict
}
if
(
out
<
lo
||
out
>
hi
)
{
err
.
throw_error
(
"value outside supported range"
,
name
);
err
->
throw_error
(
"value outside supported range"
,
name
);
}
if
(
strict
&&
out
==
val
)
{
report_strict_violation
(
err
,
"cannot assign explicit value the same as default or inherited value"
,
report_strict_violation
(
*
err
,
"cannot assign explicit value the same as default or inherited value"
,
name
);
}
...
...
@@ -265,8 +265,7 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::volume
units
::
volume
out
;
// Object via which to report errors which differs for proportional/relative values
JsonObject
err
=
jo
;
err
.
allow_omitted_members
();
const
JsonObject
*
err
=
&
jo
;
JsonObject
relative
=
jo
.
get_object
(
"relative"
);
relative
.
allow_omitted_members
();
JsonObject
proportional
=
jo
.
get_object
(
"proportional"
);
...
...
@@ -276,18 +275,18 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::volume
// such as +10% are well-formed independent of whether they affect base value
if
(
relative
.
has_member
(
name
)
)
{
units
::
volume
tmp
;
err
=
relative
;
if
(
!
parse
(
err
,
tmp
)
)
{
err
.
throw_error
(
"invalid relative value specified"
,
name
);
err
=
&
relative
;
if
(
!
parse
(
*
err
,
tmp
)
)
{
err
->
throw_error
(
"invalid relative value specified"
,
name
);
}
strict
=
false
;
out
=
val
+
tmp
;
}
else
if
(
proportional
.
has_member
(
name
)
)
{
double
scalar
;
err
=
proportional
;
if
(
!
err
.
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
.
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
err
=
&
proportional
;
if
(
!
err
->
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
->
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
}
strict
=
false
;
out
=
val
*
scalar
;
...
...
@@ -297,11 +296,12 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::volume
}
if
(
out
<
lo
||
out
>
hi
)
{
err
.
throw_error
(
"value outside supported range"
,
name
);
err
->
throw_error
(
"value outside supported range"
,
name
);
}
if
(
strict
&&
out
==
val
)
{
report_strict_violation
(
err
,
"cannot assign explicit value the same as default or inherited value"
,
report_strict_violation
(
*
err
,
"cannot assign explicit value the same as default or inherited value"
,
name
);
}
...
...
@@ -331,8 +331,7 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::mass &
units
::
mass
out
;
// Object via which to report errors which differs for proportional/relative values
JsonObject
err
=
jo
;
err
.
allow_omitted_members
();
const
JsonObject
*
err
=
&
jo
;
JsonObject
relative
=
jo
.
get_object
(
"relative"
);
relative
.
allow_omitted_members
();
JsonObject
proportional
=
jo
.
get_object
(
"proportional"
);
...
...
@@ -342,18 +341,18 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::mass &
// such as +10% are well-formed independent of whether they affect base value
if
(
relative
.
has_member
(
name
)
)
{
units
::
mass
tmp
;
err
=
relative
;
if
(
!
parse
(
err
,
tmp
)
)
{
err
.
throw_error
(
"invalid relative value specified"
,
name
);
err
=
&
relative
;
if
(
!
parse
(
*
err
,
tmp
)
)
{
err
->
throw_error
(
"invalid relative value specified"
,
name
);
}
strict
=
false
;
out
=
val
+
tmp
;
}
else
if
(
proportional
.
has_member
(
name
)
)
{
double
scalar
;
err
=
proportional
;
if
(
!
err
.
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
.
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
err
=
&
proportional
;
if
(
!
err
->
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
->
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
}
strict
=
false
;
out
=
val
*
scalar
;
...
...
@@ -363,11 +362,12 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::mass &
}
if
(
out
<
lo
||
out
>
hi
)
{
err
.
throw_error
(
"value outside supported range"
,
name
);
err
->
throw_error
(
"value outside supported range"
,
name
);
}
if
(
strict
&&
out
==
val
)
{
report_strict_violation
(
err
,
"cannot assign explicit value the same as default or inherited value"
,
report_strict_violation
(
*
err
,
"cannot assign explicit value the same as default or inherited value"
,
name
);
}
...
...
@@ -397,8 +397,7 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::length
units
::
length
out
;
// Object via which to report errors which differs for proportional/relative values
JsonObject
err
=
jo
;
err
.
allow_omitted_members
();
const
JsonObject
*
err
=
&
jo
;
JsonObject
relative
=
jo
.
get_object
(
"relative"
);
relative
.
allow_omitted_members
();
JsonObject
proportional
=
jo
.
get_object
(
"proportional"
);
...
...
@@ -408,18 +407,18 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::length
// such as +10% are well-formed independent of whether they affect base value
if
(
relative
.
has_member
(
name
)
)
{
units
::
length
tmp
;
err
=
relative
;
if
(
!
parse
(
err
,
tmp
)
)
{
err
.
throw_error
(
"invalid relative value specified"
,
name
);
err
=
&
relative
;
if
(
!
parse
(
*
err
,
tmp
)
)
{
err
->
throw_error
(
"invalid relative value specified"
,
name
);
}
strict
=
false
;
out
=
val
+
tmp
;
}
else
if
(
proportional
.
has_member
(
name
)
)
{
double
scalar
;
err
=
proportional
;
if
(
!
err
.
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
.
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
err
=
&
proportional
;
if
(
!
err
->
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
->
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
}
strict
=
false
;
out
=
val
*
scalar
;
...
...
@@ -429,11 +428,12 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::length
}
if
(
out
<
lo
||
out
>
hi
)
{
err
.
throw_error
(
"value outside supported range"
,
name
);
err
->
throw_error
(
"value outside supported range"
,
name
);
}
if
(
strict
&&
out
==
val
)
{
report_strict_violation
(
err
,
"cannot assign explicit value the same as default or inherited value"
,
report_strict_violation
(
*
err
,
"cannot assign explicit value the same as default or inherited value"
,
name
);
}
...
...
@@ -463,8 +463,7 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::money
units
::
money
out
;
// Object via which to report errors which differs for proportional/relative values
JsonObject
err
=
jo
;
err
.
allow_omitted_members
();
const
JsonObject
*
err
=
&
jo
;
JsonObject
relative
=
jo
.
get_object
(
"relative"
);
relative
.
allow_omitted_members
();
JsonObject
proportional
=
jo
.
get_object
(
"proportional"
);
...
...
@@ -474,18 +473,18 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::money
// such as +10% are well-formed independent of whether they affect base value
if
(
relative
.
has_member
(
name
)
)
{
units
::
money
tmp
;
err
=
relative
;
if
(
!
parse
(
err
,
tmp
)
)
{
err
.
throw_error
(
"invalid relative value specified"
,
name
);
err
=
&
relative
;
if
(
!
parse
(
*
err
,
tmp
)
)
{
err
->
throw_error
(
"invalid relative value specified"
,
name
);
}
strict
=
false
;
out
=
val
+
tmp
;
}
else
if
(
proportional
.
has_member
(
name
)
)
{
double
scalar
;
err
=
proportional
;
if
(
!
err
.
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
.
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
err
=
&
proportional
;
if
(
!
err
->
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
->
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
}
strict
=
false
;
out
=
val
*
scalar
;
...
...
@@ -495,11 +494,12 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::money
}
if
(
out
<
lo
||
out
>
hi
)
{
err
.
throw_error
(
"value outside supported range"
,
name
);
err
->
throw_error
(
"value outside supported range"
,
name
);
}
if
(
strict
&&
out
==
val
)
{
report_strict_violation
(
err
,
"cannot assign explicit value the same as default or inherited value"
,
report_strict_violation
(
*
err
,
"cannot assign explicit value the same as default or inherited value"
,
name
);
}
...
...
@@ -534,8 +534,7 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::energy
units
::
energy
out
;
// Object via which to report errors which differs for proportional/relative values
JsonObject
err
=
jo
;
err
.
allow_omitted_members
();
const
JsonObject
*
err
=
&
jo
;
JsonObject
relative
=
jo
.
get_object
(
"relative"
);
relative
.
allow_omitted_members
();
JsonObject
proportional
=
jo
.
get_object
(
"proportional"
);
...
...
@@ -545,18 +544,18 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::energy
// such as +10% are well-formed independent of whether they affect base value
if
(
relative
.
has_member
(
name
)
)
{
units
::
energy
tmp
;
err
=
relative
;
if
(
!
parse
(
err
,
tmp
)
)
{
err
.
throw_error
(
"invalid relative value specified"
,
name
);
err
=
&
relative
;
if
(
!
parse
(
*
err
,
tmp
)
)
{
err
->
throw_error
(
"invalid relative value specified"
,
name
);
}
strict
=
false
;
out
=
val
+
tmp
;
}
else
if
(
proportional
.
has_member
(
name
)
)
{
double
scalar
;
err
=
proportional
;
if
(
!
err
.
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
.
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
err
=
&
proportional
;
if
(
!
err
->
read
(
name
,
scalar
)
||
scalar
<=
0
||
scalar
==
1
)
{
err
->
throw_error
(
"multiplier must be a positive number other than 1"
,
name
);
}
strict
=
false
;
out
=
val
*
scalar
;
...
...
@@ -566,11 +565,12 @@ inline bool assign( const JsonObject &jo, const std::string &name, units::energy
}
if
(
out
<
lo
||
out
>
hi
)
{
err
.
throw_error
(
"value outside supported range"
,
name
);
err
->
throw_error
(
"value outside supported range"
,
name
);
}
if
(
strict
&&
out
==
val
)
{
report_strict_violation
(
err
,
"cannot assign explicit value the same as default or inherited value"
,
report_strict_violation
(
*
err
,
"cannot assign explicit value the same as default or inherited value"
,
name
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录