ICU 63.1 63.1

errorcode.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 *******************************************************************************
5 *
6 * Copyright (C) 2009-2011, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 * file name: errorcode.h
11 * encoding: UTF-8
12 * tab size: 8 (not used)
13 * indentation:4
14 *
15 * created on: 2009mar10
16 * created by: Markus W. Scherer
17 */
18
19 #ifndef __ERRORCODE_H__
20 #define __ERRORCODE_H__
21
28 #include "unicode/utypes.h"
29 #include "unicode/uobject.h"
30
31 U_NAMESPACE_BEGIN
32
81 class U_COMMON_API ErrorCode: public UMemory {
82 public:
87 ErrorCode() : errorCode(U_ZERO_ERROR) {}
89 virtual ~ErrorCode();
91 operator UErrorCode & () { return errorCode; }
93 operator UErrorCode * () { return &errorCode; }
95 UBool isSuccess() const { return U_SUCCESS(errorCode); }
97 UBool isFailure() const { return U_FAILURE(errorCode); }
99 UErrorCode get() const { return errorCode; }
101 void set(UErrorCode value) { errorCode=value; }
103 UErrorCode reset();
113 void assertSuccess() const;
120 const char* errorName() const;
121
122 protected:
127 UErrorCode errorCode;
134 virtual void handleFailure() const {}
135 };
136
137 U_NAMESPACE_END
138
139 #endif // __ERRORCODE_H__
icu::ErrorCode::ErrorCode
ErrorCode()
Default constructor.
Definition: errorcode.h:87
U_SUCCESS
#define U_SUCCESS(x)
Does the error code indicate success?
Definition: utypes.h:694
U_FAILURE
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition: utypes.h:699
icu::ErrorCode
Wrapper class for UErrorCode, with conversion operators for direct use in ICU C and C++ APIs...
Definition: errorcode.h:81
U_ZERO_ERROR
No error, no warning.
Definition: utypes.h:435
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
icu::ErrorCode::errorCode
UErrorCode errorCode
Internal UErrorCode, accessible to subclasses.
Definition: errorcode.h:127
uobject.h
C++ API: Common ICU base class UObject.
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:401
icu::ErrorCode::isSuccess
UBool isSuccess() const
Tests for U_SUCCESS().
Definition: errorcode.h:95
icu::ErrorCode::handleFailure
virtual void handleFailure() const
Called by assertSuccess() if isFailure() is true.
Definition: errorcode.h:134
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
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:300
icu::ErrorCode::isFailure
UBool isFailure() const
Tests for U_FAILURE().
Definition: errorcode.h:97
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:109
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225