Formula Student Autonomous Systems
The code for the main driverless system
Loading...
Searching...
No Matches
configParser.cpp
Go to the documentation of this file.
1
#include "
configParser.hpp
"
2
3
NodeType::value
ConfigElement::getType
() {
return
this->
type
; }
4
5
Node
ConfigElement::getNode
() {
return
this->
node
; }
6
7
vector<ConfigElement>
ConfigElement::getElements
()
8
{
9
if
(this->
type
!= NodeType::Sequence)
10
{
11
throw
runtime_error(
"Not a sequence but a "
+ to_string(this->
type
));
12
}
13
14
vector<ConfigElement> res;
15
for
(const_iterator it = this->
node
.begin(); it != this->
node
.end(); ++it)
16
{
17
Node child = *it;
18
res.push_back(
ConfigElement
(child));
19
}
20
return
res;
21
}
22
23
ConfigElement
ConfigElement::getElement
(
string
elementName)
24
{
25
if
(this->
type
!= NodeType::Map)
26
{
27
throw
runtime_error(
"Not a map but a "
+ to_string(this->
type
));
28
}
29
30
if
(!this->
hasElement
(elementName))
31
{
32
throw
runtime_error(elementName +
" is not a member of this config item"
);
33
}
34
return
this->
node
[elementName];
35
}
36
37
bool
ConfigElement::hasElement
(
string
elementName)
38
{
39
if
(this->
type
!= NodeType::Map && this->
type
!= NodeType::Scalar)
40
{
41
return
false
;
42
}
43
if
(!this->
node
[elementName])
44
{
45
return
false
;
46
}
47
return
true
;
48
}
49
50
bool
ConfigElement::getElement
(
ConfigElement
* element,
string
elementName)
51
{
52
if
(this->
type
!= NodeType::Map && this->
type
!= NodeType::Scalar)
53
{
54
return
false
;
55
}
56
*element = this->
node
[elementName];
57
return
true
;
58
}
59
60
bool
ConfigElement::getElements
(vector<ConfigElement>* vec)
61
{
62
if
(this->
type
!= NodeType::Sequence)
63
{
64
return
false
;
65
}
66
for
(const_iterator it = this->
node
.begin(); it != this->
node
.end(); ++it)
67
{
68
Node child = *it;
69
vec->push_back(
ConfigElement
(child));
70
}
71
return
true
;
72
}
ConfigElement
Definition
configParser.hpp:15
ConfigElement::hasElement
bool hasElement(string elementName)
Definition
configParser.cpp:37
ConfigElement::getNode
Node getNode()
Definition
configParser.cpp:5
ConfigElement::getElement
ConfigElement getElement(string elementName)
Definition
configParser.cpp:23
ConfigElement::node
Node node
Definition
configParser.hpp:54
ConfigElement::getType
NodeType::value getType()
Definition
configParser.cpp:3
ConfigElement::type
NodeType::value type
Definition
configParser.hpp:55
ConfigElement::getElements
vector< ConfigElement > getElements()
Definition
configParser.cpp:7
configParser.hpp
src
pacsim
src
configParser.cpp
Generated by
1.9.8