Boost Reflect Library 0.1.0
reflect_function_signature.hpp
Go to the documentation of this file.
00001 #ifndef BOOST_PP_IS_ITERATING
00002 
00003 #   ifndef BOOST_REFLECT_FUNCTION_SIGNATURE_HPP
00004 #       define BOOST_REFLECT_FUNCTION_SIGNATURE_HPP
00005 
00006 #       include <boost/preprocessor/repetition.hpp>
00007 #       include <boost/type_traits/remove_const.hpp>
00008 #       include <boost/type_traits/remove_pointer.hpp>
00009 #       include <boost/type_traits/remove_reference.hpp>
00010 #       include <boost/preprocessor/arithmetic/sub.hpp>
00011 #       include <boost/preprocessor/comparison/less.hpp>
00012 #       include <boost/preprocessor/control/expr_if.hpp>
00013 #       include <boost/preprocessor/punctuation/comma_if.hpp>
00014 
00015 #        ifndef GET_REFLECT_PARAMETER_SIZE
00016 #           define GET_REFLECT_PARAMETER_SIZE 8
00017 #        endif
00018 
00019 
00020 namespace boost { namespace reflect {
00021 
00022 #ifndef RCR
00023 #define RCR(X) typename boost::remove_const<typename boost::remove_reference<X>::type>::type
00024 #endif
00025     
00026         #define ADD_PARAM(z,n,v)    *sig += get_typename<RCR(BOOST_PP_CAT(A,n))>() \
00027                                             BOOST_PP_EXPR_IF( BOOST_PP_LESS(n,v), + std::string(",") );
00028 
00029 #       include <boost/preprocessor/iteration/iterate.hpp>
00030 #       define BOOST_PP_ITERATION_LIMITS (0, GET_REFLECT_PARAMETER_SIZE )
00031 #       define BOOST_PP_FILENAME_1 <boost/reflect/reflect_function_signature.hpp>
00032 #       include BOOST_PP_ITERATE()
00033 
00034         #undef PARAM_TYPE
00035         #undef PARAM_NAME
00036         #undef PARAM_ARG
00037         #undef ADD_PARAM
00038         #undef RCR
00039 } } // boost::reflect
00040 
00041 #   endif // BOOST_REFLECT_FUNCTION_SIGNATURE_HPP
00042 
00043 #else // BOOST_PP_IS_ITERATING
00044 
00045 #   define n BOOST_PP_ITERATION()
00046 
00047 template<typename Rtn BOOST_PP_ENUM_TRAILING_PARAMS(n, typename A)>
00048 struct get_typeinfo<Rtn (BOOST_PP_ENUM_PARAMS(n, A))>
00049 {
00050     static const char* name()
00051     {
00052         static std::string* sig = NULL;
00053         if( !sig )
00054         {
00055             sig = new std::string( get_typename<Rtn>() );
00056             *sig += '(';
00057             BOOST_PP_REPEAT( n, ADD_PARAM, BOOST_PP_SUB(n,1) )
00058             *sig += ')';
00059         }
00060         return sig->c_str();
00061     }
00062 };
00063 
00064 
00065 
00066 #undef n
00067 
00068 
00069 #endif // BOOST_PP_IS_ITERATING

© Daniel Larimer 2010-2011 - Licensed under Boost Software License, Version 1.0 Boost Reflect Library