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
Chaofan Chen
ogs
Commits
39960303
Commit
39960303
authored
9 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[BL] make default behaviour strict
Also checks are made publicly callable
parent
345348b5
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/ConfigTreeNew.cpp
+7
-3
7 additions, 3 deletions
BaseLib/ConfigTreeNew.cpp
BaseLib/ConfigTreeNew.h
+11
-5
11 additions, 5 deletions
BaseLib/ConfigTreeNew.h
with
18 additions
and
8 deletions
BaseLib/ConfigTreeNew.cpp
+
7
−
3
View file @
39960303
...
@@ -54,14 +54,14 @@ ConfigTreeNew(ConfigTreeNew && other)
...
@@ -54,14 +54,14 @@ ConfigTreeNew(ConfigTreeNew && other)
ConfigTreeNew
::~
ConfigTreeNew
()
ConfigTreeNew
::~
ConfigTreeNew
()
{
{
check
FullyRead
();
check
AndInvalidate
();
}
}
ConfigTreeNew
&
ConfigTreeNew
&
ConfigTreeNew
::
ConfigTreeNew
::
operator
=
(
ConfigTreeNew
&&
other
)
operator
=
(
ConfigTreeNew
&&
other
)
{
{
check
FullyRead
();
check
AndInvalidate
();
_tree
=
other
.
_tree
;
_tree
=
other
.
_tree
;
other
.
_tree
=
nullptr
;
other
.
_tree
=
nullptr
;
...
@@ -221,7 +221,7 @@ markVisitedDecrement(std::string const& key) const
...
@@ -221,7 +221,7 @@ markVisitedDecrement(std::string const& key) const
}
}
void
void
ConfigTreeNew
::
check
FullyRead
()
const
ConfigTreeNew
::
check
AndInvalidate
()
{
{
if
(
!
_tree
)
return
;
if
(
!
_tree
)
return
;
...
@@ -240,6 +240,10 @@ ConfigTreeNew::checkFullyRead() const
...
@@ -240,6 +240,10 @@ ConfigTreeNew::checkFullyRead() const
+
" time(s) less than it was present in the configuration tree."
);
+
" time(s) less than it was present in the configuration tree."
);
}
}
}
}
// The following invalidates this instance, s.t. it can not be read from it anymore,
// but it also prevents double-checking.
_tree
=
nullptr
;
}
}
}
}
This diff is collapsed.
Click to expand it.
BaseLib/ConfigTreeNew.h
+
11
−
5
View file @
39960303
...
@@ -180,10 +180,13 @@ public:
...
@@ -180,10 +180,13 @@ public:
* If a custom error callback is provided, this function should break out of
* If a custom error callback is provided, this function should break out of
* the normal execution order, e.g., by throwing or by calling std::abort(),
* the normal execution order, e.g., by throwing or by calling std::abort(),
* because otherwise this class will effectively treat errors as no-errors.
* because otherwise this class will effectively treat errors as no-errors.
*
* Defaults are strict: By default, both callbacks are set to the same function,
* i.e., warnings will also result in program abortion!
*/
*/
explicit
ConfigTreeNew
(
PTree
const
&
tree
,
explicit
ConfigTreeNew
(
PTree
const
&
tree
,
Callback
const
&
error_cb
=
onerror
,
Callback
const
&
error_cb
=
onerror
,
Callback
const
&
warning_cb
=
on
warning
);
Callback
const
&
warning_cb
=
on
error
);
//! copying is not compatible with the semantics of this class
//! copying is not compatible with the semantics of this class
ConfigTreeNew
(
ConfigTreeNew
const
&
)
=
delete
;
ConfigTreeNew
(
ConfigTreeNew
const
&
)
=
delete
;
...
@@ -302,6 +305,13 @@ public:
...
@@ -302,6 +305,13 @@ public:
*/
*/
void
ignoreConfParamAll
(
std
::
string
const
&
param
)
const
;
void
ignoreConfParamAll
(
std
::
string
const
&
param
)
const
;
/*! Checks if the top level of this tree has been read entirely (and not too often).
*
* Caution: This method also invalidates the instance, i.e., afterwards it can not
* be read from the tree anymore!
*/
void
checkAndInvalidate
();
//! The destructor performs the check if all nodes at the current level of the tree
//! The destructor performs the check if all nodes at the current level of the tree
//! have been read.
//! have been read.
~
ConfigTreeNew
();
~
ConfigTreeNew
();
...
@@ -362,10 +372,6 @@ private:
...
@@ -362,10 +372,6 @@ private:
//! and the number of times it exists in the ConfigTree
//! and the number of times it exists in the ConfigTree
void
markVisitedDecrement
(
std
::
string
const
&
key
)
const
;
void
markVisitedDecrement
(
std
::
string
const
&
key
)
const
;
//! Helper method that checks if the top level of this tree has
//! been red entirely (and not too often).
void
checkFullyRead
()
const
;
//! returns a short string at suitable for error/warning messages
//! returns a short string at suitable for error/warning messages
static
std
::
string
shortString
(
std
::
string
const
&
s
);
static
std
::
string
shortString
(
std
::
string
const
&
s
);
...
...
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