libSBML Perl API  libSBML 5.8.0 Perl API
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
SBMLErrorLog Class Reference
Inheritance diagram for SBMLErrorLog:
[legend]

Detailed Description

Log of errors and other events encountered during SBML processing.

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(), 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().

See Also
SBMLError
XMLErrorLog
XMLError

Public Member Functions

void clearLog ()
 Deletes all errors from this log. More...
 
bool contains (const unsigned int errorId)
 Returns true if SBMLErrorLog contains an errorId. More...
 
const SBMLErrorgetError (unsigned int n) const
 Returns the nth SBMLError object 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...
 
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...
 
std::string toString () const
 Writes all errors contained in this log to a string and returns it. More...
 

Member Function Documentation

void XMLErrorLog::clearLog ( )
inherited

Deletes all errors from this log.

bool SBMLErrorLog::contains ( const unsigned int  errorId)

Returns true if SBMLErrorLog contains an errorId.

Parameters
errorIdthe 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.

Parameters
nthe index number of the error to retrieve (with 0 being the first error).
Returns
the nth SBMLError in this log, or NULL if n is greater than or equal to getNumErrors().
See Also
getNumErrors()
unsigned int XMLErrorLog::getNumErrors ( ) const
inherited

Returns the number of errors that have been logged.

To retrieve individual errors from the log, callers may use XMLErrorLog::getError(unsigned int n) .

Returns
the number of errors that have been logged.
unsigned int SBMLErrorLog::getNumFailsWithSeverity ( unsigned int  severity)

Returns the number of errors that have been logged with the given severity code.

LibSBML associates severity levels with every SBMLError object to provide an indication of how serious the problem is. Severities range from informational diagnostics to fatal (irrecoverable) errors. Given an SBMLError object instance, a caller can interrogate it for its severity level using methods such as SBMLError::getSeverity(), SBMLError::isFatal(), and so on. The present method encapsulates iteration and interrogation of all objects in an SBMLErrorLog, making it easy to check for the presence of error objects with specific severity levels.

Returns
a count of the number of errors with the given severity code.
See Also
getNumErrors()
unsigned int SBMLErrorLog::getNumFailsWithSeverity ( unsigned int  severity) const

Returns the number of errors that have been logged with the given severity code.

LibSBML associates severity levels with every SBMLError object to provide an indication of how serious the problem is. Severities range from informational diagnostics to fatal (irrecoverable) errors. Given an SBMLError object instance, a caller can interrogate it for its severity level using methods such as SBMLError::getSeverity(), SBMLError::isFatal(), and so on. The present method encapsulates iteration and interrogation of all objects in an SBMLErrorLog, making it easy to check for the presence of error objects with specific severity levels.

Returns
a count of the number of errors with the given severity code.
See Also
getNumErrors()
void XMLErrorLog::printErrors ( std::ostream &  stream = std::cerr) const
inherited

Prints all the errors or warnings stored in this error log.

It prints the text to the stream given by the optional parameter stream. If no parameter is given, it prints the output to the standard error stream.

If no errors have occurred, i.e., getNumErrors() == 0, no output will be sent to the stream.

The format of the output is:

  N error(s):
    line NNN: (id) message
Parameters
streamthe ostream or ostringstream object indicating where the output should be printed.
Documentation note:
The native C++ implementation of this method defines a default argument value. In the documentation generated for different libSBML language bindings, you may or may not see corresponding arguments in the method declarations. For example, in Java and C#, a default argument is handled by declaring two separate methods, with one of them having the argument and the other one lacking the argument. However, the libSBML documentation will be identical for both methods. Consequently, if you are reading this and do not see an argument even though one is described, please look for descriptions of other variants of this method near where this one appears in the documentation.
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.

Parameters
errorIdthe error identifier of the error to be removed.
string XMLErrorLog::toString ( ) const
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.

Returns
a string containing all logged errors and warnings.
See Also
printErrors()