PhoenixFileParser  1.5.1
Set of tools to ease file parsing
Loading...
Searching...
No Matches
ConfigNode.h
Go to the documentation of this file.
1/***************************************
2 Auteur : Pierre Aubert
3 Mail : pierre.aubert@lapp.in2p3.fr
4 Licence : CeCILL-C
5****************************************/
6
7#ifndef __CONFIGNODE_H__
8#define __CONFIGNODE_H__
9
10#include <vector>
11#include <map>
12#include "PString.h"
13#include "PLocation.h"
14
15class ConfigNodeIter;
16
19 public:
20 ConfigNode();
21 virtual ~ConfigNode();
22 void setValue(const PString & value);
23 void setName(const PString & name);
24 void setVecChild(const std::vector<ConfigNode*> & vecChild);
25 void setMapChild(const std::map<PString, ConfigNode*> & mapChild);
26 void setLocation(const PLocation & location);
27
28 const PString & getValue() const;
29 PString & getValue();
30 const PString & getName() const;
31 PString & getName();
32 const std::vector<ConfigNode*> & getVecChild() const;
33 std::vector<ConfigNode*> & getVecChild();
34 const std::map<PString, ConfigNode*> & getMapChild() const;
35 std::map<PString, ConfigNode*> & getMapChild();
36 PLocation getLocation() const;
37 const ConfigNode* getParent() const;
38
39 void setFileName(const PPath & fileName);
40 const PPath & getFileName() const;
41 void setLineCol(const PLocation & location);
42 ConfigNode * addChild(const PString & name = "");
43 ConfigNode * getChild(const PString & name);
44 const ConfigNode * getChild(const PString & name) const;
45 ConfigNode * addValue(const PString & value);
46 PString getString() const;
47
48 bool hasValue() const;
49 bool hasVecChild() const;
50 bool hasMapChild() const;
51
52 void clear();
53
54 ConfigNodeIter iter(std::ostream & out = std::cout) const;
55 ConfigNodeIter iterWrite(std::ostream & out = std::cout);
56
57 private:
58 void setParent(const ConfigNode* parent);
61 PString p_value;
63 PString p_name;
65 std::vector<ConfigNode*> p_vecChild;
67 std::map<PString, ConfigNode*> p_mapChild;
72};
73
74typedef std::vector<ConfigNode*> VecConfigNode;
75typedef std::map<PString, ConfigNode*> MapConfigNode;
76
77#include "ConfigNodeIter.h"
78
79#endif
80
std::vector< ConfigNode * > VecConfigNode
Definition ConfigNode.h:74
std::map< PString, ConfigNode * > MapConfigNode
Definition ConfigNode.h:75
Iterator of the ConfigNode.
PString getString() const
Get string value without " or ' at the beginning of the end.
const PString & getValue() const
Gets the value of the ConfigNode.
void setValue(const PString &value)
Sets the value of the ConfigNode.
PLocation getLocation() const
Gets the location of the ConfigNode.
ConfigNode()
Constructor of class ConfigNode.
void setMapChild(const std::map< PString, ConfigNode * > &mapChild)
Sets the mapChild of the ConfigNode.
void setParent(const ConfigNode *parent)
Sets the parent of the ConfigNode.
std::vector< ConfigNode * > p_vecChild
Vector of sub ConfigNode.
Definition ConfigNode.h:65
const ConfigNode * p_parent
Parent of the current ConfigNode.
Definition ConfigNode.h:71
std::map< PString, ConfigNode * > p_mapChild
Map of sub ConfigNode.
Definition ConfigNode.h:67
void clear()
Clear the vector of children.
void setLineCol(const PLocation &location)
Set the line and the column of the current ConfigNode.
virtual ~ConfigNode()
Destructor of class ConfigNode.
bool hasMapChild() const
Say if the current ConfigNode has a map of children.
const PString & getName() const
Gets the name of the ConfigNode.
ConfigNodeIter iter(std::ostream &out=std::cout) const
Create an iterator of ConfigNode.
const std::vector< ConfigNode * > & getVecChild() const
Gets the vecChild of the ConfigNode.
ConfigNode * addValue(const PString &value)
Add a value in the ConfigNode.
ConfigNode * addChild(const PString &name="")
Add a child in the current ConfigNode.
PString p_value
Value of the current entry.
Definition ConfigNode.h:61
void setLocation(const PLocation &location)
Sets the location of the ConfigNode.
void initialisationConfigNode()
Initialisation Function of class ConfigNode.
ConfigNode * getChild(const PString &name)
Get the child of the given name.
void setVecChild(const std::vector< ConfigNode * > &vecChild)
Sets the vecChild of the ConfigNode.
bool hasVecChild() const
Say if the current ConfigNode has a vector of children.
const ConfigNode * getParent() const
Gets the parent of the ConfigNode.
void setName(const PString &name)
Sets the name of the ConfigNode.
const std::map< PString, ConfigNode * > & getMapChild() const
Gets the mapChild of the ConfigNode.
void setFileName(const PPath &fileName)
Set the fileName of the current ConfigNode.
const PPath & getFileName() const
Get current file name.
PString p_name
Name of the current entry.
Definition ConfigNode.h:63
bool hasValue() const
Say if the current ConfigNode has a value.
PLocation p_location
Location of the definition of the current ConfigNode.
Definition ConfigNode.h:69
ConfigNodeIter iterWrite(std::ostream &out=std::cout)
Create an iterator of ConfigNode.
Classe qui permet de décrire une localisation, avec un nom de fichier et une ligne.
Definition PLocation.h:15