Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
wolf
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
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
mobile_robotics
wolf_projects
wolf_lib
wolf
Commits
27ce5838
Commit
27ce5838
authored
4 years ago
by
Joaquim Casals Buñuel
Browse files
Options
Downloads
Patches
Plain Diff
Add some comments
parent
d0c16a48
No related branches found
No related tags found
No related merge requests found
Pipeline
#5886
passed
4 years ago
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
include/core/utils/converter.h
+26
-0
26 additions, 0 deletions
include/core/utils/converter.h
src/yaml/parser_yaml.cpp
+9
-0
9 additions, 0 deletions
src/yaml/parser_yaml.cpp
with
35 additions
and
0 deletions
include/core/utils/converter.h
+
26
−
0
View file @
27ce5838
...
@@ -20,9 +20,35 @@
...
@@ -20,9 +20,35 @@
/**
/**
@file
@file
converter.h
@brief This file implements a set of simple functions that deal with the correspondence between
classes and their string representation. The YAML autosetup framework makes heavy use of this file.
*/
//Note: In order to deal with string representations we make heavy use of regexps.
// We use the standard C++11 regular expressions capabilities.
/*
** This file is structured essentially in two parts:
** in the first part (which starts after the CONVERTERS ~~~~ STRING ----> TYPE line)
** we have functions to convert from string to C++ class. For example:
string v1 = "[3,4,5,6,7,8,9,10,11]";
vector<int> v = converter<vector<int>>::convert(v1);
This code snippet transforms the string v1 which represents an std::vector into an actual std::vector value.
The second part (which starts after the TYPES ----> ToSTRING line) has the functions to
transform from C++ classes to strings. For instance, if we wanted to convert from a C++ class
to a string we would do something like this:
vector<int> vect{ 10, 20, 30 };
string str = converter<std::string>::convert(vect);
//str == "[10,20,30]"
*/
*/
namespace
wolf
{
namespace
wolf
{
//This definition is a bit of a "hack". The reason of redefining the pair class is to be able
//to have two string representations of a pair, namely
//"(·,·)" -> typical pair/tuple representation
//"{·,·}" -> key-value pair representation used to represent maps.
//This is purely an aesthetic reason and could be removed without problems.
template
<
class
A
,
class
B
>
template
<
class
A
,
class
B
>
struct
Wpair
:
std
::
pair
<
A
,
B
>
struct
Wpair
:
std
::
pair
<
A
,
B
>
{
{
...
...
This diff is collapsed.
Click to expand it.
src/yaml/parser_yaml.cpp
+
9
−
0
View file @
27ce5838
...
@@ -345,6 +345,12 @@ void ParserYaml::updateActiveName(std::string _tag)
...
@@ -345,6 +345,12 @@ void ParserYaml::updateActiveName(std::string _tag)
{
{
active_name_
=
_tag
;
active_name_
=
_tag
;
}
}
/*
** @brief This function is responsible for parsing the first level of the YAML file.
** The first level here can be thought as the entry point of the YAML file. Since we impose a certain structure
** this function is responsible for enforcing said structure.
**
*/
void
ParserYaml
::
parseFirstLevel
(
YAML
::
Node
_n
,
std
::
string
_file
)
void
ParserYaml
::
parseFirstLevel
(
YAML
::
Node
_n
,
std
::
string
_file
)
{
{
...
@@ -550,6 +556,9 @@ void ParserYaml::parse()
...
@@ -550,6 +556,9 @@ void ParserYaml::parse()
}
}
parsing_file_
.
pop
();
parsing_file_
.
pop
();
}
}
/*
** @brief This function gives the ability to run the parser without enforcing the wolf YAML structure.
*/
void
ParserYaml
::
parse_freely
()
void
ParserYaml
::
parse_freely
()
{
{
parsing_file_
.
push
(
generatePath
(
file_
));
parsing_file_
.
push
(
generatePath
(
file_
));
...
...
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