A base class for diagnostic classes.
More...
#include <diagnostic.h>
|
static size_t | deferred () |
| Count the diagnostics enqueued for deferred action.
|
|
static size_t | discard (unsigned reason) |
| Discard any queued diagnostics that match a reason-code, returning the number discarded. More...
|
|
static size_t | discard (severity level) |
| Discard any queued diagnostics that match a severity, returning the number discarded. More...
|
|
static void | discard_all () |
| Discard all queued diagnostics.
|
|
static size_t | flush (unsigned reason) |
| Emit all queued diagnostics that match a reason-code.
|
|
static size_t | flush (severity level) |
| Emit all queued diagnostics that match a severity.
|
|
static void | flush_all () |
| Emit any queued diagnostics.
|
|
static void | epilogue () |
| Write summary diagnostics on cerr at exit. More...
|
|
static int | exitcode () |
| Convert the internal exit status to an exit code for exit() . More...
|
|
|
virtual void | count () const |
| Increment global counts appropriately for the runtime type.
|
|
virtual diagnostic_base * | clone () const |
| Clone the runtime object on the heap.
|
|
void | despatch () const throw (unsigned) |
| Emit the diagnostic.
|
|
|
bool | _gagged |
| Is the diagnostic suppressed?
|
|
std::stringstream | _text |
| The text of the diagnostic.
|
|
|
template<class T > |
static size_t | volley (T match, T(diagnostic_base::*selector)() const, void(diagnostic_base::*action)() const =nullptr) |
| Call a member function on all queued diagnostics for which a given member function returns a given result. More...
|
|
A base class for diagnostic classes.
Definition at line 85 of file diagnostic.h.
diagnostic_base::diagnostic_base |
( |
std::string const & |
severity_name, |
|
|
severity |
level, |
|
|
unsigned |
id, |
|
|
bool |
in_code_only = false |
|
) |
| |
Constructor.
- Parameters
-
severity_name | Name of the severity level of the diagnostic |
level | The severity level of the diagnostic |
id | The causal identifier of the diagnostic |
in_code_only | True if the diagnostic is applicable only when parsing code. |
Definition at line 61 of file diagnostic.cpp.
static unsigned diagnostic_base::code |
( |
severity |
level, |
|
|
unsigned |
id |
|
) |
| |
|
inlinestaticprotected |
Get the reason-code that encodes a causal identifier and severity.
- Parameters
-
level | The severity to be encoded. |
id | The causal identifier to be encoded. |
- Returns
- The reason-code that encodes a causal identifier and severity level.
Definition at line 314 of file diagnostic.h.
static size_t diagnostic_base::discard |
( |
unsigned |
reason | ) |
|
|
inlinestatic |
Discard any queued diagnostics that match a reason-code, returning the number discarded.
- Parameters
-
reason | The reason-code for selecting the queued diagnostics to discard. |
- Returns
- The number of discarded diagnostics.
Definition at line 217 of file diagnostic.h.
static size_t diagnostic_base::discard |
( |
severity |
level | ) |
|
|
inlinestatic |
Discard any queued diagnostics that match a severity, returning the number discarded.
- Parameters
-
level | The severityfor selecting the queued diagnostics to discard. |
- Returns
- The number of discarded diagnostics.
Definition at line 227 of file diagnostic.h.
unsigned diagnostic_base::encode |
( |
| ) |
const |
|
inline |
Get the reason-code of the diagnostic.
The reason-code encodes the id of the diagnostic and its severity.
- Returns
- The reason-code of the diagnostic.
Definition at line 138 of file diagnostic.h.
void diagnostic_base::epilogue |
( |
| ) |
|
|
static |
Write summary diagnostics on cerr
at exit.
The summary diagnostics will be output unless --gag summary
is in force, which it is by default.
Definition at line 101 of file diagnostic.cpp.
int diagnostic_base::exitcode |
( |
| ) |
|
|
static |
Convert the internal exit status to an exit code for exit()
.
- Returns
- RC such that:
RC & 0x12: Input lines were dropped on output (info).
- RC & 0x22: Input lines were changed on output (info)
- RC & 0x44: Lines were changed to
error
s on output (warning).
- RC & 0x84: Unconditional
error
s were output.
Definition at line 156 of file diagnostic.cpp.
virtual unsigned diagnostic_base::id |
( |
| ) |
const |
|
inlinevirtual |
Get the unique identifier of the runtime type.
Each distinct cause that may be reported by a diagnostic has a distinct identifier.
- Returns
- The unique identifier of the runtime type.
Reimplemented in diagnostic< Level, Id >, diagnostic< severity::summary_info, Id >, diagnostic< severity::info, Id >, diagnostic< severity::warning, Id >, diagnostic< severity::summary_progress, Id >, diagnostic< severity::error, Id >, diagnostic< severity::summary_warning, Id >, diagnostic< severity::abend, Id >, and diagnostic< severity::progress, Id >.
Definition at line 127 of file diagnostic.h.
Insert an arbitrary object into the diagnostic.
- Template Parameters
-
T | Type of the object to be inserted. |
- Parameters
-
- Returns
- A reference to
*this
.
The member function inserts obj
into the text of the diagnostic.
Definition at line 171 of file diagnostic.h.
Queue the diagnostic for deferred action.
Inserting a token object of type defer
to the diagnostic adds the diagnostic to the deferred queue.
- Returns
- A reference to
*this
.
Definition at line 185 of file diagnostic.h.
Emit the diagnostic.
Inserting a token object of type emit
to the diagnostic
causes it to be emitted.
- Returns
- A reference to
*this
.
Definition at line 199 of file diagnostic.h.
template<class T >
static size_t diagnostic_base::volley |
( |
T |
match, |
|
|
T(diagnostic_base::*)() const |
selector, |
|
|
void(diagnostic_base::*)() const |
action = nullptr |
|
) |
| |
|
inlinestaticprivate |
Call a member function on all queued diagnostics for which a given member function returns a given result.
- Template Parameters
-
T | Type returned by the selector member function. |
- Parameters
-
match | The T that shall be returned by the selector function to select the diagnostic. |
selector | The member method that selects queued diagnostics for action. |
action | The member method, if any, to be called on selected diagnostics, else null. |
- Returns
- The number of diagnostics selected.
Definition at line 353 of file diagnostic.h.
Queue of deferred diagnostics.
A diagnostic may have to be constructed before we know whether it should be issued. In the meantime it can be queued.
Definition at line 323 of file diagnostic.h.
The documentation for this struct was generated from the following files: