Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
2309bc22
Commit
2309bc22
authored
Sep 08, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix picking up inspect_value overloads
parent
7f414346
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
9 deletions
+20
-9
libcaf_core/caf/load_inspector_base.hpp
libcaf_core/caf/load_inspector_base.hpp
+9
-3
libcaf_core/test/config_value.cpp
libcaf_core/test/config_value.cpp
+11
-6
No files found.
libcaf_core/caf/load_inspector_base.hpp
View file @
2309bc22
...
@@ -57,9 +57,15 @@ public:
...
@@ -57,9 +57,15 @@ public:
}
}
template
<
class
Get
,
class
Set
>
template
<
class
Get
,
class
Set
>
bool
apply_value
(
Get
&&
get
,
Set
&&
)
{
bool
apply_value
(
Get
&&
get
,
Set
&&
set
)
{
auto
&&
x
=
get
();
using
field_type
=
std
::
decay_t
<
decltype
(
get
())
>
;
return
detail
::
load_value
(
dref
(),
x
);
auto
tmp
=
field_type
{};
if
(
apply_value
(
tmp
))
{
if
(
set
(
std
::
move
(
tmp
)))
return
true
;
this
->
set_error
(
sec
::
load_callback_failed
);
}
return
false
;
}
}
private:
private:
...
...
libcaf_core/test/config_value.cpp
View file @
2309bc22
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include "caf/config_value.hpp"
#include "caf/config_value.hpp"
#include "core-test.hpp"
#include "core-test.hpp"
#include "nasty.hpp"
#include <list>
#include <list>
#include <map>
#include <map>
...
@@ -475,9 +476,9 @@ bool inspect(Inspector& f, line& x) {
...
@@ -475,9 +476,9 @@ bool inspect(Inspector& f, line& x) {
}
// namespace
}
// namespace
CAF_TEST
(
config
values
pick
up
user
defined
inspect
overloads
)
{
CAF_TEST
(
config
values
pick
up
user
defined
inspect
overloads
)
{
config_value
x
;
CAF_MESSAGE
(
"users can fill dictionaries with field contents"
);
CAF_MESSAGE
(
"fill config value with the fields necessary for a 'line'"
);
{
{
config_value
x
;
auto
&
dict
=
x
.
as_dictionary
();
auto
&
dict
=
x
.
as_dictionary
();
put
(
dict
,
"p1.x"
,
1
);
put
(
dict
,
"p1.x"
,
1
);
put
(
dict
,
"p1.y"
,
2
);
put
(
dict
,
"p1.y"
,
2
);
...
@@ -485,14 +486,11 @@ CAF_TEST(config values pick up user defined inspect overloads) {
...
@@ -485,14 +486,11 @@ CAF_TEST(config values pick up user defined inspect overloads) {
put
(
dict
,
"p2.x"
,
10
);
put
(
dict
,
"p2.x"
,
10
);
put
(
dict
,
"p2.y"
,
20
);
put
(
dict
,
"p2.y"
,
20
);
put
(
dict
,
"p2.z"
,
30
);
put
(
dict
,
"p2.z"
,
30
);
}
CAF_MESSAGE
(
"read 'line' via get_if and verify the object"
);
{
auto
l
=
get_if
<
line
>
(
&
x
);
auto
l
=
get_if
<
line
>
(
&
x
);
if
(
CAF_CHECK_NOT_EQUAL
(
l
,
none
))
if
(
CAF_CHECK_NOT_EQUAL
(
l
,
none
))
CAF_CHECK_EQUAL
(
*
l
,
(
line
{{
1
,
2
,
3
},
{
10
,
20
,
30
}}));
CAF_CHECK_EQUAL
(
*
l
,
(
line
{{
1
,
2
,
3
},
{
10
,
20
,
30
}}));
}
}
CAF_MESSAGE
(
"
parse config value directly from string input
"
);
CAF_MESSAGE
(
"
users can pass objects as dictionaries on the command line
"
);
{
{
auto
val
=
config_value
::
parse
(
"{p1{x=1,y=2,z=3},p2{x=10,y=20,z=30}}"
);
auto
val
=
config_value
::
parse
(
"{p1{x=1,y=2,z=3},p2{x=10,y=20,z=30}}"
);
CAF_CHECK
(
val
);
CAF_CHECK
(
val
);
...
@@ -502,4 +500,11 @@ CAF_TEST(config values pick up user defined inspect overloads) {
...
@@ -502,4 +500,11 @@ CAF_TEST(config values pick up user defined inspect overloads) {
CAF_CHECK_EQUAL
(
*
l
,
(
line
{{
1
,
2
,
3
},
{
10
,
20
,
30
}}));
CAF_CHECK_EQUAL
(
*
l
,
(
line
{{
1
,
2
,
3
},
{
10
,
20
,
30
}}));
}
}
}
}
CAF_MESSAGE
(
"value readers appear as inspectors with human-readable format"
);
{
config_value
x
{
std
::
string
{
"saturday"
}};
auto
val
=
get_if
<
weekday
>
(
&
x
);
if
(
CAF_CHECK
(
val
))
CAF_CHECK_EQUAL
(
*
val
,
weekday
::
saturday
);
}
}
}
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