Gromacs
2024.4
|
#include <gromacs/fileio/warninp.h>
General warning handling object.
If allowWarnings
is false, all warnings (calls to warning()) will be transformed into errors, calls to warning_note still produce notes. maxNumberWarnings
determines the maximum number of warnings that are allowed for proceeding. When this number is exceeded check_warning_error and done_warning will generate a fatal error. allowWarnings should only be true in programs that have a -maxwarn command line option.
Public Member Functions | |
WarningHandler (bool allowWarnings, int maxNumberWarnings) | |
void | setFileAndLineNumber (const std::filesystem::path &fileName, int lineNumber) |
Set fileName and lineNumber for the warning. More... | |
std::filesystem::path | getFileName () const |
Get filename for the warning */. | |
int | errorCount () const |
int | warningCount () const |
int | noteCount () const |
int | maxWarningCount () const |
void | addWarning (std::string_view message) |
Issue a warning, with the string message . More... | |
void | addNote (std::string_view message) |
Issue a note, with the string message . More... | |
void | addError (std::string_view message) |
Issue an error, with the string message . More... | |
void WarningHandler::addError | ( | std::string_view | message | ) |
Issue an error, with the string message
.
If message
== nullptr, then warn_buf will be printed instead. The file and line set by setLine are printed, number of errors is incremented.
void WarningHandler::addNote | ( | std::string_view | message | ) |
Issue a note, with the string message
.
If message
== nullptr, then warn_buf will be printed instead. The file and line set by setLine are printed, number of notes is incremented. This is for issues which could be a problem for some systems, but 100% ok for other systems.
void WarningHandler::addWarning | ( | std::string_view | message | ) |
Issue a warning, with the string message
.
If message
== nullptr, then warn_buf will be printed instead. The file and line set by setLine are printed, and the number of warnings is incremented. A fatal error will be generated after processing the input when number of warnings is larger than maxNumberWarning passed during construction. So addWarning should only be called for issues that should be resolved, otherwise addNote should be called.
void WarningHandler::setFileAndLineNumber | ( | const std::filesystem::path & | fileName, |
int | lineNumber | ||
) |
Set fileName
and lineNumber
for the warning.
Note that fileName
can be nullptr, leading to no file information being printed.