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
32 public:
40
41 void remark(const std::string &tag, const std::vector<std::string> &lines) const override;
42
43 void remark_note(const std::string &tag, const std::vector<std::string> &lines) const override;
44
45 void warning_note(const std::string &tag, const std::vector<std::string> &lines) const override;
46
47 void error_note(const std::string &tag, const std::vector<std::string> &lines) const override;
48
49 void warning(const std::string &tag, const std::vector<std::string> &lines) const override;
50
51 void error(const std::string &tag, const std::vector<std::string> &lines) const override;
52
53 void emit_fatal_proximate(const Error &err) const override;
54
55 void emit_fatal_step(const Error &err) const override;
56
57 void emit_fatal_root(const Error &err) const override;
58
66 [[nodiscard]] const std::vector<std::vector<std::string>> &remarks() const
67 {
68 return remarks_;
69 }
70
78 [[nodiscard]] const std::vector<std::vector<std::string>> &remark_notes() const
79 {
80 return remark_notes_;
81 }
82
90 [[nodiscard]] const std::vector<std::vector<std::string>> &warning_notes() const
91 {
92 return warning_notes_;
93 }
94
102 [[nodiscard]] const std::vector<std::vector<std::string>> &error_notes() const
103 {
104 return error_notes_;
105 }
106
114 [[nodiscard]] const std::vector<std::vector<std::string>> &warnings() const
115 {
116 return warnings_;
117 }
118
126 [[nodiscard]] const std::vector<std::vector<std::string>> &errors() const
127 {
128 return errors_;
129 }
130
139 [[nodiscard]] const std::vector<std::vector<std::string>> &fatal_proximates() const
140 {
141 return fatal_proximates_;
142 }
143
151 [[nodiscard]] const std::vector<std::vector<std::string>> &fatal_steps() const
152 {
153 return fatal_steps_;
154 }
155
163 [[nodiscard]] const std::vector<std::vector<std::string>> &fatal_roots() const
164 {
165 return fatal_roots_;
166 }
167
175 [[nodiscard]] const std::map<std::string, size_t> &remark_tag_counts() const
176 {
177 return remark_tag_counts_;
178 }
179
187 [[nodiscard]] const std::map<std::string, size_t> &remark_note_tag_counts() const
188 {
189 return remark_note_tag_counts_;
190 }
191
199 [[nodiscard]] const std::map<std::string, size_t> &warning_note_tag_counts() const
200 {
201 return warning_note_tag_counts_;
202 }
203
211 [[nodiscard]] const std::map<std::string, size_t> &error_note_tag_counts() const
212 {
213 return error_note_tag_counts_;
214 }
215
223 [[nodiscard]] const std::map<std::string, size_t> &warning_tag_counts() const
224 {
225 return warning_tag_counts_;
226 }
227
235 [[nodiscard]] const std::map<std::string, size_t> &error_tag_counts() const
236 {
237 return error_tag_counts_;
238 }
239
240 private:
241 explicit BufferedUserDiagnostics(std::unique_ptr<TextFormatter> formatter)
242 : UserDiagnostics{formatter.get()}, format_{std::move(formatter)}
243 {
244 }
245
246 mutable std::vector<std::vector<std::string>> remarks_;
247 mutable std::vector<std::vector<std::string>> remark_notes_;
248 mutable std::vector<std::vector<std::string>> warning_notes_;
249 mutable std::vector<std::vector<std::string>> error_notes_;
250 mutable std::vector<std::vector<std::string>> warnings_;
251 mutable std::vector<std::vector<std::string>> errors_;
252 mutable std::vector<std::vector<std::string>> fatal_proximates_;
253 mutable std::vector<std::vector<std::string>> fatal_steps_;
254 mutable std::vector<std::vector<std::string>> fatal_roots_;
255 mutable std::map<std::string, size_t> remark_tag_counts_;
256 mutable std::map<std::string, size_t> remark_note_tag_counts_;
257 mutable std::map<std::string, size_t> warning_note_tag_counts_;
258 mutable std::map<std::string, size_t> error_note_tag_counts_;
259 mutable std::map<std::string, size_t> warning_tag_counts_;
260 mutable std::map<std::string, size_t> error_tag_counts_;
261
262 std::unique_ptr<TextFormatter> format_;
263};
264
265} // 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:17
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.