/* Copyright (C) 2019 * * This file is part of the osdev components suite * * 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 2, 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, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA */ #ifndef OSDEV_COMPONENTS_MQTT_MACRODEFS_H #define OSDEV_COMPONENTS_MQTT_MACRODEFS_H #include #include "compiletimestring.h" /// @brief Helper macro to stringify a symbol #define OSDEV_COMPONENTS_STRINGIFY(x) #x /// @brief Use this macro to safely stringify a symbol /// This will also work for nested macro's #define OSDEV_COMPONENTS_TOSTRING(x) OSDEV_COMPONENTS_STRINGIFY(x) /// @brief Helper macro to combine two symbols #define OSDEV_COMPONENTS_COMBINER(x, y) x##y /// @brief Use this macro to safely combine two symbols /// This will also work for nested macro's #define OSDEV_COMPONENTS_COMBINE(x, y) OSDEV_COMPONENTS_COMBINER(x, y) /// @brief Macro that reduces a path to the basename #define OSDEV_COMPONENTS_MANAGEDBASEFILENAME \ OSDEV_COMPONENTS_CSTRING_BOUNDED(__FILE__, osdev::components::rfind(__FILE__, '/') + 1, sizeof(__FILE__) - 1) /// @brief Compiletime test if an instance derives from a certain base class #define OSDEV_COMPONENTS_DERIVESFROM(derived, baseType) \ static_assert(std::is_base_of::type>::type>::value, \ OSDEV_COMPONENTS_TOSTRING(derived) " must be derived from " OSDEV_COMPONENTS_TOSTRING(baseType)) #endif //OSDEV_COMPONENTS_MQTT_MACRODEFS_H