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
ab7535c7
Commit
ab7535c7
authored
Nov 22, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement new get_as function for config_value
parent
dc04d789
Changes
12
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
1303 additions
and
161 deletions
+1303
-161
libcaf_core/caf/config_value.hpp
libcaf_core/caf/config_value.hpp
+324
-13
libcaf_core/caf/detail/bounds_checker.hpp
libcaf_core/caf/detail/bounds_checker.hpp
+7
-0
libcaf_core/caf/detail/parse.hpp
libcaf_core/caf/detail/parse.hpp
+32
-14
libcaf_core/caf/detail/print.hpp
libcaf_core/caf/detail/print.hpp
+8
-0
libcaf_core/caf/dictionary.hpp
libcaf_core/caf/dictionary.hpp
+0
-14
libcaf_core/caf/settings.hpp
libcaf_core/caf/settings.hpp
+3
-0
libcaf_core/src/config_value.cpp
libcaf_core/src/config_value.cpp
+313
-40
libcaf_core/src/detail/stringification_inspector.cpp
libcaf_core/src/detail/stringification_inspector.cpp
+2
-4
libcaf_core/src/settings.cpp
libcaf_core/src/settings.cpp
+2
-0
libcaf_core/test/config_value.cpp
libcaf_core/test/config_value.cpp
+602
-70
libcaf_core/test/core-test.hpp
libcaf_core/test/core-test.hpp
+6
-2
libcaf_core/test/detail/parser/read_config.cpp
libcaf_core/test/detail/parser/read_config.cpp
+4
-4
No files found.
libcaf_core/caf/config_value.hpp
View file @
ab7535c7
This diff is collapsed.
Click to expand it.
libcaf_core/caf/detail/bounds_checker.hpp
View file @
ab7535c7
...
...
@@ -33,6 +33,13 @@ struct bounds_checker {
}
};
template
<
>
struct
bounds_checker
<
int64_t
,
false
>
{
static
constexpr
bool
check
(
int64_t
)
noexcept
{
return
true
;
}
};
template
<
class
To
>
struct
bounds_checker
<
To
,
true
>
{
static
constexpr
bool
check
(
int64_t
x
)
noexcept
{
...
...
libcaf_core/caf/detail/parse.hpp
View file @
ab7535c7
...
...
@@ -222,8 +222,15 @@ template <class First, class Second, size_t N>
void
parse_element
(
string_parser_state
&
ps
,
std
::
pair
<
First
,
Second
>&
kvp
,
const
char
(
&
char_blacklist
)[
N
]);
template
<
class
T
>
enable_if_tt
<
is_iterable
<
T
>>
parse
(
string_parser_state
&
ps
,
T
&
xs
)
{
struct
require_opening_char_t
{};
constexpr
auto
require_opening_char
=
require_opening_char_t
{};
struct
allow_omitting_opening_char_t
{};
constexpr
auto
allow_omitting_opening_char
=
allow_omitting_opening_char_t
{};
template
<
class
T
,
class
Policy
=
allow_omitting_opening_char_t
>
enable_if_tt
<
is_iterable
<
T
>>
parse
(
string_parser_state
&
ps
,
T
&
xs
,
Policy
=
{})
{
using
value_type
=
deconst_kvp_t
<
typename
T
::
value_type
>
;
static
constexpr
auto
is_map_type
=
is_pair
<
value_type
>::
value
;
static
constexpr
auto
opening_char
=
is_map_type
?
'{'
:
'['
;
...
...
@@ -252,6 +259,9 @@ enable_if_tt<is_iterable<T>> parse(string_parser_state& ps, T& xs) {
}
return
;
}
if
constexpr
(
std
::
is_same
<
Policy
,
require_opening_char_t
>::
value
)
{
ps
.
code
=
pec
::
unexpected_character
;
}
else
{
// An empty string simply results in an empty list/map.
if
(
ps
.
at_end
())
return
;
...
...
@@ -265,6 +275,7 @@ enable_if_tt<is_iterable<T>> parse(string_parser_state& ps, T& xs) {
*
out
++
=
std
::
move
(
tmp
);
}
while
(
ps
.
consume
(
','
));
ps
.
code
=
ps
.
at_end
()
?
pec
::
success
:
pec
::
trailing_character
;
}
}
template
<
class
T
>
...
...
@@ -306,4 +317,11 @@ auto parse(string_view str, T& x) {
return
parse_result
(
ps
,
str
);
}
template
<
class
T
,
class
Policy
>
auto
parse
(
string_view
str
,
T
&
x
,
Policy
policy
)
{
string_parser_state
ps
{
str
.
begin
(),
str
.
end
()};
parse
(
ps
,
x
,
policy
);
return
parse_result
(
ps
,
str
);
}
}
// namespace caf::detail
libcaf_core/caf/detail/print.hpp
View file @
ab7535c7
...
...
@@ -18,6 +18,7 @@
#pragma once
#include "caf/none.hpp"
#include "caf/string_view.hpp"
#include <chrono>
...
...
@@ -60,6 +61,13 @@ void print_escaped(Buffer& buf, string_view str) {
buf
.
push_back
(
'"'
);
}
template
<
class
Buffer
>
void
print
(
Buffer
&
buf
,
none_t
)
{
using
namespace
caf
::
literals
;
auto
str
=
"null"
_sv
;
buf
.
insert
(
buf
.
end
(),
str
.
begin
(),
str
.
end
());
}
template
<
class
Buffer
>
void
print
(
Buffer
&
buf
,
bool
x
)
{
using
namespace
caf
::
literals
;
...
...
libcaf_core/caf/dictionary.hpp
View file @
ab7535c7
...
...
@@ -330,14 +330,6 @@ private:
map_type
xs_
;
};
// -- free functions -----------------------------------------------------------
// @relates dictionary
template
<
class
T
>
std
::
string
to_string
(
const
dictionary
<
T
>&
xs
)
{
return
deep_to_string
(
xs
.
container
());
}
// -- operators ----------------------------------------------------------------
// @relates dictionary
...
...
@@ -376,10 +368,4 @@ bool operator>=(const dictionary<T>& xs, const dictionary<T>& ys) {
return
xs
.
container
()
>=
ys
.
container
();
}
// @relates dictionary
template
<
class
T
>
std
::
ostream
&
operator
<<
(
std
::
ostream
&
out
,
const
dictionary
<
T
>&
xs
)
{
return
out
<<
to_string
(
xs
);
}
}
// namespace caf
libcaf_core/caf/settings.hpp
View file @
ab7535c7
...
...
@@ -33,6 +33,9 @@ namespace caf {
/// @relates config_value
using
settings
=
dictionary
<
config_value
>
;
/// @relates config_value
CAF_CORE_EXPORT
std
::
string
to_string
(
const
settings
&
xs
);
/// Tries to retrieve the value associated to `name` from `xs`.
/// @relates config_value
CAF_CORE_EXPORT
const
config_value
*
...
...
libcaf_core/src/config_value.cpp
View file @
ab7535c7
This diff is collapsed.
Click to expand it.
libcaf_core/src/detail/stringification_inspector.cpp
View file @
ab7535c7
...
...
@@ -130,15 +130,13 @@ bool stringification_inspector::value(float x) {
bool
stringification_inspector
::
value
(
double
x
)
{
sep
();
auto
str
=
std
::
to_string
(
x
);
result_
+=
str
;
detail
::
print
(
result_
,
x
);
return
true
;
}
bool
stringification_inspector
::
value
(
long
double
x
)
{
sep
();
auto
str
=
std
::
to_string
(
x
);
result_
+=
str
;
detail
::
print
(
result_
,
x
);
return
true
;
}
...
...
libcaf_core/src/settings.cpp
View file @
ab7535c7
...
...
@@ -22,6 +22,8 @@
namespace
caf
{
// note: to_string is implemented in config_value.cpp
const
config_value
*
get_if
(
const
settings
*
xs
,
string_view
name
)
{
// Access the key directly unless the user specified a dot-separated path.
auto
pos
=
name
.
find
(
'.'
);
...
...
libcaf_core/test/config_value.cpp
View file @
ab7535c7
This diff is collapsed.
Click to expand it.
libcaf_core/test/core-test.hpp
View file @
ab7535c7
...
...
@@ -108,8 +108,12 @@ struct i64_wrapper {
};
struct
my_request
{
int32_t
a
;
int32_t
b
;
int32_t
a
=
0
;
int32_t
b
=
0
;
my_request
()
=
default
;
my_request
(
int
a
,
int
b
)
:
a
(
a
),
b
(
b
)
{
// nop
}
};
[[
maybe_unused
]]
inline
bool
operator
==
(
const
my_request
&
x
,
...
...
libcaf_core/test/detail/parser/read_config.cpp
View file @
ab7535c7
...
...
@@ -145,7 +145,7 @@ const auto conf0_log = make_log(
"key: foo=bar"
,
"{"
,
"key: foo"
,
"value (string):
\"
bar
\"
"
,
"value (string):
bar
"
,
"}"
,
"key: 1group"
,
"{"
,
...
...
@@ -162,7 +162,7 @@ const auto conf0_log = make_log(
"key: padding"
,
"value (integer): 10"
,
"key: file-name"
,
"value (string):
\"
foobar.ini
\"
"
,
"value (string):
foobar.ini
"
,
"}"
,
"key: scheduler"
,
"{"
,
...
...
@@ -184,7 +184,7 @@ const auto conf0_log = make_log(
"value (integer): 23"
,
"value (integer): 2"
,
"value (integer): 4"
,
"value (string):
\"
abc
\"
"
,
"value (string):
abc
"
,
"]"
,
"key: some-map"
,
"{"
,
...
...
@@ -193,7 +193,7 @@ const auto conf0_log = make_log(
"key: entry2"
,
"value (integer): 23"
,
"key: entry3"
,
"value (string):
\"
abc
\"
"
,
"value (string):
abc
"
,
"}"
,
"key: middleman"
,
"{"
,
...
...
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