PhoenixYml  0.5.0
Yml parser for Phoenix
Loading...
Searching...
No Matches
vec_value_utils.h File Reference
#include "DicoValue.h"
#include "VecValue.h"
+ Include dependency graph for vec_value_utils.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef std::vector< VecValueVecVecValue
 

Functions

VecValueaddChildToParentVecValue (VecValue &mainVecValue, const std::vector< size_t > &vecIndentation, bool isCompactMode, const VecValue &child, size_t currentIndentation=-1lu)
 Add the given child to the main VecValue and return a pointer to the added child.
 
VecValueaddChildToParentVecValueAddListItem (VecValue &mainVecValue, const std::vector< size_t > &vecIndentation, bool isCompactMode, const VecValue &child, size_t currentIndentation=-1lu)
 Add the given child to the main VecValue and return a pointer to the added child.
 
VecValuegetLastVecValue (VecValue &vecVal, size_t depth=-1lu)
 Get the last VecValue added at the specified depth.
 
VecValuegetParentVecValue (VecValue &vecAllVal, const std::vector< size_t > &vecIndentation, size_t currentIndentation)
 Get the parent VecValue by respect to its indentation.
 
VecValuegetParentVecValueListItem (VecValue &vecAllVal, const std::vector< size_t > &vecIndentation, size_t currentIndentation)
 
void vecValueToDicoValue (DicoValue &dicoValue, const VecValue &vecVal, bool isMainValue=true)
 Convert a VecValue into a DicoValue.
 

Typedef Documentation

◆ VecVecValue

typedef std::vector<VecValue> VecVecValue

Definition at line 14 of file vec_value_utils.h.

Function Documentation

◆ addChildToParentVecValue()

VecValue * addChildToParentVecValue ( VecValue & mainVecValue,
const std::vector< size_t > & vecIndentation,
bool isCompactMode,
const VecValue & child,
size_t currentIndentation )

Add the given child to the main VecValue and return a pointer to the added child.

Parameters
[out]mainVecValue: main VecValue to be used
vecIndentation: vector of the last indentation of the children VecValue
isCompactMode: true if the compact mode is enabled, false otherwise
child: child VecValue to be added to the main VecValue
currentIndentation: indentation of the current VecValue
Returns
pointer to the added child (cannot be NULL)

Definition at line 110 of file vec_value_utils.cpp.

110 {
111 VecValue * parent = NULL;
112 if(isCompactMode){
113 parent = &mainVecValue;
114 }else{
115 if(currentIndentation != -1lu){
116 parent = getParentVecValue(mainVecValue, vecIndentation, currentIndentation);
117 }else{
118 parent = getLastVecValue(mainVecValue);
119 }
120 }
121 parent->getVecChild().push_back(child);
122 return &(parent->getVecChild().back());
123}
Vector of keys and values.
Definition VecValue.h:15
const std::vector< VecValue > & getVecChild() const
Gets the vecChild of the VecValue.
Definition VecValue.cpp:104
VecValue * getParentVecValue(VecValue &vecAllVal, const std::vector< size_t > &vecIndentation, size_t currentIndentation)
Get the parent VecValue by respect to its indentation.
VecValue * getLastVecValue(VecValue &vecVal, size_t depth)
Get the last VecValue added at the specified depth.

References getLastVecValue(), getParentVecValue(), and VecValue::getVecChild().

Referenced by parse_yml_dicoContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addChildToParentVecValueAddListItem()

VecValue * addChildToParentVecValueAddListItem ( VecValue & mainVecValue,
const std::vector< size_t > & vecIndentation,
bool isCompactMode,
const VecValue & child,
size_t currentIndentation )

Add the given child to the main VecValue and return a pointer to the added child.

Parameters
[out]mainVecValue: main VecValue to be used
vecIndentation: vector of the last indentation of the children VecValue
isCompactMode: true if the compact mode is enabled, false otherwise
child: child VecValue to be added to the main VecValue
currentIndentation: indentation of the current VecValue
Returns
pointer to the added child (cannot be NULL)

Definition at line 133 of file vec_value_utils.cpp.

133 {
134 VecValue * parent = NULL;
135 if(isCompactMode){
136 parent = &mainVecValue;
137 }else{
138 if(currentIndentation != -1lu){
139 parent = getParentVecValueListItem(mainVecValue, vecIndentation, currentIndentation, child);
140 }else{
141 parent = getLastVecValue(mainVecValue);
142 }
143 }
144 parent->getVecChild().push_back(child);
145 return &(parent->getVecChild().back());
146}
VecValue * getParentVecValueListItem(VecValue &vecAllVal, const std::vector< size_t > &vecIndentation, size_t currentIndentation, const VecValue &child)
Get the parent VecValue by respect to its indentation.

References getLastVecValue(), getParentVecValueListItem(), and VecValue::getVecChild().

Referenced by parse_yml_listContent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getLastVecValue()

VecValue * getLastVecValue ( VecValue & vecVal,
size_t depth )

Get the last VecValue added at the specified depth.

Parameters
vecVal: VecValue to be used
depth: depth of the last VecValue to be returned
Returns
pointer to the corresponding VecValue (cannot be NULL)

Definition at line 15 of file vec_value_utils.cpp.

15 {
16 VecVecValue & vecChildren = vecVal.getVecChild();
17 if(vecChildren.size() == 0lu || depth == 0lu){return &vecVal;}
18 else{return getLastVecValue(vecChildren.back(), depth - 1lu);}
19}
std::vector< VecValue > VecVecValue

References getLastVecValue(), and VecValue::getVecChild().

Referenced by addChildToParentVecValue(), addChildToParentVecValueAddListItem(), getLastVecValue(), getParentVecValue(), and getParentVecValueListItem().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentVecValue()

VecValue * getParentVecValue ( VecValue & vecAllVal,
const std::vector< size_t > & vecIndentation,
size_t currentIndentation )

Get the parent VecValue by respect to its indentation.

Parameters
[out]vecAllVal: main VecValue
vecIndentation: vector of the last indentation of the children VecValue
currentIndentation: indentation of the current VecValue
Returns
pointer to the corresponding VecValue (cannot be NULL)

Definition at line 27 of file vec_value_utils.cpp.

27 {
28 if(vecIndentation.size() == 0lu){
29 return getLastVecValue(vecAllVal);
30 }
31 size_t depth(0lu);
32 std::vector<size_t>::const_iterator it(vecIndentation.begin());
33 bool isCurrentLower(true);
34 while(isCurrentLower && it != vecIndentation.end()){
35 isCurrentLower = *it < currentIndentation;
36 if(isCurrentLower){
37 ++depth;
38 }
39 ++it;
40 }
41 VecValue * out = getLastVecValue(vecAllVal, depth);
42 return out;
43}

References getLastVecValue().

Referenced by addChildToParentVecValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getParentVecValueListItem()

VecValue * getParentVecValueListItem ( VecValue & vecAllVal,
const std::vector< size_t > & vecIndentation,
size_t currentIndentation )

◆ vecValueToDicoValue()

void vecValueToDicoValue ( DicoValue & dicoValue,
const VecValue & vecVal,
bool isMainValue )

Convert a VecValue into a DicoValue.

Parameters
[out]dicoValue: converted DicoValue
vecVal: vector of value
isMainValue: true if the VecValue is the main one

Definition at line 153 of file vec_value_utils.cpp.

153 {
154 PString key(vecVal.getKey());
155 const VecVecValue & vecChildren = vecVal.getVecChild();
156 if(vecChildren.size() == 0lu){
157 PString value(vecVal.getValue());
158 if(key == ""){ //The vecVal is a value only
159 DicoValue subDico;
160 subDico.setValue(value);
161 dicoValue.getVecChild().push_back(subDico);
162 }else{ //The vecVal is a key-value
163 DicoValue subDico;
164 subDico.setKey(key);
165 subDico.setValue(value);
166 dicoValue.getMapChild()[key] = subDico;
167 }
168 }else{
169 if(key != ""){
170 DicoValue subDico;
171 subDico.setKey(vecVal.getKey());
172 for(VecVecValue::const_iterator it(vecChildren.begin()); it != vecChildren.end(); ++it){
173 vecValueToDicoValue(subDico, *it, false);
174 }
175 dicoValue.getMapChild()[key] = subDico;
176 }else{
177 if(isMainValue){
178 for(VecVecValue::const_iterator it(vecChildren.begin()); it != vecChildren.end(); ++it){
179 vecValueToDicoValue(dicoValue, *it, false);
180 }
181 }else{
182 DicoValue dashValue;
183 for(VecVecValue::const_iterator it(vecChildren.begin()); it != vecChildren.end(); ++it){
184 vecValueToDicoValue(dashValue, *it, false);
185 }
186 dicoValue.getVecChild().push_back(dashValue);
187 }
188 }
189 }
190}
const PString & getValue() const
Gets the value of the VecValue.
Definition VecValue.cpp:76
const PString & getKey() const
Gets the key of the VecValue.
Definition VecValue.cpp:90
void vecValueToDicoValue(DicoValue &dicoValue, const VecValue &vecVal, bool isMainValue)
Convert a VecValue into a DicoValue.

References VecValue::getKey(), VecValue::getValue(), VecValue::getVecChild(), and vecValueToDicoValue().

Referenced by parser_yml(), and vecValueToDicoValue().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: