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-04 12:09:00 +00:00
|
|
|
class ContextOverride;
|
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;
|
|
|
|
|
2020-04-04 12:09:00 +00:00
|
|
|
friend class ContextOverride;
|
2010-06-27 17:20:21 +00:00
|
|
|
// not implemented
|
|
|
|
|
|
|
|
StreamErrorHandler (const StreamErrorHandler&);
|
|
|
|
StreamErrorHandler& operator= (const StreamErrorHandler&);
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void report (const std::string& message, const TokenLoc& loc, Type type) override;
|
2010-06-27 17:20:21 +00:00
|
|
|
///< Report error to the user.
|
|
|
|
|
2020-10-16 18:18:54 +00:00
|
|
|
void report (const std::string& message, Type type) override;
|
2010-06-27 17:20:21 +00:00
|
|
|
///< Report a file related error
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
2020-04-04 12:09:00 +00:00
|
|
|
void setContext(const std::string& context);
|
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
|
|
|
|
2020-04-04 12:09:00 +00:00
|
|
|
class ContextOverride
|
2020-04-02 18:14:52 +00:00
|
|
|
{
|
2020-04-04 12:09:00 +00:00
|
|
|
StreamErrorHandler& mHandler;
|
2020-04-02 18:14:52 +00:00
|
|
|
const std::string mContext;
|
|
|
|
public:
|
2020-04-04 12:09:00 +00:00
|
|
|
ContextOverride (StreamErrorHandler& handler, const std::string& context);
|
2020-04-02 18:14:52 +00:00
|
|
|
|
2020-04-04 12:09:00 +00:00
|
|
|
ContextOverride (const ContextOverride&) = delete;
|
|
|
|
ContextOverride& operator= (const ContextOverride&) = delete;
|
2020-04-02 18:27:52 +00:00
|
|
|
|
2020-04-04 12:09:00 +00:00
|
|
|
~ContextOverride();
|
2020-04-02 18:14:52 +00:00
|
|
|
};
|
2010-06-27 17:20:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|