Deepsolver
Classes | Public Types | Public Member Functions | Static Public Member Functions
Deepsolver::ConfigFileException Class Reference

The exception class for config file syntax errors. More...

Inheritance diagram for Deepsolver::ConfigFileException:
Deepsolver::AbstractException

List of all members.

Classes

struct  Descr

Public Types

enum  {
  SectionInvalidType, SectionWaitingOpenBracket, SectionWaitingName, SectionInvalidNameChar,
  SectionWaitingCloseBracketOrArg, SectionUnexpectedArgEnd, SectionWaitingCloseBracket, ValueWaitingName,
  ValueInvalidNameChar, ValueWaitingAssignOrNewName, ValueWaitingNewName, ValueUnexpectedValueEnd,
  CodeCount
}

Public Member Functions

void accept (ExceptionVisitor &visitor) const
 Calls appropriate visitor method.
 ConfigFileException (int code, const std::string &fileName, size_t lineNumber, std::string::size_type pos, const std::string &line)
 The constructor.
int getCode () const
 Returns the error code.
const std::string & getFileName () const
 Returns the name of a file with invalid line.
const std::string & getLine () const
 Returns the text of the invalid line.
size_t getLineNumber () const
 Returns a number of the invalid line.
std::string getMessage () const
 Returns a single line error description.
std::string::size_type getPos () const
 Returns the position of the invalid character.
std::string getType () const
 Returns a string with short error type designation.
virtual ~ConfigFileException ()
 The destructor.

Static Public Member Functions

static std::string getDescr (int code)
 Generates English problem description by the given code.

Detailed Description

This class instance is thrown when something is wrong with configuration file syntax. Through this class various information about the problem can be obtained, like file name, line number, character position, line content and error code. Be careful, character position is given in unibyte string representation, hence, if UTF-8 sequences are present additional processing is needed to find real character number. This class does not provide any text descriptions.

See also:
ConfigException

Constructor & Destructor Documentation

Deepsolver::ConfigFileException::ConfigFileException ( int  code,
const std::string &  fileName,
size_t  lineNumber,
std::string::size_type  pos,
const std::string &  line 
) [inline]
Parameters:
[in]codeThe error code
[in]fileNameName of a file being processed
[in]lineNumberThe number of the line with encountered error
[in]posThe problem character position (unibyte coding)
[in]lineThe content of the invalid line

Member Function Documentation

void Deepsolver::ConfigFileException::accept ( ExceptionVisitor visitor) const [inline, virtual]

This method performs invocation of corresponding visit() method of the visitor, provided by the reference. You should use it each time, when you want to make particular handling action for various exception types, as it suggested by design pattern "visitor".

Parameters:
[in]visitorThe reference to the visitor

Implements Deepsolver::AbstractException.

int Deepsolver::ConfigFileException::getCode ( ) const [inline]
Returns:
The error code
static std::string Deepsolver::ConfigFileException::getDescr ( int  code) [inline, static]
Parameters:
[in]codeThe error code to generate description for
Returns:
The generated English error description
const std::string& Deepsolver::ConfigFileException::getFileName ( ) const [inline]
Returns:
Name of a file with an invalid line
const std::string& Deepsolver::ConfigFileException::getLine ( ) const [inline]
Returns:
The content of the invalid line
size_t Deepsolver::ConfigFileException::getLineNumber ( ) const [inline]
Returns:
Number of the invalid line
std::string Deepsolver::ConfigFileException::getMessage ( ) const [virtual]

This method returns a single line string value with error description. Usually it is the value printed to user in the error message. The value should not include error type, since it can be obtained through getType() method.

Returns:
A single line error description

Implements Deepsolver::AbstractException.

std::string::size_type Deepsolver::ConfigFileException::getPos ( ) const [inline]
Returns:
The number of the invalid character
std::string Deepsolver::ConfigFileException::getType ( ) const [inline, virtual]

This method returns a short string with one or two words describing the error type. For example, this method can return values like "system", "back-end" etc. A value returned by this method usually is used for error message construction.

Returns:
A short string with error type designation

Implements Deepsolver::AbstractException.