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
1f6e55da
Unverified
Commit
1f6e55da
authored
Oct 05, 2019
by
Dominik Charousset
Committed by
GitHub
Oct 05, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #923
Add/improve to_string and ostream overloads
parents
6a8b05f1
578c940f
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
47 additions
and
7 deletions
+47
-7
libcaf_core/caf/atom.hpp
libcaf_core/caf/atom.hpp
+6
-2
libcaf_core/caf/dictionary.hpp
libcaf_core/caf/dictionary.hpp
+16
-0
libcaf_core/caf/node_id.hpp
libcaf_core/caf/node_id.hpp
+6
-0
libcaf_core/src/actor_control_block.cpp
libcaf_core/src/actor_control_block.cpp
+10
-4
libcaf_core/src/atom.cpp
libcaf_core/src/atom.cpp
+9
-1
No files found.
libcaf_core/caf/atom.hpp
View file @
1f6e55da
...
...
@@ -18,8 +18,9 @@
#pragma once
#include <string>
#include <functional>
#include <iosfwd>
#include <string>
#include <type_traits>
#include "caf/detail/atom_val.hpp"
...
...
@@ -35,7 +36,10 @@ enum class atom_value : uint64_t {
};
/// @relates atom_value
std
::
string
to_string
(
const
atom_value
&
what
);
std
::
string
to_string
(
atom_value
x
);
/// @relates atom_value
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
atom_value
x
);
/// @relates atom_value
atom_value
to_lowercase
(
atom_value
x
);
...
...
libcaf_core/caf/dictionary.hpp
View file @
1f6e55da
...
...
@@ -21,8 +21,10 @@
#include <algorithm>
#include <iterator>
#include <map>
#include <ostream>
#include <string>
#include "caf/deep_to_string.hpp"
#include "caf/string_view.hpp"
namespace
caf
{
...
...
@@ -328,6 +330,14 @@ private:
map_type
xs_
;
};
// -- free functions -----------------------------------------------------------
// @relates dictionary
template
<
class
T
>
std
::
string
to_string
(
const
dictionary
<
T
>&
xs
)
{
return
deep_to_string
(
xs
.
container
());
}
// -- operators ----------------------------------------------------------------
// @relates dictionary
...
...
@@ -366,4 +376,10 @@ bool operator>=(const dictionary<T>& xs, const dictionary<T>& ys) {
return
xs
.
container
()
>=
ys
.
container
();
}
// @relates dictionary
template
<
class
T
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
dictionary
<
T
>&
xs
)
{
return
out
<<
to_string
(
xs
);
}
}
// namespace caf
libcaf_core/caf/node_id.hpp
View file @
1f6e55da
...
...
@@ -225,6 +225,12 @@ private:
intrusive_ptr
<
data
>
data_
;
};
/// Returns whether `x` contains an URI.
/// @relates node_id
inline
bool
wraps_uri
(
const
node_id
&
x
)
noexcept
{
return
x
&&
x
->
implementation_id
()
==
node_id
::
uri_data
::
class_id
;
}
/// @relates node_id
inline
bool
operator
==
(
const
node_id
&
x
,
const
node_id
&
y
)
noexcept
{
return
x
.
compare
(
y
)
==
0
;
...
...
libcaf_core/src/actor_control_block.cpp
View file @
1f6e55da
...
...
@@ -114,11 +114,17 @@ namespace {
void
append_to_string_impl
(
std
::
string
&
x
,
const
actor_control_block
*
y
)
{
if
(
y
!=
nullptr
)
{
if
(
wraps_uri
(
y
->
nid
))
{
append_to_string
(
x
,
y
->
nid
);
x
+=
"/id/"
;
x
+=
std
::
to_string
(
y
->
aid
);
}
else
{
x
+=
std
::
to_string
(
y
->
aid
);
x
+=
'@'
;
append_to_string
(
x
,
y
->
nid
);
}
}
else
{
x
+=
"
0@invalid-node
"
;
x
+=
"
null:pointer
"
;
}
}
...
...
libcaf_core/src/atom.cpp
View file @
1f6e55da
...
...
@@ -20,6 +20,7 @@
#include <array>
#include <cstring>
#include <ostream>
#include "caf/string_view.hpp"
...
...
@@ -65,12 +66,19 @@ atom_value atom_from_string(string_view x) {
return
static_cast
<
atom_value
>
(
detail
::
atom_val
(
buf
.
data
()));
}
std
::
string
to_string
(
const
atom_value
&
x
)
{
std
::
string
to_string
(
atom_value
x
)
{
atom_value_buf
str
;
auto
len
=
decode
(
str
,
x
);
return
std
::
string
(
str
.
begin
(),
str
.
begin
()
+
len
);
}
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
atom_value
x
)
{
atom_value_buf
str
;
auto
len
=
decode
(
str
,
x
);
out
.
write
(
str
.
data
(),
len
);
return
out
;
}
int
compare
(
atom_value
x
,
atom_value
y
)
{
return
memcmp
(
&
x
,
&
y
,
sizeof
(
atom_value
));
}
...
...
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