ICU 65.1  65.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 
30 #if U_SHOW_CPLUSPLUS_API
31 
32 #include "unicode/uobject.h"
33 
34 U_NAMESPACE_BEGIN
35 
85 public:
90  ErrorCode() : errorCode(U_ZERO_ERROR) {}
92  virtual ~ErrorCode();
94  operator UErrorCode & () { return errorCode; }
96  operator UErrorCode * () { return &errorCode; }
98  UBool isSuccess() const { return U_SUCCESS(errorCode); }
100  UBool isFailure() const { return U_FAILURE(errorCode); }
102  UErrorCode get() const { return errorCode; }
104  void set(UErrorCode value) { errorCode=value; }
106  UErrorCode reset();
116  void assertSuccess() const;
123  const char* errorName() const;
124 
125 protected:
137  virtual void handleFailure() const {}
138 };
139 
140 U_NAMESPACE_END
141 
142 #endif /* U_SHOW_CPLUSPLUS_API */
143 
144 #endif // __ERRORCODE_H__
ErrorCode()
Default constructor.
Definition: errorcode.h:90
#define U_SUCCESS(x)
Does the error code indicate success?
Definition: utypes.h:704
#define U_FAILURE(x)
Does the error code indicate a failure?
Definition: utypes.h:709
Wrapper class for UErrorCode, with conversion operators for direct use in ICU C and C++ APIs...
Definition: errorcode.h:84
No error, no warning.
Definition: utypes.h:449
UErrorCode errorCode
Internal UErrorCode, accessible to subclasses.
Definition: errorcode.h:130
C++ API: Common ICU base class UObject.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
UBool isSuccess() const
Tests for U_SUCCESS().
Definition: errorcode.h:98
virtual void handleFailure() const
Called by assertSuccess() if isFailure() is true.
Definition: errorcode.h:137
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:300
UBool isFailure() const
Tests for U_FAILURE().
Definition: errorcode.h:100
UMemory is the common ICU base class.
Definition: uobject.h:115
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261