Bond
 
Loading...
Searching...
No Matches
extern_macro.h
1// Copyright (c) Microsoft. All rights reserved.
2// Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
4#pragma once
5
6#include <bond/core/config.h>
7
8#if !defined(BOND_COMPACT_BINARY_PROTOCOL) \
9 && !defined(BOND_SIMPLE_BINARY_PROTOCOL) \
10 && !defined(BOND_FAST_BINARY_PROTOCOL) \
11 && !defined(BOND_SIMPLE_JSON_PROTOCOL)
12#error None of the built-in protocols are enabled. Either enable one of them or set BOND_LIB_TYPE to BOND_LIB_TYPE_HEADER.
13#endif
14
15#include <boost/preprocessor/facilities/expand.hpp>
16#include <boost/preprocessor/seq/for_each_product.hpp>
17#include <boost/preprocessor/seq/pop_front.hpp>
18#include <boost/preprocessor/seq/seq.hpp>
19#include <boost/preprocessor/seq/to_tuple.hpp>
20
21
22#ifdef BOND_COMPACT_BINARY_PROTOCOL
23#define BOND_DETAIL_BUILTIN_READER_COMPACT_BINARY (bond::CompactBinaryReader<bond::InputBuffer>)
24#define BOND_DETAIL_BUILTIN_WRITER_COMPACT_BINARY (bond::CompactBinaryWriter<bond::OutputBuffer>) \
25 (bond::CompactBinaryWriter<bond::OutputBuffer>::Pass0)
26#else
27#define BOND_DETAIL_BUILTIN_READER_COMPACT_BINARY BOOST_PP_SEQ_NIL
28#define BOND_DETAIL_BUILTIN_WRITER_COMPACT_BINARY BOOST_PP_SEQ_NIL
29#endif
30
31#ifdef BOND_SIMPLE_BINARY_PROTOCOL
32#define BOND_DETAIL_BUILTIN_READER_SIMPLE_BINARY (bond::SimpleBinaryReader<bond::InputBuffer>)
33#define BOND_DETAIL_BUILTIN_WRITER_SIMPLE_BINARY (bond::SimpleBinaryWriter<bond::OutputBuffer>)
34#else
35#define BOND_DETAIL_BUILTIN_READER_SIMPLE_BINARY BOOST_PP_SEQ_NIL
36#define BOND_DETAIL_BUILTIN_WRITER_SIMPLE_BINARY BOOST_PP_SEQ_NIL
37#endif
38
39#ifdef BOND_FAST_BINARY_PROTOCOL
40#define BOND_DETAIL_BUILTIN_READER_FAST_BINARY (bond::FastBinaryReader<bond::InputBuffer>)
41#define BOND_DETAIL_BUILTIN_WRITER_FAST_BINARY (bond::FastBinaryWriter<bond::OutputBuffer>)
42#else
43#define BOND_DETAIL_BUILTIN_READER_FAST_BINARY BOOST_PP_SEQ_NIL
44#define BOND_DETAIL_BUILTIN_WRITER_FAST_BINARY BOOST_PP_SEQ_NIL
45#endif
46
47#ifdef BOND_SIMPLE_JSON_PROTOCOL
48#define BOND_DETAIL_BUILTIN_READER_SIMPLE_JSON (bond::SimpleJsonReader<bond::InputBuffer>)
49#define BOND_DETAIL_BUILTIN_WRITER_SIMPLE_JSON (bond::SimpleJsonWriter<bond::OutputBuffer>)
50#else
51#define BOND_DETAIL_BUILTIN_READER_SIMPLE_JSON BOOST_PP_SEQ_NIL
52#define BOND_DETAIL_BUILTIN_WRITER_SIMPLE_JSON BOOST_PP_SEQ_NIL
53#endif
54
55#define BOND_DETAIL_BUILTIN_READERS \
56 ( \
57 BOND_DETAIL_BUILTIN_READER_COMPACT_BINARY \
58 BOND_DETAIL_BUILTIN_READER_SIMPLE_BINARY \
59 BOND_DETAIL_BUILTIN_READER_FAST_BINARY \
60 /*BOND_DETAIL_BUILTIN_READER_SIMPLE_JSON*/ \
61 )
62
63#define BOND_DETAIL_BUILTIN_WRITERS \
64 ( \
65 BOND_DETAIL_BUILTIN_WRITER_COMPACT_BINARY \
66 BOND_DETAIL_BUILTIN_WRITER_SIMPLE_BINARY \
67 BOND_DETAIL_BUILTIN_WRITER_FAST_BINARY \
68 /*BOND_DETAIL_BUILTIN_WRITER_SIMPLE_JSON*/ \
69 )
70
71#define BOND_DETAIL_BUILTIN_BASIC_TYPES \
72 ( \
73 (void) \
74 (bool) \
75 (uint8_t) \
76 (uint16_t) \
77 (uint32_t) \
78 (uint64_t) \
79 (float) \
80 (double) \
81 (std::string) \
82 (std::wstring) \
83 (int8_t) \
84 (int16_t) \
85 (int32_t) \
86 (int64_t) \
87 )
88
89#define BOND_DETAIL_BUILTIN_READERS_WRITERS BOND_DETAIL_BUILTIN_READERS BOND_DETAIL_BUILTIN_WRITERS
90
91#define BOND_DETAIL_BUILTIN_READERS_WRITERS_BASIC_TYPES \
92 BOND_DETAIL_BUILTIN_READERS BOND_DETAIL_BUILTIN_WRITERS BOND_DETAIL_BUILTIN_BASIC_TYPES
93
94
95#define BOND_DETAIL_APPLY_FUNC(_, product) \
96 BOOST_PP_EXPAND(BOOST_PP_SEQ_HEAD(product) BOOST_PP_EXPAND(BOOST_PP_SEQ_TO_TUPLE(BOOST_PP_SEQ_POP_FRONT(product))))
97
98#define BOND_DETAIL_DECLARE(func, seq) BOOST_PP_SEQ_FOR_EACH_PRODUCT(BOND_DETAIL_APPLY_FUNC, ((func))seq)
99
100#define BOND_DETAIL_PREFIX_TEMPLATE(func) template func
101#define BOND_DETAIL_INSTANTIATE(func, seq) BOND_DETAIL_DECLARE(BOND_DETAIL_PREFIX_TEMPLATE(func), seq)
102
103#define BOND_DETAIL_PREFIX_EXTERN(func) extern BOND_DETAIL_PREFIX_TEMPLATE(func)
104#define BOND_DETAIL_EXTERN(func, seq) BOND_DETAIL_DECLARE(BOND_DETAIL_PREFIX_EXTERN(func), seq)