#include <modecontroller.h>
Public Types | |
| typedef IConfigurationParser < std::string, std::string > | StringParser |
Public Member Functions | |
| ModeConfigurationParser (StringParser &parser) | |
| std::istream * | setStream (std::istream *str) |
| void | skip () |
| bool | eod () |
| bool | parse (ModeRule &rule, PropertyMode &mode) |
Private Attributes | |
| StringParser & | baseParser |
Decorator for IConfigurationParser with ModeRule and PropertyMode specialization.
This class doesn't provide any stream reading. Instead it delegates all reading work to low-level baseParser (provided in constructor) which provides string representation of Rule and mode. Responisbility of this class is to parse those values to correct ModeRule and PropertyMode types.
ModeRule is supposed to have format:
Type[.Value] : stringmode
All other IConfigurationParser operations are delegated to the baseParser.
| typedef IConfigurationParser<std::string, std::string> configuration::ModeConfigurationParser::StringParser |
| configuration::ModeConfigurationParser::ModeConfigurationParser | ( | StringParser & | parser | ) | [inline] |
Initialization constructor. Initializes baseParser field.
| bool configuration::ModeConfigurationParser::eod | ( | ) | [inline, virtual] |
Checks whether we are on end of data.
Delegates to baseParser.eod()
Implements configuration::IConfigurationParser< ModeRule, PropertyMode >.
References baseParser, and configuration::IConfigurationParser< KeyType, ValueType >::eod().
| bool configuration::ModeConfigurationParser::parse | ( | ModeRule & | rule, | |
| PropertyMode & | mode | |||
| ) | [virtual] |
Parses key, value pair and transforms them to rule and mode.
| rule | Reference where to put parsed rule. | |
| mode | Reference where to put parsed mode. |
Delegates to baseParser.parse and transforms returned strings to rule and mode.
Rule string has format:
type[.name]
If `.' is not found name or there are no characters behind, name is empty. Everything before `.' is Type. It can also be empty. Both parts are trimed before set (all leading and trailing blanks re skiped).
Name string should be same as PropertyMode names. If not recognized, returns with an error.
Note that !parse() && eod() means no error but nothing more to parse.
Implements configuration::IConfigurationParser< ModeRule, PropertyMode >.
References baseParser, mdAdvanced, mdHidden, mdNormal, mdReadOnly, mdUnknown, configuration::ModeRule::name, configuration::IConfigurationParser< KeyType, ValueType >::parse(), configuration::utils::tokenizer(), configuration::utils::trim(), and configuration::ModeRule::type.
| std::istream* configuration::ModeConfigurationParser::setStream | ( | std::istream * | str | ) | [inline, virtual] |
Sets new data stream.
| str | Stream to set. |
Delegates to baseStream (sets stream to low level string parser).
Reimplemented from configuration::IConfigurationParser< ModeRule, PropertyMode >.
References baseParser, and configuration::IConfigurationParser< KeyType, ValueType >::setStream().
| void configuration::ModeConfigurationParser::skip | ( | ) | [inline, virtual] |
Skips current key, value pair. Delegates to baseParser.skip()
Implements configuration::IConfigurationParser< ModeRule, PropertyMode >.
References baseParser, and configuration::IConfigurationParser< KeyType, ValueType >::skip().
Low level string parser. This parser is initialized in constructor and it is used for input data parsing.
Referenced by eod(), parse(), setStream(), and skip().