TECA
The Toolkit for Extreme Climate Analysis
teca_bad_cast.h
1
#ifndef teca_bad_cast_h
2
#define teca_bad_cast_h
3
4
#include <exception>
5
#include <string>
6
7
/** @brief
8
* An exception that maybe thrown when a conversion between two data types
9
* fails.
10
*/
11
class
teca_bad_cast
:
public
std::exception
12
{
13
public
:
14
teca_bad_cast
() =
delete
;
15
~
teca_bad_cast
() =
default
;
16
17
teca_bad_cast
(
const
std::string &from,
const
std::string &to);
18
19
const
char
* what()
const
noexcept {
return
m_what.c_str(); }
20
21
private
:
22
std::string m_what;
23
};
24
25
/** returns the class name of the teca_algorithm or the string "nullptr"
26
* if the algorithm is a nullptr.
27
*/
28
template
<
typename
class
_t>
29
const
std::string safe_class_name(
const
class_t &o)
30
{
31
return
o ? std::string(o->get_class_name()) : std::string(
"nullptr"
);
32
}
33
34
#endif
teca_bad_cast
An exception that maybe thrown when a conversion between two data types fails.
Definition:
teca_bad_cast.h:11
rtd_doxygen
core
teca_bad_cast.h
Generated on Thu Oct 14 2021 20:46:27 for TECA by
1.8.17