messagepack implementation for embedded systems (mbed / arduino)
Dependents: hello_message_pack
insert.hpp
00001 # /* ************************************************************************** 00002 # * * 00003 # * (C) Copyright Paul Mensonides 2002. 00004 # * Distributed under the Boost Software License, Version 1.0. (See 00005 # * accompanying file LICENSE_1_0.txt or copy at 00006 # * http://www.boost.org/LICENSE_1_0.txt) 00007 # * * 00008 # ************************************************************************** */ 00009 # 00010 # /* See http://www.boost.org for most recent version. */ 00011 # 00012 # ifndef MSGPACK_PREPROCESSOR_ARRAY_INSERT_HPP 00013 # define MSGPACK_PREPROCESSOR_ARRAY_INSERT_HPP 00014 # 00015 # include <msgpack/preprocessor/arithmetic/inc.hpp> 00016 # include <msgpack/preprocessor/array/elem.hpp> 00017 # include <msgpack/preprocessor/array/push_back.hpp> 00018 # include <msgpack/preprocessor/array/size.hpp> 00019 # include <msgpack/preprocessor/comparison/not_equal.hpp> 00020 # include <msgpack/preprocessor/control/deduce_d.hpp> 00021 # include <msgpack/preprocessor/control/iif.hpp> 00022 # include <msgpack/preprocessor/control/while.hpp> 00023 # include <msgpack/preprocessor/tuple/elem.hpp> 00024 # 00025 # /* MSGPACK_PP_ARRAY_INSERT */ 00026 # 00027 # define MSGPACK_PP_ARRAY_INSERT(array, i, elem) MSGPACK_PP_ARRAY_INSERT_I(MSGPACK_PP_DEDUCE_D(), array, i, elem) 00028 # define MSGPACK_PP_ARRAY_INSERT_I(d, array, i, elem) MSGPACK_PP_ARRAY_INSERT_D(d, array, i, elem) 00029 # 00030 # /* MSGPACK_PP_ARRAY_INSERT_D */ 00031 # 00032 # if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG() 00033 # define MSGPACK_PP_ARRAY_INSERT_D(d, array, i, elem) MSGPACK_PP_TUPLE_ELEM(5, 3, MSGPACK_PP_WHILE_ ## d(MSGPACK_PP_ARRAY_INSERT_P, MSGPACK_PP_ARRAY_INSERT_O, (0, i, elem, (0, ()), array))) 00034 # else 00035 # define MSGPACK_PP_ARRAY_INSERT_D(d, array, i, elem) MSGPACK_PP_ARRAY_INSERT_D_I(d, array, i, elem) 00036 # define MSGPACK_PP_ARRAY_INSERT_D_I(d, array, i, elem) MSGPACK_PP_TUPLE_ELEM(5, 3, MSGPACK_PP_WHILE_ ## d(MSGPACK_PP_ARRAY_INSERT_P, MSGPACK_PP_ARRAY_INSERT_O, (0, i, elem, (0, ()), array))) 00037 # endif 00038 # 00039 # if MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_STRICT() 00040 # define MSGPACK_PP_ARRAY_INSERT_P(d, state) MSGPACK_PP_ARRAY_INSERT_P_I state 00041 # else 00042 # define MSGPACK_PP_ARRAY_INSERT_P(d, state) MSGPACK_PP_ARRAY_INSERT_P_I(nil, nil, nil, MSGPACK_PP_TUPLE_ELEM(5, 3, state), MSGPACK_PP_TUPLE_ELEM(5, 4, state)) 00043 # endif 00044 # 00045 # define MSGPACK_PP_ARRAY_INSERT_P_I(_i, _ii, _iii, res, arr) MSGPACK_PP_NOT_EQUAL(MSGPACK_PP_ARRAY_SIZE(res), MSGPACK_PP_INC(MSGPACK_PP_ARRAY_SIZE(arr))) 00046 # 00047 # if MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_STRICT() 00048 # define MSGPACK_PP_ARRAY_INSERT_O(d, state) MSGPACK_PP_ARRAY_INSERT_O_I state 00049 # else 00050 # define MSGPACK_PP_ARRAY_INSERT_O(d, state) MSGPACK_PP_ARRAY_INSERT_O_I(MSGPACK_PP_TUPLE_ELEM(5, 0, state), MSGPACK_PP_TUPLE_ELEM(5, 1, state), MSGPACK_PP_TUPLE_ELEM(5, 2, state), MSGPACK_PP_TUPLE_ELEM(5, 3, state), MSGPACK_PP_TUPLE_ELEM(5, 4, state)) 00051 # endif 00052 # 00053 # define MSGPACK_PP_ARRAY_INSERT_O_I(n, i, elem, res, arr) (MSGPACK_PP_IIF(MSGPACK_PP_NOT_EQUAL(MSGPACK_PP_ARRAY_SIZE(res), i), MSGPACK_PP_INC(n), n), i, elem, MSGPACK_PP_ARRAY_PUSH_BACK(res, MSGPACK_PP_IIF(MSGPACK_PP_NOT_EQUAL(MSGPACK_PP_ARRAY_SIZE(res), i), MSGPACK_PP_ARRAY_ELEM(n, arr), elem)), arr) 00054 # 00055 # endif
Generated on Tue Jul 12 2022 22:51:45 by 1.7.2