Changeset 30949 in vbox
- Timestamp:
- Jul 21, 2010 11:35:03 AM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/cpp/exception.h
r30833 r30949 1 1 /** @file 2 * IPRT - C++ Utilities (useful templates, defines and such).2 * IPRT - C++ Base Exceptions. 3 3 */ 4 4 5 5 /* 6 * Copyright (C) 2006-20 07Oracle Corporation6 * Copyright (C) 2006-2010 Oracle Corporation 7 7 * 8 8 * This file is part of VirtualBox Open Source Edition (OSE), as … … 24 24 */ 25 25 26 #ifndef ___iprt_ exception_h27 #define ___iprt_ exception_h26 #ifndef ___iprt_cpp_exception_h 27 #define ___iprt_cpp_exception_h 28 28 29 29 #include <iprt/cpp/ministring.h> 30 30 31 /** @defgroup grp_rt_cpp utilsC++ Exceptions31 /** @defgroup grp_rt_cppxcpt C++ Exceptions 32 32 * @ingroup grp_rt 33 33 * @{ … … 82 82 83 83 private: 84 // hide the default constructor to make sure the extended one above is always used 84 /* Hide the default constructor to make sure the extended one above is 85 always used. */ 85 86 Error(); 86 87 … … 88 89 }; 89 90 90 } / / namespace iprt91 } /* namespace iprt */ 91 92 92 93 /** @} */ 93 94 94 #endif // ___iprt_cpputils_h95 #endif 95 96 96 /** @file97 * IPRT - C++ Utilities (useful templates, defines and such).98 */99 100 /*101 * Copyright (C) 2006-2007 Oracle Corporation102 *103 * This file is part of VirtualBox Open Source Edition (OSE), as104 * available from http://www.virtualbox.org. This file is free software;105 * you can redistribute it and/or modify it under the terms of the GNU106 * General Public License (GPL) as published by the Free Software107 * Foundation, in version 2 as it comes in the "COPYING" file of the108 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the109 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.110 *111 * The contents of this file may alternatively be used under the terms112 * of the Common Development and Distribution License Version 1.0113 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the114 * VirtualBox OSE distribution, in which case the provisions of the115 * CDDL are applicable instead of those of the GPL.116 *117 * You may elect to license modified versions of this file under the118 * terms and conditions of either the GPL or the CDDL or both.119 */120 121 #ifndef ___iprt_exception_h122 #define ___iprt_exception_h123 124 #include <iprt/cpp/ministring.h>125 126 /** @defgroup grp_rt_cpputils C++ Exceptions127 * @ingroup grp_rt128 * @{129 */130 131 namespace iprt132 {133 134 /**135 * Base exception class for IPRT, derived from std::exception.136 * The XML exceptions are based on this.137 */138 class RT_DECL_CLASS Error139 : public std::exception140 {141 public:142 143 Error(const char *pcszMessage)144 : m_s(pcszMessage)145 {146 }147 148 Error(const iprt::MiniString &s)149 : m_s(s)150 {151 }152 153 Error(const Error &s)154 : std::exception(s),155 m_s(s.what())156 {157 }158 159 virtual ~Error() throw()160 {161 }162 163 void operator=(const Error &s)164 {165 m_s = s.what();166 }167 168 void setWhat(const char *pcszMessage)169 {170 m_s = pcszMessage;171 }172 173 virtual const char* what() const throw()174 {175 return m_s.c_str();176 }177 178 private:179 // hide the default constructor to make sure the extended one above is always used180 Error();181 182 iprt::MiniString m_s;183 };184 185 } // namespace iprt186 187 /** @} */188 189 #endif // ___iprt_cpputils_h190
Note:
See TracChangeset
for help on using the changeset viewer.