17using std::string_view;
18using namespace std::literals;
21namespace swoc {
inline namespace SWOC_VERSION_NS {
25std::vector<Errata::Sink::Handle> Sink_List;
30 auto span =
_arena.alloc(src.size()).rebind<
char>();
31 memcpy(span.data(), src.data(), src.size());
32 return {span.data(), span.size()};
44 {
"Info",
"Warning",
"Error"}
56 for (
auto &f : Sink_List) {
68 _data = arena.make<
Data>(std::move(arena));
75 return this->
data()->_arena.alloc(n).rebind<
char>();
84 auto span = this->
alloc(text.size());
93 auto d = this->
data();
102 auto d = this->
data();
106 for (
auto const &annotation : that) {
107 d->_notes.append(d->_arena.make<
Annotation>(d->localize(annotation._text), annotation._severity, annotation._level + 1));
123 Sink_List.push_back(s);
137bwformat(BufferWriter &bw, bwf::Spec
const &, Errata
const &errata) {
138 bwf::Format
const code_fmt{
"[{0:s} {0:d}] "};
148 bool trailing_p =
false;
152 for (
auto ¬e : errata) {
154 bw.
print(
"{}{}{}{}", swoc::bwf::If(trailing_p,
"{}", glue), swoc::bwf::Pattern{int(note.level()), id_txt},
155 swoc::bwf::If(note.has_severity(),
"{}{}", note.severity(), a_s_glue), note.text());
159 if (trailing_p && errata._data->_glue_final_p) {
160 bw.
print(
"{}", glue);
174operator<<(std::ostream &os,
Errata const &err) {
175 return err.
write(os);
SubText< Args... > If(bool flag, TextView const &fmt, Args &&...args)
BufferWriter & print(const TextView &fmt, Args &&...args)
std::shared_ptr< self_type > Handle
Handle type.
static Severity FAILURE_SEVERITY
Severity level at which the instance is a failure of some sort.
TextView severity_glue_text() const
self_type & note(std::string_view text)
TextView annotation_glue_text() const
TextView annotation_severity_glue_text() const
self_type & note_localized(std::string_view const &text, std::optional< Severity > severity=std::optional< Severity >{})
Add Annotation with already localized text.
TextView indent_text() const
code_type const & code() const
The code for the top message.
static void register_sink(Sink::Handle const &s)
Register a sink for discarded erratum.
bool has_severity() const
self_type & assign(Severity severity)
std::ostream & write(std::ostream &out) const
static Severity DEFAULT_SEVERITY
Severity reported if severity not set.
static MemSpan< TextView const > SEVERITY_NAMES
self_type & note_s(std::optional< Severity > severity, std::string_view text)
static Severity FILTER_SEVERITY
self_type & update(Severity severity)
MemSpan< char > alloc(size_t n)
Severity severity() const
For template deduction guides.
BufferWriter & bwformat(BufferWriter &w, bwf::Spec const &spec, std::string_view sv)
std::array< swoc::TextView, 3 > Severity_Names
Default set of severity names.
std::string & bwprint(std::string &s, TextView fmt, Args &&...args)
void * memcpy(void *dst, const std::string_view &src)
swoc::MemArena _arena
Annotation text storage.
std::string_view localize(std::string_view src)
severity_type _raw
Severity numeric value.