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
23e09f28
Commit
23e09f28
authored
Feb 19, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename `message::{filter => extract}`
parent
85a2898c
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
45 deletions
+45
-45
examples/qtsupport/qt_group_chat.cpp
examples/qtsupport/qt_group_chat.cpp
+1
-1
examples/remote_actors/distributed_calculator.cpp
examples/remote_actors/distributed_calculator.cpp
+1
-1
examples/remote_actors/group_chat.cpp
examples/remote_actors/group_chat.cpp
+1
-1
libcaf_core/caf/message.hpp
libcaf_core/caf/message.hpp
+10
-10
libcaf_core/caf/message_builder.hpp
libcaf_core/caf/message_builder.hpp
+6
-6
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+6
-6
unit_testing/test_message.cpp
unit_testing/test_message.cpp
+20
-20
No files found.
examples/qtsupport/qt_group_chat.cpp
View file @
23e09f28
...
@@ -30,7 +30,7 @@ using namespace caf;
...
@@ -30,7 +30,7 @@ using namespace caf;
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
string
name
;
string
name
;
string
group_id
;
string
group_id
;
auto
res
=
message_builder
(
argv
+
1
,
argv
+
argc
).
filter_cli
({
auto
res
=
message_builder
(
argv
+
1
,
argv
+
argc
).
extract_opts
({
{
"name,n"
,
"set chat name"
,
name
},
{
"name,n"
,
"set chat name"
,
name
},
{
"group,g"
,
"join chat group"
,
group_id
}
{
"group,g"
,
"join chat group"
,
group_id
}
});
});
...
...
examples/remote_actors/distributed_calculator.cpp
View file @
23e09f28
...
@@ -184,7 +184,7 @@ void client_repl(const string& host, uint16_t port) {
...
@@ -184,7 +184,7 @@ void client_repl(const string& host, uint16_t port) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
uint16_t
port
=
0
;
uint16_t
port
=
0
;
string
host
=
"localhost"
;
string
host
=
"localhost"
;
auto
res
=
message_builder
(
argv
+
1
,
argv
+
argc
).
filter_cli
({
auto
res
=
message_builder
(
argv
+
1
,
argv
+
argc
).
extract_opts
({
{
"port,p"
,
"set port (either to publish at or to connect to)"
,
port
},
{
"port,p"
,
"set port (either to publish at or to connect to)"
,
port
},
{
"host,H"
,
"set host (client mode only, default: localhost)"
,
host
},
{
"host,H"
,
"set host (client mode only, default: localhost)"
,
host
},
{
"server,s"
,
"run in server mode"
},
{
"server,s"
,
"run in server mode"
},
...
...
examples/remote_actors/group_chat.cpp
View file @
23e09f28
...
@@ -68,7 +68,7 @@ void client(event_based_actor* self, const string& name) {
...
@@ -68,7 +68,7 @@ void client(event_based_actor* self, const string& name) {
int
main
(
int
argc
,
char
**
argv
)
{
int
main
(
int
argc
,
char
**
argv
)
{
string
name
;
string
name
;
string
group_id
;
string
group_id
;
auto
res
=
message_builder
(
argv
+
1
,
argv
+
argc
).
filter_cli
({
auto
res
=
message_builder
(
argv
+
1
,
argv
+
argc
).
extract_opts
({
{
"name,n"
,
"set name"
,
name
},
{
"name,n"
,
"set name"
,
name
},
{
"group,g"
,
"join group"
,
group_id
}
{
"group,g"
,
"join group"
,
group_id
}
});
});
...
...
libcaf_core/caf/message.hpp
View file @
23e09f28
...
@@ -169,8 +169,8 @@ class message {
...
@@ -169,8 +169,8 @@ class message {
*
*
* ~~~
* ~~~
* auto msg = make_message(1, 2.f, 3.f, 4);
* auto msg = make_message(1, 2.f, 3.f, 4);
* //
filter
float and integer pairs
* //
extract
float and integer pairs
* auto msg2 = msg.
filter
({
* auto msg2 = msg.
extract
({
* [](float, float) { },
* [](float, float) { },
* [](int, int) { }
* [](int, int) { }
* });
* });
...
@@ -187,10 +187,10 @@ class message {
...
@@ -187,10 +187,10 @@ class message {
* - Slice 7: `(4)`, no match
* - Slice 7: `(4)`, no match
*
*
* Slice 7 is `(4)`, i.e., does not contain the first element, because the
* Slice 7 is `(4)`, i.e., does not contain the first element, because the
* match on slice 6 occurred at index position 1. The function `
filter
`
* match on slice 6 occurred at index position 1. The function `
extract
`
* iterates a message only once, from left to right.
* iterates a message only once, from left to right.
*/
*/
message
filter
(
message_handler
handler
)
const
;
message
extract
(
message_handler
handler
)
const
;
/**
/**
* Stores the name of a command line option ("<long name>[,<short name>]")
* Stores the name of a command line option ("<long name>[,<short name>]")
...
@@ -246,14 +246,14 @@ class message {
...
@@ -246,14 +246,14 @@ class message {
struct
cli_res
;
struct
cli_res
;
/**
/**
* A simplistic interface for using `
filter
` to parse command line options.
* A simplistic interface for using `
extract
` to parse command line options.
* Usage example:
* Usage example:
*
*
* ~~~
* ~~~
* int main(int argc, char** argv) {
* int main(int argc, char** argv) {
* uint16_t port;
* uint16_t port;
* string host = "localhost";
* string host = "localhost";
* auto res = message_builder(argv + 1, argv + argc).
filter_cli
({
* auto res = message_builder(argv + 1, argv + argc).
extract_opts
({
* {"port,p", "set port", port},
* {"port,p", "set port", port},
* {"host,H", "set host (default: localhost)", host},
* {"host,H", "set host (default: localhost)", host},
* {"verbose,v", "enable verbose mode"}
* {"verbose,v", "enable verbose mode"}
...
@@ -264,7 +264,7 @@ class message {
...
@@ -264,7 +264,7 @@ class message {
* return 0;
* return 0;
* }
* }
* if (!res.remainder.empty()) {
* if (!res.remainder.empty()) {
* // ...
filter
did not consume all CLI arguments ...
* // ...
extract
did not consume all CLI arguments ...
* }
* }
* if (res.opts.count("verbose") > 0) {
* if (res.opts.count("verbose") > 0) {
* // ... enable verbose mode ...
* // ... enable verbose mode ...
...
@@ -273,7 +273,7 @@ class message {
...
@@ -273,7 +273,7 @@ class message {
* }
* }
* ~~~
* ~~~
*/
*/
cli_res
filter_cli
(
std
::
vector
<
cli_arg
>
args
)
const
;
cli_res
extract_opts
(
std
::
vector
<
cli_arg
>
args
)
const
;
/**
/**
* Queries whether the element at position `p` is of type `T`.
* Queries whether the element at position `p` is of type `T`.
...
@@ -373,13 +373,13 @@ class message {
...
@@ -373,13 +373,13 @@ class message {
return
match_element
<
T
>
(
P
)
&&
match_elements_impl
(
next_p
,
next_list
);
return
match_element
<
T
>
(
P
)
&&
match_elements_impl
(
next_p
,
next_list
);
}
}
message
filter
_impl
(
size_t
start
,
message_handler
handler
)
const
;
message
extract
_impl
(
size_t
start
,
message_handler
handler
)
const
;
data_ptr
m_vals
;
data_ptr
m_vals
;
};
};
/**
/**
* Stores the result of `message::
filter_cli
`.
* Stores the result of `message::
extract_opts
`.
*/
*/
struct
message
::
cli_res
{
struct
message
::
cli_res
{
/**
/**
...
...
libcaf_core/caf/message_builder.hpp
View file @
23e09f28
...
@@ -93,17 +93,17 @@ class message_builder {
...
@@ -93,17 +93,17 @@ class message_builder {
message
move_to_message
();
message
move_to_message
();
/**
/**
* @copydoc message::
filter
* @copydoc message::
extract
*/
*/
inline
message
filter
(
message_handler
f
)
const
{
inline
message
extract
(
message_handler
f
)
const
{
return
to_message
().
filter
(
f
);
return
to_message
().
extract
(
f
);
}
}
/**
/**
* @copydoc message::
filter_cli
* @copydoc message::
extract_opts
*/
*/
inline
message
::
cli_res
filter_cli
(
std
::
vector
<
message
::
cli_arg
>
args
)
const
{
inline
message
::
cli_res
extract_opts
(
std
::
vector
<
message
::
cli_arg
>
args
)
const
{
return
to_message
().
filter_cli
(
std
::
move
(
args
));
return
to_message
().
extract_opts
(
std
::
move
(
args
));
}
}
/**
/**
...
...
libcaf_core/src/message.cpp
View file @
23e09f28
...
@@ -116,7 +116,7 @@ optional<message> message::apply(message_handler handler) {
...
@@ -116,7 +116,7 @@ optional<message> message::apply(message_handler handler) {
return
handler
(
*
this
);
return
handler
(
*
this
);
}
}
message
message
::
filter
_impl
(
size_t
start
,
message_handler
handler
)
const
{
message
message
::
extract
_impl
(
size_t
start
,
message_handler
handler
)
const
{
auto
s
=
size
();
auto
s
=
size
();
for
(
size_t
i
=
start
;
i
<
s
;
++
i
)
{
for
(
size_t
i
=
start
;
i
<
s
;
++
i
)
{
for
(
size_t
n
=
(
s
-
i
)
;
n
>
0
;
--
n
)
{
for
(
size_t
n
=
(
s
-
i
)
;
n
>
0
;
--
n
)
{
...
@@ -132,18 +132,18 @@ message message::filter_impl(size_t start, message_handler handler) const {
...
@@ -132,18 +132,18 @@ message message::filter_impl(size_t start, message_handler handler) const {
}
}
message
next
{
detail
::
decorated_tuple
::
create
(
m_vals
,
message
next
{
detail
::
decorated_tuple
::
create
(
m_vals
,
std
::
move
(
mapping
))};
std
::
move
(
mapping
))};
return
next
.
filter
_impl
(
i
,
handler
);
return
next
.
extract
_impl
(
i
,
handler
);
}
}
}
}
}
}
return
*
this
;
return
*
this
;
}
}
message
message
::
filter
(
message_handler
handler
)
const
{
message
message
::
extract
(
message_handler
handler
)
const
{
return
filter
_impl
(
0
,
handler
);
return
extract
_impl
(
0
,
handler
);
}
}
message
::
cli_res
message
::
filter_cli
(
std
::
vector
<
cli_arg
>
cliargs
)
const
{
message
::
cli_res
message
::
extract_opts
(
std
::
vector
<
cli_arg
>
cliargs
)
const
{
std
::
set
<
std
::
string
>
opts
;
std
::
set
<
std
::
string
>
opts
;
cli_arg
dummy
{
"help,h"
,
""
};
cli_arg
dummy
{
"help,h"
,
""
};
std
::
map
<
std
::
string
,
cli_arg
*>
shorts
;
std
::
map
<
std
::
string
,
cli_arg
*>
shorts
;
...
@@ -171,7 +171,7 @@ message::cli_res message::filter_cli(std::vector<cli_arg> cliargs) const {
...
@@ -171,7 +171,7 @@ message::cli_res message::filter_cli(std::vector<cli_arg> cliargs) const {
opts
.
insert
(
ptr
->
name
.
substr
(
0
,
separator
));
opts
.
insert
(
ptr
->
name
.
substr
(
0
,
separator
));
}
}
};
};
auto
res
=
filter
({
auto
res
=
extract
({
[
&
](
const
std
::
string
&
arg
)
->
optional
<
skip_message_t
>
{
[
&
](
const
std
::
string
&
arg
)
->
optional
<
skip_message_t
>
{
if
(
arg
.
empty
()
||
arg
.
front
()
!=
'-'
)
{
if
(
arg
.
empty
()
||
arg
.
front
()
!=
'-'
)
{
return
skip_message
();
return
skip_message
();
...
...
unit_testing/test_message.cpp
View file @
23e09f28
...
@@ -45,14 +45,14 @@ void test_slice() {
...
@@ -45,14 +45,14 @@ void test_slice() {
CAF_CHECK_EQUAL
(
to_string
(
m2
),
to_string
(
make_message
(
3
,
4
)));
CAF_CHECK_EQUAL
(
to_string
(
m2
),
to_string
(
make_message
(
3
,
4
)));
}
}
void
test_
filter
1
(
int
lhs1
,
int
lhs2
,
int
lhs3
,
int
rhs1
,
int
rhs2
,
int
val
)
{
void
test_
extract
1
(
int
lhs1
,
int
lhs2
,
int
lhs3
,
int
rhs1
,
int
rhs2
,
int
val
)
{
auto
m1
=
make_message
(
lhs1
,
lhs2
,
lhs3
);
auto
m1
=
make_message
(
lhs1
,
lhs2
,
lhs3
);
auto
m2
=
make_message
(
rhs1
,
rhs2
);
auto
m2
=
make_message
(
rhs1
,
rhs2
);
auto
m3
=
m1
.
filter
(
on
(
val
)
>>
[]
{});
auto
m3
=
m1
.
extract
(
on
(
val
)
>>
[]
{});
CAF_CHECK_EQUAL
(
to_string
(
m2
),
to_string
(
m3
));
CAF_CHECK_EQUAL
(
to_string
(
m2
),
to_string
(
m3
));
}
}
void
test_
filter
2
()
{
void
test_
extract
2
()
{
auto
m1
=
make_message
(
1.0
,
2.0
,
3.0
);
auto
m1
=
make_message
(
1.0
,
2.0
,
3.0
);
auto
m2
=
make_message
(
1
,
2
,
1.0
,
2.0
,
3.0
);
auto
m2
=
make_message
(
1
,
2
,
1.0
,
2.0
,
3.0
);
auto
m3
=
make_message
(
1.0
,
1
,
2
,
2.0
,
3.0
);
auto
m3
=
make_message
(
1.0
,
1
,
2
,
2.0
,
3.0
);
...
@@ -64,19 +64,19 @@ void test_filter2() {
...
@@ -64,19 +64,19 @@ void test_filter2() {
[](
int
,
int
)
{
},
[](
int
,
int
)
{
},
[](
float
,
float
)
{
}
[](
float
,
float
)
{
}
};
};
CAF_CHECK_EQUAL
(
to_string
(
m2
.
filter
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m2
.
extract
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m3
.
filter
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m3
.
extract
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m4
.
filter
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m4
.
extract
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m5
.
filter
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m5
.
extract
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m6
.
filter
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m6
.
extract
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m7
.
filter
(
f
)),
to_string
(
m1
));
CAF_CHECK_EQUAL
(
to_string
(
m7
.
extract
(
f
)),
to_string
(
m1
));
}
}
void
test_
filter
3
()
{
void
test_
extract
3
()
{
auto
m1
=
make_message
(
1
);
auto
m1
=
make_message
(
1
);
CAF_CHECK_EQUAL
(
to_string
(
m1
.
filter
([](
int
)
{})),
to_string
(
message
{}));
CAF_CHECK_EQUAL
(
to_string
(
m1
.
extract
([](
int
)
{})),
to_string
(
message
{}));
auto
m2
=
make_message
(
1.0
,
2
,
3
,
4.0
);
auto
m2
=
make_message
(
1.0
,
2
,
3
,
4.0
);
auto
m3
=
m2
.
filter
({
auto
m3
=
m2
.
extract
({
[](
int
,
int
)
{
},
[](
int
,
int
)
{
},
[](
double
,
double
)
{
}
[](
double
,
double
)
{
}
});
});
...
@@ -84,10 +84,10 @@ void test_filter3() {
...
@@ -84,10 +84,10 @@ void test_filter3() {
CAF_CHECK_EQUAL
(
to_string
(
m3
),
to_string
(
make_message
(
1.0
,
4.0
)));
CAF_CHECK_EQUAL
(
to_string
(
m3
),
to_string
(
make_message
(
1.0
,
4.0
)));
}
}
void
test_
filter_cli
()
{
void
test_
extract_opts
()
{
auto
f
=
[](
std
::
vector
<
std
::
string
>
args
)
{
auto
f
=
[](
std
::
vector
<
std
::
string
>
args
)
{
std
::
string
filename
;
std
::
string
filename
;
auto
res
=
message_builder
(
args
.
begin
(),
args
.
end
()).
filter_cli
({
auto
res
=
message_builder
(
args
.
begin
(),
args
.
end
()).
extract_opts
({
{
"version,v"
,
"print version"
},
{
"version,v"
,
"print version"
},
{
"file,f"
,
"set output file"
,
filename
},
{
"file,f"
,
"set output file"
,
filename
},
{
"whatever"
,
"do whatever"
}
{
"whatever"
,
"do whatever"
}
...
@@ -109,12 +109,12 @@ int main() {
...
@@ -109,12 +109,12 @@ int main() {
CAF_TEST
(
message
);
CAF_TEST
(
message
);
test_drop
();
test_drop
();
test_slice
();
test_slice
();
test_
filter
1
(
1
,
2
,
3
,
2
,
3
,
1
);
test_
extract
1
(
1
,
2
,
3
,
2
,
3
,
1
);
test_
filter
1
(
1
,
2
,
3
,
1
,
3
,
2
);
test_
extract
1
(
1
,
2
,
3
,
1
,
3
,
2
);
test_
filter
1
(
1
,
2
,
3
,
1
,
2
,
3
);
test_
extract
1
(
1
,
2
,
3
,
1
,
2
,
3
);
test_
filter
2
();
test_
extract
2
();
test_
filter
3
();
test_
extract
3
();
test_
filter_cli
();
test_
extract_opts
();
test_type_token
();
test_type_token
();
return
CAF_TEST_RESULT
();
return
CAF_TEST_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