1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-09 21:42:13 +00:00
OpenMW/components/compiler/streamerrorhandler.hpp

52 lines
1.3 KiB
C++
Raw Normal View History

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;
/// \brief Error handler implementation: Write errors into logging stream
2010-06-27 17:20:21 +00:00
class StreamErrorHandler : public ErrorHandler
{
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);
2010-06-27 17:20:21 +00:00
// constructors
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