PhoenixFileParser  1.5.1
Set of tools to ease file parsing
Loading...
Searching...
No Matches
ConfigNodeIter Class Reference

Iterator of the ConfigNode. More...

#include <ConfigNodeIter.h>

+ Collaboration diagram for ConfigNodeIter:

Public Member Functions

 ConfigNodeIter (const ConfigNodeIter &other)
 Copy constructor of ConfigNodeIter.
 
bool down (const PString &childName)
 Move to the child of the current node.
 
template<typename T>
bool getChildValue (const PString &childName, T &data, const GenericConfigCheck *checker=NULL)
 Get a value from the current ConfigNode and check data.
 
std::ostream * getOut ()
 Get the pointer of the output stream.
 
template<typename T>
bool getValue (T &data) const
 Get a value from the current ConfigNode.
 
template<typename T>
bool getValue (T &data, const GenericConfigCheck *checker) const
 Get a value from the current ConfigNode and check data.
 
bool isWriteMode () const
 Say if the iterator is in write mode.
 
ConfigNodeoperator-> ()
 Get the current ConfigNode.
 
ConfigNodeIteroperator= (const ConfigNodeIter &other)
 Definition of equal operator of ConfigNodeIter.
 
void up ()
 Move to the parent of the current node.
 
virtual ~ConfigNodeIter ()
 Destructor of ConfigNodeIter.
 

Public Attributes

friend ConfigNode
 

Protected Member Functions

void copyConfigNodeIter (const ConfigNodeIter &other)
 Copy function of ConfigNodeIter.
 

Private Member Functions

 ConfigNodeIter (const ConfigNode *current, std::ostream *out, bool isWriteMode)
 Default constructor of ConfigNodeIter.
 
void initialisationConfigNodeIter ()
 Initialisation function of the class ConfigNodeIter.
 

Private Attributes

ConfigNodep_current
 Current ConfigNode.
 
bool p_isWriteMode
 True if the ConfigNodeIter is in writing mode.
 
std::ostream * p_out
 std::ostream to be used for the error messages
 

Detailed Description

Iterator of the ConfigNode.

Definition at line 16 of file ConfigNodeIter.h.

Constructor & Destructor Documentation

◆ ConfigNodeIter() [1/2]

ConfigNodeIter::ConfigNodeIter ( const ConfigNodeIter & other)

Copy constructor of ConfigNodeIter.

Parameters
other: class to copy

Definition at line 23 of file ConfigNodeIter.cpp.

23 {
24 copyConfigNodeIter(other);
25}
void copyConfigNodeIter(const ConfigNodeIter &other)
Copy function of ConfigNodeIter.

References ConfigNodeIter(), and copyConfigNodeIter().

Referenced by ConfigNodeIter(), copyConfigNodeIter(), and operator=().

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

◆ ~ConfigNodeIter()

ConfigNodeIter::~ConfigNodeIter ( )
virtual

Destructor of ConfigNodeIter.

Definition at line 28 of file ConfigNodeIter.cpp.

28 {
29
30}

◆ ConfigNodeIter() [2/2]

ConfigNodeIter::ConfigNodeIter ( const ConfigNode * current,
std::ostream * out,
bool isWriteMode )
private

Default constructor of ConfigNodeIter.

Parameters
current: pointer to the current ConfigNode
out: std::ostream to be used for the error messages

Definition at line 14 of file ConfigNodeIter.cpp.

16{
18}
bool p_isWriteMode
True if the ConfigNodeIter is in writing mode.
ConfigNode * p_current
Current ConfigNode.
bool isWriteMode() const
Say if the iterator is in write mode.
std::ostream * p_out
std::ostream to be used for the error messages
void initialisationConfigNodeIter()
Initialisation function of the class ConfigNodeIter.

References ConfigNode, initialisationConfigNodeIter(), isWriteMode(), p_current, p_isWriteMode, and p_out.

+ Here is the call graph for this function:

Member Function Documentation

◆ copyConfigNodeIter()

void ConfigNodeIter::copyConfigNodeIter ( const ConfigNodeIter & other)
protected

Copy function of ConfigNodeIter.

Parameters
other: class to copy

Definition at line 94 of file ConfigNodeIter.cpp.

94 {
95 p_current = other.p_current;
96 p_out = other.p_out;
98}

References ConfigNodeIter(), p_current, p_isWriteMode, and p_out.

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

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

◆ down()

bool ConfigNodeIter::down ( const PString & childName)

Move to the child of the current node.

Parameters
childName: name of the child
Returns
true if the child does exist, false otherwise

Definition at line 67 of file ConfigNodeIter.cpp.

67 {
68 const ConfigNode * child = p_current->getChild(childName);
69 if(child != NULL){
70 p_current = (ConfigNode *)child;
71 return true;
72 }else{
73 if(p_isWriteMode){
74 ConfigNode * child = p_current->addChild(childName);
75 p_current = child;
76 return true;
77 }else{
78 *p_out << "ConfigNodeIter::down : no child '"<<childName<<"' defined in ConfigNode " << p_current->getLocation() << std::endl;
79 return false;
80 }
81 }
82}

References ConfigNode, p_current, p_isWriteMode, and p_out.

Referenced by getChildValue().

+ Here is the caller graph for this function:

◆ getChildValue()

template<typename T>
bool ConfigNodeIter::getChildValue ( const PString & childName,
T & data,
const GenericConfigCheck * checker = NULL )

Get a value from the current ConfigNode and check data.

Parameters
childName: name of the child to get value
[out]data: value to get
checker: checker of given data
Returns
true if the value does exist, false otherwise

Definition at line 66 of file ConfigNodeIter_impl.h.

66 {
67 if(!down(childName)){return false;}
68 if(!getValue(data, checker)){return false;}
69 up();
70 return true;
71}
bool down(const PString &childName)
Move to the child of the current node.
void up()
Move to the parent of the current node.
bool getValue(T &data) const
Get a value from the current ConfigNode.

References down(), getValue(), and up().

+ Here is the call graph for this function:

◆ getOut()

std::ostream * ConfigNodeIter::getOut ( )

Get the pointer of the output stream.

Returns
pointer of the output stream

Definition at line 51 of file ConfigNodeIter.cpp.

51 {
52 return p_out;
53}

References p_out.

◆ getValue() [1/2]

template<typename T>
bool ConfigNodeIter::getValue ( T & data) const

Get a value from the current ConfigNode.

Parameters
[out]data: value to get
Returns
true if the value does exist, false otherwise

Definition at line 18 of file ConfigNodeIter_impl.h.

18 {
19 if(p_current->hasValue()){
20 if(p_isWriteMode){
21 p_current->setValue(PString::toString(data));
22 }else{
23 data = PString::toValue<T>(p_current->getString());
24 }
25 return true;
26 }else{
27 *p_out << "ConfigNodeIter::getValue : no value in ConfigNode defined at " << p_current->getLocation() << std::endl;
28 return false;
29 }
30}

References p_current, p_isWriteMode, and p_out.

Referenced by getChildValue(), and getValue().

+ Here is the caller graph for this function:

◆ getValue() [2/2]

template<typename T>
bool ConfigNodeIter::getValue ( T & data,
const GenericConfigCheck * checker ) const

Get a value from the current ConfigNode and check data.

Parameters
[out]data: value to get
checker: checker of given data
Returns
true if the value does exist, false otherwise

Definition at line 38 of file ConfigNodeIter_impl.h.

38 {
39 if(checker != NULL && p_isWriteMode){
40 if(!checker->isOk(*p_out)){
41 *p_out << "\tdefined in ConfigNode '"<<p_current->getName()<<"'. I am sorry but since this is not yet a file I do not have any line numbers" << std::endl;
42 return false;
43 }
44 }
45 if(getValue(data)){
46 if(checker != NULL){
47 if(checker->isOk(*p_out)){
48 return true;
49 }else{
50 *p_out << "\tdefined at " << p_current->getLocation() << std::endl;
51 }
52 }else{
53 return true;
54 }
55 }
56 return false;
57}
virtual bool isOk(std::ostream &out) const =0

References getValue(), GenericConfigCheck::isOk(), p_current, p_isWriteMode, and p_out.

+ Here is the call graph for this function:

◆ initialisationConfigNodeIter()

void ConfigNodeIter::initialisationConfigNodeIter ( )
private

Initialisation function of the class ConfigNodeIter.

Definition at line 101 of file ConfigNodeIter.cpp.

101 {
102
103}

Referenced by ConfigNodeIter().

+ Here is the caller graph for this function:

◆ isWriteMode()

bool ConfigNodeIter::isWriteMode ( ) const

Say if the iterator is in write mode.

Returns
true if the iterator is in write mode

Definition at line 87 of file ConfigNodeIter.cpp.

87 {
88 return p_isWriteMode;
89}

References p_isWriteMode.

Referenced by ConfigNodeIter().

+ Here is the caller graph for this function:

◆ operator->()

ConfigNode * ConfigNodeIter::operator-> ( )

Get the current ConfigNode.

Returns
current ConfigNode

Definition at line 44 of file ConfigNodeIter.cpp.

44 {
45 return p_current;
46}

References ConfigNode, and p_current.

◆ operator=()

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

Definition of equal operator of ConfigNodeIter.

Parameters
other: class to copy
Returns
copied class

Definition at line 36 of file ConfigNodeIter.cpp.

36 {
37 copyConfigNodeIter(other);
38 return *this;
39}

References ConfigNodeIter(), and copyConfigNodeIter().

+ Here is the call graph for this function:

◆ up()

void ConfigNodeIter::up ( )

Move to the parent of the current node.

Definition at line 56 of file ConfigNodeIter.cpp.

56 {
57 const ConfigNode * parent = p_current->getParent();
58 if(parent != NULL){
59 p_current = (ConfigNode *)parent;
60 }
61}

References ConfigNode, and p_current.

Referenced by getChildValue().

+ Here is the caller graph for this function:

Member Data Documentation

◆ ConfigNode

friend ConfigNodeIter::ConfigNode

Definition at line 18 of file ConfigNodeIter.h.

Referenced by ConfigNodeIter(), down(), operator->(), and up().

◆ p_current

ConfigNode* ConfigNodeIter::p_current
private

Current ConfigNode.

Definition at line 46 of file ConfigNodeIter.h.

Referenced by ConfigNodeIter(), copyConfigNodeIter(), down(), getValue(), getValue(), operator->(), and up().

◆ p_isWriteMode

bool ConfigNodeIter::p_isWriteMode
private

True if the ConfigNodeIter is in writing mode.

Definition at line 50 of file ConfigNodeIter.h.

Referenced by ConfigNodeIter(), copyConfigNodeIter(), down(), getValue(), getValue(), and isWriteMode().

◆ p_out

std::ostream* ConfigNodeIter::p_out
private

std::ostream to be used for the error messages

Definition at line 48 of file ConfigNodeIter.h.

Referenced by ConfigNodeIter(), copyConfigNodeIter(), down(), getOut(), getValue(), and getValue().


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