Wrapper class for UErrorCode, with conversion operators for direct use in ICU C and C++ APIs.
More...
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.
Features:
- The constructor initializes the internal UErrorCode to U_ZERO_ERROR, removing one common source of errors.
- Same use in C APIs taking a UErrorCode * (pointer) and C++ taking UErrorCode & (reference) via conversion operators.
- Possible automatic checking for success when it goes out of scope.
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:
public:
if(isFailure()) { handleFailure(); }
}
protected:
virtual void handleFailure() const {
}
};
"Smart pointer" base class; do not use directly: use LocalPointer etc.
void ucnv_close(UConverter *converter)
Deletes the unicode converter and releases resources associated with just this instance.
int32_t ucnv_fromUChars(UConverter *cnv, char *dest, int32_t destCapacity, const UChar *src, int32_t srcLength, UErrorCode *pErrorCode)
Convert the Unicode string into a codepage string using an existing UConverter.
UConverter * ucnv_open(const char *converterName, UErrorCode *err)
Creates a UConverter object with the name of a coded character set specified as a C string.
struct UConverter UConverter
const char * u_errorName(UErrorCode code)
Return a string for a UErrorCode value.
- Stable:
- ICU 4.2
Definition at line 79 of file errorcode.h.