libSBML C++ API
5.20.2
|
This class of objects is defined by libSBML only and has no direct equivalent in terms of SBML components. This class is not prescribed by the SBML specifications, although it is used to implement features defined in SBML.
The error log is a list. Each SBMLDocument maintains its own SBMLErrorLog. When a libSBML operation on SBML content results in an error, or when there is something worth noting about the SBML content, the issue is reported as an SBMLError object stored in the SBMLErrorLog list.
SBMLErrorLog is derived from XMLErrorLog, an object class that serves exactly the same purpose but for the XML parsing layer. XMLErrorLog provides crucial methods such as getNumErrors() for determining how many SBMLError or XMLError objects are in the log. SBMLErrorLog inherits these methods.
The general approach to working with SBMLErrorLog in user programs involves first obtaining a pointer to a log from a libSBML object such as SBMLDocument. Callers should then use getNumErrors() to inquire how many objects there are in the list. (The answer may be 0.) If there is at least one SBMLError object in the SBMLErrorLog instance, callers can then iterate over the list using SBMLErrorLog::getError()const, using methods provided by the SBMLError class to find out the error code and associated information such as the error severity, the message, and the line number in the input.
If you wish to simply print the error strings for a human to read, an easier and more direct way might be to use SBMLDocument::printErrors().
Public Member Functions | |
void | changeErrorSeverity (XMLErrorSeverity_t originalSeverity, XMLErrorSeverity_t targetSeverity, std::string package="all") |
Changes the severity override for errors in the log that have a given severity. More... | |
void | clearLog () |
Deletes all errors from this log. More... | |
bool | contains (const unsigned int errorId) const |
Returns true if SBMLErrorLog contains an errorId. More... | |
const SBMLError * | getError (unsigned int n) const |
Returns the nth SBMLError object in this log. More... | |
const SBMLError * | getErrorWithSeverity (unsigned int n, unsigned int severity) const |
Returns the nth SBMLError object with given severity in this log. More... | |
unsigned int | getNumErrors () const |
Returns the number of errors that have been logged. More... | |
unsigned int | getNumFailsWithSeverity (unsigned int severity) |
Returns the number of errors that have been logged with the given severity code. More... | |
unsigned int | getNumFailsWithSeverity (unsigned int severity) const |
Returns the number of errors that have been logged with the given severity code. More... | |
XMLErrorSeverityOverride_t | getSeverityOverride () const |
Returns the current override. More... | |
bool | isSeverityOverridden () const |
Returns a boolean indicating whether or not the severity has been overridden. More... | |
void | printErrors (std::ostream &stream, unsigned int severity) const |
Prints the errors or warnings with given severity stored in this error log. More... | |
void | printErrors (std::ostream &stream=std::cerr) const |
Prints all the errors or warnings stored in this error log. More... | |
void | remove (const unsigned int errorId) |
Removes an error having errorId from the SBMLError list. More... | |
void | removeAll (const unsigned int errorId) |
Removes all errors having errorId from the SBMLError list. More... | |
void | setSeverityOverride (XMLErrorSeverityOverride_t severity) |
Set the severity override. More... | |
std::string | toString () const |
Writes all errors contained in this log to a string and returns it. More... | |
void | unsetSeverityOverride () |
Usets an existing override. More... | |
|
inherited |
Changes the severity override for errors in the log that have a given severity.
This method searches through the list of errors in the log, comparing each one's severity to the value of originalSeverity
. For each error encountered with that severity logged by the named package
, the severity of the error is reset to targetSeverity
.
originalSeverity | the severity code to match. |
targetSeverity | the severity code to use as the new severity. |
package | a string, the name of an SBML Level 3 package extension to use to narrow the search for errors. A value of "all" signifies to match against errors logged from any package; a value of a package nickname such as "comp" signifies to limit consideration to errors from just that package. If no value is provided, "all" is the default. |
|
inherited |
Deletes all errors from this log.
bool SBMLErrorLog::contains | ( | const unsigned int | errorId | ) | const |
Returns true
if SBMLErrorLog contains an errorId.
errorId | the error identifier of the error to be found. |
const SBMLError * SBMLErrorLog::getError | ( | unsigned int | n | ) | const |
Returns the nth SBMLError object in this log.
Index n
is counted from 0. Callers should first inquire about the number of items in the log by using the getNumErrors() method. Attempts to use an error index number that exceeds the actual number of errors in the log will result in a NULL
being returned.
n | the index number of the error to retrieve (with 0 being the first error). |
NULL
if n
is greater than or equal to getNumErrors().const SBMLError * SBMLErrorLog::getErrorWithSeverity | ( | unsigned int | n, |
unsigned int | severity | ||
) | const |
Returns the nth SBMLError object with given severity in this log.
Index n
is counted from 0. Callers should first inquire about the number of items in the log by using the getNumFailsWithSeverity() method. Attempts to use an error index number that exceeds the actual number of errors in the log will result in a NULL
being returned.
n | the index number of the error to retrieve (with 0 being the first error). |
severity | the severity of the error to retrieve. |
NULL
if n
is greater than or equal to getNumFailsWithSeverity().
|
inherited |
Returns the number of errors that have been logged.
To retrieve individual errors from the log, callers may use getError().
unsigned int SBMLErrorLog::getNumFailsWithSeverity | ( | unsigned int | severity | ) |
Returns the number of errors that have been logged with the given severity code.
severity | a value from SBMLErrorSeverity_t |
unsigned int SBMLErrorLog::getNumFailsWithSeverity | ( | unsigned int | severity | ) | const |
Returns the number of errors that have been logged with the given severity code.
severity | a value from SBMLErrorSeverity_t |
|
inherited |
Returns the current override.
|
inherited |
Returns a boolean indicating whether or not the severity has been overridden.
true
if an error severity override has been set, false
otherwise.
|
inherited |
Prints the errors or warnings with given severity stored in this error log.
This method prints the text to the stream given by the optional parameter stream
. If no stream is given, the method prints the output to the standard error stream.
The format of the output is:
N error(s): line NNN: (id) message
If no errors with that severity was found, then no output will be produced.
stream | the ostream or ostringstream object indicating where the output should be printed. |
severity | the severity of the errors sought. |
|
inherited |
Prints all the errors or warnings stored in this error log.
This method prints the text to the stream given by the optional parameter stream
. If no stream is given, the method prints the output to the standard error stream.
The format of the output is:
N error(s): line NNN: (id) message
If no errors have occurred, i.e., getNumErrors() == 0
, then no output will be produced.
stream | the ostream or ostringstream object indicating where the output should be printed. |
void SBMLErrorLog::remove | ( | const unsigned int | errorId | ) |
Removes an error having errorId from the SBMLError list.
Only the first item will be removed if there are multiple errors with the given errorId.
errorId | the error identifier of the error to be removed. |
void SBMLErrorLog::removeAll | ( | const unsigned int | errorId | ) |
Removes all errors having errorId from the SBMLError list.
errorId | the error identifier of the error to be removed. |
|
inherited |
Set the severity override.
severity | an override code indicating what to do. If the value is LIBSBML_OVERRIDE_DISABLED (the default setting) all errors logged will be given the severity specified in their usual definition. If the value is LIBSBML_OVERRIDE_WARNING, then all errors will be logged as warnings. If the value is LIBSBML_OVERRIDE_DONT_LOG, no error will be logged, regardless of their severity. |
|
inherited |
Writes all errors contained in this log to a string and returns it.
This method uses printErrors() to format the diagnostic messages. Please consult that method for information about the organization of the messages in the string returned by this method.
|
inherited |
Usets an existing override.