blob: 3f487a9a97226e0975e8d1588d5909526fb92435 [file] [log] [blame]
Jeff Thompsona28eed82013-08-22 16:21:10 -07001// 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 Thompson3d613fd2013-10-15 15:39:04 -07007#define n NDNBOOST_PP_ITERATION()
Jeff Thompsona28eed82013-08-22 16:21:10 -07008
9// function pointers
10
Jeff Thompson3d613fd2013-10-15 15:39:04 -070011template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
12struct encode_type_impl<V, R(*)(NDNBOOST_PP_ENUM_PARAMS(n, P))>
Jeff Thompsona28eed82013-08-22 16:21:10 -070013{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070014 typedef R NDNBOOST_PP_CAT(P, n);
15 typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_PTR_ID + n) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070016};
17
Jeff Thompson3d613fd2013-10-15 15:39:04 -070018template<class V, class R NDNBOOST_PP_ENUM_TRAILING_PARAMS(n, class P)>
19struct encode_type_impl<V, R(*)(NDNBOOST_PP_ENUM_PARAMS(n, P) ...)>
Jeff Thompsona28eed82013-08-22 16:21:10 -070020{
Jeff Thompson3d613fd2013-10-15 15:39:04 -070021 typedef R NDNBOOST_PP_CAT(P, n);
22 typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_VAR_PTR_ID + n) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070023};
24
25template<class Iter>
26struct decode_type_impl<ndnboost::mpl::size_t<FUN_PTR_ID + n>, Iter>
27{
28 typedef Iter iter0;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070029 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 Thompsona28eed82013-08-22 16:21:10 -070032};
33
34template<class Iter>
35struct decode_type_impl<ndnboost::mpl::size_t<FUN_VAR_PTR_ID + n>, Iter>
36{
37 typedef Iter iter0;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070038 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 Thompsona28eed82013-08-22 16:21:10 -070041};
42
Jeff Thompson3d613fd2013-10-15 15:39:04 -070043#ifndef NDNBOOST_TYPEOF_NO_FUNCTION_TYPES
Jeff Thompsona28eed82013-08-22 16:21:10 -070044
45 // function references
46
Jeff Thompson3d613fd2013-10-15 15:39:04 -070047 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 Thompsona28eed82013-08-22 16:21:10 -070049 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070050 typedef R NDNBOOST_PP_CAT(P, n);
51 typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_REF_ID + n) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070052 };
53
Jeff Thompson3d613fd2013-10-15 15:39:04 -070054 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 Thompsona28eed82013-08-22 16:21:10 -070056 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070057 typedef R NDNBOOST_PP_CAT(P, n);
58 typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_VAR_REF_ID + n) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070059 };
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 Thompson3d613fd2013-10-15 15:39:04 -070065 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 Thompsona28eed82013-08-22 16:21:10 -070068 };
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 Thompson3d613fd2013-10-15 15:39:04 -070074 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 Thompsona28eed82013-08-22 16:21:10 -070077 };
78
79 // functions
80
Jeff Thompson3d613fd2013-10-15 15:39:04 -070081 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 Thompsona28eed82013-08-22 16:21:10 -070083 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070084 typedef R NDNBOOST_PP_CAT(P, n);
85 typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_ID + n) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070086 };
87
Jeff Thompson3d613fd2013-10-15 15:39:04 -070088 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 Thompsona28eed82013-08-22 16:21:10 -070090 {
Jeff Thompson3d613fd2013-10-15 15:39:04 -070091 typedef R NDNBOOST_PP_CAT(P, n);
92 typedef NDNBOOST_TYPEOF_ENCODE_PARAMS(NDNBOOST_PP_INC(n), FUN_VAR_ID + n) type;
Jeff Thompsona28eed82013-08-22 16:21:10 -070093 };
94
95 template<class Iter>
96 struct decode_type_impl<ndnboost::mpl::size_t<FUN_ID + n>, Iter>
97 {
98 typedef Iter iter0;
Jeff Thompson3d613fd2013-10-15 15:39:04 -070099 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 Thompsona28eed82013-08-22 16:21:10 -0700102 };
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 Thompson3d613fd2013-10-15 15:39:04 -0700108 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 Thompsona28eed82013-08-22 16:21:10 -0700111 };
112
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700113#endif//NDNBOOST_TYPEOF_NO_FUNCTION_TYPES
Jeff Thompsona28eed82013-08-22 16:21:10 -0700114
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700115#ifndef NDNBOOST_TYPEOF_NO_MEMBER_FUNCTION_TYPES
Jeff Thompsona28eed82013-08-22 16:21:10 -0700116// member functions
117
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700118#define NDNBOOST_TYPEOF_qualifier
119#define NDNBOOST_TYPEOF_id MEM_FUN_ID
Jeff Thompsona28eed82013-08-22 16:21:10 -0700120#include <ndnboost/typeof/register_mem_functions.hpp>
121
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700122#define NDNBOOST_TYPEOF_qualifier const
123#define NDNBOOST_TYPEOF_id CONST_MEM_FUN_ID
Jeff Thompsona28eed82013-08-22 16:21:10 -0700124#include <ndnboost/typeof/register_mem_functions.hpp>
125
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700126#define NDNBOOST_TYPEOF_qualifier volatile
127#define NDNBOOST_TYPEOF_id VOLATILE_MEM_FUN_ID
Jeff Thompsona28eed82013-08-22 16:21:10 -0700128#include <ndnboost/typeof/register_mem_functions.hpp>
129
Jeff Thompson3d613fd2013-10-15 15:39:04 -0700130#define NDNBOOST_TYPEOF_qualifier volatile const
131#define NDNBOOST_TYPEOF_id VOLATILE_CONST_MEM_FUN_ID
Jeff Thompsona28eed82013-08-22 16:21:10 -0700132#include <ndnboost/typeof/register_mem_functions.hpp>
133
134#undef n
135#endif