CeresEngine 0.2.0
A game development framework
Loading...
Searching...
No Matches
ReportHandler.hpp
Go to the documentation of this file.
1//
2// CeresEngine - A game development framework
3//
4// Created by Rogiel Sulzbach.
5// Copyright (c) 2018-2022 Rogiel Sulzbach. All rights reserved.
6//
7
8#pragma once
9
15
18
20
21#include <functional>
22
24
25 class SourceCode;
26
27 // Interface for a common report callback procedure (either for error or warning messages).
28 using OnReportProc = Function<void(const String& msg, const AST* ast) const>;
29
30 // Report handler class for simpler error and warning handling.
32 public:
34
35 void warning(bool breakWithException, const String& msg, SourceCode* sourceCode = nullptr, const SourceArea& area = SourceArea::ignore);
36
37 void submitReport(bool breakWithException, const ReportTypes type, const String& typeName, const String& msg, SourceCode* sourceCode = nullptr,
39
40 // Returns true if any errors have been submitted.
41 [[nodiscard]] inline bool hasErrors() const { return mHasErrors; }
42
43 // Pushes the specified context description string onto the stack. The top most description will be added to the next report message.
46
49 static void hintForNextReport(const String& hint);
50
51 private:
52 Report makeReport(const ReportTypes type, const String& msg, SourceCode* sourceCode, const SourceArea& area, const Vector<SourceArea>& secondaryAreas);
53
54 Log* mLog = nullptr;
55 bool mHasErrors = false;
56
58
59 // TODO: sometimes the same error/warning message appears multiple times, these sets are a workaround for this issue
62 };
63
64} // namespace CeresEngine::ShaderCompiler
Log base class.
Definition Log.hpp:19
Definition ReportHandler.hpp:31
Set< SourcePosition > mErrorPositions
Definition ReportHandler.hpp:60
bool mHasErrors
Definition ReportHandler.hpp:55
Set< SourcePosition > mWarningPositions
Definition ReportHandler.hpp:61
void pushContextDesc(const String &contextDesc)
void submitReport(bool breakWithException, const ReportTypes type, const String &typeName, const String &msg, SourceCode *sourceCode=nullptr, const SourceArea &area=SourceArea::ignore, const Vector< SourceArea > &secondaryAreas={})
void warning(bool breakWithException, const String &msg, SourceCode *sourceCode=nullptr, const SourceArea &area=SourceArea::ignore)
Log * mLog
Definition ReportHandler.hpp:54
Report makeReport(const ReportTypes type, const String &msg, SourceCode *sourceCode, const SourceArea &area, const Vector< SourceArea > &secondaryAreas)
Stack< String > mContextDescStack
Definition ReportHandler.hpp:57
bool hasErrors() const
Definition ReportHandler.hpp:41
static void hintForNextReport(const String &hint)
Appends a hint for the next upcomming report.
Report exception class which contains a completely constructed message with optional line marker,...
Definition Report.hpp:31
Definition SourceArea.hpp:20
static const SourceArea ignore
Definition SourceArea.hpp:23
Definition SourceCode.hpp:24
Definition AST.hpp:33
Function< void(const String &msg, const AST *ast) const > OnReportProc
Definition ReportHandler.hpp:28
ReportTypes
Report types enumeration.
Definition Report.hpp:18
std::stack< T, Container > Stack
The Stack class is a container adapter that gives the programmer the functionality of a stack - speci...
Definition Stack.hpp:18
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
FunctionBase< true, true, fu2::capacity_default, true, false, Signatures... > Function
An owning copyable function wrapper for arbitrary callable types.
Definition Function.hpp:54
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
std::set< Key, Compare, ScopedAllocatorAdaptor< StdAllocator< Key, RawAllocator > > > Set
Set is an associative container that contains a sorted set of unique objects of type Key.
Definition Set.hpp:21