![]() |
PhoenixInkscape
2.0.0
Generate multiple png files with svg inkscape files
|
Dictionnary of values. More...
#include <DicoValue.h>
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... | |
const DicoValue * | getElementInVecWhere (const PString &key, const PString &value) const |
Get the element of a vector of children of the current DicoValue which has 'key'.value = value. More... | |
PString & | getKey () |
Gets the key of the DicoValue. More... | |
const PString & | getKey () const |
Gets the key of the DicoValue. More... | |
DicoValue * | getMap (const PString &key) |
Get a DicoValue in the map of the current one. More... | |
const DicoValue * | getMap (const PString &key) const |
Get a DicoValue in the map of the current one. More... | |
const DicoValue * | getMap (const PVecString &vecKey) const |
Get a nested 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... | |
PString & | getValue () |
Gets the value of the DicoValue. More... | |
template<typename T > | |
T | getValue () const |
Convert the value of the current DicoValue into a type. More... | |
const PString & | getValue () 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... | |
DicoValue & | operator= (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 | parseList (PFileParser &parser, bool &isRunning) |
Parse a list or a map. More... | |
bool | parseListOrMap (PFileParser &parser, bool &isRunning) |
Parse a list or a map. More... | |
bool | parseString (PString &parsedString, PFileParser &parser) |
Parse a string. More... | |
PString | saveRecurse (const PString &indentation, const PString &valueDecorator, PString baseIndentation, PString baseNewLine, bool isInList=false) const |
Save the DicoValue with a text file. More... | |
Private Attributes | |
PString | p_key |
Key of the current entry. More... | |
std::map< PString, DicoValue > | p_mapChild |
Map of sub DicoValue. More... | |
PString | p_value |
Value of the current entry. More... | |
std::vector< DicoValue > | p_vecChild |
Vector of sub DicoValue. More... | |
Dictionnary of values.
Definition at line 17 of file DicoValue.h.
DicoValue::DicoValue | ( | ) |
DicoValue::DicoValue | ( | const DicoValue & | other | ) |
Copy Constructor of class DicoValue.
other | : DicoValue we want ot copy |
Definition at line 18 of file DicoValue.cpp.
References copyDicoValue().
|
virtual |
|
protected |
Copy Function of class DicoValue.
other | : DicoValue we want ot copy |
Definition at line 278 of file DicoValue.cpp.
References p_key, p_mapChild, p_value, and p_vecChild.
Referenced by DicoValue(), and operator=().
|
private |
Print the parsing error.
[out] | parser | : parser to be used |
[out] | isRunning | : true to continue the parsing, false to stop it |
errorMsg | : error message |
Definition at line 419 of file DicoValue.cpp.
References PFileParser::getLocation(), and PFileParser::getNextToken().
Referenced by loadParser(), parseDicoValue(), parseList(), and parseListOrMap().
bool DicoValue::fromString | ( | const PString & | content | ) |
Create a DicoValue from a PString.
content | : content to be parsed |
Definition at line 62 of file DicoValue.cpp.
References loadParser(), PFileParser::setEscapeChar(), and PFileParser::setFileContent().
Referenced by testFromJSonToJSon().
const DicoValue * DicoValue::getElementInVecWhere | ( | const PString & | key, |
const PString & | value | ||
) | const |
Get the element of a vector of children of the current DicoValue which has 'key'.value = value.
key | : key to be found in a child of the current DicoValue |
value | : expected value of the child |
Definition at line 149 of file DicoValue.cpp.
References getMap(), getString(), hasVec(), p_mapChild, and p_vecChild.
PString & DicoValue::getKey | ( | ) |
const PString & DicoValue::getKey | ( | ) | const |
Gets the key of the DicoValue.
Definition at line 236 of file DicoValue.cpp.
References p_key.
Referenced by dico_find_all_var(), and testDicoValue().
Get a DicoValue in the map of the current one.
key | : name of the DicoValue to get |
Definition at line 175 of file DicoValue.cpp.
References p_mapChild.
Get a DicoValue in the map of the current one.
key | : name of the DicoValue to get |
Definition at line 117 of file DicoValue.cpp.
References p_mapChild.
Referenced by checkConstDicoValue(), getElementInVecWhere(), getMap(), phoenix_get_nested_string(), 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().
const DicoValue * DicoValue::getMap | ( | const PVecString & | vecKey | ) | const |
Get a nested DicoValue in the map of the current one.
vecKey | : full address name of the DicoValue to get |
Definition at line 130 of file DicoValue.cpp.
References getMap(), and hasMap().
Gets the mapChild of the DicoValue.
Definition at line 271 of file DicoValue.cpp.
References p_mapChild.
Gets the mapChild of the DicoValue.
Definition at line 264 of file DicoValue.cpp.
References p_mapChild.
Referenced by checkLoadFromConfig(), dico_find_all_var(), phoenix_save_value_to_dico(), testDicoDicoValueKeyPtr(), testDicoValue(), and testDicoValue2().
PString DicoValue::getString | ( | ) | const |
Get a string value without the first and/or last quote or double quote in there are some.
Definition at line 229 of file DicoValue.cpp.
References PString::eraseFirstLastChar(), and p_value.
Referenced by dico_find_all_var(), getElementInVecWhere(), phoenix_get_nested_string(), phoenix_get_string(), phoenix_load_value_from_config< bool >(), and phoenix_load_value_from_dico< bool >().
PString & DicoValue::getValue | ( | ) |
T DicoValue::getValue |
Convert the value of the current DicoValue into a type.
Definition at line 16 of file DicoValue_impl.h.
References p_value.
Referenced by dico_update_all_nestedCall(), phoenix_load_value_from_config(), phoenix_load_value_from_dico(), testDicoValue(), testDicoValueKey(), and testDicoValueKeyPtr().
const PString & DicoValue::getValue | ( | ) | const |
std::vector< DicoValue > & DicoValue::getVecChild | ( | ) |
Gets the vecChild of the DicoValue.
Definition at line 257 of file DicoValue.cpp.
References p_vecChild.
const std::vector< DicoValue > & DicoValue::getVecChild | ( | ) | const |
Gets the vecChild of the DicoValue.
Definition at line 250 of file DicoValue.cpp.
References p_vecChild.
Referenced by checkLoadFromConfig(), dico_find_all_var(), phoenix_get_vecstring(), phoenix_load_vecValue_from_config(), testDicoValue(), and testDicoVecValueKeyPtr().
bool DicoValue::hasKey | ( | ) | const |
Say if the DicoValue has a key.
Definition at line 92 of file DicoValue.cpp.
References p_key.
Referenced by checkLoadFromConfig(), and dico_find_all_var().
bool DicoValue::hasMap | ( | ) | const |
Say if the DicoValue has a map of children.
Definition at line 97 of file DicoValue.cpp.
References p_mapChild.
Referenced by checkLoadFromConfig(), dico_find_all_var(), and getMap().
bool DicoValue::hasVec | ( | ) | const |
Say if the DicoValue has a vector of children.
Definition at line 102 of file DicoValue.cpp.
References p_vecChild.
Referenced by checkLoadFromConfig(), dico_find_all_var(), and getElementInVecWhere().
bool DicoValue::isKeyExist | ( | const PString & | key | ) | const |
Say if the given key exists in the map of children.
key | : key to be checked |
Definition at line 108 of file DicoValue.cpp.
References p_mapChild.
Referenced by testDicoValue2().
bool DicoValue::load | ( | const PPath & | fileName | ) |
Load the DicoValue with a text file.
fileName | : name of the file to be loaded |
Definition at line 40 of file DicoValue.cpp.
References loadParser(), and PFileParser::open().
Referenced by testDicoBadParsing(), testDicoDicoString(), testDicoGoodParsing(), testDicoValue(), testDicoValue2(), testDicoValue3(), testDicoVecString(), testDicoVecValue(), and testFromJSonToJSon().
|
private |
Load the DicoValue with a parser.
[out] | parser | : parser to be used |
Definition at line 289 of file DicoValue.cpp.
References errorAt(), PFileParser::isEndOfFile(), parseDicoValue(), PFileParser::setEscapeChar(), PFileParser::setSeparator(), PFileParser::setWhiteSpace(), and PFileParser::skipWhiteSpace().
Referenced by fromString(), and load().
Operator = of class DicoValue.
other | : DicoValue we want ot copy |
Definition at line 31 of file DicoValue.cpp.
References copyDicoValue().
|
private |
Parse a DicoValue with a text file.
[out] | parser | : parser to be used |
[out] | isRunning | : true to continue the parsing, false to stop it |
Definition at line 309 of file DicoValue.cpp.
References errorAt(), PFileParser::getStrComposedOf(), PFileParser::isMatch(), p_key, p_value, parseList(), parseListOrMap(), parseString(), and PFileParser::skipWhiteSpace().
Referenced by loadParser(), parseList(), and parseListOrMap().
|
private |
Parse a list or a map.
[out] | parser | : parser to be used |
[out] | isRunning | : true to continue the parsing, false to stop it |
Definition at line 370 of file DicoValue.cpp.
References errorAt(), PFileParser::isEndOfFile(), PFileParser::isMatch(), PFileParser::isMatchRewind(), p_key, p_mapChild, p_vecChild, and parseDicoValue().
Referenced by parseDicoValue().
|
private |
Parse a list or a map.
[out] | parser | : parser to be used |
[out] | isRunning | : true to continue the parsing, false to stop it |
Definition at line 341 of file DicoValue.cpp.
References errorAt(), PFileParser::isEndOfFile(), PFileParser::isMatch(), PFileParser::isMatchRewind(), p_key, p_mapChild, p_vecChild, and parseDicoValue().
Referenced by parseDicoValue().
|
private |
Parse a string.
[out] | parsedString | : parsed string |
[out] | parser | : parser to be used |
Definition at line 400 of file DicoValue.cpp.
References PFileParser::getUntilKeyWithoutPatern(), and PFileParser::isMatch().
Referenced by parseDicoValue().
void DicoValue::print | ( | ) | const |
Print the DicoValue.
Definition at line 83 of file DicoValue.cpp.
References saveRecurse().
bool DicoValue::save | ( | const PPath & | fileName, |
const PString & | valueDecorator = "" , |
||
PString | baseIndentation = "\t" , |
||
PString | baseNewLine = "\n" |
||
) | const |
Save the DicoValue with a text file.
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 |
Definition at line 53 of file DicoValue.cpp.
References PPath::saveFileContent(), and toString().
Referenced by saveDico(), testDicoSaveParsing(), and testFromJSonToJSon().
|
private |
Save the DicoValue with a text file.
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 |
isInList | : true if the dico value is in a list |
Definition at line 435 of file DicoValue.cpp.
References PString::find(), p_key, p_mapChild, p_value, and p_vecChild.
Referenced by print(), and toString().
void DicoValue::setKey | ( | const PString & | key | ) |
Sets the key of the DicoValue.
key | : key of the DicoValue |
Definition at line 194 of file DicoValue.cpp.
References p_key.
Referenced by checkLoadFromConfig(), and phoenix_save_value_to_dico().
Sets the mapChild of the DicoValue.
mapChild | : mapChild of the DicoValue |
Definition at line 208 of file DicoValue.cpp.
References p_mapChild.
Referenced by testDicoValue().
void DicoValue::setValue | ( | const PString & | value | ) |
Sets the value of the DicoValue.
value | : value of the DicoValue |
Definition at line 187 of file DicoValue.cpp.
References p_value.
Referenced by checkLoadFromConfig(), dico_update_all_nestedCall(), phoenix_save_value_to_dico(), and testDicoSaveParsing().
void DicoValue::setVecChild | ( | const std::vector< DicoValue > & | vecChild | ) |
Sets the vecChild of the DicoValue.
vecChild | : vecChild of the DicoValue |
Definition at line 201 of file DicoValue.cpp.
References p_vecChild.
Referenced by testDicoValue().
PString DicoValue::toString | ( | const PString & | valueDecorator = "" , |
PString | baseIndentation = "\t" , |
||
PString | baseNewLine = "\n" |
||
) | const |
Convert the DicoValue into a string.
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 |
Definition at line 75 of file DicoValue.cpp.
References saveRecurse().
Referenced by save(), and testFromJSonToJSon().
|
private |
Key of the current entry.
Definition at line 72 of file DicoValue.h.
Referenced by copyDicoValue(), getKey(), hasKey(), parseDicoValue(), parseList(), parseListOrMap(), saveRecurse(), and setKey().
Map of sub DicoValue.
Definition at line 76 of file DicoValue.h.
Referenced by copyDicoValue(), getElementInVecWhere(), getMap(), getMapChild(), hasMap(), isKeyExist(), parseList(), parseListOrMap(), saveRecurse(), and setMapChild().
|
private |
Value of the current entry.
Definition at line 70 of file DicoValue.h.
Referenced by copyDicoValue(), getString(), getValue(), parseDicoValue(), saveRecurse(), and setValue().
|
private |
Vector of sub DicoValue.
Definition at line 74 of file DicoValue.h.
Referenced by copyDicoValue(), getElementInVecWhere(), getVecChild(), hasVec(), parseList(), parseListOrMap(), saveRecurse(), and setVecChild().