summaryrefslogtreecommitdiff
path: root/src/errors.hh
diff options
context:
space:
mode:
authorJoel Klinghed <the_jk@spawned.biz>2025-09-27 20:11:32 +0200
committerJoel Klinghed <the_jk@spawned.biz>2025-09-28 22:48:24 +0200
commitc1ae5d53fb0fa7ceb9d6fc7a60c87df958ce37fe (patch)
treef028a04619aa1b69f8b0aa72a5154f6ba1c09775 /src/errors.hh
parent2f13baa843bd1fb5db6630a2823681ffaff9fb11 (diff)
WIPWIP
Diffstat (limited to 'src/errors.hh')
-rw-r--r--src/errors.hh64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/errors.hh b/src/errors.hh
new file mode 100644
index 0000000..d8b3d60
--- /dev/null
+++ b/src/errors.hh
@@ -0,0 +1,64 @@
+#ifndef ERRORS_HH
+#define ERRORS_HH
+
+#include "location.hh"
+
+#include <iosfwd>
+#include <memory>
+#include <string>
+#include <string_view>
+
+namespace src {
+
+class Errors {
+ public:
+ virtual ~Errors() = default;
+
+ virtual void err(Location loc, std::string_view msg) = 0;
+
+ virtual void warn(Location loc, std::string_view msg) = 0;
+
+#if !defined(NDEBUG)
+ virtual void dbg(Location loc, std::string_view msg) = 0;
+#else
+ void dbg(Location, std::string_view) {}
+#endif
+
+ [[nodiscard]]
+ virtual uint64_t errors() const = 0;
+ [[nodiscard]]
+ virtual uint64_t warnings() const = 0;
+
+ protected:
+ Errors() = default;
+
+ Errors(Errors const&) = delete;
+ Errors& operator=(Errors const&) = delete;
+};
+
+class ErrorsOutput {
+ public:
+ virtual ~ErrorsOutput() = default;
+
+ virtual void println(std::string_view line) = 0;
+
+ protected:
+ ErrorsOutput() = default;
+
+ ErrorsOutput(ErrorsOutput const&) = delete;
+ ErrorsOutput& operator=(ErrorsOutput const&) = delete;
+};
+
+[[nodiscard]]
+std::unique_ptr<Errors> file_errors(
+ std::string filename, std::shared_ptr<ErrorsOutput> output = nullptr);
+
+[[nodiscard]]
+std::unique_ptr<Errors> ignore_errors();
+
+[[nodiscard]]
+std::unique_ptr<ErrorsOutput> errors_output_ios(std::ostream& out);
+
+} // namespace src
+
+#endif // ERRORS_HH