2010-06-27 17:20:21 +00:00
|
|
|
#ifndef COMPILER_STREAMERRORHANDLER_H_INCLUDED
|
|
|
|
#define COMPILER_STREAMERRORHANDLER_H_INCLUDED
|
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
|
|
|
|
#include "errorhandler.hpp"
|
|
|
|
|
|
|
|
namespace Compiler
|
|
|
|
{
|
2020-04-02 18:14:52 +00:00
|
|
|
class ContextRestore;
|
2019-04-21 10:12:32 +00:00
|
|
|
/// \brief Error handler implementation: Write errors into logging stream
|
2010-06-27 17:20:21 +00:00
|
|
|
|
|
|
|
class StreamErrorHandler : public ErrorHandler
|
|
|
|
{
|
2017-02-20 20:09:15 +00:00
|
|
|
std::string mContext;
|
|
|
|
|
2010-06-27 17:20:21 +00:00
|
|
|
// not implemented
|
|
|
|
|
|
|
|
StreamErrorHandler (const StreamErrorHandler&);
|
|
|
|
StreamErrorHandler& operator= (const StreamErrorHandler&);
|
|
|
|
|
|
|
|
virtual void report (const std::string& message, const TokenLoc& loc, Type type);
|
|
|
|
///< Report error to the user.
|
|
|
|
|
|
|
|
virtual void report (const std::string& message, Type type);
|
|
|
|
///< Report a file related error
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2020-04-02 18:14:52 +00:00
|
|
|
ContextRestore setContext(const std::string& context, bool restore = false);
|
2017-02-20 20:09:15 +00:00
|
|
|
|
2010-06-27 17:20:21 +00:00
|
|
|
// constructors
|
|
|
|
|
2019-04-21 10:12:32 +00:00
|
|
|
StreamErrorHandler ();
|
2011-01-05 21:18:21 +00:00
|
|
|
///< constructor
|
2010-06-27 17:20:21 +00:00
|
|
|
};
|
2020-04-02 18:14:52 +00:00
|
|
|
|
|
|
|
class ContextRestore
|
|
|
|
{
|
|
|
|
StreamErrorHandler* mHandler;
|
|
|
|
const std::string mContext;
|
|
|
|
public:
|
|
|
|
ContextRestore (StreamErrorHandler* handler, const std::string& context);
|
|
|
|
|
2020-04-02 18:27:52 +00:00
|
|
|
ContextRestore (ContextRestore&& other);
|
|
|
|
|
2020-04-02 18:14:52 +00:00
|
|
|
~ContextRestore();
|
|
|
|
};
|
2010-06-27 17:20:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|