Node of the configuration items tree. More...
#include <OBTConfigurationItem.h>
Public Member Functions | |
ConfigurationItem (const char *name) | |
constructor | |
virtual | ~ConfigurationItem () |
destructor | |
const char * | getName () const |
accessor to the configuration item name | |
const ConfigurationItem * | getChild (unsigned int childNumber) const |
accessor to a child | |
std::vector< const ConfigurationItem * > | getChildren (const char *name) const |
accessor to the configuration items childrem named name | |
void | addChild (const ConfigurationItem &child) |
add a child to the configuration item | |
unsigned int | getChildrenCount () const |
accessor to the children count | |
const char * | getArgument (const char *key) const |
accessor to the value of an argument | |
std::pair< const char *, const char * > | getArgument (unsigned int argument) const |
accessor to the key and value of an argument | |
void | addArgument (const char *key, const char *value) |
add an argument to the configuration item | |
unsigned int | getArgumentsCount () const |
accessor to the arguments count | |
std::string | traceConfigurationItems () const |
fill a string with the configuration items name, arguments and children | |
const char * | getText () const |
accessor to the configuration item text | |
void | setText (const char *text) |
set the configuration item text | |
int | getLine () const |
accessor to the configuration item line in the configuration file | |
void | setLine (int line) |
set the configuration item line location | |
int | getColumn () const |
accessor to the configuration item column in the configuration file | |
void | setColumn (int column) |
set the configuration item column location | |
Private Member Functions | |
ConfigurationItem & | touchChild (unsigned int childNumber) |
accessor to a child | |
std::vector< ConfigurationItem * > | touchChildren (const char *name) |
accessor to the configuration items childrem named name | |
Private Attributes | |
std::string | _name |
configuration item name | |
std::string | _text |
text | |
int | _line |
line in XML file | |
int | _column |
column in XML file | |
std::map< std::string, std::string > | _arguments |
arguments | |
std::vector< ConfigurationItem > | _children |
children | |
Friends | |
class | AbstractConfigurationFileParser |
Node of the configuration items tree.
This class is used to fill the configuration tree. Each configuration item is defined by :
Definition at line 21 of file OBTConfigurationItem.h.
ConfigurationItem::ConfigurationItem | ( | const char * | name | ) |
ConfigurationItem::~ConfigurationItem | ( | ) | [virtual] |
void OBT::ConfigurationItem::addArgument | ( | const char * | key, | |
const char * | value | |||
) | [inline] |
add an argument to the configuration item
key | of the argument | |
value | of the argument |
Definition at line 334 of file OBTConfigurationItem.h.
References _arguments.
00335 { 00336 _arguments.insert( std::make_pair( key, value ) ) ; 00337 }
void OBT::ConfigurationItem::addChild | ( | const ConfigurationItem & | child | ) | [inline] |
add a child to the configuration item
child | const reference to the child to add |
Definition at line 276 of file OBTConfigurationItem.h.
References _children.
Referenced by OBT::ConfigurationTree::addChild(), and OBT::XMLConfigurationFileParser::AddChildren().
00277 { 00278 _children.push_back( child ) ; 00279 }
std::pair< const char *, const char * > OBT::ConfigurationItem::getArgument | ( | unsigned int | argument | ) | const [inline] |
accessor to the key and value of an argument
argument | number of the argument to retrieve |
Definition at line 320 of file OBTConfigurationItem.h.
References _arguments.
00321 { 00322 std::map<std::string, std::string>::const_iterator ite( _arguments.begin() ) ; 00323 for ( ; argument != 0; --argument ) 00324 { 00325 ++ite ; 00326 } 00327 return std::pair< const char*, const char* >( ite->first.c_str(), ite->second.c_str() ) ; 00328 }
const char * OBT::ConfigurationItem::getArgument | ( | const char * | key | ) | const [inline] |
accessor to the value of an argument
key | of the argument |
Definition at line 294 of file OBTConfigurationItem.h.
References _arguments.
Referenced by traceConfigurationItems().
00295 { 00296 std::map<std::string, std::string>::const_iterator ite( _arguments.find( key ) ) ; 00297 if ( ite != _arguments.end() ) 00298 { 00299 return ite->second.c_str() ; 00300 } 00301 else 00302 { 00303 return NULL ; 00304 } 00305 }
unsigned int OBT::ConfigurationItem::getArgumentsCount | ( | ) | const [inline] |
accessor to the arguments count
Definition at line 311 of file OBTConfigurationItem.h.
References _arguments.
Referenced by traceConfigurationItems().
00312 { 00313 return static_cast< unsigned int >( _arguments.size( ) ) ; 00314 }
const ConfigurationItem * OBT::ConfigurationItem::getChild | ( | unsigned int | childNumber | ) | const [inline] |
accessor to a child
childNumber | number of the child to retrieve |
Definition at line 251 of file OBTConfigurationItem.h.
References _children.
Referenced by traceConfigurationItems().
std::vector< const ConfigurationItem * > ConfigurationItem::getChildren | ( | const char * | name | ) | const |
accessor to the configuration items childrem named name
name | of the children to return |
Definition at line 29 of file OBTConfigurationItem.cpp.
References _children, and _name.
00030 { 00031 std::vector<const ConfigurationItem*> configItems ; 00032 if ( name == _name ) 00033 { 00034 configItems.push_back( this ) ; 00035 } 00036 std::vector<const ConfigurationItem*> returnedItems ; 00037 std::string str( name ) ; 00038 std::vector<ConfigurationItem>::const_iterator ite( _children.begin() ) ; 00039 std::vector<ConfigurationItem>::const_iterator iteE( _children.end() ) ; 00040 for ( ; ite != iteE ; ++ite ) 00041 { 00042 returnedItems = ite->getChildren( name ) ; 00043 if ( returnedItems.size() != 0 ) 00044 { 00045 configItems.insert( configItems.end(), returnedItems.begin(), returnedItems.end() ) ; 00046 } 00047 } 00048 return configItems ; 00049 }
unsigned int OBT::ConfigurationItem::getChildrenCount | ( | ) | const [inline] |
accessor to the children count
Definition at line 285 of file OBTConfigurationItem.h.
References _children.
Referenced by traceConfigurationItems().
00286 { 00287 return static_cast<unsigned int>( _children.size() ) ; 00288 }
int OBT::ConfigurationItem::getColumn | ( | ) | const [inline] |
accessor to the configuration item column in the configuration file
Definition at line 233 of file OBTConfigurationItem.h.
References _column.
00234 { 00235 return _column ; 00236 }
int OBT::ConfigurationItem::getLine | ( | ) | const [inline] |
accessor to the configuration item line in the configuration file
Definition at line 215 of file OBTConfigurationItem.h.
References _line.
00216 { 00217 return _line ; 00218 }
const char * OBT::ConfigurationItem::getName | ( | ) | const [inline] |
accessor to the configuration item name
Definition at line 178 of file OBTConfigurationItem.h.
References _name.
Referenced by traceConfigurationItems().
00179 { 00180 return _name.c_str() ; 00181 }
const char * OBT::ConfigurationItem::getText | ( | ) | const [inline] |
accessor to the configuration item text
Definition at line 187 of file OBTConfigurationItem.h.
References _text.
Referenced by traceConfigurationItems().
void OBT::ConfigurationItem::setColumn | ( | int | column | ) | [inline] |
set the configuration item column location
column | of the configuration item in the configuration file |
Definition at line 242 of file OBTConfigurationItem.h.
References _column.
00243 { 00244 _column = column ; 00245 }
void OBT::ConfigurationItem::setLine | ( | int | line | ) | [inline] |
set the configuration item line location
line | of the configuration item in the configuration file |
Definition at line 224 of file OBTConfigurationItem.h.
References _line.
00225 { 00226 _line = line ; 00227 }
void OBT::ConfigurationItem::setText | ( | const char * | text | ) | [inline] |
set the configuration item text
text | of the configuration item |
Definition at line 203 of file OBTConfigurationItem.h.
References _text.
00204 { 00205 if ( text ) 00206 { 00207 _text = text ; 00208 } 00209 }
ConfigurationItem & OBT::ConfigurationItem::touchChild | ( | unsigned int | childNumber | ) | [inline, private] |
accessor to a child
childNumber | number of the child to retrieve |
Definition at line 267 of file OBTConfigurationItem.h.
References _children.
Referenced by OBT::AbstractConfigurationFileParser::touchChild().
00268 { 00269 return _children.at( childNumber ) ; 00270 }
std::vector< ConfigurationItem * > ConfigurationItem::touchChildren | ( | const char * | name | ) | [private] |
accessor to the configuration items childrem named name
name | of the children to return |
Definition at line 55 of file OBTConfigurationItem.cpp.
References _children, and _name.
00056 { 00057 std::vector< ConfigurationItem*> configItems ; 00058 if ( name == _name ) 00059 { 00060 configItems.push_back( this ) ; 00061 } 00062 std::vector< ConfigurationItem*> returnedItems ; 00063 std::string str( name ) ; 00064 std::vector<ConfigurationItem>::iterator ite( _children.begin() ) ; 00065 std::vector<ConfigurationItem>::iterator iteE( _children.end() ) ; 00066 for ( ; ite != iteE ; ++ite ) 00067 { 00068 returnedItems = ite->touchChildren( name ) ; 00069 if ( returnedItems.size() != 0 ) 00070 { 00071 configItems.insert( configItems.end(), returnedItems.begin(), returnedItems.end() ) ; 00072 } 00073 } 00074 return configItems ; 00075 }
std::string ConfigurationItem::traceConfigurationItems | ( | ) | const |
fill a string with the configuration items name, arguments and children
Definition at line 81 of file OBTConfigurationItem.cpp.
References getArgument(), getArgumentsCount(), getChild(), getChildrenCount(), getName(), getText(), and traceConfigurationItems().
Referenced by traceConfigurationItems().
00082 { 00083 static std::string tabString ; 00084 std::string result ; 00085 result += tabString ; 00086 result += getName() ; 00087 if ( getText() ) 00088 { 00089 result += "[" ; 00090 result += getText() ; 00091 result += "]" ; 00092 } 00093 00094 std::pair< const char*, const char* > argument ; 00095 unsigned int nArguments = getArgumentsCount() ; 00096 for ( unsigned int i = 0 ; i < nArguments ; ++i ) 00097 { 00098 argument = getArgument( i ) ; 00099 result += " " ; 00100 result += argument.first ; 00101 result += "=" ; 00102 result += argument.second ; 00103 } 00104 00105 result += "\n" ; 00106 00107 unsigned int nChildren = getChildrenCount() ; 00108 for ( unsigned int i = 0 ; i < nChildren ; ++i ) 00109 { 00110 tabString += " " ; 00111 result += getChild( i )->traceConfigurationItems() ; 00112 tabString = tabString.substr( 0, tabString.size() - 3 ) ; 00113 } 00114 return result ; 00115 }
friend class AbstractConfigurationFileParser [friend] |
Definition at line 25 of file OBTConfigurationItem.h.
std::map<std::string, std::string> OBT::ConfigurationItem::_arguments [private] |
arguments
Definition at line 167 of file OBTConfigurationItem.h.
Referenced by addArgument(), getArgument(), and getArgumentsCount().
std::vector<ConfigurationItem> OBT::ConfigurationItem::_children [private] |
children
Definition at line 170 of file OBTConfigurationItem.h.
Referenced by addChild(), getChild(), getChildren(), getChildrenCount(), touchChild(), and touchChildren().
int OBT::ConfigurationItem::_column [private] |
column in XML file
Definition at line 164 of file OBTConfigurationItem.h.
Referenced by getColumn(), and setColumn().
int OBT::ConfigurationItem::_line [private] |
line in XML file
Definition at line 161 of file OBTConfigurationItem.h.
std::string OBT::ConfigurationItem::_name [private] |
configuration item name
Definition at line 155 of file OBTConfigurationItem.h.
Referenced by getChildren(), getName(), and touchChildren().
std::string OBT::ConfigurationItem::_text [private] |