1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-02-16 03:40:16 +00:00
OpenMW/components/compiler/streamerrorhandler.hpp

52 lines
1.3 KiB
C++
Raw Normal View History

2010-06-27 19:20:21 +02:00
#ifndef COMPILER_STREAMERRORHANDLER_H_INCLUDED
#define COMPILER_STREAMERRORHANDLER_H_INCLUDED
#include "errorhandler.hpp"
namespace Compiler
{
2020-04-04 14:09:00 +02:00
class ContextOverride;
/// \brief Error handler implementation: Write errors into logging stream
2010-06-27 19:20:21 +02:00
class StreamErrorHandler : public ErrorHandler
{
2022-09-22 21:26:05 +03:00
std::string mContext;
2022-09-22 21:26:05 +03:00
friend class ContextOverride;
2010-06-27 19:20:21 +02:00
// not implemented
2022-09-22 21:26:05 +03:00
StreamErrorHandler(const StreamErrorHandler&);
StreamErrorHandler& operator=(const StreamErrorHandler&);
2010-06-27 19:20:21 +02:00
2022-09-22 21:26:05 +03:00
void report(const std::string& message, const TokenLoc& loc, Type type) override;
///< Report error to the user.
2010-06-27 19:20:21 +02:00
2022-09-22 21:26:05 +03:00
void report(const std::string& message, Type type) override;
///< Report a file related error
2010-06-27 19:20:21 +02:00
2022-09-22 21:26:05 +03:00
public:
void setContext(const std::string& context);
2010-06-27 19:20:21 +02:00
// constructors
2022-09-22 21:26:05 +03:00
StreamErrorHandler();
///< constructor
2010-06-27 19:20:21 +02:00
};
2020-04-02 20:14:52 +02:00
2020-04-04 14:09:00 +02:00
class ContextOverride
2020-04-02 20:14:52 +02:00
{
2022-09-22 21:26:05 +03:00
StreamErrorHandler& mHandler;
const std::string mContext;
public:
ContextOverride(StreamErrorHandler& handler, const std::string& context);
2020-04-02 20:14:52 +02:00
2022-09-22 21:26:05 +03:00
ContextOverride(const ContextOverride&) = delete;
ContextOverride& operator=(const ContextOverride&) = delete;
2020-04-02 20:27:52 +02:00
2022-09-22 21:26:05 +03:00
~ContextOverride();
2020-04-02 20:14:52 +02:00
};
2010-06-27 19:20:21 +02:00
}
#endif