00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ******************************************************************************* 00005 * 00006 * Copyright (C) 2009-2011, International Business Machines 00007 * Corporation and others. All Rights Reserved. 00008 * 00009 ******************************************************************************* 00010 * file name: errorcode.h 00011 * encoding: UTF-8 00012 * tab size: 8 (not used) 00013 * indentation:4 00014 * 00015 * created on: 2009mar10 00016 * created by: Markus W. Scherer 00017 */ 00018 00019 #ifndef __ERRORCODE_H__ 00020 #define __ERRORCODE_H__ 00021 00028 #include "unicode/utypes.h" 00029 #include "unicode/uobject.h" 00030 00031 U_NAMESPACE_BEGIN 00032 00081 class U_COMMON_API ErrorCode: public UMemory { 00082 public: 00087 ErrorCode() : errorCode(U_ZERO_ERROR) {} 00089 virtual ~ErrorCode(); 00091 operator UErrorCode & () { return errorCode; } 00093 operator UErrorCode * () { return &errorCode; } 00095 UBool isSuccess() const { return U_SUCCESS(errorCode); } 00097 UBool isFailure() const { return U_FAILURE(errorCode); } 00099 UErrorCode get() const { return errorCode; } 00101 void set(UErrorCode value) { errorCode=value; } 00103 UErrorCode reset(); 00113 void assertSuccess() const; 00120 const char* errorName() const; 00121 00122 protected: 00127 UErrorCode errorCode; 00134 virtual void handleFailure() const {} 00135 }; 00136 00137 U_NAMESPACE_END 00138 00139 #endif // __ERRORCODE_H__
1.6.1