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
5a4a1b7f
Commit
5a4a1b7f
authored
Aug 24, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Enable vectors in config setups
parent
35af5369
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
80 additions
and
1 deletion
+80
-1
libcaf_core/caf/config_option.hpp
libcaf_core/caf/config_option.hpp
+61
-1
libcaf_core/caf/detail/type_traits.hpp
libcaf_core/caf/detail/type_traits.hpp
+19
-0
No files found.
libcaf_core/caf/config_option.hpp
View file @
5a4a1b7f
...
@@ -22,6 +22,7 @@
...
@@ -22,6 +22,7 @@
#include <memory>
#include <memory>
#include <string>
#include <string>
#include <vector>
#include <cstdint>
#include <cstdint>
#include <cstring>
#include <cstring>
#include <functional>
#include <functional>
...
@@ -33,6 +34,8 @@
...
@@ -33,6 +34,8 @@
#include "caf/deep_to_string.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/static_visitor.hpp"
#include "caf/static_visitor.hpp"
#include "caf/detail/type_traits.hpp"
namespace
caf
{
namespace
caf
{
/// Helper class to generate config readers for different input types.
/// Helper class to generate config readers for different input types.
...
@@ -117,7 +120,8 @@ private:
...
@@ -117,7 +120,8 @@ private:
char
short_name_
;
char
short_name_
;
};
};
template
<
class
T
>
template
<
class
T
,
bool
IsInsertable
=
detail
::
can_insert_elements
<
T
>()
&&
!
std
::
is_same
<
T
,
std
::
string
>::
value
>
class
config_option_impl
:
public
config_option
{
class
config_option_impl
:
public
config_option
{
public:
public:
config_option_impl
(
T
&
ref
,
const
char
*
ctg
,
const
char
*
nm
,
const
char
*
xp
)
config_option_impl
(
T
&
ref
,
const
char
*
ctg
,
const
char
*
nm
,
const
char
*
xp
)
...
@@ -166,6 +170,62 @@ private:
...
@@ -166,6 +170,62 @@ private:
T
&
ref_
;
T
&
ref_
;
};
};
template
<
class
T
>
class
config_option_impl
<
T
,
true
>
:
public
config_option
{
public:
using
value_type
=
typename
T
::
value_type
;
config_option_impl
(
T
&
ref
,
const
char
*
ctg
,
const
char
*
nm
,
const
char
*
xp
)
:
config_option
(
ctg
,
nm
,
xp
),
ref_
(
ref
)
{
// nop
}
std
::
string
to_string
()
const
override
{
return
deep_to_string
(
ref_
);
}
message
::
cli_arg
to_cli_arg
(
bool
use_caf_prefix
)
override
{
std
::
string
argname
;
if
(
use_caf_prefix
)
argname
=
"caf#"
;
if
(
strcmp
(
category
(),
"global"
)
!=
0
)
{
argname
+=
category
();
argname
+=
"."
;
}
argname
+=
name
();
if
(
short_name
()
!=
'\0'
)
{
argname
+=
','
;
argname
+=
short_name
();
}
return
{
std
::
move
(
argname
),
explanation
(),
ref_
};
}
config_reader_sink
to_sink
()
override
{
return
[
=
](
size_t
ln
,
config_value
&
x
)
{
// the INI parser accepts all integers as int64_t
using
cfg_type
=
typename
std
::
conditional
<
std
::
is_integral
<
value_type
>::
value
&&
!
std
::
is_same
<
bool
,
value_type
>::
value
,
int64_t
,
value_type
>::
type
;
value_type
tmp
;
if
(
get
<
cfg_type
>
(
&
x
)
&&
assign_config_value
(
tmp
,
get
<
cfg_type
>
(
x
)))
{
ref_
.
insert
(
ref_
.
end
(),
std
::
move
(
tmp
));
return
;
}
type_name_visitor
tnv
;
report_type_error
(
ln
,
x
,
tnv
(
tmp
));
};
}
private:
T
&
ref_
;
};
template
<
class
T
>
template
<
class
T
>
std
::
unique_ptr
<
config_option
>
std
::
unique_ptr
<
config_option
>
make_config_option
(
T
&
storage
,
const
char
*
category
,
make_config_option
(
T
&
storage
,
const
char
*
category
,
...
...
libcaf_core/caf/detail/type_traits.hpp
View file @
5a4a1b7f
...
@@ -588,6 +588,25 @@ struct strip_reference_wrapper<std::reference_wrapper<T>> {
...
@@ -588,6 +588,25 @@ struct strip_reference_wrapper<std::reference_wrapper<T>> {
using
type
=
T
;
using
type
=
T
;
};
};
template
<
class
T
>
constexpr
bool
can_insert_elements_impl
(
T
*
,
decltype
(
std
::
declval
<
T
&>
()
.
insert
(
std
::
declval
<
T
&>
().
end
(),
std
::
declval
<
typename
T
::
value_type
>
()))
*
=
nullptr
)
{
return
true
;
}
template
<
class
T
>
constexpr
bool
can_insert_elements_impl
(
void
*
)
{
return
false
;
}
template
<
class
T
>
constexpr
bool
can_insert_elements
()
{
return
can_insert_elements_impl
<
T
>
(
static_cast
<
T
*>
(
nullptr
));
}
}
// namespace detail
}
// namespace detail
}
// namespace caf
}
// namespace caf
...
...
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