senf::console::CommandParser Class Reference
[The parser]

Parse commands. More...

#include <senf/Utils/Console/Parse.hh>

List of all members.


Detailed Description

Parse commands.

This class implements a parser for the console/config language. It supports parsing strings as well as files. For every parsed command, a callback function is called.

Implementation note:
The implementation is based on Boost.Spirit. See the file Parse.ih for the formal language grammar.
Implementation note:
Parsing an arbitrary iostream is not supported since arbitrary streams are not seekable. If this is needed, it can however be provided using stream iterators and some special iterator adaptors from Boost.Spirit. However, the amount of backtracking needs to be analyzed before this is viable.

Definition at line 586 of file Parse.hh.


Classes

struct   ParserErrorException
  Exception thrown when the parser detects an error. More...
struct   SetIncremental

Public Types

typedef boost::function< void(ParseCommandInfo
const &)> 
Callback

Public Member Functions

void  parse (std::string const &command, Callback cb)
  Parse string.
void  parseFile (std::string const &filename, Callback cb)
  Parse file.
void  parseArguments (std::string const &arguments, ParseCommandInfo &info)
  Parse arguments.
void  parsePath (std::string const &path, ParseCommandInfo &info)
  Parse path.
std::string::size_type  parseIncremental (std::string const &commands, Callback cb)
  Incremental parse.

Static Public Member Functions

static bool  isSpecialChar (char ch)
  Check, if ch is a special character.
static bool  isPunctuationChar (char ch)
  Check, if ch is a punctuation character.
static bool  isSpaceChar (char ch)
  Check, if ch is a space character.
static bool  isInvalidChar (char ch)
  Check, if ch is an invalid character.
static bool  isWordChar (char ch)
  Check, if ch is a word character.

Structors and default members

  CommandParser ()
  ~CommandParser ()

Member Typedef Documentation

typedef boost::function<void (ParseCommandInfo const &)> senf::console::CommandParser::
Callback

Definition at line 593 of file Parse.hh.


Constructor & Destructor Documentation

senf::console::CommandParser::
CommandParser ()

Definition at line 324 of file Parse.cc.

senf::console::CommandParser::
~CommandParser ()

Definition at line 328 of file Parse.cc.


Member Function Documentation

bool senf::console::CommandParser::
isInvalidChar ( char  ch )

Check, if ch is an invalid character.

Definition at line 492 of file Parse.cc.

bool senf::console::CommandParser::
isPunctuationChar ( char  ch )

Check, if ch is a punctuation character.

Definition at line 482 of file Parse.cc.

bool senf::console::CommandParser::
isSpaceChar ( char  ch )

Check, if ch is a space character.

Definition at line 487 of file Parse.cc.

bool senf::console::CommandParser::
isSpecialChar ( char  ch )

Check, if ch is a special character.

Definition at line 477 of file Parse.cc.

bool senf::console::CommandParser::
isWordChar ( char  ch )

Check, if ch is a word character.

Definition at line 497 of file Parse.cc.

void senf::console::CommandParser::
parse ( std::string const &  command,
Callback  cb )

Parse string.

Definition at line 379 of file Parse.cc.

void senf::console::CommandParser::
parseArguments ( std::string const &  arguments,
ParseCommandInfo info )

Parse arguments.

parseArguments() parses the string arguments which contains arbitrary command arguments (without the name of the command). The argument tokens are written into info.

Definition at line 405 of file Parse.cc.

void senf::console::CommandParser::
parseFile ( std::string const &  filename,
Callback  cb )

Parse file.

Exceptions:
SystemException  if the file cannot be read.

Definition at line 384 of file Parse.cc.

std::string::size_type senf::console::CommandParser::
parseIncremental ( std::string const &  commands,
Callback  cb )

Incremental parse.

An incremental parse will parse all complete statements in commands. parseIncremental() will return the number of characters successfully parsed from commands.

Note:
The incremental parser requires all statements to be terminated explicitly. This means, that the last ';' is not optional in this case.

Definition at line 467 of file Parse.cc.

void senf::console::CommandParser::
parsePath ( std::string const &  path,
ParseCommandInfo info )

Parse path.

parsePath() parses the string path as an arbitrary command path. The result is written into info.

Definition at line 429 of file Parse.cc.


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