Loading...
Searching...
No Matches
TfErrorMark Class Reference

Class used to record the end of the error-list. More...

#include <errorMark.h>

Public Types

typedef TfDiagnosticMgr::ErrorIterator Iterator
 

Public Member Functions

TF_API TfErrorMark ()
 Default constructor.
 
TF_API ~TfErrorMark ()
 Destroy this ErrorMark.
 
void SetMark ()
 Record future errors.
 
bool IsClean () const
 Return true if no new errors were posted in this thread since the last call to SetMark(), false otherwise.
 
bool Clear () const
 Remove all errors in this mark from the error system.
 
TfErrorTransport Transport () const
 Remove all errors in this mark fom the error system and return them in a TfErrorTransport.
 
void TransportTo (TfErrorTransport &dest) const
 Remove all errors in this mark fom the error system and return them in a TfErrorTransport.
 
Iterator GetBegin (size_t *nErrors=0) const
 Return an iterator to the first error added to the error list after SetMark().
 
Iterator GetEnd () const
 Return an iterator past the last error in the error system.
 
Iterator begin () const
 Equivalent to GetBegin()
 
Iterator end () const
 Equivalent to GetEnd()
 

Friends

class TfDiagnosticMgr
 

Detailed Description

Class used to record the end of the error-list.

See The TfError Error Posting System for a detailed description.

A TfErrorMark is used as follows:

m.SetMark(); // (A)
... ;
... ;
// (B)
if (!m.IsClean()) {
// errors occurred between (A) and (B)
}
Class used to record the end of the error-list.
Definition: errorMark.h:65
bool IsClean() const
Return true if no new errors were posted in this thread since the last call to SetMark(),...
Definition: errorMark.h:99
void SetMark()
Record future errors.
Definition: errorMark.h:88

Another common pattern is

if (TF_HAS_ERRORS(m, expr)) {
// handle errors;
}
#define TF_HAS_ERRORS(marker, expr)
Convenience macro to check if errors occurred.
Definition: errorMark.h:203

Definition at line 64 of file errorMark.h.

Member Typedef Documentation

◆ Iterator

Definition at line 70 of file errorMark.h.

Constructor & Destructor Documentation

◆ TfErrorMark()

TF_API TfErrorMark ( )

Default constructor.

The default constructor automatically calls SetMark() at the point of declaration.

◆ ~TfErrorMark()

TF_API ~TfErrorMark ( )

Destroy this ErrorMark.

If this is the last ErrorMark on this thread of execution and there are pending errors, this will report them via the diagnostic delegate (if one is installed) otherwise by printing to stderr.

Member Function Documentation

◆ begin()

Iterator begin ( ) const
inline

Equivalent to GetBegin()

Definition at line 170 of file errorMark.h.

◆ Clear()

bool Clear ( ) const
inline

Remove all errors in this mark from the error system.

Return true if any errors were cleared, false if there were no errors in this mark.

Clear all errors contained in this mark from the error system. Subsequently, these errors will be considered handled.

Definition at line 109 of file errorMark.h.

◆ end()

Iterator end ( ) const
inline

Equivalent to GetEnd()

Definition at line 173 of file errorMark.h.

◆ GetBegin()

Iterator GetBegin ( size_t *  nErrors = 0) const
inline

Return an iterator to the first error added to the error list after SetMark().

If there are no errors on the error list that were not already present when SetMark() was called, the iterator returned is equal to the iterator returned by TfDiagnosticMgr::GetErrorEnd(). Otherwise, the iterator points to the earliest error added to the list since SetMark() was called.

This function takes O(n) time where n is the number of errors from the end of the list to the mark i.e. GetMark() walks the list from the end until it finds the mark and then returns an iterator to that spot.

If nErrors is non-NULL, then *nErrors is set to the number of errors between the returned iterator and the end of the list.

Definition at line 156 of file errorMark.h.

◆ GetEnd()

Iterator GetEnd ( ) const
inline

Return an iterator past the last error in the error system.

This iterator is always equivalent to the iterator returned by TfDiagnosticMgr::GetErrorEnd().

Definition at line 165 of file errorMark.h.

◆ IsClean()

bool IsClean ( ) const
inline

Return true if no new errors were posted in this thread since the last call to SetMark(), false otherwise.

When no threads are issuing errors the cost of this function is an atomic integer read and comparison. Otherwise thread-specific data is accessed to make the determination. Thus, this function is fast when diagnostics are not being issued.

Definition at line 99 of file errorMark.h.

◆ SetMark()

void SetMark ( )
inline

Record future errors.

SetMark() arranges to record future errors in *this.

Definition at line 88 of file errorMark.h.

◆ Transport()

TfErrorTransport Transport ( ) const
inline

Remove all errors in this mark fom the error system and return them in a TfErrorTransport.

This can be used to transfer errors from one thread to another. See TfErrorTransport for more information. As with Clear(), all the removed errors are considered handled for this thread. See also TransportTo().

Definition at line 126 of file errorMark.h.

◆ TransportTo()

void TransportTo ( TfErrorTransport dest) const
inline

Remove all errors in this mark fom the error system and return them in a TfErrorTransport.

This is a variant of Transport(). Instead of returning a new TfErrorTransport object it fills an existing one.

Definition at line 137 of file errorMark.h.

Friends And Related Function Documentation

◆ TfDiagnosticMgr

friend class TfDiagnosticMgr
friend

Definition at line 176 of file errorMark.h.


The documentation for this class was generated from the following file: