ICU 73.2  73.2
errorcode.h
Go to the documentation of this file.
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 
00030 #if U_SHOW_CPLUSPLUS_API
00031 
00032 #include "unicode/uobject.h"
00033 
00034 U_NAMESPACE_BEGIN
00035 
00084 class U_COMMON_API ErrorCode: public UMemory {
00085 public:
00090     ErrorCode() : errorCode(U_ZERO_ERROR) {}
00092     virtual ~ErrorCode();
00094     operator UErrorCode & () { return errorCode; }
00096     operator UErrorCode * () { return &errorCode; }
00098     UBool isSuccess() const { return U_SUCCESS(errorCode); }
00100     UBool isFailure() const { return U_FAILURE(errorCode); }
00102     UErrorCode get() const { return errorCode; }
00104     void set(UErrorCode value) { errorCode=value; }
00106     UErrorCode reset();
00116     void assertSuccess() const;
00123     const char* errorName() const;
00124 
00125 protected:
00130     UErrorCode errorCode;
00137     virtual void handleFailure() const {}
00138 };
00139 
00140 U_NAMESPACE_END
00141 
00142 #endif /* U_SHOW_CPLUSPLUS_API */
00143 
00144 #endif  // __ERRORCODE_H__