My Project
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Properties Macros
ExceptionImplBase.h
1 /*
2  * Copyright (C) 2013 Canonical Ltd
3  *
4  * This program is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License version 3 as
6  * published by the Free Software Foundation.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU Lesser General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program. If not, see <http://www.gnu.org/licenses/>.
15  *
16  * Authored by: Michi Henning <michi.henning@canonical.com>
17  */
18 
19 #ifndef UNITY_EXCEPTIONIMPLBASE_H
20 #define UNITY_EXCEPTIONIMPLBASE_H
21 
22 #include <unity/SymbolExport.h>
23 #include <unity/util/NonCopyable.h>
24 
25 #include <exception>
26 #include <string>
27 #include <memory>
28 
29 namespace unity
30 {
31 
32 namespace internal
33 {
34 class ExceptionData;
35 }
36 
37 class Exception;
38 
44 class UNITY_API ExceptionImplBase : public util::NonCopyable
45 {
46 public:
47  explicit ExceptionImplBase(Exception const* owner, std::string const& reason);
49  virtual ~ExceptionImplBase() noexcept;
51 
52  std::string reason() const;
53 
54  std::string to_string(std::nested_exception const* nested, int indent_level, std::string const& indent) const;
55 
56  std::exception_ptr set_earlier(std::exception_ptr earlier_exception);
57  std::exception_ptr get_earlier() const noexcept;
58 
59 private:
60  std::shared_ptr<internal::ExceptionData> p_; // shared_ptr (not unique_ptr) because ExceptionData is incomplete
61 };
62 
63 } // namespace unity
64 
65 #endif