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
fde9e45b
Commit
fde9e45b
authored
Jan 17, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow users to omit [global] in config file
parent
a4d0e2ef
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
40 additions
and
3 deletions
+40
-3
libcaf_core/caf/detail/parser/read_ini.hpp
libcaf_core/caf/detail/parser/read_ini.hpp
+2
-1
libcaf_core/src/ini_consumer.cpp
libcaf_core/src/ini_consumer.cpp
+2
-1
libcaf_core/test/ini_consumer.cpp
libcaf_core/test/ini_consumer.cpp
+36
-1
No files found.
libcaf_core/caf/detail/parser/read_ini.hpp
View file @
fde9e45b
...
...
@@ -239,7 +239,7 @@ void read_ini_section(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_ini
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&&
consumer
)
{
using
std
::
swap
;
std
::
string
tmp
;
std
::
string
tmp
{
"global"
}
;
auto
alnum_or_dash
=
[](
char
x
)
{
return
isalnum
(
x
)
||
x
==
'-'
||
x
==
'_'
;
};
...
...
@@ -255,6 +255,7 @@ void read_ini(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
transition
(
init
,
"
\t\n
"
)
fsm_epsilon
(
read_ini_comment
(
ps
,
consumer
),
init
,
';'
)
transition
(
start_section
,
'['
)
fsm_epsilon_if
(
tmp
==
"global"
,
read_ini_section
(
ps
,
begin_section
()),
init
)
}
// Read the section key after reading an '['.
state
(
start_section
)
{
...
...
libcaf_core/src/ini_consumer.cpp
View file @
fde9e45b
...
...
@@ -155,7 +155,8 @@ ini_consumer* ini_category_consumer::dparent() {
ini_consumer
::
ini_consumer
(
config_option_set
&
options
,
settings
&
cfg
)
:
options_
(
options
),
cfg_
(
cfg
)
{
cfg_
(
cfg
),
current_key
(
"global"
)
{
// nop
}
...
...
libcaf_core/test/ini_consumer.cpp
View file @
fde9e45b
...
...
@@ -34,7 +34,6 @@ using ls = std::vector<std::string>;
namespace
{
const
char
test_ini
[]
=
R"(
[global]
is_server=true
port=4242
nodes=["sun", "venus", ]
...
...
@@ -45,6 +44,19 @@ file-name = "foobar.ini" ; our file name
impl = 'foo';some atom
)"
;
const
char
test_ini2
[]
=
R"(
is_server = true
port = 4242
nodes = ["sun", "venus"]
logger = {
file-name = "foobar.ini"
}
scheduler = {
timing = 2us,
impl = 'foo'
}
)"
;
struct
fixture
{
detail
::
parser
::
state
<
std
::
string
::
const_iterator
>
res
;
config_option_set
options
;
...
...
@@ -90,4 +102,27 @@ CAF_TEST(ini_consumer) {
CAF_CHECK_EQUAL
(
get
<
atom_value
>
(
config
,
"scheduler.impl"
),
atom
(
"foo"
));
}
CAF_TEST
(
simplified
syntax
)
{
std
::
string
str
=
test_ini
;
CAF_MESSAGE
(
"read test_ini"
);
{
detail
::
ini_consumer
consumer
{
options
,
config
};
res
.
i
=
str
.
begin
();
res
.
e
=
str
.
end
();
detail
::
parser
::
read_ini
(
res
,
consumer
);
CAF_CHECK_EQUAL
(
res
.
code
,
pec
::
success
);
}
str
=
test_ini2
;
settings
config2
;
CAF_MESSAGE
(
"read test_ini2"
);
{
detail
::
ini_consumer
consumer
{
options
,
config2
};
res
.
i
=
str
.
begin
();
res
.
e
=
str
.
end
();
detail
::
parser
::
read_ini
(
res
,
consumer
);
CAF_CHECK_EQUAL
(
res
.
code
,
pec
::
success
);
}
CAF_CHECK_EQUAL
(
config
,
config2
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
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