Bytemaster's Boost Libraries
|
00001 #ifndef _BOOST_REFLECT_TYPEINFO_HPP 00002 #define _BOOST_REFLECT_TYPEINFO_HPP 00003 namespace boost { namespace reflect { 00004 00008 template<typename T> 00009 struct get_typeinfo { 00010 enum is_defined_enum{ is_defined = 0 }; 00011 static const char* name() { return typeid(T).name(); } 00012 }; 00013 00017 template<typename T> 00018 inline const char* get_typename() { 00019 return get_typeinfo<typename boost::remove_const< 00020 typename boost::remove_reference< 00021 typename boost::remove_pointer<T>::type>::type>::type>::name(); 00022 } 00023 #ifndef DOXYGEN 00024 template<typename TP> 00025 struct get_typeinfo< std::vector<TP> > { 00026 enum is_defined_enum{ is_defined = get_typeinfo<TP>::is_defined }; 00027 static const char* name() 00028 { 00029 static std::string n = "std::vector<" + std::string(get_typename<TP>()) + ">"; 00030 return n.c_str(); 00031 } 00032 }; 00033 template<typename TP> 00034 struct get_typeinfo< std::list<TP> > { 00035 enum is_defined_enum{ is_defined = get_typeinfo<TP>::is_defined }; 00036 static const char* name() 00037 { 00038 static std::string n = "std::list<" + std::string(get_typename<TP>()) + ">"; 00039 return n.c_str(); 00040 } 00041 }; 00042 00043 template<typename TP, typename TP2> 00044 struct get_typeinfo< std::map<TP,TP2> > { 00045 enum is_defined_enum{ is_defined = get_typeinfo<TP>::is_defined && get_typeinfo<TP2>::is_defined }; 00046 static const char* name() 00047 { 00048 static std::string n = "std::map<" + std::string(get_typename<TP>()) + "," + 00049 std::string(get_typename<TP2>() ) + ">"; 00050 return n.c_str(); 00051 } 00052 }; 00053 #endif 00054 00059 #define BOOST_REFLECT_TYPEINFO( NAME ) \ 00060 namespace boost { namespace reflect { \ 00061 template<> struct get_typeinfo<NAME> { \ 00062 enum is_defined_enum{ is_defined = 1 }; \ 00063 static const char* name() { return BOOST_PP_STRINGIZE(NAME); } \ 00064 }; } } 00065 00066 00070 #define BOOST_REFLECT_TEMPLATE_TYPEINFO( NAME ) \ 00071 namespace boost { namespace reflect {\ 00072 template<> struct get_typeinfo<NAME<void_t> > { \ 00073 enum is_defined_enum{ is_defined = 1 }; \ 00074 static const char* name() { return BOOST_PP_STRINGIZE(NAME); } \ 00075 }; } } 00076 00080 #define BOOST_REFLECT_TEMPLATE2_TYPEINFO( NAME ) \ 00081 namespace boost { namespace reflect {\ 00082 template<> struct get_typeinfo<NAME<void_t,void_t> > { \ 00083 enum is_defined_enum{ is_defined = 1 }; \ 00084 static const char* name() { return BOOST_PP_STRINGIZE(NAME); } \ 00085 }; } } 00086 00087 } } // boost::reflect 00088 00089 00090 // these macros specify namespace boost::reflect 00091 BOOST_REFLECT_TYPEINFO( void ) 00092 BOOST_REFLECT_TYPEINFO( bool ) 00093 BOOST_REFLECT_TYPEINFO( uint8_t ) 00094 BOOST_REFLECT_TYPEINFO( uint16_t ) 00095 BOOST_REFLECT_TYPEINFO( uint32_t ) 00096 BOOST_REFLECT_TYPEINFO( uint64_t ) 00097 BOOST_REFLECT_TYPEINFO( int8_t ) 00098 BOOST_REFLECT_TYPEINFO( int16_t ) 00099 BOOST_REFLECT_TYPEINFO( int32_t ) 00100 BOOST_REFLECT_TYPEINFO( int64_t ) 00101 BOOST_REFLECT_TYPEINFO( double ) 00102 BOOST_REFLECT_TYPEINFO( float ) 00103 BOOST_REFLECT_TYPEINFO( void_t ) 00104 BOOST_REFLECT_TYPEINFO( std::string ) 00105 BOOST_REFLECT_TEMPLATE_TYPEINFO( std::vector ) 00106 BOOST_REFLECT_TEMPLATE_TYPEINFO( std::set ) 00107 BOOST_REFLECT_TEMPLATE_TYPEINFO( std::list ) 00108 BOOST_REFLECT_TEMPLATE2_TYPEINFO( std::map ) 00109 BOOST_REFLECT_TEMPLATE2_TYPEINFO( std::pair ) 00110 00111 #include <boost/reflect/reflect_function_signature.hpp> 00112 00113 #endif