Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 1 | // Copyright (C) 2004 Arkadiy Vertleyb |
| 2 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 3 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 4 | |
| 5 | #include <ndnboost/typeof/encode_decode_params.hpp> |
| 6 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 7 | #define n NDNBOOST_PP_ITERATION() |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 8 | |
| 9 | // function pointers |
| 10 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 11 | template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> |
| 12 | struct encode_type_impl<V, R(*)(NDNBOOST_PP_ENUM_PARAMS(n, P))> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 13 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 14 | typedef R NDNBOOST_PP_CAT(P, n); |
| 15 | typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_PTR_ID + n) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 16 | }; |
| 17 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 18 | template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> |
| 19 | struct encode_type_impl<V, R(*)(NDNBOOST_PP_ENUM_PARAMS(n, P) ...)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 20 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 21 | typedef R NDNBOOST_PP_CAT(P, n); |
| 22 | typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_VAR_PTR_ID + n) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 23 | }; |
| 24 | |
| 25 | template<class Iter> |
| 26 | struct decode_type_impl<ndnboost::mpl::size_t<FUN_PTR_ID + n>, Iter> |
| 27 | { |
| 28 | typedef Iter iter0; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 29 | NDNBOOST_TYPEOF_DECODE_PARAMS(NDNBOOST_PP_INC(n)) |
| 30 | typedef NDNBOOST_PP_CAT(p, n)(*type)(NDNBOOST_PP_ENUM_PARAMS(n, p)); |
| 31 | typedef NDNBOOST_PP_CAT(iter, NDNBOOST_PP_INC(n)) iter; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | template<class Iter> |
| 35 | struct decode_type_impl<ndnboost::mpl::size_t<FUN_VAR_PTR_ID + n>, Iter> |
| 36 | { |
| 37 | typedef Iter iter0; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 38 | NDNBOOST_TYPEOF_DECODE_PARAMS(NDNBOOST_PP_INC(n)) |
| 39 | typedef NDNBOOST_PP_CAT(p, n)(*type)(NDNBOOST_PP_ENUM_PARAMS(n, p) ...); |
| 40 | typedef NDNBOOST_PP_CAT(iter, NDNBOOST_PP_INC(n)) iter; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 41 | }; |
| 42 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 43 | #ifndef NDNBOOST_TYPEOF_NO_FUNCTION_TYPES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 44 | |
| 45 | // function references |
| 46 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 47 | template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> |
| 48 | struct encode_type_impl<V, R(&)(NDNBOOST_PP_ENUM_PARAMS(n, P))> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 49 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 50 | typedef R NDNBOOST_PP_CAT(P, n); |
| 51 | typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_REF_ID + n) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 52 | }; |
| 53 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 54 | template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> |
| 55 | struct encode_type_impl<V, R(&)(NDNBOOST_PP_ENUM_PARAMS(n, P) ...)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 56 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 57 | typedef R NDNBOOST_PP_CAT(P, n); |
| 58 | typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_VAR_REF_ID + n) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 59 | }; |
| 60 | |
| 61 | template<class Iter> |
| 62 | struct decode_type_impl<ndnboost::mpl::size_t<FUN_REF_ID + n>, Iter> |
| 63 | { |
| 64 | typedef Iter iter0; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 65 | NDNBOOST_TYPEOF_DECODE_PARAMS(NDNBOOST_PP_INC(n)) |
| 66 | typedef NDNBOOST_PP_CAT(p, n)(&type)(NDNBOOST_PP_ENUM_PARAMS(n, p)); |
| 67 | typedef NDNBOOST_PP_CAT(iter, NDNBOOST_PP_INC(n)) iter; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 68 | }; |
| 69 | |
| 70 | template<class Iter> |
| 71 | struct decode_type_impl<ndnboost::mpl::size_t<FUN_VAR_REF_ID + n>, Iter> |
| 72 | { |
| 73 | typedef Iter iter0; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 74 | NDNBOOST_TYPEOF_DECODE_PARAMS(NDNBOOST_PP_INC(n)) |
| 75 | typedef NDNBOOST_PP_CAT(p, n)(&type)(NDNBOOST_PP_ENUM_PARAMS(n, p) ...); |
| 76 | typedef NDNBOOST_PP_CAT(iter, NDNBOOST_PP_INC(n)) iter; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 77 | }; |
| 78 | |
| 79 | // functions |
| 80 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 81 | template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> |
| 82 | struct encode_type_impl<V, R(NDNBOOST_PP_ENUM_PARAMS(n, P))> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 83 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 84 | typedef R NDNBOOST_PP_CAT(P, n); |
| 85 | typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_ID + n) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 86 | }; |
| 87 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 88 | template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)> |
| 89 | struct encode_type_impl<V, R(NDNBOOST_PP_ENUM_PARAMS(n, P) ...)> |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 90 | { |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 91 | typedef R NDNBOOST_PP_CAT(P, n); |
| 92 | typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_VAR_ID + n) type; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 93 | }; |
| 94 | |
| 95 | template<class Iter> |
| 96 | struct decode_type_impl<ndnboost::mpl::size_t<FUN_ID + n>, Iter> |
| 97 | { |
| 98 | typedef Iter iter0; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 99 | NDNBOOST_TYPEOF_DECODE_PARAMS(NDNBOOST_PP_INC(n)) |
| 100 | typedef NDNBOOST_PP_CAT(p, n)(type)(NDNBOOST_PP_ENUM_PARAMS(n, p)); |
| 101 | typedef NDNBOOST_PP_CAT(iter, NDNBOOST_PP_INC(n)) iter; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 102 | }; |
| 103 | |
| 104 | template<class Iter> |
| 105 | struct decode_type_impl<ndnboost::mpl::size_t<FUN_VAR_ID + n>, Iter> |
| 106 | { |
| 107 | typedef Iter iter0; |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 108 | NDNBOOST_TYPEOF_DECODE_PARAMS(NDNBOOST_PP_INC(n)) |
| 109 | typedef NDNBOOST_PP_CAT(p, n)(type)(NDNBOOST_PP_ENUM_PARAMS(n, p) ...); |
| 110 | typedef NDNBOOST_PP_CAT(iter, NDNBOOST_PP_INC(n)) iter; |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 111 | }; |
| 112 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 113 | #endif//NDNBOOST_TYPEOF_NO_FUNCTION_TYPES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 114 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 115 | #ifndef NDNBOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 116 | // member functions |
| 117 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 118 | #define NDNBOOST_TYPEOF_qualifier |
| 119 | #define NDNBOOST_TYPEOF_id MEM_FUN_ID |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 120 | #include <ndnboost/typeof/register_mem_functions.hpp> |
| 121 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 122 | #define NDNBOOST_TYPEOF_qualifier const |
| 123 | #define NDNBOOST_TYPEOF_id CONST_MEM_FUN_ID |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 124 | #include <ndnboost/typeof/register_mem_functions.hpp> |
| 125 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 126 | #define NDNBOOST_TYPEOF_qualifier volatile |
| 127 | #define NDNBOOST_TYPEOF_id VOLATILE_MEM_FUN_ID |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 128 | #include <ndnboost/typeof/register_mem_functions.hpp> |
| 129 | |
Jeff Thompson | 3d613fd | 2013-10-15 15:39:04 -0700 | [diff] [blame^] | 130 | #define NDNBOOST_TYPEOF_qualifier volatile const |
| 131 | #define NDNBOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID |
Jeff Thompson | a28eed8 | 2013-08-22 16:21:10 -0700 | [diff] [blame] | 132 | #include <ndnboost/typeof/register_mem_functions.hpp> |
| 133 | |
| 134 | #undef n |
| 135 | #endif |