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
40ed1153
Commit
40ed1153
authored
Jun 19, 2023
by
Samir Halilcevic
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove space separated config-file value
parent
7ac22638
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
30 additions
and
15 deletions
+30
-15
libcaf_core/caf/config_option.hpp
libcaf_core/caf/config_option.hpp
+4
-5
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+5
-1
libcaf_core/src/config_option.cpp
libcaf_core/src/config_option.cpp
+2
-2
libcaf_core/src/config_option_set.cpp
libcaf_core/src/config_option_set.cpp
+4
-6
libcaf_core/test/actor_system_config.cpp
libcaf_core/test/actor_system_config.cpp
+15
-1
No files found.
libcaf_core/caf/config_option.hpp
View file @
40ed1153
...
...
@@ -104,11 +104,10 @@ private:
mutable
void
*
value_
;
};
/// Finds `config_option` string with a matching long name in the string
/// argument list [`first`, `last`). Returns an `argument_iterator` to the
/// matching location and a `string_view` of the option value if the entry is
/// found, or a `arugment_iterator` to `last` with an empty `string_view`
/// otherwise.
/// Finds `config_option` string with a matching long name in the argument list
/// [`first`, `last`). Returns an `iterator` to the matching location and a
/// `string_view` of the option value if the entry is found, or a `iterator`
/// to `last` with an empty `string_view` otherwise.
std
::
pair
<
std
::
vector
<
std
::
string
>::
const_iterator
,
std
::
string_view
>
find_by_long_name
(
const
config_option
&
x
,
std
::
vector
<
std
::
string
>::
const_iterator
first
,
...
...
libcaf_core/src/actor_system_config.cpp
View file @
40ed1153
...
...
@@ -470,7 +470,11 @@ actor_system_config::extract_config_file_path(string_list& args) {
std
::
string
{}};
}
else
{
auto
path_str
=
std
::
string
{
path
.
begin
(),
path
.
end
()};
args
.
erase
(
i
);
if
(
i
->
find
(
'='
)
!=
std
::
string
::
npos
)
{
args
.
erase
(
i
);
}
else
{
args
.
erase
(
i
,
i
+
2
);
}
config_value
val
{
path_str
};
if
(
auto
err
=
ptr
->
sync
(
val
);
!
err
)
{
put
(
content
,
"config-file"
,
std
::
move
(
val
));
...
...
libcaf_core/src/config_option.cpp
View file @
40ed1153
...
...
@@ -133,7 +133,7 @@ std::string_view config_option::buf_slice(size_t from,
return
{
buf_
.
get
()
+
from
,
to
-
from
};
}
// TODO: consider deprecating this
// TODO: consider
using `config_option_set` and
deprecating this
std
::
pair
<
std
::
vector
<
std
::
string
>::
const_iterator
,
std
::
string_view
>
find_by_long_name
(
const
config_option
&
x
,
std
::
vector
<
std
::
string
>::
const_iterator
first
,
...
...
@@ -157,7 +157,7 @@ find_by_long_name(const config_option& x,
str
.
remove_prefix
(
1
);
return
{
first
,
str
};
}
else
if
(
str
.
empty
()
&&
(
first
+
1
)
!=
last
)
{
// Get the next argument
as
value
// Get the next argument
the
value
++
first
;
return
{
first
,
std
::
string_view
{
*
first
}};
}
else
{
...
...
libcaf_core/src/config_option_set.cpp
View file @
40ed1153
...
...
@@ -167,18 +167,16 @@ auto config_option_set::parse(settings& config, argument_iterator first,
}
}
};
// We loop over the first N-1 values, because we always consider two
// arguments at once.
for
(
auto
i
=
first
;
i
!=
last
;)
{
if
(
i
->
size
()
<
2
)
return
{
pec
::
not_an_option
,
i
};
if
(
*
i
==
"--"
)
return
{
pec
::
success
,
std
::
next
(
first
)};
if
(
i
->
compare
(
0
,
2
,
"--"
)
==
0
)
{
// Long options co
ne in three varia
ties:
//
syntax "--<name>=<value>" formated as a single single argument,
//
sytnax "--<name> <value>", comes as two arguments
//
special case "--<name>", boolean flag
// Long options co
me in three varie
ties:
//
"--<name>", config option is a boolean flag
//
"--<name>=<value>", formatted as a single argument with the value,
//
"--<name> <value>", formatted as two arguments,
const
auto
npos
=
std
::
string
::
npos
;
auto
assign_op
=
i
->
find
(
'='
);
auto
name
=
assign_op
==
npos
?
i
->
substr
(
2
)
...
...
libcaf_core/test/actor_system_config.cpp
View file @
40ed1153
...
...
@@ -55,7 +55,6 @@ struct fixture {
void
parse
(
const
char
*
file_content
,
string_list
args
=
{})
{
cfg
.
clear
();
cfg
.
remainder
.
clear
();
std
::
istringstream
conf
{
file_content
};
if
(
auto
err
=
cfg
.
parse
(
std
::
move
(
args
),
conf
))
CAF_FAIL
(
"parse() failed: "
<<
err
);
...
...
@@ -150,6 +149,21 @@ CAF_TEST(file input overrides defaults but CLI args always win) {
CHECK_EQ
(
content
(
cfg
),
res
);
}
CAF_TEST
(
parsing
-
with
config
file
cli
option
)
{
MESSAGE
(
"Try opening non-existent config file"
);
cfg
.
clear
();
auto
err
=
cfg
.
parse
(
string_list
{
"--config-file=test-me"
});
CHECK_EQ
(
err
,
caf
::
sec
::
cannot_open_file
);
CHECK
(
cfg
.
remainder
.
empty
());
CHECK_EQ
(
get_or
(
cfg
,
"config-file"
,
""
),
"test-me"
);
cfg
.
clear
();
err
=
cfg
.
parse
(
string_list
{
"--config-file"
,
"test-me"
});
CHECK_EQ
(
err
,
caf
::
sec
::
cannot_open_file
);
CHECK
(
cfg
.
remainder
.
empty
());
CHECK_EQ
(
get_or
(
cfg
,
"config-file"
,
""
),
"test-me"
);
}
// Checks whether both a synced variable and the corresponding entry in
// content(cfg) are equal to `value`.
#define CHECK_SYNCED(var, ...) \
...
...
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