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
1d99dc5e
Commit
1d99dc5e
authored
Jun 26, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use string_view for lookups in config_option_set
parent
f1681080
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
14 additions
and
13 deletions
+14
-13
libcaf_core/caf/actor_system_config.hpp
libcaf_core/caf/actor_system_config.hpp
+2
-2
libcaf_core/caf/config_option_set.hpp
libcaf_core/caf/config_option_set.hpp
+5
-4
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+1
-1
libcaf_core/src/config_option_set.cpp
libcaf_core/src/config_option_set.cpp
+6
-6
No files found.
libcaf_core/caf/actor_system_config.hpp
View file @
1d99dc5e
...
...
@@ -105,7 +105,7 @@ public:
/// Sets a config by using its INI name `config_name` to `config_value`.
template
<
class
T
>
actor_system_config
&
set
(
const
char
*
name
,
T
&&
value
)
{
actor_system_config
&
set
(
string_view
name
,
T
&&
value
)
{
return
set_impl
(
name
,
config_value
{
std
::
forward
<
T
>
(
value
)});
}
...
...
@@ -403,7 +403,7 @@ private:
&
make_type_erased_value
<
T
>
);
}
actor_system_config
&
set_impl
(
const
char
*
name
,
config_value
value
);
actor_system_config
&
set_impl
(
string_view
name
,
config_value
value
);
static
std
::
string
render_sec
(
uint8_t
,
atom_value
,
const
message
&
);
...
...
libcaf_core/caf/config_option_set.hpp
View file @
1d99dc5e
...
...
@@ -28,6 +28,7 @@
#include "caf/fwd.hpp"
#include "caf/make_config_option.hpp"
#include "caf/pec.hpp"
#include "caf/string_view.hpp"
namespace
caf
{
...
...
@@ -69,18 +70,18 @@ public:
/// `<prefix>#<category>.<long-name>`. Users can omit `<prefix>`
/// for options that have an empty prefix and `<category>`
/// if the category is "global".
option_pointer
cli_long_name_lookup
(
const
std
::
string
&
name
)
const
;
option_pointer
cli_long_name_lookup
(
string_view
name
)
const
;
/// Returns the first `config_option` that matches the CLI short option name.
option_pointer
cli_short_name_lookup
(
char
short_name
)
const
;
/// Returns the first `config_option` that matches category and long name.
option_pointer
qualified_name_lookup
(
const
std
::
string
&
category
,
const
std
::
string
&
long_name
)
const
;
option_pointer
qualified_name_lookup
(
string_view
category
,
string_view
long_name
)
const
;
/// Returns the first `config_option` that matches the qualified name.
/// @param name Config option name formatted as `<category>.<long-name>`.
option_pointer
qualified_name_lookup
(
const
std
::
string
&
name
)
const
;
option_pointer
qualified_name_lookup
(
string_view
name
)
const
;
/// Returns the number of stored config options.
inline
size_t
size
()
const
noexcept
{
...
...
libcaf_core/src/actor_system_config.cpp
View file @
1d99dc5e
...
...
@@ -387,7 +387,7 @@ actor_system_config::add_error_category(atom_value x, error_renderer y) {
return
*
this
;
}
actor_system_config
&
actor_system_config
::
set_impl
(
const
char
*
name
,
actor_system_config
&
actor_system_config
::
set_impl
(
string_view
name
,
config_value
value
)
{
auto
opt
=
custom_options_
.
qualified_name_lookup
(
name
);
if
(
opt
!=
nullptr
&&
opt
->
check
(
value
)
==
none
)
{
...
...
libcaf_core/src/config_option_set.cpp
View file @
1d99dc5e
...
...
@@ -224,12 +224,12 @@ config_option_set::parse(config_map& config,
}
config_option_set
::
option_pointer
config_option_set
::
cli_long_name_lookup
(
const
string
&
name
)
const
{
config_option_set
::
cli_long_name_lookup
(
string_view
name
)
const
{
// We accept "caf#" prefixes for backward compatibility, but ignore them.
size_t
offset
=
name
.
compare
(
0
,
4
,
"caf#"
)
!=
0
?
0u
:
4u
;
// Extract category and long name.
string
category
;
string
long_name
;
string
_view
category
;
string
_view
long_name
;
auto
sep
=
name
.
find
(
'.'
,
offset
);
if
(
sep
==
string
::
npos
)
{
category
=
"global"
;
...
...
@@ -255,15 +255,15 @@ config_option_set::cli_short_name_lookup(char short_name) const {
}
config_option_set
::
option_pointer
config_option_set
::
qualified_name_lookup
(
const
std
::
string
&
category
,
const
std
::
string
&
long_name
)
const
{
config_option_set
::
qualified_name_lookup
(
string_view
category
,
string_view
long_name
)
const
{
return
detail
::
ptr_find_if
(
opts_
,
[
&
](
const
config_option
&
opt
)
{
return
opt
.
category
()
==
category
&&
opt
.
long_name
()
==
long_name
;
});
}
config_option_set
::
option_pointer
config_option_set
::
qualified_name_lookup
(
const
std
::
string
&
name
)
const
{
config_option_set
::
qualified_name_lookup
(
string_view
name
)
const
{
auto
sep
=
name
.
find
(
'.'
);
if
(
sep
==
string
::
npos
)
return
nullptr
;
...
...
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