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
53ab97d2
Commit
53ab97d2
authored
Aug 26, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'topic/config-value'
parents
5d4f8645
23979bf3
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
23 deletions
+47
-23
libcaf_core/caf/config_value.hpp
libcaf_core/caf/config_value.hpp
+4
-0
libcaf_core/caf/detail/stringification_inspector.hpp
libcaf_core/caf/detail/stringification_inspector.hpp
+27
-13
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+6
-6
libcaf_core/src/config_value.cpp
libcaf_core/src/config_value.cpp
+6
-1
libcaf_core/src/stringification_inspector.cpp
libcaf_core/src/stringification_inspector.cpp
+1
-0
libcaf_core/test/message.cpp
libcaf_core/test/message.cpp
+1
-1
libcaf_core/test/sum_type.cpp
libcaf_core/test/sum_type.cpp
+2
-2
No files found.
libcaf_core/caf/config_value.hpp
View file @
53ab97d2
...
...
@@ -20,6 +20,7 @@
#include <chrono>
#include <cstdint>
#include <iosfwd>
#include <iterator>
#include <map>
#include <string>
...
...
@@ -452,6 +453,9 @@ inline bool operator!=(const config_value& x, const config_value& y) {
/// @relates config_value
std
::
string
to_string
(
const
config_value
&
x
);
/// @relates config_value
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
config_value
&
x
);
template
<
class
...
Ts
>
config_value
make_config_value_list
(
Ts
&&
...
xs
)
{
std
::
vector
<
config_value
>
lst
{
config_value
{
std
::
forward
<
Ts
>
(
xs
)}...};
...
...
libcaf_core/caf/detail/stringification_inspector.hpp
View file @
53ab97d2
...
...
@@ -24,24 +24,22 @@
#include <vector>
#include "caf/atom.hpp"
#include "caf/detail/append_hex.hpp"
#include "caf/detail/apply_args.hpp"
#include "caf/detail/int_list.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/error.hpp"
#include "caf/meta/annotation.hpp"
#include "caf/meta/hex_formatted.hpp"
#include "caf/meta/omittable.hpp"
#include "caf/meta/omittable_if_empty.hpp"
#include "caf/meta/omittable_if_none.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/none.hpp"
#include "caf/string_view.hpp"
#include "caf/timespan.hpp"
#include "caf/timestamp.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/meta/omittable.hpp"
#include "caf/meta/annotation.hpp"
#include "caf/meta/hex_formatted.hpp"
#include "caf/meta/omittable_if_none.hpp"
#include "caf/meta/omittable_if_empty.hpp"
#include "caf/detail/append_hex.hpp"
#include "caf/detail/apply_args.hpp"
#include "caf/detail/int_list.hpp"
#include "caf/detail/type_traits.hpp"
namespace
caf
{
namespace
detail
{
...
...
@@ -154,7 +152,23 @@ public:
}
template
<
class
T
>
enable_if_t
<
is_iterable
<
T
>::
value
enable_if_t
<
is_map_like
<
T
>::
value
&&
!
is_inspectable
<
stringification_inspector
,
T
>::
value
&&
!
std
::
is_convertible
<
T
,
string_view
>::
value
&&
!
has_to_string
<
T
>::
value
>
consume
(
T
&
xs
)
{
result_
+=
'{'
;
for
(
const
auto
&
kvp
:
xs
)
{
sep
();
consume
(
deconst
(
kvp
.
first
));
result_
+=
" = "
;
consume
(
deconst
(
kvp
.
second
));
}
result_
+=
'}'
;
}
template
<
class
T
>
enable_if_t
<
is_list_like
<
T
>::
value
&&
!
is_inspectable
<
stringification_inspector
,
T
>::
value
&&
!
std
::
is_convertible
<
T
,
string_view
>::
value
&&
!
has_to_string
<
T
>::
value
>
...
...
libcaf_core/caf/detail/type_traits.hpp
View file @
53ab97d2
...
...
@@ -53,11 +53,12 @@
class has_##name##_alias { \
private: \
template <class C> \
static std::true_type sfinae(
C* ptr, typename C::name* arg = nullptr);
\
static std::true_type sfinae(
typename C::name*);
\
\
static std::false_type sfinae(void* ptr); \
template <class> \
static std::false_type sfinae(...); \
\
using sfinae_type = decltype(sfinae
(static_cast<T*>(nullptr)));
\
using sfinae_type = decltype(sfinae
<T>(nullptr));
\
\
public: \
static constexpr bool value = sfinae_type::value; \
...
...
@@ -768,7 +769,7 @@ CAF_HAS_ALIAS_TRAIT(mapped_type);
// -- constexpr functions for use in enable_if & friends -----------------------
/// Checks whether T behaves like
a `std::map` or a `std::unordered_
map`.
/// Checks whether T behaves like
`std::
map`.
template
<
class
T
>
struct
is_map_like
{
static
constexpr
bool
value
=
is_iterable
<
T
>::
value
...
...
@@ -776,12 +777,11 @@ struct is_map_like {
&&
has_mapped_type_alias
<
T
>::
value
;
};
/// Checks whether T behaves like
a `std::vector` or a `std::lis
t`.
/// Checks whether T behaves like
`std::vector`, `std::list`, or `std::se
t`.
template
<
class
T
>
struct
is_list_like
{
static
constexpr
bool
value
=
is_iterable
<
T
>::
value
&&
has_value_type_alias
<
T
>::
value
&&
!
has_key_type_alias
<
T
>::
value
&&
!
has_mapped_type_alias
<
T
>::
value
;
};
...
...
libcaf_core/src/config_value.cpp
View file @
53ab97d2
...
...
@@ -19,6 +19,8 @@
#include "caf/config_value.hpp"
#include <ostream>
#include "caf/detail/ini_consumer.hpp"
#include "caf/detail/parser/read_ini.hpp"
#include "caf/detail/type_traits.hpp"
...
...
@@ -136,5 +138,8 @@ std::string to_string(const config_value& x) {
return
deep_to_string
(
x
.
get_data
());
}
}
// namespace caf
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
config_value
&
x
)
{
return
out
<<
to_string
(
x
);
}
}
// namespace caf
libcaf_core/src/stringification_inspector.cpp
View file @
53ab97d2
...
...
@@ -28,6 +28,7 @@ void stringification_inspector::sep() {
switch
(
result_
.
back
())
{
case
'('
:
case
'['
:
case
'{'
:
case
' '
:
// only at back if we've printed ", " before
break
;
default:
...
...
libcaf_core/test/message.cpp
View file @
53ab97d2
...
...
@@ -261,7 +261,7 @@ CAF_TEST(strings_to_string) {
CAF_TEST
(
maps_to_string
)
{
map
<
int
,
int
>
m1
{{
1
,
10
},
{
2
,
20
},
{
3
,
30
}};
auto
msg1
=
make_message
(
move
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
msg1
),
"(
[(1, 10), (2, 20), (3, 30)]
)"
);
CAF_CHECK_EQUAL
(
to_string
(
msg1
),
"(
{1 = 10, 2 = 20, 3 = 30}
)"
);
}
CAF_TEST
(
tuples_to_string
)
{
...
...
libcaf_core/test/sum_type.cpp
View file @
53ab97d2
...
...
@@ -233,7 +233,7 @@ CAF_TEST(unary visit) {
x
=
string
{
"hello world"
};
CAF_CHECK_EQUAL
(
visit
(
stringify
,
x
),
"hello world"
);
x
=
map_type
{{
1
,
1
},
{
2
,
2
}};
CAF_CHECK_EQUAL
(
visit
(
stringify
,
x
),
"
[(1, 1), (2, 2)]
"
);
CAF_CHECK_EQUAL
(
visit
(
stringify
,
x
),
"
{1 = 1, 2 = 2}
"
);
}
CAF_TEST
(
binary
visit
)
{
...
...
@@ -253,5 +253,5 @@ CAF_TEST(ternary visit) {
x
=
42
;
y
=
string
{
"foo"
};
z
=
map_type
{{
1
,
1
},
{
2
,
2
}};
CAF_CHECK_EQUAL
(
visit
(
stringify
,
x
,
y
,
z
),
"42, foo,
[(1, 1), (2, 2)]
"
);
CAF_CHECK_EQUAL
(
visit
(
stringify
,
x
,
y
,
z
),
"42, foo,
{1 = 1, 2 = 2}
"
);
}
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