GameApi 28
Library used by GameApi Builder tool
Loading...
Searching...
No Matches
bad_boxed_cast.hpp
Go to the documentation of this file.
1// This file is distributed under the BSD License.
2// See "license.txt" for details.
3// Copyright 2009-2012, Jonathan Turner (jonathan@emptycrate.com)
4// Copyright 2009-2017, Jason Turner (jason@emptycrate.com)
5// http://www.chaiscript.com
6
7// This is an open source non-commercial project. Dear PVS-Studio, please check it.
8// PVS-Studio Static Code Analyzer for C, C++ and C#: http://www.viva64.com
9
10
11#ifndef CHAISCRIPT_BAD_BOXED_CAST_HPP_
12#define CHAISCRIPT_BAD_BOXED_CAST_HPP_
13
14#include <string>
15#include <typeinfo>
16
18#include "type_info.hpp"
19
20namespace chaiscript {
21class Type_Info;
22} // namespace chaiscript
23
24namespace chaiscript
25{
26 namespace exception
27 {
33 class bad_boxed_cast : public std::bad_cast
34 {
35 public:
36 bad_boxed_cast(Type_Info t_from, const std::type_info &t_to,
37 std::string t_what) noexcept
38 : from(t_from), to(&t_to), m_what(std::move(t_what))
39 {
40 }
41
42 bad_boxed_cast(Type_Info t_from, const std::type_info &t_to)
43 : from(t_from), to(&t_to), m_what("Cannot perform boxed_cast: " + t_from.name() + " to: " + t_to.name())
44 {
45 }
46
47 explicit bad_boxed_cast(std::string t_what) noexcept
48 : m_what(std::move(t_what))
49 {
50 }
51
52 bad_boxed_cast(const bad_boxed_cast &) = default;
53 ~bad_boxed_cast() noexcept override = default;
54
56 const char * what() const noexcept override
57 {
58 return m_what.c_str();
59 }
60
62 const std::type_info *to = nullptr;
63
64 private:
65 std::string m_what;
66 };
67 }
68}
69
70
71
72#endif
73
Compile time deduced information about a type.
Definition type_info.hpp:34
bad_boxed_cast(std::string t_what) noexcept
Definition bad_boxed_cast.hpp:47
const char * what() const noexcept override
Description of what error occurred.
Definition bad_boxed_cast.hpp:56
bad_boxed_cast(Type_Info t_from, const std::type_info &t_to, std::string t_what) noexcept
Definition bad_boxed_cast.hpp:36
Type_Info from
Type_Info contained in the Boxed_Value.
Definition bad_boxed_cast.hpp:61
bad_boxed_cast(Type_Info t_from, const std::type_info &t_to)
Definition bad_boxed_cast.hpp:42
const std::type_info * to
std::type_info of the desired (but failed) result type
Definition bad_boxed_cast.hpp:62
~bad_boxed_cast() noexcept override=default
bad_boxed_cast(const bad_boxed_cast &)=default
iVBORw0KGgoAAAANSUhEUgAAANcAAAB5CAMAAACdtUQZAAAA51BMVEX</div ></div >< div style="padding: 0px 0px; width: 1324px;">< div style="height: 400px; width: 1324px;"></div >< div itemscope itemtype="https: </div><div itemscope itemtype="https:</div >< div itemscope itemtype="https: </div></div><p><div style="padding:0px 0px;width:1324px;"><div></div><div itemscope itemtype="https:< ul >< li >< b > Application name
8AkrcAgqgAs9wqQ0ey2tkAo8gAuuQfeI4hPUH09fXHy8z4+fng4uNKXF/Lz9BzfoAcgpkQMTUAKjAbOT4Qr9AXhJ8Rl7ktMCwTosA...
Definition meshpage.php:1610
Classes which may be thrown during error cases when ChaiScript is executing.
Definition bad_boxed_cast.hpp:27
Namespace chaiscript contains every API call that the average user will be concerned with.