PhoenixFileParser
1.7.3
Set of tools to ease file parsing
Toggle main menu visibility
Loading...
Searching...
No Matches
ConfigNodeIter_impl.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 __CONFIGNODEITER_IMPL_H__
8
#define __CONFIGNODEITER_IMPL_H__
9
10
#include "
ConfigNode.h
"
11
12
14
17
template
<
typename
T>
18
bool
ConfigNodeIter::getValue
(T & data)
const
{
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
}
31
33
37
template
<
typename
T>
38
bool
ConfigNodeIter::getValue
(T & data,
const
GenericConfigCheck
* checker)
const
{
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
}
58
60
65
template
<
typename
T>
66
bool
ConfigNodeIter::getChildValue
(
const
PString & childName, T & data,
const
GenericConfigCheck
* checker){
67
if
(!
down
(childName)){
return
false
;}
68
if
(!
getValue
(data, checker)){
return
false
;}
69
up
();
70
return
true
;
71
}
72
73
74
#endif
ConfigNode.h
ConfigNodeIter::getChildValue
bool getChildValue(const PString &childName, T &data, const GenericConfigCheck *checker=NULL)
Get a value from the current ConfigNode and check data.
Definition
ConfigNodeIter_impl.h:66
ConfigNodeIter::p_isWriteMode
bool p_isWriteMode
True if the ConfigNodeIter is in writing mode.
Definition
ConfigNodeIter.h:50
ConfigNodeIter::down
bool down(const PString &childName)
Move to the child of the current node.
Definition
ConfigNodeIter.cpp:67
ConfigNodeIter::up
void up()
Move to the parent of the current node.
Definition
ConfigNodeIter.cpp:56
ConfigNodeIter::getValue
bool getValue(T &data) const
Get a value from the current ConfigNode.
Definition
ConfigNodeIter_impl.h:18
ConfigNodeIter::p_current
ConfigNode * p_current
Current ConfigNode.
Definition
ConfigNodeIter.h:46
ConfigNodeIter::p_out
std::ostream * p_out
std::ostream to be used for the error messages
Definition
ConfigNodeIter.h:48
GenericConfigCheck
Generic class for a configuration check.
Definition
GenericConfigCheck.h:13
GenericConfigCheck::isOk
virtual bool isOk(std::ostream &out) const =0
src
ConfigNodeIter_impl.h
Generated by
1.17.0