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
wenqing
ogs
Commits
435d697b
Commit
435d697b
authored
9 years ago
by
Christoph Lehmann
Browse files
Options
Downloads
Patches
Plain Diff
[BL] added filename member
parent
7ffba173
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
BaseLib/ConfigTreeNew.cpp
+15
-7
15 additions, 7 deletions
BaseLib/ConfigTreeNew.cpp
BaseLib/ConfigTreeNew.h
+9
-4
9 additions, 4 deletions
BaseLib/ConfigTreeNew.h
with
24 additions
and
11 deletions
BaseLib/ConfigTreeNew.cpp
+
15
−
7
View file @
435d697b
...
...
@@ -18,9 +18,10 @@ const std::string ConfigTreeNew::key_chars = key_chars_start + "_0123456789";
ConfigTreeNew
::
ConfigTreeNew
(
PTree
const
&
tree
,
std
::
string
const
&
filename
,
Callback
const
&
error_cb
,
Callback
const
&
warning_cb
)
:
_tree
(
&
tree
),
_onerror
(
error_cb
),
_onwarning
(
warning_cb
)
:
_tree
(
&
tree
),
_filename
(
filename
),
_onerror
(
error_cb
),
_onwarning
(
warning_cb
)
{
if
(
!
_onerror
)
{
ERR
(
"ConfigTree: No valid error handler provided."
);
...
...
@@ -36,6 +37,7 @@ ConfigTreeNew::
ConfigTreeNew
(
PTree
const
&
tree
,
ConfigTreeNew
const
&
parent
,
std
::
string
const
&
root
)
:
_tree
(
&
tree
),
_path
(
joinPaths
(
parent
.
_path
,
root
)),
_filename
(
parent
.
_filename
),
_onerror
(
parent
.
_onerror
),
_onwarning
(
parent
.
_onwarning
)
{
checkKeyname
(
root
);
...
...
@@ -45,6 +47,7 @@ ConfigTreeNew::
ConfigTreeNew
(
ConfigTreeNew
&&
other
)
:
_tree
(
other
.
_tree
)
,
_path
(
std
::
move
(
other
.
_path
))
,
_filename
(
std
::
move
(
other
.
_filename
))
,
_visited_params
(
std
::
move
(
other
.
_visited_params
))
,
_have_read_data
(
other
.
_have_read_data
)
,
_onerror
(
std
::
move
(
other
.
_onerror
))
...
...
@@ -67,6 +70,7 @@ operator=(ConfigTreeNew&& other)
_tree
=
other
.
_tree
;
other
.
_tree
=
nullptr
;
_path
=
std
::
move
(
other
.
_path
);
_filename
=
std
::
move
(
other
.
_filename
);
_visited_params
=
std
::
move
(
other
.
_visited_params
);
_have_read_data
=
other
.
_have_read_data
;
_onerror
=
std
::
move
(
other
.
_onerror
);
...
...
@@ -157,25 +161,29 @@ void ConfigTreeNew::ignoreConfParamAll(const std::string ¶m) const
void
ConfigTreeNew
::
error
(
const
std
::
string
&
message
)
const
{
_onerror
(
_path
,
message
);
_onerror
(
_filename
,
_path
,
message
);
std
::
abort
();
}
void
ConfigTreeNew
::
warning
(
const
std
::
string
&
message
)
const
{
_onwarning
(
_path
,
message
);
_onwarning
(
_filename
,
_path
,
message
);
}
void
ConfigTreeNew
::
onerror
(
const
std
::
string
&
path
,
const
std
::
string
&
message
)
void
ConfigTreeNew
::
onerror
(
const
std
::
string
&
filename
,
const
std
::
string
&
path
,
const
std
::
string
&
message
)
{
ERR
(
"ConfigTree: At path <%s>: %s"
,
path
.
c_str
(),
message
.
c_str
());
ERR
(
"ConfigTree: In file `%s' at path <%s>: %s"
,
filename
.
c_str
(),
path
.
c_str
(),
message
.
c_str
());
std
::
abort
();
}
void
ConfigTreeNew
::
onwarning
(
const
std
::
string
&
path
,
const
std
::
string
&
message
)
void
ConfigTreeNew
::
onwarning
(
const
std
::
string
&
filename
,
const
std
::
string
&
path
,
const
std
::
string
&
message
)
{
WARN
(
"ConfigTree: At path <%s>: %s"
,
path
.
c_str
(),
message
.
c_str
());
WARN
(
"ConfigTree: In file `%s' at path <%s>: %s"
,
filename
.
c_str
(),
path
.
c_str
(),
message
.
c_str
());
}
std
::
string
ConfigTreeNew
::
shortString
(
const
std
::
string
&
s
)
...
...
This diff is collapsed.
Click to expand it.
BaseLib/ConfigTreeNew.h
+
9
−
4
View file @
435d697b
...
...
@@ -172,7 +172,8 @@ public:
//! Type of the function objects used as callbacks.
//! The first argument denotes the path in the tree at which an event (warning/error)
//! occured, the second argument is the associated message
using
Callback
=
std
::
function
<
void
(
const
std
::
string
&
path
,
using
Callback
=
std
::
function
<
void
(
const
std
::
string
&
filename
,
const
std
::
string
&
path
,
const
std
::
string
&
message
)
>
;
/*!
...
...
@@ -194,6 +195,7 @@ public:
* i.e., warnings will also result in program abortion!
*/
explicit
ConfigTreeNew
(
PTree
const
&
tree
,
std
::
string
const
&
filename
,
Callback
const
&
error_cb
=
onerror
,
Callback
const
&
warning_cb
=
onerror
);
...
...
@@ -340,11 +342,13 @@ public:
//! Default error callback function
//! Will print an error message and call std::abort()
static
void
onerror
(
std
::
string
const
&
path
,
std
::
string
const
&
message
);
static
void
onerror
(
std
::
string
const
&
filename
,
std
::
string
const
&
path
,
std
::
string
const
&
message
);
//! Default warning callback function
//! Will print a warning message
static
void
onwarning
(
std
::
string
const
&
path
,
std
::
string
const
&
message
);
static
void
onwarning
(
std
::
string
const
&
filename
,
std
::
string
const
&
path
,
std
::
string
const
&
message
);
private
:
struct
CountType
...
...
@@ -417,7 +421,8 @@ private:
//! A path printed in error/warning messages.
std
::
string
_path
;
//! \todo add file name
//! TODO doc
std
::
string
_filename
;
using
KeyType
=
std
::
pair
<
bool
,
std
::
string
>
;
...
...
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