Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Dmitri Naumov
ogs
Commits
ffd9feb3
Commit
ffd9feb3
authored
9 years ago
by
Dmitri Naumov
Browse files
Options
Downloads
Patches
Plain Diff
[BL] Add ConfigTree::getConfParam* for vector<T>.
parent
513d6c82
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseLib/ConfigTree-impl.h
+29
-5
29 additions, 5 deletions
BaseLib/ConfigTree-impl.h
BaseLib/ConfigTree.h
+10
-0
10 additions, 0 deletions
BaseLib/ConfigTree.h
with
39 additions
and
5 deletions
BaseLib/ConfigTree-impl.h
+
29
−
5
View file @
ffd9feb3
...
@@ -9,6 +9,8 @@
...
@@ -9,6 +9,8 @@
#include
"ConfigTree.h"
#include
"ConfigTree.h"
#include
<sstream>
namespace
BaseLib
namespace
BaseLib
{
{
...
@@ -50,15 +52,37 @@ getConfParam(std::string const& param, T const& default_value) const
...
@@ -50,15 +52,37 @@ getConfParam(std::string const& param, T const& default_value) const
return
default_value
;
return
default_value
;
}
}
template
<
typename
T
>
template
<
typename
T
>
boost
::
optional
<
T
>
boost
::
optional
<
T
>
ConfigTree
::
getConfParamOptional
(
ConfigTree
::
std
::
string
const
&
param
)
const
getConfParamOptional
(
std
::
string
const
&
param
)
const
{
{
checkUnique
(
param
);
checkUnique
(
param
);
return
getConfParamOptionalImpl
(
param
,
static_cast
<
T
*>
(
nullptr
));
}
template
<
typename
T
>
boost
::
optional
<
T
>
ConfigTree
::
getConfParamOptionalImpl
(
std
::
string
const
&
param
,
T
*
)
const
{
if
(
auto
p
=
getConfSubtreeOptional
(
param
))
return
p
->
getValue
<
T
>
();
return
boost
::
none
;
}
template
<
typename
T
>
boost
::
optional
<
std
::
vector
<
T
>>
ConfigTree
::
getConfParamOptionalImpl
(
std
::
string
const
&
param
,
std
::
vector
<
T
>*
)
const
{
if
(
auto
p
=
getConfSubtreeOptional
(
param
))
if
(
auto
p
=
getConfSubtreeOptional
(
param
))
return
p
->
getValue
<
T
>
();
{
std
::
istringstream
sstr
{
p
->
getValue
<
std
::
string
>
()};
std
::
vector
<
T
>
result
;
T
value
;
while
(
sstr
>>
value
)
result
.
push_back
(
value
);
return
boost
::
make_optional
(
result
);
}
return
boost
::
none
;
return
boost
::
none
;
}
}
...
...
This diff is collapsed.
Click to expand it.
BaseLib/ConfigTree.h
+
10
−
0
View file @
ffd9feb3
...
@@ -15,6 +15,7 @@
...
@@ -15,6 +15,7 @@
#include
<functional>
#include
<functional>
#include
<memory>
#include
<memory>
#include
<vector>
#include
<boost/property_tree/ptree.hpp>
#include
<boost/property_tree/ptree.hpp>
...
@@ -497,6 +498,15 @@ public:
...
@@ -497,6 +498,15 @@ public:
static
void
onwarning
(
std
::
string
const
&
filename
,
std
::
string
const
&
path
,
static
void
onwarning
(
std
::
string
const
&
filename
,
std
::
string
const
&
path
,
std
::
string
const
&
message
);
std
::
string
const
&
message
);
private
:
//! Default implementation of reading a value of type T.
template
<
typename
T
>
boost
::
optional
<
T
>
getConfParamOptionalImpl
(
std
::
string
const
&
param
,
T
*
)
const
;
//! Implementation of reading a vector of values of type T.
template
<
typename
T
>
boost
::
optional
<
std
::
vector
<
T
>>
getConfParamOptionalImpl
(
std
::
string
const
&
param
,
std
::
vector
<
T
>*
)
const
;
private
:
private
:
struct
CountType
struct
CountType
{
{
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment