Warning, file /include/QtCore/qtmochelpers.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004 #ifndef QTMOCHELPERS_H
0005 #define QTMOCHELPERS_H
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018 #include <QtCore/qglobal.h>
0019
0020 #include <algorithm> // std::min
0021 #include <limits>
0022
0023 #if 0
0024 #pragma qt_no_master_include
0025 #endif
0026
0027 QT_BEGIN_NAMESPACE
0028 namespace QtMocHelpers {
0029
0030
0031 static constexpr size_t MaxStringSize =
0032 (std::min)(size_t((std::numeric_limits<uint>::max)()),
0033 size_t((std::numeric_limits<qsizetype>::max)()));
0034
0035 template <uint... Nx> constexpr size_t stringDataSizeHelper(std::integer_sequence<uint, Nx...>)
0036 {
0037
0038
0039
0040 size_t total = 0;
0041 uint sizes[] = { Nx... };
0042 for (uint n : sizes)
0043 total += n;
0044 return total;
0045 }
0046
0047 template <int Count, size_t StringSize> struct StringData
0048 {
0049 static_assert(StringSize <= MaxStringSize, "Meta Object data is too big");
0050 uint offsetsAndSizes[Count] = {};
0051 char stringdata0[StringSize] = {};
0052 constexpr StringData() = default;
0053 };
0054
0055 template <uint... Nx> constexpr auto stringData(const char (&...strings)[Nx])
0056 {
0057 constexpr size_t StringSize = stringDataSizeHelper<Nx...>({});
0058 constexpr size_t Count = 2 * sizeof...(Nx);
0059
0060 StringData<Count, StringSize> result;
0061 const char *inputs[] = { strings... };
0062 uint sizes[] = { Nx... };
0063
0064 uint offset = 0;
0065 char *output = result.stringdata0;
0066 for (size_t i = 0; i < sizeof...(Nx); ++i) {
0067
0068 uint len = sizes[i];
0069 for (uint j = 0; j < len; ++j)
0070 output[offset + j] = inputs[i][j];
0071 result.offsetsAndSizes[2 * i] = offset + sizeof(result.offsetsAndSizes);
0072 result.offsetsAndSizes[2 * i + 1] = len - 1;
0073 offset += len;
0074 }
0075
0076 return result;
0077 }
0078
0079 # define QT_MOC_HAS_STRINGDATA 1
0080
0081 }
0082 QT_END_NAMESPACE
0083
0084 QT_USE_NAMESPACE
0085
0086 #endif