configuration::IConfigurationParser< KeyType, ValueType > Class Template Reference

#include <confparser.h>

List of all members.

Public Member Functions

 IConfigurationParser ()
 IConfigurationParser (std::istream *str)
virtual ~IConfigurationParser ()
virtual void skip ()=0
virtual std::istream * setStream (std::istream *str)
virtual bool parse (KeyType &key, ValueType &value)=0
virtual bool eod ()=0

Protected Attributes

std::istream * stream

Detailed Description

template<typename KeyType = std::string, typename ValueType = std::string>
class configuration::IConfigurationParser< KeyType, ValueType >

Interface for configuration parsers. Defines methods needed for parsing configuration file. Template paramters specifies concrete types for configuration entities which allways consist of two parts key and value, where key determines meaning of value. Implementator gives meaning to both of them.
Current unparsed key, value pair may be skipped by skip method.
Note that this interface doesn't say how format looks like or whether data are read by lines or what so ever. One parse method call fills key and value and moves to following one or returns with false if no more data are available.
Data are read from input stream which is set in constructor and stored in this class as protected field. Stream may be changed by setStream method.


Constructor & Destructor Documentation

template<typename KeyType = std::string, typename ValueType = std::string>
configuration::IConfigurationParser< KeyType, ValueType >::IConfigurationParser (  )  [inline]

Empty constructor. Initializes stream to NULL.

template<typename KeyType = std::string, typename ValueType = std::string>
configuration::IConfigurationParser< KeyType, ValueType >::IConfigurationParser ( std::istream *  str  )  [inline]

Initialization constructor.

Parameters:
str Stream with data.

Sets stream field.

template<typename KeyType = std::string, typename ValueType = std::string>
virtual configuration::IConfigurationParser< KeyType, ValueType >::~IConfigurationParser (  )  [inline, virtual]

Empty virtual destructor.


Member Function Documentation

template<typename KeyType = std::string, typename ValueType = std::string>
virtual bool configuration::IConfigurationParser< KeyType, ValueType >::eod (  )  [pure virtual]

Checks whether we are on end of data.

Allways returns true if no stream is specified (it is NULL).

Returns:
true if there is nothing more to read, false otherwise.

Implemented in configuration::ModeConfigurationParser, and configuration::StringConfigurationParser.

Referenced by configuration::ModeConfigurationParser::eod().

template<typename KeyType = std::string, typename ValueType = std::string>
virtual bool configuration::IConfigurationParser< KeyType, ValueType >::parse ( KeyType &  key,
ValueType &  value 
) [pure virtual]

Parse current key, value pair.

Parameters:
key Reference where to put parsed key.
value Reference where to put parsed value.

Moves current parsing position after parsed data.

Returns:
true if parsing was successfull or false otherwise.

Implemented in configuration::ModeConfigurationParser, and configuration::StringConfigurationParser.

Referenced by configuration::ModeConfigurationParser::parse().

template<typename KeyType = std::string, typename ValueType = std::string>
virtual std::istream* configuration::IConfigurationParser< KeyType, ValueType >::setStream ( std::istream *  str  )  [inline, virtual]

Sets new data stream.

Parameters:
str Stream to set.

Sets new value of stream.

Returns:
Current stream.

Reimplemented in configuration::ModeConfigurationParser.

Referenced by configuration::ModeConfigurationParser::setStream().

template<typename KeyType = std::string, typename ValueType = std::string>
virtual void configuration::IConfigurationParser< KeyType, ValueType >::skip (  )  [pure virtual]

Member Data Documentation

template<typename KeyType = std::string, typename ValueType = std::string>
std::istream* configuration::IConfigurationParser< KeyType, ValueType >::stream [protected]

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