Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Y
Yaml Configurator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
BIAS
Configurators
Yaml Configurator
Compare revisions
8176ab6718c7b75c564b706cbf82e4133fcb6988 to 619b119743e1f4de6313910e037447f5fe2876d4
Compare revisions
Changes are shown as if the
source
revision was being merged into the
target
revision.
Learn more about comparing revisions.
Source
bias/configurators/yaml-configurator
Select target project
No results found
619b119743e1f4de6313910e037447f5fe2876d4
Select Git revision
Branches
main
Tags
v1.0
Swap
Target
bias/configurators/yaml-configurator
Select target project
bias/configurators/yaml-configurator
1 result
8176ab6718c7b75c564b706cbf82e4133fcb6988
Select Git revision
Branches
main
Tags
v1.0
Show changes
Only incoming changes from source
Include changes to target since source was created
Compare
Commits on Source (3)
adding doxygen
· 19b7f81d
Valerio Pastore
authored
1 year ago
19b7f81d
.
· afff41df
Valerio Pastore
authored
1 year ago
afff41df
.
· 619b1197
Valerio Pastore
authored
1 year ago
619b1197
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
deps/Base-DAQ
+1
-1
1 addition, 1 deletion
deps/Base-DAQ
include/Yaml_Conf.h
+14
-1
14 additions, 1 deletion
include/Yaml_Conf.h
src/Yaml_Conf.cpp
+20
-6
20 additions, 6 deletions
src/Yaml_Conf.cpp
with
35 additions
and
8 deletions
Base-DAQ
@
a00f9a27
Compare
8a0ea2d0
...
a00f9a27
Subproject commit
8
a0
ea2d0e699863df5fe1c91caf2d7b0855957be
Subproject commit a0
0f9a27afbf5f75dab7db2368b9b9b6fcb395e1
This diff is collapsed.
Click to expand it.
include/Yaml_Conf.h
View file @
619b1197
...
...
@@ -6,6 +6,10 @@
namespace
inaf
::
oasbo
::
Configurators
{
/**
* @brief The YamlConfigurator class is a subclass of BaseConfigurator that provides functionality for reading and writing YAML configuration files.
* It inherits from the BaseConfigurator class. Check Base_Configurator.h for more information.
*/
class
YamlConfigurator
:
public
BaseConfigurator
{
protected:
YAML
::
Node
file
;
...
...
@@ -13,13 +17,22 @@ protected:
public:
std
::
string
path
;
/**
* @brief Constructs a YamlConfigurator object with the specified path to the YAML configuration file.
* @param path The path to the YAML configuration file.
*/
YamlConfigurator
(
std
::
string
path
);
int
readConfigFromSource
()
override
;
int
readConfigFromSource
(
std
::
string
target
)
override
;
int
pushConfigToSource
()
override
;
int
pushConfigToSource
(
std
::
string
target
)
override
;
int
insert
(
std
::
map
<
std
::
string
,
std
::
string
>
,
std
::
string
target
)
override
;
int
insert
(
std
::
map
<
std
::
string
,
std
::
string
>
,
std
::
string
target
)
override
;
};
}
This diff is collapsed.
Click to expand it.
src/Yaml_Conf.cpp
View file @
619b1197
...
...
@@ -39,8 +39,7 @@ void YamlConfigurator::load(std::string path) {
}
/**
Updates the YAML configuration file by adding new configuration entries for the target key.
@brief Updates the YAML configuration file by adding new configuration entries for the target key.
It also removes old configurations corresponding to the target key.
@param target The target key for which to add and remove configuration entries.
*/
...
...
@@ -84,11 +83,11 @@ int YamlConfigurator::pushConfigToSource(std::string target) {
for
(;
pos
<
file_content
.
size
();
pos
++
)
{
if
(
file_content
[
pos
][
0
]
!=
'-'
)
{
line
=
file_content
[
pos
];
//
Elimina gli spazi vuoti all'inizio della stringa e Ferma l'
analis
i
a
l
cara
t
ter
e ":" escluso
//
Remove leading whitespace from the string and stop
anal
ys
is a
t the ":"
c
h
ara
c
ter
(excluding it)
line
=
line
.
erase
(
0
,
line
.
find_first_not_of
(
' '
)).
substr
(
0
,
line
.
find
(
':'
));
boost
::
to_lower
(
line
);
bool
found
=
false
;
// C
ontrolla se la riga è stata sostituita dalla nuova c
on
f
bool
found
=
false
;
// C
hecks if the line has been replaced by the new configurati
on
for
(
auto
key
:
filteredMap
)
{
if
(
key
.
first
.
compare
(
line
)
==
0
)
{
found
=
true
;
...
...
@@ -164,12 +163,27 @@ int YamlConfigurator::readConfigFromSource() {
if
(
file
.
IsNull
())
return
-
1
;
try
{
// Itera sugli elementi del documento YAML
// Iterate over the elements of the YAML document
for
(
const
auto
&
element
:
file
)
{
for
(
const
auto
&
pair
:
element
)
{
std
::
string
elementName
=
element
.
first
.
as
<
std
::
string
>
();
boost
::
to_lower
(
elementName
);
// If the element is a map, extract the keys and values
if
(
pair
.
second
.
IsMap
())
{
for
(
const
auto
&
subPair
:
pair
.
second
)
{
std
::
string
key
=
elementName
+
"_"
+
subPair
.
first
.
as
<
std
::
string
>
();
std
::
string
value
=
subPair
.
second
.
as
<
std
::
string
>
();
config
[
key
]
=
value
;
}
}
}
}
for
(
const
auto
&
element
:
file
)
{
for
(
const
auto
&
pair
:
element
)
{
std
::
string
elementName
=
element
.
first
.
as
<
std
::
string
>
();
boost
::
to_lower
(
elementName
);
//
Se l'
element
o è un
a map
pa
, e
s
tra
i le chiavi e i
val
ori
//
If the
element
is
a map, e
x
tra
ct the keys and
val
ues
if
(
pair
.
second
.
IsMap
())
{
for
(
const
auto
&
subPair
:
pair
.
second
)
{
std
::
string
key
=
elementName
+
"_"
...
...
This diff is collapsed.
Click to expand it.