Loading...
Searching...
No Matches
errorcode.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
*
* Copyright (C) 2009-2011, International Business Machines
* Corporation and others. All Rights Reserved.
*
*******************************************************************************
* file name: errorcode.h
* encoding: UTF-8
* tab size: 8 (not used)
* indentation:4
*
* created on: 2009mar10
* created by: Markus W. Scherer
*/
#ifndef __ERRORCODE_H__
#define __ERRORCODE_H__
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#include "unicode/uobject.h"
U_NAMESPACE_BEGIN
class U_COMMON_API ErrorCode: public UMemory {
public:
ErrorCode() : errorCode(U_ZERO_ERROR) {}
virtual ~ErrorCode();
operator UErrorCode & () { return errorCode; }
operator UErrorCode * () { return &errorCode; }
UBool isSuccess() const { return U_SUCCESS(errorCode); }
UBool isFailure() const { return U_FAILURE(errorCode); }
UErrorCode get() const { return errorCode; }
void set(UErrorCode value) { errorCode=value; }
UErrorCode reset();
void assertSuccess() const;
const char* errorName() const;
protected:
UErrorCode errorCode;
virtual void handleFailure() const {}
};
U_NAMESPACE_END
#endif /* U_SHOW_CPLUSPLUS_API */
#endif // __ERRORCODE_H__
icu::ErrorCode::isFailure
UBool isFailure() const
Tests for U_FAILURE().
Definition errorcode.h:100
icu::ErrorCode::~ErrorCode
virtual ~ErrorCode()
Destructor, does nothing.
icu::ErrorCode::handleFailure
virtual void handleFailure() const
Called by assertSuccess() if isFailure() is true.
Definition errorcode.h:137
icu::ErrorCode::assertSuccess
void assertSuccess() const
Asserts isSuccess().
icu::ErrorCode::errorCode
UErrorCode errorCode
Internal UErrorCode, accessible to subclasses.
Definition errorcode.h:130
icu::ErrorCode::isSuccess
UBool isSuccess() const
Tests for U_SUCCESS().
Definition errorcode.h:98
icu::ErrorCode::set
void set(UErrorCode value)
Sets the UErrorCode value.
Definition errorcode.h:104
icu::ErrorCode::reset
UErrorCode reset()
Returns the UErrorCode value and resets it to U_ZERO_ERROR.
icu::ErrorCode::get
UErrorCode get() const
Returns the UErrorCode value.
Definition errorcode.h:102
icu::ErrorCode::ErrorCode
ErrorCode()
Default constructor.
Definition errorcode.h:90
icu::ErrorCode::errorName
const char * errorName() const
Return a string for the UErrorCode value.
icu::UMemory
UMemory is the common ICU base class.
Definition uobject.h:115
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition umachine.h:269
uobject.h
C++ API: Common ICU base class UObject.
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
U_ZERO_ERROR
@ U_ZERO_ERROR
No error, no warning.
Definition utypes.h:544
U_FAILURE
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition utypes.h:827
U_SUCCESS
#define U_SUCCESS(x)
Does the error code indicate success?
Definition utypes.h:822
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition utypes.h:315