messagepack implementation for embedded systems (mbed / arduino)

Dependents:   hello_message_pack

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers replace.hpp Source File

replace.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_REPLACE_HPP
00013 # define MSGPACK_PREPROCESSOR_ARRAY_REPLACE_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/comparison/not_equal.hpp>
00019 # include <msgpack/preprocessor/config/config.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_REPLACE */
00026 #
00027 # define MSGPACK_PP_ARRAY_REPLACE(array, i, elem) MSGPACK_PP_ARRAY_REPLACE_I(MSGPACK_PP_DEDUCE_D(), array, i, elem)
00028 # define MSGPACK_PP_ARRAY_REPLACE_I(d, array, i, elem) MSGPACK_PP_ARRAY_REPLACE_D(d, array, i, elem)
00029 #
00030 # /* MSGPACK_PP_ARRAY_REPLACE_D */
00031 #
00032 # if ~MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_EDG()
00033 #    define MSGPACK_PP_ARRAY_REPLACE_D(d, array, i, elem) MSGPACK_PP_TUPLE_ELEM(5, 3, MSGPACK_PP_WHILE_ ## d(MSGPACK_PP_ARRAY_REPLACE_P, MSGPACK_PP_ARRAY_REPLACE_O, (0, i, elem, (0, ()), array)))
00034 # else
00035 #    define MSGPACK_PP_ARRAY_REPLACE_D(d, array, i, elem) MSGPACK_PP_ARRAY_REPLACE_D_I(d, array, i, elem)
00036 #    define MSGPACK_PP_ARRAY_REPLACE_D_I(d, array, i, elem) MSGPACK_PP_TUPLE_ELEM(5, 3, MSGPACK_PP_WHILE_ ## d(MSGPACK_PP_ARRAY_REPLACE_P, MSGPACK_PP_ARRAY_REPLACE_O, (0, i, elem, (0, ()), array)))
00037 # endif
00038 #
00039 # define MSGPACK_PP_ARRAY_REPLACE_P(d, state) MSGPACK_PP_NOT_EQUAL(MSGPACK_PP_TUPLE_ELEM(5, 0, state), MSGPACK_PP_ARRAY_SIZE(MSGPACK_PP_TUPLE_ELEM(5, 4, state)))
00040 #
00041 # if MSGPACK_PP_CONFIG_FLAGS() & MSGPACK_PP_CONFIG_STRICT()
00042 #    define MSGPACK_PP_ARRAY_REPLACE_O(d, state) MSGPACK_PP_ARRAY_REPLACE_O_I state
00043 # else
00044 #    define MSGPACK_PP_ARRAY_REPLACE_O(d, state) MSGPACK_PP_ARRAY_REPLACE_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))
00045 # endif
00046 #
00047 # define MSGPACK_PP_ARRAY_REPLACE_O_I(n, i, elem, res, arr) (MSGPACK_PP_INC(n), i, elem, MSGPACK_PP_ARRAY_PUSH_BACK(res, MSGPACK_PP_IIF(MSGPACK_PP_NOT_EQUAL(n, i), MSGPACK_PP_ARRAY_ELEM(n, arr), elem)), arr)
00048 #
00049 # endif