Debian Codegraph @

src/mpt/exception/exception.hpp

raw
1 /* SPDX-License-Identifier: BSL-1.0 OR BSD-3-Clause */
2
3 #ifndef MPT_EXCEPTION_EXCEPTION_HPP
4 #define MPT_EXCEPTION_EXCEPTION_HPP
5
6
7
8 #include "mpt/base/namespace.hpp"
9 #include "mpt/string/types.hpp"
10 #include "mpt/string_transcode/transcode.hpp"
11
12
13
14 namespace mpt {
15 inline namespace MPT_INLINE_NS {
16
17
18
19 class exception_ustring_wrapper_base {
20 protected:
21 exception_ustring_wrapper_base() = default;
22 virtual ~exception_ustring_wrapper_base() = default;
23 public:
24 virtual mpt::ustring uwhat() const = 0;
25 };
26
27 template <typename T>
28 class exception_ustring_wrapper : public T
29 , public virtual mpt::exception_ustring_wrapper_base {
30 private:
31 mpt::ustring m_what;
32 public:
33 exception_ustring_wrapper(mpt::ustring str)
34 : T(mpt::transcode<std::string>(mpt::exception_encoding, str))
35 , m_what(str) {
36 return;
37 }
38 ~exception_ustring_wrapper() override = default;
39 mpt::ustring uwhat() const override {
40 return m_what;
41 }
42 };
43
44
45
46 } // namespace MPT_INLINE_NS
47 } // namespace mpt
48
49
50
51 #endif // MPT_EXCEPTION_EXCEPTION_HPP