Deepsolver
|
The exception class for config file syntax errors. More...
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. |
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.
Deepsolver::ConfigFileException::ConfigFileException | ( | int | code, |
const std::string & | fileName, | ||
size_t | lineNumber, | ||
std::string::size_type | pos, | ||
const std::string & | line | ||
) | [inline] |
[in] | code | The error code |
[in] | fileName | Name of a file being processed |
[in] | lineNumber | The number of the line with encountered error |
[in] | pos | The problem character position (unibyte coding) |
[in] | line | The content of the invalid line |
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".
[in] | visitor | The reference to the visitor |
Implements Deepsolver::AbstractException.
int Deepsolver::ConfigFileException::getCode | ( | ) | const [inline] |
static std::string Deepsolver::ConfigFileException::getDescr | ( | int | code | ) | [inline, static] |
[in] | code | The error code to generate description for |
const std::string& Deepsolver::ConfigFileException::getFileName | ( | ) | const [inline] |
const std::string& Deepsolver::ConfigFileException::getLine | ( | ) | const [inline] |
size_t Deepsolver::ConfigFileException::getLineNumber | ( | ) | const [inline] |
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.
Implements Deepsolver::AbstractException.
std::string::size_type Deepsolver::ConfigFileException::getPos | ( | ) | const [inline] |
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.
Implements Deepsolver::AbstractException.