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
f4c56936
Commit
f4c56936
authored
Jan 05, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate review feedback
parent
09696f0a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
36 additions
and
127 deletions
+36
-127
libcaf_core/caf/config_value.hpp
libcaf_core/caf/config_value.hpp
+2
-2
libcaf_core/caf/detail/parse.hpp
libcaf_core/caf/detail/parse.hpp
+0
-98
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+2
-2
libcaf_core/test/config_option.cpp
libcaf_core/test/config_option.cpp
+8
-1
libcaf_test/caf/test/unit_test.hpp
libcaf_test/caf/test/unit_test.hpp
+24
-24
No files found.
libcaf_core/caf/config_value.hpp
View file @
f4c56936
...
...
@@ -474,11 +474,11 @@ expected<T> get_as(const config_value& x, inspector_access_type::list) {
if
(
auto
wrapped_values
=
x
.
to_list
())
{
using
value_type
=
typename
T
::
value_type
;
T
result
;
if
constexpr
(
detail
::
has_reserve_
t
<
T
>
)
if
constexpr
(
detail
::
has_reserve_
v
<
T
>
)
result
.
reserve
(
wrapped_values
->
size
());
for
(
const
auto
&
wrapped_value
:
*
wrapped_values
)
if
(
auto
maybe_value
=
get_as
<
value_type
>
(
wrapped_value
))
{
if
constexpr
(
detail
::
has_emplace_back_
t
<
T
>
)
if
constexpr
(
detail
::
has_emplace_back_
v
<
T
>
)
result
.
emplace_back
(
std
::
move
(
*
maybe_value
));
else
result
.
insert
(
result
.
end
(),
std
::
move
(
*
maybe_value
));
...
...
libcaf_core/caf/detail/parse.hpp
View file @
f4c56936
...
...
@@ -213,104 +213,6 @@ void parse(string_parser_state& ps,
x
=
value_type
{
since_epoch
};
}
/*
// -- container types ----------------------------------------------------------
CAF_CORE_EXPORT void parse_element(string_parser_state& ps, std::string& x,
const char* char_blacklist);
template <class T>
enable_if_t<!is_pair<T>::value>
parse_element(string_parser_state& ps, T& x, const char*);
template <class First, class Second, size_t N>
void parse_element(string_parser_state& ps, std::pair<First, Second>& kvp,
const char (&char_blacklist)[N]);
struct require_opening_char_t {};
constexpr auto require_opening_char = require_opening_char_t{};
struct allow_omitting_opening_char_t {};
constexpr auto allow_omitting_opening_char = allow_omitting_opening_char_t{};
template <class T, class Policy = allow_omitting_opening_char_t>
enable_if_tt<is_iterable<T>>
parse(string_parser_state& ps, T& xs, Policy = {}) {
using value_type = deconst_kvp_t<typename T::value_type>;
static constexpr auto is_map_type = is_pair<value_type>::value;
static constexpr auto opening_char = is_map_type ? '{' : '[';
static constexpr auto closing_char = is_map_type ? '}' : ']';
auto out = std::inserter(xs, xs.end());
// List/map using [] or {} notation.
if (ps.consume(opening_char)) {
char char_blacklist[] = {closing_char, ',', '\0'};
do {
if (ps.consume(closing_char)) {
ps.skip_whitespaces();
ps.code = ps.at_end() ? pec::success : pec::trailing_character;
return;
}
value_type tmp;
parse_element(ps, tmp, char_blacklist);
if (ps.code > pec::trailing_character)
return;
*out++ = std::move(tmp);
} while (ps.consume(','));
if (ps.consume(closing_char)) {
ps.skip_whitespaces();
ps.code = ps.at_end() ? pec::success : pec::trailing_character;
} else {
ps.code = pec::unexpected_character;
}
return;
}
if constexpr (std::is_same<Policy, require_opening_char_t>::value) {
ps.code = pec::unexpected_character;
} else {
// An empty string simply results in an empty list/map.
if (ps.at_end())
return;
// List/map without [] or {}.
do {
char char_blacklist[] = {',', '\0'};
value_type tmp;
parse_element(ps, tmp, char_blacklist);
if (ps.code > pec::trailing_character)
return;
*out++ = std::move(tmp);
} while (ps.consume(','));
ps.code = ps.at_end() ? pec::success : pec::trailing_character;
}
}
template <class T>
enable_if_t<!is_pair<T>::value>
parse_element(string_parser_state& ps, T& x, const char*) {
parse(ps, x);
}
template <class First, class Second, size_t N>
void parse_element(string_parser_state& ps, std::pair<First, Second>& kvp,
const char (&char_blacklist)[N]) {
static_assert(N > 0, "empty array");
// TODO: consider to guard the blacklist computation with
// `if constexpr (is_same_v<First, string>)` when switching to C++17.
char key_blacklist[N + 1];
if (N > 1)
memcpy(key_blacklist, char_blacklist, N - 1);
key_blacklist[N - 1] = '=';
key_blacklist[N] = '\0';
parse_element(ps, kvp.first, key_blacklist);
if (ps.code > pec::trailing_character)
return;
if (!ps.consume('=')) {
ps.code = pec::unexpected_character;
return;
}
parse_element(ps, kvp.second, char_blacklist);
}
*/
// -- convenience functions ----------------------------------------------------
CAF_CORE_EXPORT
...
...
libcaf_core/caf/detail/type_traits.hpp
View file @
f4c56936
...
...
@@ -701,7 +701,7 @@ public:
};
template
<
class
T
>
constexpr
bool
has_reserve_
t
=
has_reserve
<
T
>::
value
;
constexpr
bool
has_reserve_
v
=
has_reserve
<
T
>::
value
;
template
<
class
T
>
struct
has_emplace_back
{
...
...
@@ -721,7 +721,7 @@ public:
};
template
<
class
T
>
constexpr
bool
has_emplace_back_
t
=
has_emplace_back
<
T
>::
value
;
constexpr
bool
has_emplace_back_
v
=
has_emplace_back
<
T
>::
value
;
template
<
class
T
>
class
has_call_error_handler
{
...
...
libcaf_core/test/config_option.cpp
View file @
f4c56936
...
...
@@ -70,7 +70,7 @@ struct state {
.
add
(
my_app_request
,
"request,r"
,
""
)
.
add
(
my_app_request_pair
,
"request-pair,R"
,
""
);
config_option_adder
{
options
,
"sys"
}
.
add
<
std
::
string
>
(
"
path,p
"
,
""
)
.
add
<
std
::
string
>
(
"
query,q
"
,
""
)
.
add
<
int8_t
>
(
"threads,tTd"
,
""
);
}
...
...
@@ -162,6 +162,13 @@ struct fixture {
""
,
R"_(my { app { request-pair { first { a = 1, b = 2 },
second { a = 3, b = 4 } } } })_"
);
add_test
({},
"sys{threads=2}"
,
R"_(sys { threads = 2 })_"
);
add_test
({
"-t"
,
"1"
},
"sys{threads=2}"
,
R"_(sys { threads = 1 })_"
);
add_test
({
"-T"
,
"1"
},
"sys{threads=2}"
,
R"_(sys { threads = 1 })_"
);
add_test
({
"-d"
,
"1"
},
"sys{threads=2}"
,
R"_(sys { threads = 1 })_"
);
add_test
({
"--sys.threads=1"
},
"sys{threads=2}"
,
R"_(sys { threads = 1 })_"
);
add_test
({
"--sys.query=foo"
},
""
,
R"_(sys { query = "foo" })_"
);
add_test
({
"-q"
,
"
\"
a
\"
in b"
},
""
,
R"_(sys { query = "\"a\" in b" })_"
);
}
};
...
...
libcaf_test/caf/test/unit_test.hpp
View file @
f4c56936
...
...
@@ -551,13 +551,13 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
} while (false)
#define CAF_CHECK(...) \
([](bool expr_result) {
\
[](bool expr_result) {
\
return ::caf::test::detail::check_un(expr_result, __FILE__, __LINE__, \
#__VA_ARGS__); \
}
)
(static_cast<bool>(__VA_ARGS__))
}(static_cast<bool>(__VA_ARGS__))
#define CAF_CHECK_FUNC(func, x_expr, y_expr) \
([](auto&& x_val, auto&& y_val) {
\
[](auto&& x_val, auto&& y_val) {
\
func comparator; \
auto caf_check_res \
= ::caf::test::detail::check(::caf::test::engine::current_test(), \
...
...
@@ -567,7 +567,7 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
::caf::test::engine::last_check_file(__FILE__); \
::caf::test::engine::last_check_line(__LINE__); \
return caf_check_res; \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_FAIL(...) \
do { \
...
...
@@ -643,80 +643,80 @@ using caf_test_case_auto_fixture = caf::test::dummy_fixture;
// -- CAF_CHECK* predicate family ----------------------------------------------
#define CAF_CHECK_EQUAL(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin(x_val == y_val, __FILE__, __LINE__, \
#x_expr " == " #y_expr, \
caf::deep_to_string(x_val), \
caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_NOT_EQUAL(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin(x_val != y_val, __FILE__, __LINE__, \
#x_expr " != " #y_expr, \
caf::deep_to_string(x_val), \
caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_LESS(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin(x_val < y_val, __FILE__, __LINE__, \
#x_expr " < " #y_expr, \
caf::deep_to_string(x_val), \
caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_NOT_LESS(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin( \
!(x_val < y_val), __FILE__, __LINE__, "not " #x_expr " < " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_LESS_OR_EQUAL(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin(x_val <= y_val, __FILE__, __LINE__, \
#x_expr " <= " #y_expr, \
caf::deep_to_string(x_val), \
caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_NOT_LESS_OR_EQUAL(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin( \
!(x_val <= y_val), __FILE__, __LINE__, "not " #x_expr " <= " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_GREATER(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin(x_val > y_val, __FILE__, __LINE__, \
#x_expr " > " #y_expr, \
caf::deep_to_string(x_val), \
caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_NOT_GREATER(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin( \
!(x_val > y_val), __FILE__, __LINE__, "not " #x_expr " > " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_GREATER_OR_EQUAL(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin(x_val >= y_val, __FILE__, __LINE__, \
#x_expr " >= " #y_expr, \
caf::deep_to_string(x_val), \
caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
#define CAF_CHECK_NOT_GREATER_OR_EQUAL(x_expr, y_expr) \
([](const auto& x_val, const auto& y_val) {
\
[](const auto& x_val, const auto& y_val) {
\
return ::caf::test::detail::check_bin( \
!(x_val >= y_val), __FILE__, __LINE__, "not " #x_expr " >= " #y_expr, \
caf::deep_to_string(x_val), caf::deep_to_string(y_val)); \
}
)
(x_expr, y_expr)
}(x_expr, y_expr)
// -- CAF_CHECK* predicate family ----------------------------------------------
...
...
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