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
83484106
Commit
83484106
authored
Aug 27, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Mimic interface of boost::join
parent
d5f43de6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
14 deletions
+38
-14
libcaf_core/caf/string_algorithms.hpp
libcaf_core/caf/string_algorithms.hpp
+30
-8
libcaf_core/src/either.cpp
libcaf_core/src/either.cpp
+3
-2
libcaf_core/src/replies_to.cpp
libcaf_core/src/replies_to.cpp
+5
-4
No files found.
libcaf_core/caf/string_algorithms.hpp
View file @
83484106
...
...
@@ -46,22 +46,44 @@ void split(std::vector<std::string>& result,
bool
keep_empties
=
true
);
template
<
class
Iterator
>
std
::
string
join
(
Iterator
begin
,
Iterator
end
,
const
std
::
string
&
glue
)
{
class
iterator_range
{
public:
using
iterator
=
Iterator
;
iterator_range
(
iterator
first
,
iterator
last
)
:
begin_
(
first
),
end_
(
last
)
{
// nop
}
iterator
begin
()
const
{
return
begin_
;
}
iterator
end
()
const
{
return
end_
;
}
private:
iterator
begin_
;
iterator
end_
;
};
template
<
class
Container
>
std
::
string
join
(
const
Container
&
c
,
const
std
::
string
&
glue
)
{
auto
begin
=
c
.
begin
();
auto
end
=
c
.
end
();
bool
first
=
true
;
std
::
ostringstream
oss
;
for
(
;
begin
!=
end
;
++
begin
)
{
if
(
first
)
first
=
false
;
else
oss
<<
glue
;
if
(
first
)
first
=
false
;
else
oss
<<
glue
;
oss
<<
*
begin
;
}
return
oss
.
str
();
}
template
<
class
Container
>
std
::
string
join
(
const
Container
&
c
,
const
std
::
string
&
glue
)
{
return
join
(
c
.
begin
(),
c
.
end
(),
glue
);
}
// end of recursion
inline
void
splice
(
std
::
string
&
,
const
std
::
string
&
)
{
// nop
...
...
libcaf_core/src/either.cpp
View file @
83484106
...
...
@@ -28,12 +28,13 @@ std::string either_or_else_type_name(size_t lefts_size,
const
std
::
string
*
lefts
,
size_t
rights_size
,
const
std
::
string
*
rights
)
{
using
irange
=
iterator_range
<
const
std
::
string
*>
;
std
::
string
glue
=
","
;
std
::
string
result
;
result
=
"caf::either<"
;
result
+=
join
(
lefts
,
lefts
+
lefts_size
,
glue
);
result
+=
join
(
irange
{
lefts
,
lefts
+
lefts_size
}
,
glue
);
result
+=
">::or_else<"
;
result
+=
join
(
rights
,
rights
+
rights_size
,
glue
);
result
+=
join
(
irange
{
rights
,
rights
+
rights_size
}
,
glue
);
result
+=
">"
;
return
result
;
}
...
...
libcaf_core/src/replies_to.cpp
View file @
83484106
...
...
@@ -30,21 +30,22 @@ std::string replies_to_type_name(size_t input_size,
const
std
::
string
*
output_opt1
,
size_t
output_opt2_size
,
const
std
::
string
*
output_opt2
)
{
using
irange
=
iterator_range
<
const
std
::
string
*>
;
std
::
string
glue
=
","
;
std
::
string
result
;
// 'void' is not an announced type, hence we check whether uniform_typeid
// did return a valid pointer to identify 'void' (this has the
// possibility of false positives, but those will be catched anyways)
result
=
"caf::replies_to<"
;
result
+=
join
(
i
nput
,
input
+
input_size
,
glue
);
result
+=
join
(
i
range
{
input
,
input
+
input_size
}
,
glue
);
if
(
output_opt2_size
==
0
)
{
result
+=
">::with<"
;
result
+=
join
(
output_opt1
,
output_opt1
+
output_opt1_size
,
glue
);
result
+=
join
(
irange
{
output_opt1
,
output_opt1
+
output_opt1_size
}
,
glue
);
}
else
{
result
+=
">::with_either<"
;
result
+=
join
(
output_opt1
,
output_opt1
+
output_opt1_size
,
glue
);
result
+=
join
(
irange
{
output_opt1
,
output_opt1
+
output_opt1_size
}
,
glue
);
result
+=
">::or_else<"
;
result
+=
join
(
output_opt2
,
output_opt2
+
output_opt2_size
,
glue
);
result
+=
join
(
irange
{
output_opt2
,
output_opt2
+
output_opt2_size
}
,
glue
);
}
result
+=
">"
;
return
result
;
...
...
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