PhoenixInkscape  2.0.0
Generate multiple png files with svg inkscape files
DicoValue Class Reference

Dictionnary of values. More...

#include <DicoValue.h>

+ Collaboration diagram for DicoValue:

Public Member Functions

 DicoValue ()
 Constructor of class DicoValue. More...
 
 DicoValue (const DicoValue &other)
 Copy Constructor of class DicoValue. More...
 
bool fromString (const PString &content)
 Create a DicoValue from a PString. More...
 
PStringgetKey ()
 Gets the key of the DicoValue. More...
 
const PStringgetKey () const
 Gets the key of the DicoValue. More...
 
DicoValuegetMap (const PString &key)
 Get a DicoValue in the map of the current one. More...
 
const DicoValuegetMap (const PString &key) const
 Get a DicoValue in the map of the current one. More...
 
std::map< PString, DicoValue > & getMapChild ()
 Gets the mapChild of the DicoValue. More...
 
const std::map< PString, DicoValue > & getMapChild () const
 Gets the mapChild of the DicoValue. More...
 
PString getString () const
 Get a string value without the first and/or last quote or double quote in there are some. More...
 
PStringgetValue ()
 Gets the value of the DicoValue. More...
 
template<typename T >
getValue () const
 Convert the value of the current DicoValue into a type. More...
 
const PStringgetValue () const
 Gets the value of the DicoValue. More...
 
std::vector< DicoValue > & getVecChild ()
 Gets the vecChild of the DicoValue. More...
 
const std::vector< DicoValue > & getVecChild () const
 Gets the vecChild of the DicoValue. More...
 
bool hasKey () const
 Say if the DicoValue has a key. More...
 
bool hasMap () const
 Say if the DicoValue has a map of children. More...
 
bool hasVec () const
 Say if the DicoValue has a vector of children. More...
 
bool isKeyExist (const PString &key) const
 Say if the given key exists in the map of children. More...
 
bool load (const PPath &fileName)
 Load the DicoValue with a text file. More...
 
DicoValueoperator= (const DicoValue &other)
 Operator = of class DicoValue. More...
 
void print () const
 Print the DicoValue. More...
 
bool save (const PPath &fileName, const PString &valueDecorator="", PString baseIndentation="\t", PString baseNewLine="\n") const
 Save the DicoValue with a text file. More...
 
void setKey (const PString &key)
 Sets the key of the DicoValue. More...
 
void setMapChild (const std::map< PString, DicoValue > &mapChild)
 Sets the mapChild of the DicoValue. More...
 
void setValue (const PString &value)
 Sets the value of the DicoValue. More...
 
void setVecChild (const std::vector< DicoValue > &vecChild)
 Sets the vecChild of the DicoValue. More...
 
PString toString (const PString &valueDecorator="", PString baseIndentation="\t", PString baseNewLine="\n") const
 Convert the DicoValue into a string. More...
 
virtual ~DicoValue ()
 Destructor of class DicoValue. More...
 

Protected Member Functions

void copyDicoValue (const DicoValue &other)
 Copy Function of class DicoValue. More...
 

Private Member Functions

bool errorAt (PFileParser &parser, bool &isRunning, const PString &errorMsg)
 Print the parsing error. More...
 
bool loadParser (PFileParser &parser)
 Load the DicoValue with a parser. More...
 
bool parseDicoValue (PFileParser &parser, bool &isRunning)
 Parse a DicoValue with a text file. More...
 
bool parseListOrMap (PFileParser &parser, bool &isRunning)
 Parse a list or a map. More...
 
PString parseString (PFileParser &parser)
 Parse a string. More...
 
PString saveRecurse (const PString &indentation, const PString &valueDecorator, PString baseIndentation, PString baseNewLine) const
 Save the DicoValue with a text file. More...
 

Private Attributes

PString p_key
 Key of the current entry. More...
 
std::map< PString, DicoValuep_mapChild
 Map of sub DicoValue. More...
 
PString p_value
 Value of the current entry. More...
 
std::vector< DicoValuep_vecChild
 Vector of sub DicoValue. More...
 

Detailed Description

Dictionnary of values.

Definition at line 17 of file DicoValue.h.

Constructor & Destructor Documentation

◆ DicoValue() [1/2]

DicoValue::DicoValue ( )

Constructor of class DicoValue.

Definition at line 11 of file DicoValue.cpp.

11  {
12 
13 }

◆ DicoValue() [2/2]

DicoValue::DicoValue ( const DicoValue other)

Copy Constructor of class DicoValue.

Parameters
other: DicoValue we want ot copy

Definition at line 18 of file DicoValue.cpp.

18  {
19  copyDicoValue(other);
20 }
void copyDicoValue(const DicoValue &other)
Copy Function of class DicoValue.
Definition: DicoValue.cpp:232

References copyDicoValue().

+ Here is the call graph for this function:

◆ ~DicoValue()

DicoValue::~DicoValue ( )
virtual

Destructor of class DicoValue.

Definition at line 23 of file DicoValue.cpp.

23  {
24 
25 }

Member Function Documentation

◆ copyDicoValue()

void DicoValue::copyDicoValue ( const DicoValue other)
protected

Copy Function of class DicoValue.

Parameters
other: DicoValue we want ot copy

Definition at line 232 of file DicoValue.cpp.

232  {
233  p_value = other.p_value;
234  p_key = other.p_key;
235  p_vecChild = other.p_vecChild;
236  p_mapChild = other.p_mapChild;
237 }
PString p_value
Value of the current entry.
Definition: DicoValue.h:67
PString p_key
Key of the current entry.
Definition: DicoValue.h:69
std::map< PString, DicoValue > p_mapChild
Map of sub DicoValue.
Definition: DicoValue.h:73
std::vector< DicoValue > p_vecChild
Vector of sub DicoValue.
Definition: DicoValue.h:71

References p_key, p_mapChild, p_value, and p_vecChild.

Referenced by DicoValue(), and operator=().

+ Here is the caller graph for this function:

◆ errorAt()

bool DicoValue::errorAt ( PFileParser parser,
bool &  isRunning,
const PString errorMsg 
)
private

Print the parsing error.

Parameters
[out]parser: parser to be used
[out]isRunning: true to continue the parsing, false to stop it
errorMsg: error message
Returns
true and stop the parsing with isRunning

Definition at line 337 of file DicoValue.cpp.

337  {
338  isRunning = false;
339  std::cerr << "DicoValue::errorAt : " << parser.getLocation() << std::endl;
340  std::cerr << "\t" << errorMsg << std::endl;
341  return true;
342 }
PLocation getLocation() const
Fonction qui renvoie la PLocation du PFileParser.

References PFileParser::getLocation().

Referenced by loadParser(), parseDicoValue(), and parseListOrMap().

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

◆ fromString()

bool DicoValue::fromString ( const PString content)

Create a DicoValue from a PString.

Parameters
content: content to be parsed
Returns
true on success, false otherwise

Definition at line 62 of file DicoValue.cpp.

62  {
63  PFileParser parser;
64  parser.setFileContent(content);
65  return loadParser(parser);
66 }
bool loadParser(PFileParser &parser)
Load the DicoValue with a parser.
Definition: DicoValue.cpp:243
classe qui permet de parser des fichiers texte en renvoyant les tokens les uns après les autres
Definition: PFileParser.h:20
void setFileContent(const PString &fileContent)
Set the file content.
Definition: PFileParser.cpp:50

References loadParser(), and PFileParser::setFileContent().

Referenced by testFromJSonToJSon().

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

◆ getKey() [1/2]

PString & DicoValue::getKey ( )

Gets the key of the DicoValue.

Returns
key of the DicoValue

Definition at line 197 of file DicoValue.cpp.

197  {
198  return p_key;
199 }

References p_key.

◆ getKey() [2/2]

const PString & DicoValue::getKey ( ) const

Gets the key of the DicoValue.

Returns
key of the DicoValue

Definition at line 190 of file DicoValue.cpp.

190  {
191  return p_key;
192 }

References p_key.

Referenced by dico_find_all_var(), and testDicoValue().

+ Here is the caller graph for this function:

◆ getMap() [1/2]

DicoValue * DicoValue::getMap ( const PString key)

Get a DicoValue in the map of the current one.

Parameters
key: name of the DicoValue to get
Returns
pointer to the found DicoValue if it exists, NULL otherwise

Definition at line 129 of file DicoValue.cpp.

129  {
130  std::map<PString, DicoValue>::const_iterator it(p_mapChild.find(key));
131  if(it != p_mapChild.end()){
132  return (DicoValue *)&(it->second);
133  }else{
134  return NULL;
135  }
136 }
Dictionnary of values.
Definition: DicoValue.h:17

References p_mapChild.

◆ getMap() [2/2]

const DicoValue * DicoValue::getMap ( const PString key) const

Get a DicoValue in the map of the current one.

Parameters
key: name of the DicoValue to get
Returns
pointer to the found DicoValue if it exists, NULL otherwise

Definition at line 116 of file DicoValue.cpp.

116  {
117  std::map<PString, DicoValue>::const_iterator it(p_mapChild.find(key));
118  if(it != p_mapChild.end()){
119  return &(it->second);
120  }else{
121  return NULL;
122  }
123 }

References p_mapChild.

Referenced by checkConstDicoValue(), phoenix_get_string(), phoenix_get_vecstring(), phoenix_load_value_from_config(), phoenix_load_value_from_config< bool >(), phoenix_load_value_from_dico(), phoenix_load_value_from_dico< bool >(), phoenix_load_vecValue_from_config(), testDicoDicoString(), testDicoDicoValueKeyPtr(), testDicoValue(), testDicoValue3(), testDicoVecString(), and testDicoVecValue().

+ Here is the caller graph for this function:

◆ getMapChild() [1/2]

std::map< PString, DicoValue > & DicoValue::getMapChild ( )

Gets the mapChild of the DicoValue.

Returns
mapChild of the DicoValue

Definition at line 225 of file DicoValue.cpp.

225  {
226  return p_mapChild;
227 }

References p_mapChild.

◆ getMapChild() [2/2]

const std::map< PString, DicoValue > & DicoValue::getMapChild ( ) const

Gets the mapChild of the DicoValue.

Returns
mapChild of the DicoValue

Definition at line 218 of file DicoValue.cpp.

218  {
219  return p_mapChild;
220 }

References p_mapChild.

Referenced by checkLoadFromConfig(), dico_find_all_var(), phoenix_save_value_to_dico(), testDicoDicoValueKeyPtr(), testDicoValue(), and testDicoValue2().

+ Here is the caller graph for this function:

◆ getString()

PString DicoValue::getString ( ) const

Get a string value without the first and/or last quote or double quote in there are some.

Returns
value without the first and/or last quote or double quote in there are some

Definition at line 183 of file DicoValue.cpp.

183  {
184  return p_value.eraseFirstLastChar("\"\'");
185 }
PString eraseFirstLastChar(const PString &vecChar) const
Erase first and last char in a string.
Definition: PString.cpp:545

References PString::eraseFirstLastChar(), and p_value.

Referenced by dico_find_all_var(), phoenix_get_string(), phoenix_load_value_from_config< bool >(), and phoenix_load_value_from_dico< bool >().

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

◆ getValue() [1/3]

PString & DicoValue::getValue ( )

Gets the value of the DicoValue.

Returns
value of the DicoValue

Definition at line 176 of file DicoValue.cpp.

176  {
177  return p_value;
178 }

References p_value.

◆ getValue() [2/3]

template<typename T >
T DicoValue::getValue

Convert the value of the current DicoValue into a type.

Returns
converted value of the current DicoValue

Definition at line 16 of file DicoValue_impl.h.

16  {
17  return stringToValue<T>(p_value);
18 }

References p_value.

Referenced by dico_update_all_nestedCall(), phoenix_load_value_from_config(), phoenix_load_value_from_dico(), testDicoValue(), testDicoValueKey(), and testDicoValueKeyPtr().

+ Here is the caller graph for this function:

◆ getValue() [3/3]

const PString & DicoValue::getValue ( ) const

Gets the value of the DicoValue.

Returns
value of the DicoValue

Definition at line 169 of file DicoValue.cpp.

169  {
170  return p_value;
171 }

References p_value.

◆ getVecChild() [1/2]

std::vector< DicoValue > & DicoValue::getVecChild ( )

Gets the vecChild of the DicoValue.

Returns
vecChild of the DicoValue

Definition at line 211 of file DicoValue.cpp.

211  {
212  return p_vecChild;
213 }

References p_vecChild.

◆ getVecChild() [2/2]

const std::vector< DicoValue > & DicoValue::getVecChild ( ) const

Gets the vecChild of the DicoValue.

Returns
vecChild of the DicoValue

Definition at line 204 of file DicoValue.cpp.

204  {
205  return p_vecChild;
206 }

References p_vecChild.

Referenced by checkLoadFromConfig(), dico_find_all_var(), phoenix_get_vecstring(), phoenix_load_vecValue_from_config(), testDicoValue(), and testDicoVecValueKeyPtr().

+ Here is the caller graph for this function:

◆ hasKey()

bool DicoValue::hasKey ( ) const

Say if the DicoValue has a key.

Returns
true if the DicoValue has a key, false otherwise

Definition at line 91 of file DicoValue.cpp.

91 {return p_key != "";}

References p_key.

Referenced by checkLoadFromConfig(), and dico_find_all_var().

+ Here is the caller graph for this function:

◆ hasMap()

bool DicoValue::hasMap ( ) const

Say if the DicoValue has a map of children.

Returns
true if the DicoValue has a map of children, false otherwise

Definition at line 96 of file DicoValue.cpp.

96 {return p_mapChild.size() != 0lu;}

References p_mapChild.

Referenced by checkLoadFromConfig(), and dico_find_all_var().

+ Here is the caller graph for this function:

◆ hasVec()

bool DicoValue::hasVec ( ) const

Say if the DicoValue has a vector of children.

Returns
true if the DicoValue has a vector of children, false otherwise

Definition at line 101 of file DicoValue.cpp.

101 {return p_vecChild.size() != 0lu;}

References p_vecChild.

Referenced by checkLoadFromConfig(), and dico_find_all_var().

+ Here is the caller graph for this function:

◆ isKeyExist()

bool DicoValue::isKeyExist ( const PString key) const

Say if the given key exists in the map of children.

Parameters
key: key to be checked
Returns
true if the given key exists in the map of children, false otherwise

Definition at line 107 of file DicoValue.cpp.

107  {
108  std::map<PString, DicoValue>::const_iterator it(p_mapChild.find(key));
109  return it != p_mapChild.end();
110 }

References p_mapChild.

Referenced by testDicoValue2().

+ Here is the caller graph for this function:

◆ load()

bool DicoValue::load ( const PPath fileName)

Load the DicoValue with a text file.

Parameters
fileName: name of the file to be loaded
Returns
true on success, false otherwise

Definition at line 40 of file DicoValue.cpp.

40  {
41  PFileParser parser;
42  if(!parser.open(fileName)){return false;}
43  return loadParser(parser);
44 }
bool open(const PPath &fileName)
Fonction qui ouvre le fichier que l'on va parser.
Definition: PFileParser.cpp:24

References loadParser(), and PFileParser::open().

Referenced by testDicoBadParsing(), testDicoDicoString(), testDicoGoodParsing(), testDicoValue(), testDicoValue2(), testDicoValue3(), testDicoVecString(), testDicoVecValue(), and testFromJSonToJSon().

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

◆ loadParser()

bool DicoValue::loadParser ( PFileParser parser)
private

Load the DicoValue with a parser.

Parameters
[out]parser: parser to be used
Returns
true on success, false otherwise

Definition at line 243 of file DicoValue.cpp.

243  {
244  parser.setEscapeChar('\\');
245  parser.setWhiteSpace(" \t\n");
246  parser.setSeparator(",:{}\"");
247  bool isRunning(true);
248  while(!parser.isEndOfFile() && isRunning){
249  if(parseDicoValue(parser, isRunning)){
250  parser.skipWhiteSpace();
251  }else{
252  errorAt(parser, isRunning, "Cannot parse dico value");
253  }
254  }
255  return isRunning;
256 }
bool parseDicoValue(PFileParser &parser, bool &isRunning)
Parse a DicoValue with a text file.
Definition: DicoValue.cpp:263
bool errorAt(PFileParser &parser, bool &isRunning, const PString &errorMsg)
Print the parsing error.
Definition: DicoValue.cpp:337
void setSeparator(const PString &separator)
Initialise la liste des caractères séparateurs.
Definition: PFileParser.cpp:43
void setEscapeChar(char escapeChar)
Sets the escape character of the PFileParser.
Definition: PFileParser.cpp:58
void setWhiteSpace(const PString &whiteSpace)
Initialise la liste des caractères blancs.
Definition: PFileParser.cpp:35
void skipWhiteSpace()
Skip the white space if there is at the current caracter position.
bool isEndOfFile() const
Dit si on est à la fin du fichier.
Definition: PFileParser.cpp:88

References errorAt(), PFileParser::isEndOfFile(), parseDicoValue(), PFileParser::setEscapeChar(), PFileParser::setSeparator(), PFileParser::setWhiteSpace(), and PFileParser::skipWhiteSpace().

Referenced by fromString(), and load().

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

◆ operator=()

DicoValue & DicoValue::operator= ( const DicoValue other)

Operator = of class DicoValue.

Parameters
other: DicoValue we want ot copy
Returns
copied class DicoValue

Definition at line 31 of file DicoValue.cpp.

31  {
32  copyDicoValue(other);
33  return *this;
34 }

References copyDicoValue().

+ Here is the call graph for this function:

◆ parseDicoValue()

bool DicoValue::parseDicoValue ( PFileParser parser,
bool &  isRunning 
)
private

Parse a DicoValue with a text file.

Parameters
[out]parser: parser to be used
[out]isRunning: true to continue the parsing, false to stop it
Returns
true on success, false otherwise

Definition at line 263 of file DicoValue.cpp.

263  {
264  if(parseListOrMap(parser, isRunning)){return true;}
265  else{
266  PString nextKeyOrValue(parseString(parser));
267  if(nextKeyOrValue == ""){
268  nextKeyOrValue = parser.getStrComposedOf("abcdefghijklmnopqsrtuvwxyzABCDEFGHIJKLMNOPQSRTUVWXYZ0123456789._-+");
269  if(nextKeyOrValue == ""){
270  return errorAt(parser, isRunning,
271  "Expecting a string or a keywork composed of letters, number, underscore, slash or minus");
272  }
273  }
274  if(parser.isMatch(":")){ //It was a key for a dictionnary
275 // std::cerr << "DicoValue::parseDicoValue : find key '"<<nextKeyOrValue<<"'" << std::endl;
276  p_key = nextKeyOrValue;
277  if(!parseDicoValue(parser, isRunning)){
278  return errorAt(parser, isRunning, "Cannot parse value");
279  }
280  }else{ //It was a value
281  p_value = nextKeyOrValue;
282  }
283  parser.skipWhiteSpace();
284  }
285  return true;
286 }
bool parseListOrMap(PFileParser &parser, bool &isRunning)
Parse a list or a map.
Definition: DicoValue.cpp:293
PString parseString(PFileParser &parser)
Parse a string.
Definition: DicoValue.cpp:322
PString getStrComposedOf(const PString &charset)
Get string composed of the characters in the string charset.
bool isMatch(const PString &patern)
Says if the patern match with the current caracters of the PFileParser.
Extends the std::string.
Definition: PString.h:16

References errorAt(), PFileParser::getStrComposedOf(), PFileParser::isMatch(), p_key, p_value, parseListOrMap(), parseString(), and PFileParser::skipWhiteSpace().

Referenced by loadParser(), and parseListOrMap().

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

◆ parseListOrMap()

bool DicoValue::parseListOrMap ( PFileParser parser,
bool &  isRunning 
)
private

Parse a list or a map.

Parameters
[out]parser: parser to be used
[out]isRunning: true to continue the parsing, false to stop it
Returns
true on success, false otherwise

Definition at line 293 of file DicoValue.cpp.

293  {
294  if(!parser.isMatch("{")){return false;} //If this is not a {, then it is not a list or a map
295 
296  while(!parser.isEndOfFile() && !parser.isMatch("}") && isRunning){
297  DicoValue dv;
298  if(dv.parseDicoValue(parser, isRunning)){
299  if(dv.p_key != ""){ //It is a dico entry
300 // std::cerr << "DicoValue::parseListOrMap : loadParser add DicoValue with key '"<<dv.p_key<<"'" << std::endl;
301  p_mapChild[dv.p_key] = dv;
302  }else{ //It is a value
303  p_vecChild.push_back(dv);
304  }
305  }else{
306  errorAt(parser, isRunning, "Cannot parse dico value");
307  }
308  if(parser.isMatch(",")){}
309  else if(parser.isMatchRewind("}")){}
310  else{
311  return errorAt(parser, isRunning, "Expect ',' or '}' after value");
312  }
313  }
314 
315  return true;
316 }
bool isMatchRewind(const PString &patern)
Do a isMatch and then go back at the previous position.

References errorAt(), PFileParser::isEndOfFile(), PFileParser::isMatch(), PFileParser::isMatchRewind(), p_key, p_mapChild, p_vecChild, and parseDicoValue().

Referenced by parseDicoValue().

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

◆ parseString()

PString DicoValue::parseString ( PFileParser parser)
private

Parse a string.

Parameters
[out]parser: parser to be used
Returns
true on success, false otherwise

Definition at line 322 of file DicoValue.cpp.

322  {
323  if(parser.isMatch("\"")){
324  return parser.getUntilKeyWithoutPatern("\"");
325  }else if(parser.isMatch("'")){
326  return parser.getUntilKeyWithoutPatern("'");
327  }
328  return "";
329 }
PString getUntilKeyWithoutPatern(const PString &patern)
Renvoie la chaine de caractère du caractère courant jusqu'à patern exclu.

References PFileParser::getUntilKeyWithoutPatern(), and PFileParser::isMatch().

Referenced by parseDicoValue().

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

◆ print()

void DicoValue::print ( ) const

Print the DicoValue.

Definition at line 82 of file DicoValue.cpp.

82  {
83  std::cout << "{" << std::endl;
84  std::cout << saveRecurse("\t", "\"", "\t", "\n") << std::endl;
85  std::cout << "{" << std::endl;
86 }
PString saveRecurse(const PString &indentation, const PString &valueDecorator, PString baseIndentation, PString baseNewLine) const
Save the DicoValue with a text file.
Definition: DicoValue.cpp:351

References saveRecurse().

+ Here is the call graph for this function:

◆ save()

bool DicoValue::save ( const PPath fileName,
const PString valueDecorator = "",
PString  baseIndentation = "\t",
PString  baseNewLine = "\n" 
) const

Save the DicoValue with a text file.

Parameters
fileName: name of the file to be saved
valueDecorator: string to add around keys and values ('"' for JSON)
baseIndentation: indentation character(s) to be used
baseNewLine: new line character(s) to be used
Returns
true on success, false otherwise

Definition at line 53 of file DicoValue.cpp.

53  {
54  PString out(toString(valueDecorator, baseIndentation, baseNewLine));
55  return fileName.saveFileContent(out);
56 }
PString toString(const PString &valueDecorator="", PString baseIndentation="\t", PString baseNewLine="\n") const
Convert the DicoValue into a string.
Definition: DicoValue.cpp:74
bool saveFileContent(const PString &content) const
Save a PString in a file.
Definition: PPath.cpp:395

References PPath::saveFileContent(), and toString().

Referenced by saveDico(), testDicoSaveParsing(), and testFromJSonToJSon().

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

◆ saveRecurse()

PString DicoValue::saveRecurse ( const PString indentation,
const PString valueDecorator,
PString  baseIndentation,
PString  baseNewLine 
) const
private

Save the DicoValue with a text file.

Parameters
indentation: indentation of the current DicoValue
valueDecorator: decorator to put around keys and values ('"' for JSON)
baseIndentation: indentation character(s) to be used
baseNewLine: new line character(s) to be used
Returns
file content

Definition at line 351 of file DicoValue.cpp.

351  {
352  PString out(""), newIndentation(indentation);
353  if(p_key != ""){
354  newIndentation = indentation + baseIndentation;
355  }
356  if(p_mapChild.size() != 0lu){
357  if(p_key != ""){out += baseNewLine + indentation +valueDecorator + p_key + valueDecorator + ": {";}
358  PString comma("");
359  for(MapDicoValue::const_iterator it(p_mapChild.begin()); it != p_mapChild.end(); ++it){
360  out += comma;
361  out += it->second.saveRecurse(newIndentation, valueDecorator, baseIndentation, baseNewLine);
362  comma = ",";
363  }
364  if(p_key != ""){out += baseNewLine+indentation+"}";}
365  }else if(p_vecChild.size() != 0lu){
366  if(p_key != ""){out += baseNewLine + indentation + valueDecorator + p_key + valueDecorator + ": {";}
367  PString comma("");
368  for(VecDicoValue::const_iterator it(p_vecChild.begin()); it != p_vecChild.end(); ++it){
369  out += comma;
370  out += it->saveRecurse(newIndentation, valueDecorator, baseIndentation, baseNewLine);
371  comma = ", ";
372  }
373  if(p_key != ""){out += "}";}
374  }else{
375  PString valueToSave(p_value);
376  if(valueDecorator != ""){
377  valueToSave = valueDecorator + p_value + valueDecorator;
378  }else if(p_value.find(" \t\n':/")){
379  valueToSave = "\"" + p_value + "\"";
380  }
381  if(p_key != ""){out += baseNewLine + indentation + valueDecorator + p_key + valueDecorator + ": "+valueToSave;}
382  else{out += valueToSave;}
383  }
384  return out;
385 }
bool find(char ch) const
Find a char in a string.
Definition: PString.cpp:371

References PString::find(), p_key, p_mapChild, p_value, and p_vecChild.

Referenced by print(), and toString().

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

◆ setKey()

void DicoValue::setKey ( const PString key)

Sets the key of the DicoValue.

Parameters
key: key of the DicoValue

Definition at line 148 of file DicoValue.cpp.

148  {
149  p_key = key;
150 }

References p_key.

Referenced by checkLoadFromConfig(), and phoenix_save_value_to_dico().

+ Here is the caller graph for this function:

◆ setMapChild()

void DicoValue::setMapChild ( const std::map< PString, DicoValue > &  mapChild)

Sets the mapChild of the DicoValue.

Parameters
mapChild: mapChild of the DicoValue

Definition at line 162 of file DicoValue.cpp.

162  {
163  p_mapChild = mapChild;
164 }

References p_mapChild.

Referenced by testDicoValue().

+ Here is the caller graph for this function:

◆ setValue()

void DicoValue::setValue ( const PString value)

Sets the value of the DicoValue.

Parameters
value: value of the DicoValue

Definition at line 141 of file DicoValue.cpp.

141  {
142  p_value = value;
143 }

References p_value.

Referenced by checkLoadFromConfig(), dico_update_all_nestedCall(), phoenix_save_value_to_dico(), and testDicoSaveParsing().

+ Here is the caller graph for this function:

◆ setVecChild()

void DicoValue::setVecChild ( const std::vector< DicoValue > &  vecChild)

Sets the vecChild of the DicoValue.

Parameters
vecChild: vecChild of the DicoValue

Definition at line 155 of file DicoValue.cpp.

155  {
156  p_vecChild = vecChild;
157 }

References p_vecChild.

Referenced by testDicoValue().

+ Here is the caller graph for this function:

◆ toString()

PString DicoValue::toString ( const PString valueDecorator = "",
PString  baseIndentation = "\t",
PString  baseNewLine = "\n" 
) const

Convert the DicoValue into a string.

Parameters
valueDecorator: string to add around keys and values ('"' for JSON)
baseIndentation: indentation character(s) to be used
baseNewLine: new line character(s) to be used
Returns
corresponding string

Definition at line 74 of file DicoValue.cpp.

74  {
75  PString out(baseNewLine+"{");
76  out += saveRecurse(baseIndentation, valueDecorator, baseIndentation, baseNewLine);
77  out += baseNewLine+"}"+baseNewLine;
78  return out;
79 }

References saveRecurse().

Referenced by save(), and testFromJSonToJSon().

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

Member Data Documentation

◆ p_key

PString DicoValue::p_key
private

Key of the current entry.

Definition at line 69 of file DicoValue.h.

Referenced by copyDicoValue(), getKey(), hasKey(), parseDicoValue(), parseListOrMap(), saveRecurse(), and setKey().

◆ p_mapChild

std::map<PString, DicoValue> DicoValue::p_mapChild
private

◆ p_value

PString DicoValue::p_value
private

Value of the current entry.

Definition at line 67 of file DicoValue.h.

Referenced by copyDicoValue(), getString(), getValue(), parseDicoValue(), saveRecurse(), and setValue().

◆ p_vecChild

std::vector<DicoValue> DicoValue::p_vecChild
private

Vector of sub DicoValue.

Definition at line 71 of file DicoValue.h.

Referenced by copyDicoValue(), getVecChild(), hasVec(), parseListOrMap(), saveRecurse(), and setVecChild().


The documentation for this class was generated from the following files: