51becbde
Peter M. Groen
Committed the ent...
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
/* 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 <type_traits>
#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<baseType, \
typename std::remove_pointer<typename std::remove_reference<decltype(derived)>::type>::type>::value, \
OSDEV_COMPONENTS_TOSTRING(derived) " must be derived from " OSDEV_COMPONENTS_TOSTRING(baseType))
#endif //OSDEV_COMPONENTS_MQTT_MACRODEFS_H
|