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
3b131411
Commit
3b131411
authored
Nov 02, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support function objects in extract_opts
parent
f97dc341
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
4 deletions
+24
-4
libcaf_core/caf/message.hpp
libcaf_core/caf/message.hpp
+17
-4
libcaf_core/src/message.cpp
libcaf_core/src/message.cpp
+7
-0
No files found.
libcaf_core/caf/message.hpp
View file @
3b131411
...
...
@@ -159,6 +159,8 @@ public:
/// Stores the name of a command line option ("<long name>[,<short name>]")
/// along with a description and a callback.
struct
cli_arg
{
/// Returns `true` on a match, `false` otherwise.
using
consumer
=
std
::
function
<
bool
(
const
std
::
string
&
)
>
;
/// Full name of this CLI argument using format "<long name>[,<short name>]"
std
::
string
name
;
...
...
@@ -169,8 +171,8 @@ public:
/// Auto-generated helptext for this item.
std
::
string
helptext
;
///
Returns `true` on a match, `false` otherwise
.
std
::
function
<
bool
(
const
std
::
string
&
)
>
fun
;
///
Evaluates option arguments
.
consumer
fun
;
/// Creates a CLI argument without data.
cli_arg
(
std
::
string
name
,
std
::
string
text
);
...
...
@@ -181,10 +183,17 @@ public:
/// Creates a CLI argument appending matched arguments to `dest`.
cli_arg
(
std
::
string
name
,
std
::
string
text
,
std
::
vector
<
std
::
string
>&
dest
);
/// Creates a CLI argument using the function object `f`.
cli_arg
(
std
::
string
name
,
std
::
string
text
,
consumer
f
);
/// Creates a CLI argument for converting from strings,
/// storing its matched argument in `dest`.
template
<
class
T
>
cli_arg
(
std
::
string
name
,
std
::
string
text
,
T
&
dest
);
cli_arg
(
typename
std
::
enable_if
<
detail
::
type_nr
<
T
>::
value
!=
0
,
std
::
string
>::
type
name
,
std
::
string
text
,
T
&
dest
);
/// Creates a CLI argument for converting from strings,
/// appending matched arguments to `dest`.
...
...
@@ -405,7 +414,11 @@ inline message make_message() {
******************************************************************************/
template
<
class
T
>
message
::
cli_arg
::
cli_arg
(
std
::
string
nstr
,
std
::
string
tstr
,
T
&
arg
)
message
::
cli_arg
::
cli_arg
(
typename
std
::
enable_if
<
detail
::
type_nr
<
T
>::
value
!=
0
,
std
::
string
>::
type
nstr
,
std
::
string
tstr
,
T
&
arg
)
:
name
(
std
::
move
(
nstr
)),
text
(
std
::
move
(
tstr
)),
fun
([
&
arg
](
const
std
::
string
&
str
)
->
bool
{
...
...
libcaf_core/src/message.cpp
View file @
3b131411
...
...
@@ -340,6 +340,13 @@ message::cli_arg::cli_arg(std::string nstr, std::string tstr)
// nop
}
message
::
cli_arg
::
cli_arg
(
std
::
string
name
,
std
::
string
text
,
consumer
f
)
:
name
(
std
::
move
(
name
)),
text
(
std
::
move
(
text
)),
fun
(
std
::
move
(
f
))
{
// nop
}
message
::
cli_arg
::
cli_arg
(
std
::
string
nstr
,
std
::
string
tstr
,
std
::
string
&
arg
)
:
name
(
std
::
move
(
nstr
)),
text
(
std
::
move
(
tstr
)),
...
...
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