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
c9e8ad17
Unverified
Commit
c9e8ad17
authored
Nov 22, 2018
by
Dominik Charousset
Committed by
GitHub
Nov 22, 2018
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #801
Allow copy of config_option
parents
5b4d38ad
26b30a27
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
3 deletions
+59
-3
libcaf_core/caf/config_option.hpp
libcaf_core/caf/config_option.hpp
+8
-0
libcaf_core/caf/config_option_set.hpp
libcaf_core/caf/config_option_set.hpp
+1
-2
libcaf_core/src/config_option.cpp
libcaf_core/src/config_option.cpp
+28
-0
libcaf_core/src/config_option_set.cpp
libcaf_core/src/config_option_set.cpp
+1
-1
libcaf_core/test/config_option.cpp
libcaf_core/test/config_option.cpp
+21
-0
No files found.
libcaf_core/caf/config_option.hpp
View file @
c9e8ad17
...
@@ -54,10 +54,18 @@ public:
...
@@ -54,10 +54,18 @@ public:
config_option
(
string_view
category
,
string_view
name
,
string_view
description
,
config_option
(
string_view
category
,
string_view
name
,
string_view
description
,
const
meta_state
*
meta
,
void
*
value
=
nullptr
);
const
meta_state
*
meta
,
void
*
value
=
nullptr
);
config_option
(
const
config_option
&
);
config_option
(
config_option
&&
)
=
default
;
config_option
(
config_option
&&
)
=
default
;
config_option
&
operator
=
(
const
config_option
&
);
config_option
&
operator
=
(
config_option
&&
)
=
default
;
config_option
&
operator
=
(
config_option
&&
)
=
default
;
// -- swap function ----------------------------------------------------------
friend
void
swap
(
config_option
&
first
,
config_option
&
second
)
noexcept
;
// -- properties -------------------------------------------------------------
// -- properties -------------------------------------------------------------
/// Returns the category of the option.
/// Returns the category of the option.
...
...
libcaf_core/caf/config_option_set.hpp
View file @
c9e8ad17
...
@@ -166,8 +166,7 @@ public:
...
@@ -166,8 +166,7 @@ public:
}
}
/// Adds a config option to the set.
/// Adds a config option to the set.
/// @private
config_option_set
&
add
(
config_option
opt
);
config_option_set
&
add
(
config_option
&&
opt
);
/// Generates human-readable help text for all options.
/// Generates human-readable help text for all options.
std
::
string
help_text
(
bool
global_only
=
true
)
const
;
std
::
string
help_text
(
bool
global_only
=
true
)
const
;
...
...
libcaf_core/src/config_option.cpp
View file @
c9e8ad17
...
@@ -77,6 +77,34 @@ config_option::config_option(string_view category, string_view name,
...
@@ -77,6 +77,34 @@ config_option::config_option(string_view category, string_view name,
CAF_ASSERT
(
pos
()
==
buf_size_
);
CAF_ASSERT
(
pos
()
==
buf_size_
);
}
}
config_option
::
config_option
(
const
config_option
&
other
)
:
category_separator_
{
other
.
category_separator_
},
long_name_separator_
{
other
.
long_name_separator_
},
short_names_separator_
{
other
.
short_names_separator_
},
buf_size_
{
other
.
buf_size_
},
meta_
{
other
.
meta_
},
value_
{
other
.
value_
}
{
buf_
.
reset
(
new
char
[
buf_size_
]);
std
::
copy_n
(
other
.
buf_
.
get
(),
buf_size_
,
buf_
.
get
());
}
config_option
&
config_option
::
operator
=
(
const
config_option
&
other
)
{
config_option
tmp
{
other
};
swap
(
*
this
,
tmp
);
return
*
this
;
}
void
swap
(
config_option
&
first
,
config_option
&
second
)
noexcept
{
using
std
::
swap
;
swap
(
first
.
buf_
,
second
.
buf_
);
swap
(
first
.
category_separator_
,
second
.
category_separator_
);
swap
(
first
.
long_name_separator_
,
second
.
long_name_separator_
);
swap
(
first
.
short_names_separator_
,
second
.
short_names_separator_
);
swap
(
first
.
buf_size_
,
second
.
buf_size_
);
swap
(
first
.
meta_
,
second
.
meta_
);
swap
(
first
.
value_
,
second
.
value_
);
}
// -- properties ---------------------------------------------------------------
// -- properties ---------------------------------------------------------------
string_view
config_option
::
category
()
const
noexcept
{
string_view
config_option
::
category
()
const
noexcept
{
...
...
libcaf_core/src/config_option_set.cpp
View file @
c9e8ad17
...
@@ -52,7 +52,7 @@ void insert(string_builder& builder, size_t count, char ch) {
...
@@ -52,7 +52,7 @@ void insert(string_builder& builder, size_t count, char ch) {
namespace
caf
{
namespace
caf
{
config_option_set
&
config_option_set
::
add
(
config_option
&&
opt
)
{
config_option_set
&
config_option_set
::
add
(
config_option
opt
)
{
opts_
.
emplace_back
(
std
::
move
(
opt
));
opts_
.
emplace_back
(
std
::
move
(
opt
));
return
*
this
;
return
*
this
;
}
}
...
...
libcaf_core/test/config_option.cpp
View file @
c9e8ad17
...
@@ -87,8 +87,29 @@ void check_integer_options() {
...
@@ -87,8 +87,29 @@ void check_integer_options() {
check_integer_options
<
T
>
(
tk
);
check_integer_options
<
T
>
(
tk
);
}
}
void
compare
(
const
config_option
&
lhs
,
const
config_option
&
rhs
)
{
CAF_CHECK_EQUAL
(
lhs
.
category
(),
rhs
.
category
());
CAF_CHECK_EQUAL
(
lhs
.
long_name
(),
rhs
.
long_name
());
CAF_CHECK_EQUAL
(
lhs
.
short_names
(),
rhs
.
short_names
());
CAF_CHECK_EQUAL
(
lhs
.
description
(),
rhs
.
description
());
CAF_CHECK_EQUAL
(
lhs
.
full_name
(),
rhs
.
full_name
());
}
}
// namespace <anonymous>
}
// namespace <anonymous>
CAF_TEST
(
copy
constructor
)
{
auto
one
=
make_config_option
<
int
>
(
"cat1"
,
"one"
,
"option 1"
);
auto
two
=
one
;
compare
(
one
,
two
);
}
CAF_TEST
(
copy
assignment
)
{
auto
one
=
make_config_option
<
int
>
(
"cat1"
,
"one"
,
"option 1"
);
auto
two
=
make_config_option
<
int
>
(
"cat2"
,
"two"
,
"option 2"
);
two
=
one
;
compare
(
one
,
two
);
}
CAF_TEST
(
type_bool
)
{
CAF_TEST
(
type_bool
)
{
CAF_CHECK_EQUAL
(
read
<
bool
>
(
"true"
),
true
);
CAF_CHECK_EQUAL
(
read
<
bool
>
(
"true"
),
true
);
CAF_CHECK_EQUAL
(
read
<
bool
>
(
"false"
),
false
);
CAF_CHECK_EQUAL
(
read
<
bool
>
(
"false"
),
false
);
...
...
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