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
fb0a6784
Commit
fb0a6784
authored
3 years ago
by
Lars Bilke
Committed by
Dmitri Naumov
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
[BL] Renamed functions, abort on unknown xml patch elements, better cast
node->name is an const unsigned char *.
parent
655c33d5
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
BaseLib/ConfigTreeUtil.cpp
+14
-11
14 additions, 11 deletions
BaseLib/ConfigTreeUtil.cpp
with
14 additions
and
11 deletions
BaseLib/ConfigTreeUtil.cpp
+
14
−
11
View file @
fb0a6784
...
@@ -76,7 +76,7 @@ void traverse(boost::property_tree::ptree& parent, const fs::path bench_dir,
...
@@ -76,7 +76,7 @@ void traverse(boost::property_tree::ptree& parent, const fs::path bench_dir,
traverse_recursive
(
parent
,
""
,
parent
,
bench_dir
,
method
);
traverse_recursive
(
parent
,
""
,
parent
,
bench_dir
,
method
);
}
}
void
replace
_i
ncludes
(
void
replace
I
ncludes
(
[[
maybe_unused
]]
boost
::
property_tree
::
ptree
const
&
parent
,
[[
maybe_unused
]]
boost
::
property_tree
::
ptree
const
&
parent
,
[[
maybe_unused
]]
boost
::
property_tree
::
ptree
::
path_type
const
&
child_path
,
[[
maybe_unused
]]
boost
::
property_tree
::
ptree
::
path_type
const
&
child_path
,
boost
::
property_tree
::
ptree
&
child
,
boost
::
property_tree
::
ptree
&
child
,
...
@@ -116,7 +116,7 @@ void replace_includes(
...
@@ -116,7 +116,7 @@ void replace_includes(
}
}
// Applies a patch file to the prj content in prj_stream.
// Applies a patch file to the prj content in prj_stream.
void
patch
_s
tream
(
std
::
string
patch_file
,
std
::
stringstream
&
prj_stream
)
void
patch
S
tream
(
std
::
string
patch_file
,
std
::
stringstream
&
prj_stream
)
{
{
auto
patch
=
xmlParseFile
(
patch_file
.
c_str
());
auto
patch
=
xmlParseFile
(
patch_file
.
c_str
());
if
(
patch
==
NULL
)
if
(
patch
==
NULL
)
...
@@ -140,21 +140,24 @@ void patch_stream(std::string patch_file, std::stringstream& prj_stream)
...
@@ -140,21 +140,24 @@ void patch_stream(std::string patch_file, std::stringstream& prj_stream)
continue
;
continue
;
}
}
if
(
!
strcmp
(
(
char
*
)
node
->
name
,
"add"
))
if
(
!
strcmp
(
reinterpret_cast
<
const
char
*
>
(
node
->
name
)
,
"add"
))
{
{
rc
=
xml_patch_add
(
doc
,
node
);
rc
=
xml_patch_add
(
doc
,
node
);
}
}
else
if
(
!
strcmp
(
(
char
*
)
node
->
name
,
"replace"
))
else
if
(
!
strcmp
(
reinterpret_cast
<
const
char
*
>
(
node
->
name
)
,
"replace"
))
{
{
rc
=
xml_patch_replace
(
doc
,
node
);
rc
=
xml_patch_replace
(
doc
,
node
);
}
}
else
if
(
!
strcmp
(
(
char
*
)
node
->
name
,
"remove"
))
else
if
(
!
strcmp
(
reinterpret_cast
<
const
char
*
>
(
node
->
name
)
,
"remove"
))
{
{
rc
=
xml_patch_remove
(
doc
,
node
);
rc
=
xml_patch_remove
(
doc
,
node
);
}
}
else
else
{
{
continue
;
OGS_FATAL
(
"Error while patching prj file with patch file {:}. Only "
"'add', 'replace' and 'remove' elements are allowed!"
,
patch_file
);
}
}
if
(
rc
)
if
(
rc
)
...
@@ -177,8 +180,8 @@ void patch_stream(std::string patch_file, std::stringstream& prj_stream)
...
@@ -177,8 +180,8 @@ void patch_stream(std::string patch_file, std::stringstream& prj_stream)
// Will set prj_file to the actual .prj file and returns the final prj file
// Will set prj_file to the actual .prj file and returns the final prj file
// content in prj_stream.
// content in prj_stream.
void
read
_and_p
atch
_p
rj
(
std
::
stringstream
&
prj_stream
,
std
::
string
&
prj_file
,
void
read
AndP
atch
P
rj
(
std
::
stringstream
&
prj_stream
,
std
::
string
&
prj_file
,
std
::
vector
<
std
::
string
>
patch_files
)
std
::
vector
<
std
::
string
>
patch_files
)
{
{
// Extract base project file path if an xml (patch) file is given as prj
// Extract base project file path if an xml (patch) file is given as prj
// file and it contains the base_file attribute.
// file and it contains the base_file attribute.
...
@@ -220,7 +223,7 @@ void read_and_patch_prj(std::stringstream& prj_stream, std::string& prj_file,
...
@@ -220,7 +223,7 @@ void read_and_patch_prj(std::stringstream& prj_stream, std::string& prj_file,
{
{
for
(
const
auto
&
patch_file
:
patch_files
)
for
(
const
auto
&
patch_file
:
patch_files
)
{
{
patch
_s
tream
(
patch_file
,
prj_stream
);
patch
S
tream
(
patch_file
,
prj_stream
);
}
}
xmlCleanupParser
();
xmlCleanupParser
();
}
}
...
@@ -233,7 +236,7 @@ ConfigTreeTopLevel makeConfigTree(const std::string& filepath,
...
@@ -233,7 +236,7 @@ ConfigTreeTopLevel makeConfigTree(const std::string& filepath,
{
{
std
::
string
prj_file
=
filepath
;
std
::
string
prj_file
=
filepath
;
std
::
stringstream
prj_stream
;
std
::
stringstream
prj_stream
;
read
_and_p
atch
_p
rj
(
prj_stream
,
prj_file
,
patch_files
);
read
AndP
atch
P
rj
(
prj_stream
,
prj_file
,
patch_files
);
ConfigTree
::
PTree
ptree
;
ConfigTree
::
PTree
ptree
;
...
@@ -247,7 +250,7 @@ ConfigTreeTopLevel makeConfigTree(const std::string& filepath,
...
@@ -247,7 +250,7 @@ ConfigTreeTopLevel makeConfigTree(const std::string& filepath,
if
(
toplevel_tag
==
"OpenGeoSysProject"
)
if
(
toplevel_tag
==
"OpenGeoSysProject"
)
{
{
traverse
(
ptree
,
fs
::
path
(
prj_file
).
parent_path
(),
replace
_i
ncludes
);
traverse
(
ptree
,
fs
::
path
(
prj_file
).
parent_path
(),
replace
I
ncludes
);
}
}
}
}
catch
(
boost
::
property_tree
::
xml_parser_error
const
&
e
)
catch
(
boost
::
property_tree
::
xml_parser_error
const
&
e
)
...
...
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