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
6ad52ebb
Commit
6ad52ebb
authored
Aug 28, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add to_string and ostream overloads
parent
69bd2505
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
3 deletions
+31
-3
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/src/atom.cpp
libcaf_core/src/atom.cpp
+9
-1
No files found.
libcaf_core/caf/atom.hpp
View file @
6ad52ebb
...
@@ -18,8 +18,9 @@
...
@@ -18,8 +18,9 @@
#pragma once
#pragma once
#include <string>
#include <functional>
#include <functional>
#include <iosfwd>
#include <string>
#include <type_traits>
#include <type_traits>
#include "caf/detail/atom_val.hpp"
#include "caf/detail/atom_val.hpp"
...
@@ -35,7 +36,10 @@ enum class atom_value : uint64_t {
...
@@ -35,7 +36,10 @@ enum class atom_value : uint64_t {
};
};
/// @relates atom_value
/// @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
/// @relates atom_value
atom_value
to_lowercase
(
atom_value
x
);
atom_value
to_lowercase
(
atom_value
x
);
...
...
libcaf_core/caf/dictionary.hpp
View file @
6ad52ebb
...
@@ -21,8 +21,10 @@
...
@@ -21,8 +21,10 @@
#include <algorithm>
#include <algorithm>
#include <iterator>
#include <iterator>
#include <map>
#include <map>
#include <ostream>
#include <string>
#include <string>
#include "caf/deep_to_string.hpp"
#include "caf/string_view.hpp"
#include "caf/string_view.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -328,6 +330,14 @@ private:
...
@@ -328,6 +330,14 @@ private:
map_type
xs_
;
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 ----------------------------------------------------------------
// -- operators ----------------------------------------------------------------
// @relates dictionary
// @relates dictionary
...
@@ -366,4 +376,10 @@ bool operator>=(const dictionary<T>& xs, const dictionary<T>& ys) {
...
@@ -366,4 +376,10 @@ bool operator>=(const dictionary<T>& xs, const dictionary<T>& ys) {
return
xs
.
container
()
>=
ys
.
container
();
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
}
// namespace caf
libcaf_core/src/atom.cpp
View file @
6ad52ebb
...
@@ -20,6 +20,7 @@
...
@@ -20,6 +20,7 @@
#include <array>
#include <array>
#include <cstring>
#include <cstring>
#include <ostream>
#include "caf/string_view.hpp"
#include "caf/string_view.hpp"
...
@@ -65,12 +66,19 @@ atom_value atom_from_string(string_view x) {
...
@@ -65,12 +66,19 @@ atom_value atom_from_string(string_view x) {
return
static_cast
<
atom_value
>
(
detail
::
atom_val
(
buf
.
data
()));
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
;
atom_value_buf
str
;
auto
len
=
decode
(
str
,
x
);
auto
len
=
decode
(
str
,
x
);
return
std
::
string
(
str
.
begin
(),
str
.
begin
()
+
len
);
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
)
{
int
compare
(
atom_value
x
,
atom_value
y
)
{
return
memcmp
(
&
x
,
&
y
,
sizeof
(
atom_value
));
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