Porytiles
Loading...
Searching...
No Matches
buffered_user_diagnostics.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <map>
4#include <memory>
5#include <string>
6#include <vector>
7
11
12namespace porytiles {
13
34 public:
44
45 void remark(const std::string &tag, const std::vector<std::string> &lines) const override;
46
47 void remark_note(const std::string &tag, const std::vector<std::string> &lines) const override;
48
49 void warning_note(const std::string &tag, const std::vector<std::string> &lines) const override;
50
51 void error_note(const std::string &tag, const std::vector<std::string> &lines) const override;
52
53 void warning(const std::string &tag, const std::vector<std::string> &lines) const override;
54
55 void error(const std::string &tag, const std::vector<std::string> &lines) const override;
56
57 void emit_fatal_proximate(const Error &err) const override;
58
59 void emit_fatal_step(const Error &err) const override;
60
61 void emit_fatal_root(const Error &err) const override;
62
72 [[nodiscard]] const std::vector<std::vector<std::string>> &remarks() const
73 {
74 return remarks_;
75 }
76
86 [[nodiscard]] const std::vector<std::vector<std::string>> &remark_notes() const
87 {
88 return remark_notes_;
89 }
90
100 [[nodiscard]] const std::vector<std::vector<std::string>> &warning_notes() const
101 {
102 return warning_notes_;
103 }
104
114 [[nodiscard]] const std::vector<std::vector<std::string>> &error_notes() const
115 {
116 return error_notes_;
117 }
118
128 [[nodiscard]] const std::vector<std::vector<std::string>> &warnings() const
129 {
130 return warnings_;
131 }
132
142 [[nodiscard]] const std::vector<std::vector<std::string>> &errors() const
143 {
144 return errors_;
145 }
146
157 [[nodiscard]] const std::vector<std::vector<std::string>> &fatal_proximates() const
158 {
159 return fatal_proximates_;
160 }
161
171 [[nodiscard]] const std::vector<std::vector<std::string>> &fatal_steps() const
172 {
173 return fatal_steps_;
174 }
175
185 [[nodiscard]] const std::vector<std::vector<std::string>> &fatal_roots() const
186 {
187 return fatal_roots_;
188 }
189
199 [[nodiscard]] const std::map<std::string, size_t> &remark_tag_counts() const
200 {
201 return remark_tag_counts_;
202 }
203
213 [[nodiscard]] const std::map<std::string, size_t> &remark_note_tag_counts() const
214 {
215 return remark_note_tag_counts_;
216 }
217
227 [[nodiscard]] const std::map<std::string, size_t> &warning_note_tag_counts() const
228 {
229 return warning_note_tag_counts_;
230 }
231
241 [[nodiscard]] const std::map<std::string, size_t> &error_note_tag_counts() const
242 {
243 return error_note_tag_counts_;
244 }
245
255 [[nodiscard]] const std::map<std::string, size_t> &warning_tag_counts() const
256 {
257 return warning_tag_counts_;
258 }
259
269 [[nodiscard]] const std::map<std::string, size_t> &error_tag_counts() const
270 {
271 return error_tag_counts_;
272 }
273
274 private:
275 explicit BufferedUserDiagnostics(std::unique_ptr<TextFormatter> formatter)
276 : UserDiagnostics{formatter.get()}, format_{std::move(formatter)}
277 {
278 }
279
280 mutable std::vector<std::vector<std::string>> remarks_;
281 mutable std::vector<std::vector<std::string>> remark_notes_;
282 mutable std::vector<std::vector<std::string>> warning_notes_;
283 mutable std::vector<std::vector<std::string>> error_notes_;
284 mutable std::vector<std::vector<std::string>> warnings_;
285 mutable std::vector<std::vector<std::string>> errors_;
286 mutable std::vector<std::vector<std::string>> fatal_proximates_;
287 mutable std::vector<std::vector<std::string>> fatal_steps_;
288 mutable std::vector<std::vector<std::string>> fatal_roots_;
289 mutable std::map<std::string, size_t> remark_tag_counts_;
290 mutable std::map<std::string, size_t> remark_note_tag_counts_;
291 mutable std::map<std::string, size_t> warning_note_tag_counts_;
292 mutable std::map<std::string, size_t> error_note_tag_counts_;
293 mutable std::map<std::string, size_t> warning_tag_counts_;
294 mutable std::map<std::string, size_t> error_tag_counts_;
295
296 std::unique_ptr<TextFormatter> format_;
297};
298
299} // namespace porytiles
Testing implementation of UserDiagnostics that buffers all diagnostic output.
const std::map< std::string, size_t > & warning_tag_counts() const
Get the count of warn messages by tag.
const std::vector< std::vector< std::string > > & fatal_proximates() const
Get the buffered fatal proximate error messages.
void warning_note(const std::string &tag, const std::vector< std::string > &lines) const override
Display a tagged note message associated with a warning.
void emit_fatal_step(const Error &err) const override
Emit an intermediate step error in a fatal error chain.
const std::vector< std::vector< std::string > > & fatal_roots() const
Get the buffered fatal root error messages.
const std::vector< std::vector< std::string > > & warnings() const
Get the buffered warning messages.
const std::vector< std::vector< std::string > > & errors() const
Get the buffered error messages.
void emit_fatal_root(const Error &err) const override
Emit the root cause error in a fatal error chain.
const std::map< std::string, size_t > & warning_note_tag_counts() const
Get the count of warning-associated note messages by tag.
void emit_fatal_proximate(const Error &err) const override
Emit the proximate (immediate) error in a fatal error chain.
const std::vector< std::vector< std::string > > & remark_notes() const
Get the buffered remark-associated note messages.
const std::map< std::string, size_t > & remark_tag_counts() const
Get the count of remark messages by tag.
const std::map< std::string, size_t > & error_tag_counts() const
Get the count of error messages by tag.
const std::map< std::string, size_t > & remark_note_tag_counts() const
Get the count of remark-associated note messages by tag.
const std::map< std::string, size_t > & error_note_tag_counts() const
Get the count of error-associated note messages by tag.
const std::vector< std::vector< std::string > > & fatal_steps() const
Get the buffered fatal step error messages.
void remark(const std::string &tag, const std::vector< std::string > &lines) const override
Display a tagged remark message.
const std::vector< std::vector< std::string > > & remarks() const
Get the buffered remark messages.
const std::vector< std::vector< std::string > > & error_notes() const
Get the buffered error-associated note messages.
void remark_note(const std::string &tag, const std::vector< std::string > &lines) const override
Display a tagged note message associated with a remark.
const std::vector< std::vector< std::string > > & warning_notes() const
Get the buffered warning-associated note messages.
void error_note(const std::string &tag, const std::vector< std::string > &lines) const override
Display a tagged note message associated with an error.
BufferedUserDiagnostics()
Construct a BufferedUserDiagnostics with a PlainTextFormatter.
Abstract interface for all error types used in ChainableResult error chains.
Definition error.hpp:19
TextFormatter implementation that strips all styling from text.
Abstract class for structured error reporting and diagnostic output.
const TextFormatter & formatter() const
@ warning
Emit a warning and continue decompilation.
@ error
Emit a formatted error and fail decompilation.