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
5d7c87c7
Commit
5d7c87c7
authored
May 28, 2019
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Clean up config file path extraction
parent
777d33bc
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
15 additions
and
46 deletions
+15
-46
libcaf_core/src/actor_system_config.cpp
libcaf_core/src/actor_system_config.cpp
+15
-46
No files found.
libcaf_core/src/actor_system_config.cpp
View file @
5d7c87c7
...
@@ -24,6 +24,7 @@
...
@@ -24,6 +24,7 @@
#include <sstream>
#include <sstream>
#include "caf/config.hpp"
#include "caf/config.hpp"
#include "caf/config_option.hpp"
#include "caf/config_option_adder.hpp"
#include "caf/config_option_adder.hpp"
#include "caf/defaults.hpp"
#include "caf/defaults.hpp"
#include "caf/detail/gcd.hpp"
#include "caf/detail/gcd.hpp"
...
@@ -68,7 +69,7 @@ actor_system_config::actor_system_config()
...
@@ -68,7 +69,7 @@ actor_system_config::actor_system_config()
.
add
<
bool
>
(
"help,h?"
,
"print help text to STDERR and exit"
)
.
add
<
bool
>
(
"help,h?"
,
"print help text to STDERR and exit"
)
.
add
<
bool
>
(
"long-help"
,
"print long help text to STDERR and exit"
)
.
add
<
bool
>
(
"long-help"
,
"print long help text to STDERR and exit"
)
.
add
<
bool
>
(
"dump-config"
,
"print configuration to STDERR and exit"
)
.
add
<
bool
>
(
"dump-config"
,
"print configuration to STDERR and exit"
)
.
add
<
string
>
(
"config-file"
,
"set config file (default: caf-application.ini)"
);
.
add
<
string
>
(
config_file_path
,
"config-file"
,
"set config file (default: caf-application.ini)"
);
opt_group
{
custom_options_
,
"stream"
}
opt_group
{
custom_options_
,
"stream"
}
.
add
<
timespan
>
(
stream_desired_batch_complexity
,
"desired-batch-complexity"
,
.
add
<
timespan
>
(
stream_desired_batch_complexity
,
"desired-batch-complexity"
,
"processing time per batch"
)
"processing time per batch"
)
...
@@ -367,53 +368,21 @@ std::string actor_system_config::render_pec(uint8_t x, atom_value,
...
@@ -367,53 +368,21 @@ std::string actor_system_config::render_pec(uint8_t x, atom_value,
}
}
void
actor_system_config
::
extract_config_file_path
(
string_list
&
args
)
{
void
actor_system_config
::
extract_config_file_path
(
string_list
&
args
)
{
static
constexpr
const
char
needle
[]
=
"--caf#config-file="
;
auto
ptr
=
custom_options_
.
qualified_name_lookup
(
"global.config-file"
);
static
constexpr
const
char
needle_global
[]
=
"--config-file="
;
CAF_ASSERT
(
ptr
!=
nullptr
);
const
auto
last
=
args
.
end
();
string_list
::
iterator
i
;
size_t
len
=
0
;
string_view
path
;
auto
i
=
args
.
begin
();
std
::
tie
(
i
,
path
)
=
find_by_long_name
(
*
ptr
,
args
.
begin
(),
args
.
end
());
// Look for match and set len and i.
if
(
i
==
args
.
end
())
auto
check
=
[
&
](
const
char
*
str
)
{
return
;
i
=
std
::
find_if
(
args
.
begin
(),
last
,
[
&
](
const
std
::
string
&
arg
)
{
if
(
path
.
empty
())
{
return
arg
.
compare
(
0
,
strlen
(
str
),
str
)
==
0
;
args
.
erase
(
i
);
});
len
=
strlen
(
str
);
};
// Check for global name.
check
(
needle_global
);
if
(
i
==
last
)
{
// Check for full name.
check
(
needle
);
if
(
i
==
last
)
return
;
}
auto
arg_begin
=
i
->
begin
()
+
len
;
auto
arg_end
=
i
->
end
();
if
(
arg_begin
==
arg_end
)
{
// Missing value.
// TODO: print warning?
return
;
return
;
}
}
if
(
*
arg_begin
==
'"'
)
{
auto
evalue
=
ptr
->
parse
(
path
);
detail
::
parser
::
state
<
std
::
string
::
const_iterator
>
res
;
if
(
!
evalue
)
res
.
i
=
arg_begin
;
return
;
res
.
e
=
arg_end
;
ptr
->
store
(
*
evalue
);
struct
consumer
{
std
::
string
result
;
void
value
(
std
::
string
&&
x
)
{
result
=
std
::
move
(
x
);
}
};
consumer
f
;
detail
::
parser
::
read_string
(
res
,
f
);
if
(
res
.
code
==
pec
::
success
)
config_file_path
=
std
::
move
(
f
.
result
);
// TODO: else print warning?
}
else
{
// We support unescaped strings for convenience on the CLI.
config_file_path
=
std
::
string
{
arg_begin
,
arg_end
};
}
args
.
erase
(
i
);
}
}
error
actor_system_config
::
adjust_content
()
{
error
actor_system_config
::
adjust_content
()
{
...
...
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