#include <storeErroneousHandler.hpp>

Public Member Functions | |
| StoreErroneousHandler (std::ostream *_outputStream, const std::string &_systemId) | |
| virtual void | error (const ParseError &e) throw (Error) |
Protected Attributes | |
| std::ostream * | outputStream |
| std::string | systemId |
| System id providing information about the stream. | |
| int | lineNumber |
Error handler writing erroneous recipes to a stream. This error handler writes the indicated recipes to a stream.
Definition at line 25 of file storeErroneousHandler.hpp.
| StoreErroneousHandler::StoreErroneousHandler | ( | std::ostream * | _outputStream, | |
| const std::string & | _systemId | |||
| ) | [inline] |
Constructor.
| _outputStream | Stream to write the erroneous recipes to. | |
| _systemId | Corresponding identifier for giving error-messages. |
Definition at line 30 of file storeErroneousHandler.hpp.
00032 : outputStream(_outputStream), systemId(_systemId), lineNumber(1) {}
| void StoreErroneousHandler::error | ( | const ParseError & | e | ) | throw (Error) [virtual] |
Method writing the erroneous recipes to the output stream. This method writes the erroneous recipe to the output stream. The output is prepended with the error-message.
Definition at line 23 of file storeErroneousHandler.cpp.
References ERRORMACRO.
00024 { 00025 int size = e.getRecipeEndPos() - e.getRecipeStartPos(); 00026 00027 // Clear state of stream. 00028 e.getInputStream().clear(); 00029 00030 // Copy chunk with erroneous data. 00031 streampos previousPos = e.getInputStream().tellg(); 00032 e.getInputStream().seekg( e.getRecipeStartPos(), ios::beg ); 00033 shared_array< char > buffer( new char[ size ] ); 00034 e.getInputStream().read( buffer.get(), size ); 00035 00036 // Restore previous stream-position. 00037 e.getInputStream().seekg( previousPos, ios::beg ); 00038 00039 // Print error-information. 00040 #ifndef NDEBUG 00041 lineNumber++; 00042 #endif 00043 *outputStream << "Error in line " 00044 << ( lineNumber + e.getErrorLineNumber() - 00045 e.getRecipeStartLine() + 1 ) 00046 << ": " << e.what() << endl; 00047 lineNumber++; 00048 #ifndef NDEBUG 00049 *outputStream << "Stream-position: " << e.getRecipeStartPos() 00050 << " size of recipe: " << size << endl; 00051 #endif 00052 // Write erroneous data to the error-file. 00053 outputStream->write( buffer.get(), size ); 00054 *outputStream << endl << endl; 00055 lineNumber += e.getRecipeEndLine() - e.getRecipeStartLine() + 3; 00056 00057 ERRORMACRO( *outputStream, Error, , 00058 i18n( "Error writing to %1." ).arg( systemId ) ); 00059 }
int StoreErroneousHandler::lineNumber [protected] |
Definition at line 43 of file storeErroneousHandler.hpp.
std::ostream* StoreErroneousHandler::outputStream [protected] |
Definition at line 39 of file storeErroneousHandler.hpp.
std::string StoreErroneousHandler::systemId [protected] |
System id providing information about the stream.
Definition at line 41 of file storeErroneousHandler.hpp.