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
115b4fd0
Commit
115b4fd0
authored
May 25, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a map reader to INI parser
parent
7362662d
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
57 additions
and
2 deletions
+57
-2
libcaf_core/caf/detail/parser/read_ini.hpp
libcaf_core/caf/detail/parser/read_ini.hpp
+46
-1
libcaf_core/test/read_ini.cpp
libcaf_core/test/read_ini.cpp
+11
-1
No files found.
libcaf_core/caf/detail/parser/read_ini.hpp
View file @
115b4fd0
...
...
@@ -101,7 +101,52 @@ void read_ini_list(state<Iterator, Sentinel>& ps, Consumer& consumer) {
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_ini_map
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&
consumer
)
{
// TODO: implement me
std
::
string
key
;
auto
is_alnum_or_dash
=
[](
char
x
)
{
return
isalnum
(
x
)
||
x
==
'-'
||
x
==
'_'
;
};
start
();
state
(
init
)
{
action
(
is_char
<
'{'
>
,
await_key_name
,
consumer
.
begin_map
())
}
state
(
await_key_name
)
{
input
(
is_char
<
' '
>
,
await_key_name
)
input
(
is_char
<
'\t'
>
,
await_key_name
)
input
(
is_char
<
'\n'
>
,
await_key_name
)
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
await_key_name
)
action
(
isalnum
,
read_key_name
,
key
=
ch
)
action
(
is_char
<
'}'
>
,
done
,
consumer
.
end_map
())
}
// Reads a key of a "key=value" line.
state
(
read_key_name
)
{
action
(
is_alnum_or_dash
,
read_key_name
,
key
+=
ch
)
epsilon
(
await_assignment
)
}
// Reads the assignment operator in a "key=value" line.
state
(
await_assignment
)
{
input
(
is_char
<
' '
>
,
await_assignment
)
input
(
is_char
<
'\t'
>
,
await_assignment
)
action
(
is_char
<
'='
>
,
await_value
,
consumer
.
key
(
std
::
move
(
key
)))
}
// Reads the value in a "key=value" line.
state
(
await_value
)
{
input
(
is_char
<
' '
>
,
await_value
)
input
(
is_char
<
'\t'
>
,
await_value
)
invoke_fsm
(
read_ini_value
(
ps
,
consumer
),
after_value
)
}
// Waits for end-of-line after reading a value
state
(
after_value
)
{
input
(
is_char
<
' '
>
,
after_value
)
input
(
is_char
<
'\t'
>
,
after_value
)
input
(
is_char
<
'\n'
>
,
after_value
)
input
(
is_char
<
','
>
,
await_key_name
)
action
(
is_char
<
'}'
>
,
done
,
consumer
.
end_map
())
invoke_fsm_if
(
is_char
<
';'
>
,
read_ini_comment
(
ps
,
consumer
),
after_value
)
}
term_state
(
done
)
{
//nop
}
fin
();
}
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
...
...
libcaf_core/test/read_ini.cpp
View file @
115b4fd0
...
...
@@ -103,6 +103,14 @@ some-list=[
"abc",
'def', ; some comment and a trailing comma
]
some-map={
; here we have some list entries
entry1=123,
entry2=23 ; twenty-three!
,
entry3= "abc",
entry4 = 'def', ; some comment and a trailing comma
}
)"
;
const
auto
ini0_log
=
make_log
(
...
...
@@ -111,7 +119,9 @@ const auto ini0_log = make_log(
"value: 2000ns"
,
"key: impl"
,
"value: 'foo'"
,
"key: x_"
,
"value: "
+
deep_to_string
(
.123
),
"key: some-bool"
,
"value: true"
,
"key: some-other-bool"
,
"value: false"
,
"key: some-list"
,
"["
,
"value: 123"
,
"value: 23"
,
"value:
\"
abc
\"
"
,
"value: 'def'"
,
"]"
,
"}"
);
"value: 23"
,
"value:
\"
abc
\"
"
,
"value: 'def'"
,
"]"
,
"key: some-map"
,
"{"
,
"key: entry1"
,
"value: 123"
,
"key: entry2"
,
"value: 23"
,
"key: entry3"
,
"value:
\"
abc
\"
"
,
"key: entry4"
,
"value: 'def'"
,
"}"
,
"}"
);
}
// namespace <anonymous>
...
...
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