ICU 56.1: errorcode.h Source File

ICU 56.1 56.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

errorcode.h
Go to the documentation of this file.
1 /*
2 *******************************************************************************
3 *
4 * Copyright (C) 2009-2011, International Business Machines
5 * Corporation and others. All Rights Reserved.
6 *
7 *******************************************************************************
8 * file name: errorcode.h
9 * encoding: US-ASCII
10 * tab size: 8 (not used)
11 * indentation:4
12 *
13 * created on: 2009mar10
14 * created by: Markus W. Scherer
15 */
16
17 #ifndef __ERRORCODE_H__
18 #define __ERRORCODE_H__
19
26 #include "unicode/utypes.h"
27 #include "unicode/uobject.h"
28
29 U_NAMESPACE_BEGIN
30
79 class U_COMMON_API ErrorCode: public UMemory {
80 public:
85 ErrorCode() : errorCode(U_ZERO_ERROR) {}
87 virtual ~ErrorCode();
89 operator UErrorCode & () { return errorCode; }
91 operator UErrorCode * () { return &errorCode; }
93 UBool isSuccess() const { return U_SUCCESS(errorCode); }
95 UBool isFailure() const { return U_FAILURE(errorCode); }
97 UErrorCode get() const { return errorCode; }
99 void set(UErrorCode value) { errorCode=value; }
101 UErrorCode reset();
111 void assertSuccess() const;
118 const char* errorName() const;
119
120 protected:
125 UErrorCode errorCode;
132 virtual void handleFailure() const {}
133 };
134
135 U_NAMESPACE_END
136
137 #endif // __ERRORCODE_H__
icu::ErrorCode::handleFailure
virtual void handleFailure() const
Called by assertSuccess() if isFailure() is true.
Definition: errorcode.h:132
icu::ErrorCode::ErrorCode
ErrorCode()
Default constructor.
Definition: errorcode.h:85
U_SUCCESS
#define U_SUCCESS(x)
Does the error code indicate success?
Definition: utypes.h:711
U_FAILURE
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition: utypes.h:716
icu::ErrorCode::set
void set(UErrorCode value)
Sets the UErrorCode value.
Definition: errorcode.h:99
icu::ErrorCode
Wrapper class for UErrorCode, with conversion operators for direct use in ICU C and C++ APIs...
Definition: errorcode.h:79
U_ZERO_ERROR
No error, no warning.
Definition: utypes.h:505
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
icu::ErrorCode::errorCode
UErrorCode errorCode
Internal UErrorCode, accessible to subclasses.
Definition: errorcode.h:125
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:130
icu::ErrorCode::isSuccess
UBool isSuccess() const
Tests for U_SUCCESS().
Definition: errorcode.h:93
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
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:357
icu::ErrorCode::isFailure
UBool isFailure() const
Tests for U_FAILURE().
Definition: errorcode.h:95
icu::UMemory
UMemory is the common ICU base class.
Definition: uobject.h:110
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234