/** * @file common/Macro.hpp * @author The ARTIS Development Team * See the AUTHORS or Authors.txt file */ /* * ARTIS - the multimodeling and simulation environment * This file is a part of the ARTIS environment * * Copyright (C) 2013-2022 ULCO http://www.univ-littoral.fr * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ #ifndef COMMON_MACRO_HPP #define COMMON_MACRO_HPP #define DOUBLEESCAPE(a) #a #define ESCAPEQUOTE(a) DOUBLEESCAPE(a) #define ITEM(index, var) { index, \ std::string(ESCAPEQUOTE(index)), \ var } #define UNWRAP_ITEM(...) ITEM __VA_ARGS__ #define LIST_16(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15, L16) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9), UNWRAP_ITEM(L10), UNWRAP_ITEM(L11), UNWRAP_ITEM(L12), UNWRAP_ITEM(L13), UNWRAP_ITEM(L14), UNWRAP_ITEM(L15), UNWRAP_ITEM(L16) } #define LIST_15(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14, L15) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9), UNWRAP_ITEM(L10), UNWRAP_ITEM(L11), UNWRAP_ITEM(L12), UNWRAP_ITEM(L13), UNWRAP_ITEM(L14), UNWRAP_ITEM(L15) } #define LIST_14(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13, L14) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9), UNWRAP_ITEM(L10), UNWRAP_ITEM(L11), UNWRAP_ITEM(L12), UNWRAP_ITEM(L13), UNWRAP_ITEM(L14) } #define LIST_13(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12, L13) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9), UNWRAP_ITEM(L10), UNWRAP_ITEM(L11), UNWRAP_ITEM(L12), UNWRAP_ITEM(L13) } #define LIST_12(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11, L12) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9), UNWRAP_ITEM(L10), UNWRAP_ITEM(L11), UNWRAP_ITEM(L12) } #define LIST_11(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10, L11) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9), UNWRAP_ITEM(L10), UNWRAP_ITEM(L11) } #define LIST_10(L1, L2, L3, L4, L5, L6, L7, L8, L9, L10) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9), UNWRAP_ITEM(L10) } #define LIST_9(L1, L2, L3, L4, L5, L6, L7, L8, L9) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8), UNWRAP_ITEM(L9) } #define LIST_8(L1, L2, L3, L4, L5, L6, L7, L8) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7), UNWRAP_ITEM(L8) } #define LIST_7(L1, L2, L3, L4, L5, L6, L7) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6), UNWRAP_ITEM(L7) } #define LIST_6(L1, L2, L3, L4, L5, L6) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5), UNWRAP_ITEM(L6) } #define LIST_5(L1, L2, L3, L4, L5) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4), UNWRAP_ITEM(L5) } #define LIST_4(L1, L2, L3, L4) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3), UNWRAP_ITEM(L4) } #define LIST_3(L1, L2, L3) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2), UNWRAP_ITEM(L3) } #define LIST_2(L1, L2) { UNWRAP_ITEM(L1), UNWRAP_ITEM(L2) } #define LIST_1(L1) { UNWRAP_ITEM(L1) } #define EXPAND(X) X #define PP_NARG(...) EXPAND( PP_NARG_(__VA_ARGS__, PP_RSEQ_N()) ) #define PP_NARG_(...) EXPAND( PP_ARG_N(__VA_ARGS__) ) #define PP_ARG_N(_1, _2, _3, _4, _5, _6, _7, _8, _9, _10_, _11, _12, _13, _14, _15, _16, N, ...) N #define PP_RSEQ_N() 16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,0 #define LIST_(N) LIST_##N #define LIST_EVAL(N) LIST_(N) #define UNWRAP2(...) EXPAND( LIST_EVAL(EXPAND( PP_NARG(__VA_ARGS__) ))(__VA_ARGS__) ) #endif