exception.hpp

Go to the documentation of this file.
00001 /****
00002 ***** Copyright 2010 Intel Corporation All Rights Reserved.
00003 *****
00004 ***** The source code, information and material contained herein are owned by Intel Corporation or its suppliers  *****
00005 ***** or licensors, and title to such Material remains with Intel Corporation or its suppliers or licensors.      *****
00006 ***** The Material contains proprietary information of Intel or its suppliers and licensors. The Material is      *****
00007 ***** protected by worldwide copyright laws and treaty provisions. No part of the Material may be used, copied,   *****
00008 ***** reproduced, modified, published, uploaded, posted, transmitted, distributed or disclosed in any way without *****
00009 ***** Intel's prior express written permission.
00010 *****
00011 ***** No license under any patent, copyright or other intellectual property rights in the material is granted to  *****
00012 ***** or conferred upon you, either expressly, by implication, inducement, estoppel or otherwise. Any license     *****
00013 ***** under such intellectual property rights must be express and approved by Intel in writing.
00014 ****/
00015 
00016 /**** Copyright Ends ****/
00017 
00018 #ifndef ARBB_CPP_EXCEPTION_HPP
00019 #define ARBB_CPP_EXCEPTION_HPP
00020 
00021 #include "namespace.hpp"
00022 #include <exception>
00023 #include <string>
00024 
00025 namespace ARBB_CPP_NS {
00026 
00029 
00033 class exception : public std::exception {
00034 public:
00035   exception(const std::string& message)
00036   : m_message(message)
00037   {}
00038   virtual ~exception() throw() {}
00039 
00040   const char* what() const throw() { return m_message.c_str(); }
00041 
00042 private:
00043   std::string m_message;
00044 };
00045 
00049 class internal_error : public exception {
00050 public:
00051   internal_error(const std::string& message)
00052   : exception(message)
00053   {}
00054 };
00055 
00058 class out_of_bounds : public exception {
00059 public:
00060   out_of_bounds(const std::string& message)
00061   : exception(message)
00062   {}
00063 };
00064 
00067 class arithmetic_error : public exception {
00068 public:
00069   arithmetic_error(const std::string& message)
00070   : exception(message)
00071   {}
00072 };
00073 
00075 class bad_alloc : public exception {
00076 public:
00077   bad_alloc(const std::string& message)
00078   : exception(message)
00079   {}
00080 };
00081 
00083 class uninitialized_access : public exception {
00084 public:
00085   uninitialized_access(const std::string& message)
00086   : exception(message)
00087   {}
00088 };
00089 
00091 class invalid_op_within_map : public exception {
00092 public:
00093   invalid_op_within_map(const std::string& message)
00094   : exception(message)
00095   {}
00096 };
00097 
00099 
00100 } // namespace ARBB_CPP_NS
00101 
00103 
00104 // Internal macro used to work around an issue on some compilers where
00105 // exception types are not rethrown correctly in all cases.
00106 #define arbb_rethrow(e) \
00107     if (dynamic_cast<ARBB_CPP_NS::internal_error*>(&e) != 0){ \
00108       ARBB_CPP_NS::internal_error* new_ceh = dynamic_cast<ARBB_CPP_NS::internal_error*>(&e);\
00109       throw *new_ceh; \
00110     } else if (dynamic_cast<ARBB_CPP_NS::out_of_bounds*>(&e)!= 0){ \
00111       ARBB_CPP_NS::out_of_bounds* new_ceh = dynamic_cast<ARBB_CPP_NS::out_of_bounds*>(&e);\
00112       throw *new_ceh; \
00113     } else if (dynamic_cast<ARBB_CPP_NS::arithmetic_error*>(&e)!= 0){ \
00114       ARBB_CPP_NS::arithmetic_error* new_ceh = dynamic_cast<ARBB_CPP_NS::arithmetic_error*>(&e);\
00115       throw *new_ceh; \
00116     } else if (dynamic_cast<ARBB_CPP_NS::bad_alloc*>(&e)!= 0){ \
00117       ARBB_CPP_NS::bad_alloc* new_ceh = dynamic_cast<ARBB_CPP_NS::bad_alloc*>(&e);\
00118       throw *new_ceh; \
00119     } else if (dynamic_cast<ARBB_CPP_NS::uninitialized_access*>(&e)!= 0){ \
00120       ARBB_CPP_NS::uninitialized_access* new_ceh = dynamic_cast<ARBB_CPP_NS::uninitialized_access*>(&e);\
00121       throw *new_ceh; \
00122     } else if (dynamic_cast<ARBB_CPP_NS::invalid_op_within_map*>(&e)!= 0){ \
00123       ARBB_CPP_NS::invalid_op_within_map* new_ceh = dynamic_cast<ARBB_CPP_NS::invalid_op_within_map*>(&e);\
00124       throw *new_ceh; \
00125     } else throw e
00126 
00128 
00129 #endif // ARBB_CPP_EXCEPTION_HPP

Submit feedback on this help topic

Copyright © 2010, Intel Corporation. All rights reserved.