Files
edgetx-gx12/companion/src/macros.h
T
Max Paperno 988c837011 [Companion] Refactor settings system (CompStoreObj/AppData/etc):
~ All stored properties are fully dynamic, using an extended version of the Qt Property System;
 ~ CompStoreObj is now QObject subclass;
 + All properties now have change notifier signals;
 ~ Do not store default values in settings;
 + Add _reset() and _default() functions for each property;
 + Settings import now ignores all non-existent properties automatically;
 + Add settings export functions;
 + Add more version macros;
 ~ Remove template functions;
 ~ Move DownloadBranchType and create NewModelAction enums and register with Qt meta system;
 ~ Multiple efficiency and optimization changes (const functions, literals, etc).
2018-06-29 20:00:10 -04:00

47 lines
1.7 KiB
C++

/*
* Copyright (C) OpenTX
*
* Based on code named
* th9x - http://code.google.com/p/th9x
* er9x - http://code.google.com/p/er9x
* gruvin9x - http://code.google.com/p/gruvin9x
*
* License GPLv2: http://www.gnu.org/licenses/gpl-2.0.html
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 as
* published by the Free Software Foundation.
*
* 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.
*/
#ifndef _MACROS_H_
#define _MACROS_H_
#include <QDataStream>
#include <iterator>
// #define DIM(arr) (sizeof((arr))/sizeof((arr)[0]))
// new way for c++11
#define DIM(arr__) ((size_t)(std::end((arr__)) - std::begin((arr__))))
#ifndef CONCATENATE
#define CONCATENATE_IMPL(A, B) A ## B
#define CONCATENATE(A, B) CONCATENATE_IMPL(A, B)
#endif
#define CREATE_ENUM_STREAM_OPS3(functype, type, datatype) \
functype QDataStream& operator << (QDataStream &out, type &e) { return out << (datatype&)e; } \
functype QDataStream& operator >> (QDataStream &in, type &e) { in >> (datatype&)e; return in; }
#define CREATE_ENUM_STREAM_OPS2(type, datatype) CREATE_ENUM_STREAM_OPS3(inline, type, datatype)
#define CREATE_ENUM_STREAM_OPS(type) CREATE_ENUM_STREAM_OPS2(type, quint32)
#define CREATE_ENUM_FRIEND_STREAM_OPS2(type, datatype) CREATE_ENUM_STREAM_OPS3(friend inline , type, datatype)
#define CREATE_ENUM_FRIEND_STREAM_OPS(type) CREATE_ENUM_FRIEND_STREAM_OPS2(type, quint32)
#endif // _MACROS_H_