blob: 2fcae2fa7b601f2dc14044aba15568da03bd4b1b [file] [log] [blame]
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07001//Copyright (c) 2006-2010 Emil Dotchevski and Reverge Studios, Inc.
2
3//Distributed under the Boost Software License, Version 1.0. (See accompanying
4//file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
5
Jeff Thompson2491bd62013-10-15 17:10:24 -07006#ifndef NDNBOOST_UUID_C3E1741C754311DDB2834CCA55D89593
7#define NDNBOOST_UUID_C3E1741C754311DDB2834CCA55D89593
Jeff Thompson3d613fd2013-10-15 15:39:04 -07008#if (__GNUC__*100+__GNUC_MINOR__>301) && !defined(NDNBOOST_EXCEPTION_ENABLE_WARNINGS)
Jeff Thompsonef2d5a42013-08-22 19:09:24 -07009#pragma GCC system_header
10#endif
Jeff Thompson3d613fd2013-10-15 15:39:04 -070011#if defined(_MSC_VER) && !defined(NDNBOOST_EXCEPTION_ENABLE_WARNINGS)
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070012#pragma warning(push,1)
13#endif
14
15#include <ndnboost/detail/sp_typeinfo.hpp>
16#include <ndnboost/current_function.hpp>
17#include <ndnboost/config.hpp>
Jeff Thompson3d613fd2013-10-15 15:39:04 -070018#ifndef NDNBOOST_NO_TYPEID
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070019#include <ndnboost/units/detail/utility.hpp>
20#endif
21#include <string>
22
23namespace
24ndnboost
25 {
26 template <class T>
27 inline
28 std::string
29 tag_type_name()
30 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070031#ifdef NDNBOOST_NO_TYPEID
32 return NDNBOOST_CURRENT_FUNCTION;
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070033#else
34 return units::detail::demangle(typeid(T*).name());
35#endif
36 }
37
38 template <class T>
39 inline
40 std::string
41 type_name()
42 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070043#ifdef NDNBOOST_NO_TYPEID
44 return NDNBOOST_CURRENT_FUNCTION;
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070045#else
46 return units::detail::demangle(typeid(T).name());
47#endif
48 }
49
50 namespace
51 exception_detail
52 {
53 struct
54 type_info_
55 {
56 detail::sp_typeinfo const * type_;
57
58 explicit
59 type_info_( detail::sp_typeinfo const & type ):
60 type_(&type)
61 {
62 }
63
64 friend
65 bool
66 operator<( type_info_ const & a, type_info_ const & b )
67 {
68 return 0!=(a.type_->before(*b.type_));
69 }
70 };
71 }
72 }
73
Jeff Thompson3d613fd2013-10-15 15:39:04 -070074#define NDNBOOST_EXCEPTION_STATIC_TYPEID(T) ::ndnboost::exception_detail::type_info_(NDNBOOST_SP_TYPEID(T))
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070075
Jeff Thompson3d613fd2013-10-15 15:39:04 -070076#ifndef NDNBOOST_NO_RTTI
77#define NDNBOOST_EXCEPTION_DYNAMIC_TYPEID(x) ::ndnboost::exception_detail::type_info_(typeid(x))
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070078#endif
79
Jeff Thompson3d613fd2013-10-15 15:39:04 -070080#if defined(_MSC_VER) && !defined(NDNBOOST_EXCEPTION_ENABLE_WARNINGS)
Jeff Thompsonef2d5a42013-08-22 19:09:24 -070081#pragma warning(pop)
82#endif
83#endif