Logo Search packages:      
Sourcecode: icu version File versions  Download package

ErrorCode Class Reference

#include <errorcode.h>

Inheritance diagram for ErrorCode:


List of all members.

Detailed Description

Wrapper class for UErrorCode, with conversion operators for direct use in ICU C and C++ APIs. Intended to be used as a base class, where a subclass overrides the handleFailure() function so that it throws an exception, does an assert(), logs an error, etc. This is not an abstract base class. This class can be used and instantiated by itself, although it will be more useful when subclassed.


Note: For automatic checking for success in the destructor, a subclass must implement such logic in its own destructor because the base class destructor cannot call a subclass function (like handleFailure()). The ErrorCode base class destructor does nothing.

Note also: While it is possible for a destructor to throw an exception, it is generally unsafe to do so. This means that in a subclass the destructor and the handleFailure() function may need to take different actions.

Sample code:

   class IcuErrorCode: public icu::ErrorCode {
     virtual ~IcuErrorCode() {
       // Safe because our handleFailure() does not throw exceptions.
       if(isFailure()) { handleFailure(); }
     virtual void handleFailure() const {
   IcuErrorCode error_code;
   UConverter *cnv = ucnv_open("Shift-JIS", error_code);
   length = ucnv_fromUChars(dest, capacity, src, length, error_code);
   // IcuErrorCode destructor checks for success.

ICU 4.4

Definition at line 79 of file errorcode.h.

Public Member Functions

void assertSuccess () const
 ErrorCode ()
const char * errorName () const
UErrorCode get () const
UBool isFailure () const
UBool isSuccess () const
 operator UErrorCode & ()
 operator UErrorCode * ()
UErrorCode reset ()
void set (UErrorCode value)
virtual ~ErrorCode ()

Static Public Member Functions

static void U_EXPORT2 operator delete (void *, void *) U_NO_THROW
static void U_EXPORT2 operator delete (void *p) U_NO_THROW
static void U_EXPORT2 operator delete[] (void *p) U_NO_THROW
static void *U_EXPORT2 operator new (size_t, void *ptr) U_NO_THROW
static void *U_EXPORT2 operator new (size_t size) U_NO_THROW
static void *U_EXPORT2 operator new[] (size_t size) U_NO_THROW

Protected Member Functions

virtual void handleFailure () const

Protected Attributes

UErrorCode errorCode

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

Generated by  Doxygen 1.6.0   Back to index