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
4f728d38
Commit
4f728d38
authored
Sep 08, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert default behavior of deep_to_string
parent
ff4c3f92
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
73 additions
and
26 deletions
+73
-26
libcaf_core/caf/config_value.hpp
libcaf_core/caf/config_value.hpp
+41
-1
libcaf_core/caf/detail/stringification_inspector.hpp
libcaf_core/caf/detail/stringification_inspector.hpp
+3
-1
libcaf_core/src/config_value.cpp
libcaf_core/src/config_value.cpp
+0
-1
libcaf_core/src/detail/stringification_inspector.cpp
libcaf_core/src/detail/stringification_inspector.cpp
+10
-3
libcaf_core/src/logger.cpp
libcaf_core/src/logger.cpp
+0
-1
libcaf_core/test/actor_profiler.cpp
libcaf_core/test/actor_profiler.cpp
+10
-10
libcaf_core/test/cow_tuple.cpp
libcaf_core/test/cow_tuple.cpp
+1
-1
libcaf_core/test/message.cpp
libcaf_core/test/message.cpp
+5
-5
libcaf_core/test/variant.cpp
libcaf_core/test/variant.cpp
+3
-3
No files found.
libcaf_core/caf/config_value.hpp
View file @
4f728d38
...
@@ -274,11 +274,51 @@ struct config_value_access;
...
@@ -274,11 +274,51 @@ struct config_value_access;
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
bool
,
"boolean"
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
bool
,
"boolean"
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
double
,
"real64"
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
double
,
"real64"
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
timespan
,
"timespan"
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
uri
,
"uri"
);
CAF_DEFAULT_CONFIG_VALUE_ACCESS
(
uri
,
"uri"
);
#undef CAF_DEFAULT_CONFIG_VALUE_ACCESS
#undef CAF_DEFAULT_CONFIG_VALUE_ACCESS
template
<
>
struct
CAF_CORE_EXPORT
config_value_access
<
timespan
>
{
static
std
::
string
type_name
()
{
return
"timespan"
;
}
static
bool
is
(
const
config_value
&
x
)
{
return
static_cast
<
bool
>
(
get_if
(
&
x
));
}
static
optional
<
timespan
>
get_if
(
const
config_value
*
x
)
{
auto
data_ptr
=
std
::
addressof
(
x
->
get_data
());
if
(
auto
res
=
caf
::
get_if
<
timespan
>
(
data_ptr
))
return
static_cast
<
timespan
>
(
*
res
);
if
(
auto
str
=
caf
::
get_if
<
std
::
string
>
(
data_ptr
))
{
string_view
sv
{
*
str
};
timespan
result
;
string_parser_state
ps
{
sv
.
begin
(),
sv
.
end
()};
detail
::
parse
(
ps
,
result
);
if
(
ps
.
code
==
pec
::
success
)
return
result
;
}
return
none
;
}
static
timespan
get
(
const
config_value
&
x
)
{
auto
result
=
get_if
(
&
x
);
CAF_ASSERT
(
result
);
return
*
result
;
}
static
timespan
convert
(
timespan
x
)
{
return
x
;
}
template
<
class
Nested
>
static
void
parse_cli
(
string_parser_state
&
ps
,
timespan
&
x
,
Nested
)
{
detail
::
parse
(
ps
,
x
);
}
};
template
<
>
template
<
>
struct
CAF_CORE_EXPORT
config_value_access
<
float
>
{
struct
CAF_CORE_EXPORT
config_value_access
<
float
>
{
static
std
::
string
type_name
()
{
static
std
::
string
type_name
()
{
...
...
libcaf_core/caf/detail/stringification_inspector.hpp
View file @
4f728d38
...
@@ -53,7 +53,7 @@ public:
...
@@ -53,7 +53,7 @@ public:
return
true
;
return
true
;
}
}
bool
always_quote_strings
=
fals
e
;
bool
always_quote_strings
=
tru
e
;
// -- serializer interface ---------------------------------------------------
// -- serializer interface ---------------------------------------------------
...
@@ -236,6 +236,8 @@ private:
...
@@ -236,6 +236,8 @@ private:
void
sep
();
void
sep
();
std
::
string
&
result_
;
std
::
string
&
result_
;
bool
in_string_object_
=
false
;
};
};
}
// namespace caf::detail
}
// namespace caf::detail
libcaf_core/src/config_value.cpp
View file @
4f728d38
...
@@ -146,7 +146,6 @@ struct to_string_visitor {
...
@@ -146,7 +146,6 @@ struct to_string_visitor {
template
<
class
T
>
template
<
class
T
>
void
operator
()(
const
T
&
x
)
{
void
operator
()(
const
T
&
x
)
{
detail
::
stringification_inspector
f
{
str
};
detail
::
stringification_inspector
f
{
str
};
f
.
always_quote_strings
=
true
;
f
.
value
(
x
);
f
.
value
(
x
);
}
}
...
...
libcaf_core/src/detail/stringification_inspector.cpp
View file @
4f728d38
...
@@ -51,13 +51,20 @@ namespace caf::detail {
...
@@ -51,13 +51,20 @@ namespace caf::detail {
bool
stringification_inspector
::
begin_object
(
string_view
name
)
{
bool
stringification_inspector
::
begin_object
(
string_view
name
)
{
sep
();
sep
();
result_
.
insert
(
result_
.
end
(),
name
.
begin
(),
name
.
end
());
if
(
name
!=
"std::string"
)
{
result_
+=
'('
;
result_
.
insert
(
result_
.
end
(),
name
.
begin
(),
name
.
end
());
result_
+=
'('
;
}
else
{
in_string_object_
=
true
;
}
return
ok
;
return
ok
;
}
}
bool
stringification_inspector
::
end_object
()
{
bool
stringification_inspector
::
end_object
()
{
result_
+=
')'
;
if
(
!
in_string_object_
)
result_
+=
')'
;
else
in_string_object_
=
false
;
return
ok
;
return
ok
;
}
}
...
...
libcaf_core/src/logger.cpp
View file @
4f728d38
...
@@ -602,7 +602,6 @@ void logger::log_first_line() {
...
@@ -602,7 +602,6 @@ void logger::log_first_line() {
msg
+=
to_string
(
system_
.
node
());
msg
+=
to_string
(
system_
.
node
());
msg
+=
", excluded-components = "
;
msg
+=
", excluded-components = "
;
detail
::
stringification_inspector
f
{
msg
};
detail
::
stringification_inspector
f
{
msg
};
f
.
always_quote_strings
=
true
;
detail
::
save_value
(
f
,
filter
);
detail
::
save_value
(
f
,
filter
);
return
msg
;
return
msg
;
};
};
...
...
libcaf_core/test/actor_profiler.cpp
View file @
4f728d38
...
@@ -167,16 +167,16 @@ CAF_TEST(profilers record asynchronous messaging) {
...
@@ -167,16 +167,16 @@ CAF_TEST(profilers record asynchronous messaging) {
sys
.
spawn
(
foo
);
sys
.
spawn
(
foo
);
run
();
run
();
CAF_CHECK_EQUAL
(
string_list
({
CAF_CHECK_EQUAL
(
string_list
({
"new: foo
"
,
R"__(new: foo)__
"
,
"new: bar, parent: foo
"
,
R"__(new: bar, parent: foo)__
"
,
"foo sends: message(std::string(
\"
hello bar
\"
))
"
,
R"__(foo sends: message("hello bar"))__
"
,
"bar got: message(std::string(
\"
hello bar
\"
))
"
,
R"__(bar got: message("hello bar"))__
"
,
"bar sends: message(std::string(
\"
hello foo
\"
))
"
,
R"__(bar sends: message("hello foo"))__
"
,
"bar consumed the message
"
,
R"__(bar consumed the message)__
"
,
"foo got: message(std::string(
\"
hello foo
\"
))
"
,
R"__(foo got: message("hello foo"))__
"
,
"delete: bar
"
,
R"__(delete: bar)__
"
,
"foo consumed the message
"
,
R"__(foo consumed the message)__
"
,
"delete: foo
"
,
R"__(delete: foo)__
"
,
}),
}),
rec
.
log
);
rec
.
log
);
}
}
...
...
libcaf_core/test/cow_tuple.cpp
View file @
4f728d38
...
@@ -103,7 +103,7 @@ CAF_TEST(unsharing) {
...
@@ -103,7 +103,7 @@ CAF_TEST(unsharing) {
CAF_TEST
(
to_string
)
{
CAF_TEST
(
to_string
)
{
auto
x
=
make_cow_tuple
(
1
,
string
{
"abc"
});
auto
x
=
make_cow_tuple
(
1
,
string
{
"abc"
});
CAF_CHECK_EQUAL
(
deep_to_string
(
x
),
"[1, abc]
"
);
CAF_CHECK_EQUAL
(
deep_to_string
(
x
),
R"__([1, "abc"])__
"
);
}
}
CAF_TEST_FIXTURE_SCOPE
(
cow_tuple_tests
,
test_coordinator_fixture
<>
)
CAF_TEST_FIXTURE_SCOPE
(
cow_tuple_tests
,
test_coordinator_fixture
<>
)
...
...
libcaf_core/test/message.cpp
View file @
4f728d38
...
@@ -91,17 +91,17 @@ CAF_TEST(to_string converts messages to strings) {
...
@@ -91,17 +91,17 @@ CAF_TEST(to_string converts messages to strings) {
using
svec
=
vector
<
string
>
;
using
svec
=
vector
<
string
>
;
CAF_CHECK_EQUAL
(
msg_as_string
(),
"message()"
);
CAF_CHECK_EQUAL
(
msg_as_string
(),
"message()"
);
CAF_CHECK_EQUAL
(
msg_as_string
(
"hello"
,
"world"
),
CAF_CHECK_EQUAL
(
msg_as_string
(
"hello"
,
"world"
),
R"__(message(
std::string(hello), std::string(world)
))__"
);
R"__(message(
"hello", "world"
))__"
);
CAF_CHECK_EQUAL
(
CAF_CHECK_EQUAL
(
msg_as_string
(
svec
{
"one"
,
"two"
,
"three"
}),
msg_as_string
(
svec
{
"one"
,
"two"
,
"three"
}),
R"__(message(std::vector<std::string>([
one, two, three
])))__"
);
R"__(message(std::vector<std::string>([
"one", "two", "three"
])))__"
);
CAF_CHECK_EQUAL
(
CAF_CHECK_EQUAL
(
msg_as_string
(
svec
{
"one"
,
"two"
},
"three"
,
"four"
,
msg_as_string
(
svec
{
"one"
,
"two"
},
"three"
,
"four"
,
svec
{
"five"
,
"six"
,
"seven"
}),
svec
{
"five"
,
"six"
,
"seven"
}),
"message(std::vector<std::string>([one, two]), std::string(three),
"
R"__(message(std::vector<std::string>(["one", "two"]), "three", "four", )__
"
"std::string(four), std::vector<std::string>([five, six, seven]))
"
);
R"__(std::vector<std::string>(["five", "six", "seven"])))__
"
);
CAF_CHECK_EQUAL
(
msg_as_string
(
R"(this is a "test")"
),
CAF_CHECK_EQUAL
(
msg_as_string
(
R"(this is a "test")"
),
"message(std::string(
\"
this is a
\\\"
test
\\\"\"
))
"
);
R"__(message("this is a \"test\""))__
"
);
CAF_CHECK_EQUAL
(
msg_as_string
(
make_tuple
(
1
,
2
,
3
),
4
,
5
),
CAF_CHECK_EQUAL
(
msg_as_string
(
make_tuple
(
1
,
2
,
3
),
4
,
5
),
"message(std::tuple<int32_t, int32_t, int32_t>([1, 2, 3]), "
"message(std::tuple<int32_t, int32_t, int32_t>([1, 2, 3]), "
"int32_t(4), int32_t(5))"
);
"int32_t(4), int32_t(5))"
);
...
...
libcaf_core/test/variant.cpp
View file @
4f728d38
...
@@ -141,9 +141,9 @@ CAF_TEST(n_ary_visit) {
...
@@ -141,9 +141,9 @@ CAF_TEST(n_ary_visit) {
variant
<
float
,
int
,
std
::
string
>
b
{
"bar"
s
};
variant
<
float
,
int
,
std
::
string
>
b
{
"bar"
s
};
variant
<
int
,
std
::
string
,
double
>
c
{
123
};
variant
<
int
,
std
::
string
,
double
>
c
{
123
};
test_visitor
f
;
test_visitor
f
;
CAF_CHECK_EQUAL
(
visit
(
f
,
a
),
"[42]
"
);
CAF_CHECK_EQUAL
(
visit
(
f
,
a
),
R"__([42])__
"
);
CAF_CHECK_EQUAL
(
visit
(
f
,
a
,
b
),
"[42, bar]
"
);
CAF_CHECK_EQUAL
(
visit
(
f
,
a
,
b
),
R"__([42, "bar"])__
"
);
CAF_CHECK_EQUAL
(
visit
(
f
,
a
,
b
,
c
),
"[42, bar, 123]
"
);
CAF_CHECK_EQUAL
(
visit
(
f
,
a
,
b
,
c
),
R"__([42, "bar", 123])__
"
);
}
}
CAF_TEST
(
get_if
)
{
CAF_TEST
(
get_if
)
{
...
...
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