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
150a5a50
Unverified
Commit
150a5a50
authored
Jul 18, 2018
by
Joseph Noir
Committed by
GitHub
Jul 18, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #734
Add URI to config_value
parents
0f6b0596
9fe3598e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
95 additions
and
13 deletions
+95
-13
libcaf_core/caf/config_value.hpp
libcaf_core/caf/config_value.hpp
+4
-3
libcaf_core/caf/detail/parser/read_ini.hpp
libcaf_core/caf/detail/parser/read_ini.hpp
+29
-0
libcaf_core/src/config_value.cpp
libcaf_core/src/config_value.cpp
+1
-0
libcaf_core/test/read_ini.cpp
libcaf_core/test/read_ini.cpp
+61
-10
No files found.
libcaf_core/caf/config_value.hpp
View file @
150a5a50
...
...
@@ -36,6 +36,7 @@
#include "caf/sum_type_access.hpp"
#include "caf/sum_type_token.hpp"
#include "caf/timestamp.hpp"
#include "caf/uri.hpp"
#include "caf/variant.hpp"
namespace
caf
{
...
...
@@ -63,7 +64,7 @@ public:
using
dictionary
=
caf
::
dictionary
<
config_value
>
;
using
types
=
detail
::
type_list
<
integer
,
boolean
,
real
,
atom
,
timespan
,
using
types
=
detail
::
type_list
<
integer
,
boolean
,
real
,
atom
,
timespan
,
uri
,
string
,
list
,
dictionary
>
;
using
variant_type
=
detail
::
tl_apply_t
<
types
,
variant
>
;
...
...
@@ -157,8 +158,8 @@ private:
}
template
<
class
T
>
detail
::
enable_if_t
<
detail
::
is_one_of
<
T
,
real
,
atom
,
timespan
,
string
,
list
,
dictionary
>::
value
>
detail
::
enable_if_t
<
detail
::
is_one_of
<
T
,
real
,
atom
,
timespan
,
uri
,
string
,
list
,
dictionary
>::
value
>
set
(
T
x
)
{
data_
=
std
::
move
(
x
);
}
...
...
libcaf_core/caf/detail/parser/read_ini.hpp
View file @
150a5a50
...
...
@@ -28,8 +28,10 @@
#include "caf/detail/parser/read_bool.hpp"
#include "caf/detail/parser/read_number_or_timespan.hpp"
#include "caf/detail/parser/read_string.hpp"
#include "caf/detail/parser/read_uri.hpp"
#include "caf/detail/scope_guard.hpp"
#include "caf/pec.hpp"
#include "caf/uri_builder.hpp"
CAF_PUSH_UNUSED_LABEL_WARNING
...
...
@@ -140,6 +142,32 @@ void read_ini_map(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
fin
();
}
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_ini_uri
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&&
consumer
)
{
uri_builder
builder
;
auto
g
=
make_scope_guard
([
&
]
{
if
(
ps
.
code
<=
pec
::
trailing_character
)
consumer
.
value
(
builder
.
make
());
});
start
();
state
(
init
)
{
transition
(
init
,
"
\t\n
"
)
transition
(
before_uri
,
'<'
)
}
state
(
before_uri
)
{
transition
(
before_uri
,
"
\t\n
"
)
fsm_epsilon
(
read_uri
(
ps
,
builder
),
after_uri
)
}
state
(
after_uri
)
{
transition
(
after_uri
,
"
\t\n
"
)
transition
(
done
,
'>'
)
}
term_state
(
done
)
{
// nop
}
fin
();
}
template
<
class
Iterator
,
class
Sentinel
,
class
Consumer
>
void
read_ini_value
(
state
<
Iterator
,
Sentinel
>&
ps
,
Consumer
&&
consumer
)
{
start
();
...
...
@@ -149,6 +177,7 @@ void read_ini_value(state<Iterator, Sentinel>& ps, Consumer&& consumer) {
fsm_epsilon
(
read_number
(
ps
,
consumer
),
done
,
'.'
)
fsm_epsilon
(
read_bool
(
ps
,
consumer
),
done
,
"ft"
)
fsm_epsilon
(
read_number_or_timespan
(
ps
,
consumer
),
done
,
"0123456789+-"
)
fsm_epsilon
(
read_ini_uri
(
ps
,
consumer
),
done
,
'<'
)
fsm_transition
(
read_ini_list
(
ps
,
consumer
.
begin_list
()),
done
,
'['
)
fsm_transition
(
read_ini_map
(
ps
,
consumer
.
begin_map
()),
done
,
'{'
)
}
...
...
libcaf_core/src/config_value.cpp
View file @
150a5a50
...
...
@@ -35,6 +35,7 @@ const char* type_names[] {
"real"
,
"atom"
,
"timespan"
,
"uri"
,
"string"
,
"list"
,
"dictionary"
,
...
...
libcaf_core/test/read_ini.cpp
View file @
150a5a50
...
...
@@ -63,7 +63,12 @@ struct test_consumer {
template
<
class
T
>
void
value
(
T
x
)
{
add_entry
(
"value: "
,
deep_to_string
(
x
));
config_value
cv
{
std
::
move
(
x
)};
std
::
string
entry
=
"value ("
;
entry
+=
cv
.
type_name
();
entry
+=
"): "
;
entry
+=
to_string
(
cv
);
log
.
emplace_back
(
std
::
move
(
entry
));
}
void
add_entry
(
const
char
*
prefix
,
std
::
string
str
)
{
...
...
@@ -87,8 +92,10 @@ struct fixture {
res
.
i
=
str
.
begin
();
res
.
e
=
str
.
end
();
detail
::
parser
::
read_ini
(
res
,
f
);
if
((
res
.
code
==
pec
::
success
)
!=
expect_success
)
if
((
res
.
code
==
pec
::
success
)
!=
expect_success
)
{
CAF_MESSAGE
(
"unexpected parser result state: "
<<
res
.
code
);
CAF_MESSAGE
(
"input remainder: "
<<
std
::
string
(
res
.
i
,
res
.
e
));
}
return
std
::
move
(
f
.
log
);
}
};
...
...
@@ -125,17 +132,61 @@ entry1=123,
entry3= "abc",
entry4 = 'def', ; some comment and a trailing comma
}
[middleman]
preconnect=[<
tcp://localhost:8080
>,<udp://remotehost?trust=false>]
)"
;
const
auto
ini0_log
=
make_log
(
"key: logger"
,
"{"
,
"key: padding"
,
"value: 10"
,
"key: file-name"
,
"value:
\"
foobar.ini
\"
"
,
"}"
,
"key: scheduler"
,
"{"
,
"key: timing"
,
"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'"
,
"]"
,
"key: some-map"
,
"{"
,
"key: entry1"
,
"value: 123"
,
"key: entry2"
,
"value: 23"
,
"key: entry3"
,
"value:
\"
abc
\"
"
,
"key: entry4"
,
"value: 'def'"
,
"}"
,
"}"
);
"key: logger"
,
"{"
,
"key: padding"
,
"value (integer): 10"
,
"key: file-name"
,
"value (string):
\"
foobar.ini
\"
"
,
"}"
,
"key: scheduler"
,
"{"
,
"key: timing"
,
"value (timespan): 2000ns"
,
"key: impl"
,
"value (atom): 'foo'"
,
"key: x_"
,
"value (real): "
+
deep_to_string
(
.123
),
"key: some-bool"
,
"value (boolean): true"
,
"key: some-other-bool"
,
"value (boolean): false"
,
"key: some-list"
,
"["
,
"value (integer): 123"
,
"value (integer): 23"
,
"value (string):
\"
abc
\"
"
,
"value (atom): 'def'"
,
"]"
,
"key: some-map"
,
"{"
,
"key: entry1"
,
"value (integer): 123"
,
"key: entry2"
,
"value (integer): 23"
,
"key: entry3"
,
"value (string):
\"
abc
\"
"
,
"key: entry4"
,
"value (atom): 'def'"
,
"}"
,
"}"
,
"key: middleman"
,
"{"
,
"key: preconnect"
,
"["
,
"value (uri): tcp://localhost:8080"
,
"value (uri): udp://remotehost?trust=false"
,
"]"
,
"}"
);
}
// 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