1
- #include " rmesongstruct.h"
1
+ #include " rmesongstruct.h"
2
2
#include " rmeutils.h"
3
3
4
4
const QString RmeSong::RmeSongClientHeaderStruct::CreateTime = QStringLiteral(" 0-00-00 00:00:00" );
@@ -23,10 +23,8 @@ void RmeSong::RmeSongClientHeaderStruct::parseByteArray(const QByteArray &arr)
23
23
Q_ASSERT (arr.length () == 0x88 );
24
24
const char *data = arr.constData ();
25
25
26
- #define GETX (type, name, offset ) \
27
- this ->name = *(reinterpret_cast <const type *>(data + offset))
28
- #define GETSTR (name, offset ) \
29
- this ->name = QString::fromUtf8 (data + offset)
26
+ #define GETX (type, name, offset ) this ->name = *(reinterpret_cast <const type *>(data + offset))
27
+ #define GETSTR (name, offset ) this ->name = QString::fromUtf8(data + offset)
30
28
31
29
GETX (int32_t , Magic, 0x0 );
32
30
GETX (int32_t , Version, 0x4 );
@@ -86,10 +84,8 @@ QByteArray RmeSong::RmeSongClientHeaderStruct::toByteArray() const
86
84
87
85
void RmeSong::RmeSongClientHeaderStruct::parseMap (const QVariantMap &map)
88
86
{
89
- #define GETSTR (name ) \
90
- this ->name = map[QStringLiteral (#name)].toString ()
91
- #define GETINT (name ) \
92
- this ->name = map[QStringLiteral (#name)].toString ().trimmed ().toInt ()
87
+ #define GETSTR (name ) this ->name = map[QStringLiteral(#name)].toString()
88
+ #define GETINT (name ) this ->name = map[QStringLiteral(#name)].toString().trimmed().toInt()
93
89
94
90
GETINT (Magic);
95
91
GETINT (Version);
@@ -109,10 +105,8 @@ QVariantMap RmeSong::RmeSongClientHeaderStruct::toMap() const
109
105
{
110
106
QVariantMap map;
111
107
112
- #define SETSTR (name ) \
113
- map[QStringLiteral (#name)] = this ->name
114
- #define SETINT (name ) \
115
- map[QStringLiteral (#name)] = QString::number (static_cast <int >(this ->name )) + QStringLiteral (" " )
108
+ #define SETSTR (name ) map[QStringLiteral(#name)] = this ->name
109
+ #define SETINT (name ) map[QStringLiteral(#name)] = QString::number(static_cast <int >(this ->name)) + QStringLiteral(" " )
116
110
117
111
SETINT (Magic);
118
112
SETINT (Version);
@@ -168,10 +162,8 @@ void RmeSong::RmeSongClientItemStruct::parseByteArray(const QByteArray &arr)
168
162
Q_ASSERT (arr.length () == 0x33e );
169
163
const char *data = arr.constData ();
170
164
171
- #define GETX (type, name, offset ) \
172
- this ->m_ ##name = *(reinterpret_cast <const type *>(data + offset))
173
- #define GETSTR (name, offset ) \
174
- this ->m_ ##name = QString::fromUtf8 (data + offset)
165
+ #define GETX (type, name, offset ) this ->m_##name = *(reinterpret_cast <const type *>(data + offset))
166
+ #define GETSTR (name, offset ) this ->m_##name = QString::fromUtf8(data + offset)
175
167
176
168
GETX (int16_t , ushSongID, 0x0 );
177
169
GETX (int32_t , iVersion, 0x2 );
@@ -287,12 +279,9 @@ QByteArray RmeSong::RmeSongClientItemStruct::toByteArray() const
287
279
288
280
void RmeSong::RmeSongClientItemStruct::parseMap (const QVariantMap &map)
289
281
{
290
- #define GETSTR (name ) \
291
- this ->m_ ##name = map[QStringLiteral (" m_" #name)].toString ()
292
- #define GETINT (name ) \
293
- this ->m_ ##name = map[QStringLiteral (" m_" #name)].toString ().trimmed ().toInt ()
294
- #define GETHEX (name ) \
295
- this ->m_ ##name = map[QStringLiteral (" m_" #name)].toString ().trimmed ().mid (2 ).toInt (nullptr , 16 )
282
+ #define GETSTR (name ) this ->m_##name = map[QStringLiteral(" m_" #name)].toString()
283
+ #define GETINT (name ) this ->m_##name = map[QStringLiteral(" m_" #name)].toString().trimmed().toInt()
284
+ #define GETHEX (name ) this ->m_##name = map[QStringLiteral(" m_" #name)].toString().trimmed().mid(2 ).toInt(nullptr , 16 )
296
285
297
286
GETINT (ushSongID);
298
287
GETINT (iVersion);
@@ -341,12 +330,9 @@ QVariantMap RmeSong::RmeSongClientItemStruct::toMap() const
341
330
{
342
331
QVariantMap map;
343
332
344
- #define SETSTR (name ) \
345
- map[QStringLiteral (" m_" #name)] = this ->m_ ##name
346
- #define SETINT (name ) \
347
- map[QStringLiteral (" m_" #name)] = QString::number (static_cast <int >(this ->m_ ##name)) + QStringLiteral (" " )
348
- #define SETHEX (name ) \
349
- map[QStringLiteral (" m_" #name)] = QStringLiteral (" 0x" ) + QString::number (static_cast <int >(this ->m_ ##name), 16 ) + QStringLiteral (" " )
333
+ #define SETSTR (name ) map[QStringLiteral(" m_" #name)] = this ->m_##name
334
+ #define SETINT (name ) map[QStringLiteral(" m_" #name)] = QString::number(static_cast <int >(this ->m_##name)) + QStringLiteral(" " )
335
+ #define SETHEX (name ) map[QStringLiteral(" m_" #name)] = QStringLiteral(" 0x" ) + QString::number(static_cast <int >(this ->m_##name), 16 ) + QStringLiteral(" " )
350
336
351
337
SETINT (ushSongID);
352
338
SETINT (iVersion);
@@ -394,17 +380,9 @@ QVariantMap RmeSong::RmeSongClientItemStruct::toMap() const
394
380
}
395
381
396
382
namespace {
397
- const QStringList NoteNumSuffix = {
398
- QStringLiteral (" _4KeyEasy" ),
399
- QStringLiteral (" _4KeyNormal" ),
400
- QStringLiteral (" _4KeyHard" ),
401
- QStringLiteral (" _5KeyEasy" ),
402
- QStringLiteral (" _5KeyNormal" ),
403
- QStringLiteral (" _5KeyHard" ),
404
- QStringLiteral (" _6KeyEasy" ),
405
- QStringLiteral (" _6KeyNormal" ),
406
- QStringLiteral (" _6KeyHard" )
407
- };
383
+ const QStringList NoteNumSuffix
384
+ = {QStringLiteral (" _4KeyEasy" ), QStringLiteral (" _4KeyNormal" ), QStringLiteral (" _4KeyHard" ), QStringLiteral (" _5KeyEasy" ), QStringLiteral (" _5KeyNormal" ),
385
+ QStringLiteral (" _5KeyHard" ), QStringLiteral (" _6KeyEasy" ), QStringLiteral (" _6KeyNormal" ), QStringLiteral (" _6KeyHard" )};
408
386
}
409
387
410
388
QJsonObject RmeSong::RmeSongClientItemStruct::createPatch (const RmeSong::RmeSongClientItemStruct &orig, bool userMade) const
@@ -622,10 +600,8 @@ void RmeSong::RmePapaSongClientItemStruct::parseByteArray(const QByteArray &arr)
622
600
Q_ASSERT (arr.length () == 0x169 );
623
601
const char *data = arr.constData ();
624
602
625
- #define GETX (type, name, offset ) \
626
- this ->m_ ##name = *(reinterpret_cast <const type *>(data + offset))
627
- #define GETSTR (name, offset ) \
628
- this ->m_ ##name = QString::fromUtf8 (data + offset)
603
+ #define GETX (type, name, offset ) this ->m_##name = *(reinterpret_cast <const type *>(data + offset))
604
+ #define GETSTR (name, offset ) this ->m_##name = QString::fromUtf8(data + offset)
629
605
630
606
GETX (int16_t , ushSongID, 0x0 );
631
607
GETX (int32_t , iVersion, 0x2 );
@@ -707,12 +683,9 @@ QByteArray RmeSong::RmePapaSongClientItemStruct::toByteArray() const
707
683
708
684
void RmeSong::RmePapaSongClientItemStruct::parseMap (const QVariantMap &map)
709
685
{
710
- #define GETSTR (name ) \
711
- this ->m_ ##name = map[QStringLiteral (" m_" #name)].toString ()
712
- #define GETINT (name ) \
713
- this ->m_ ##name = map[QStringLiteral (" m_" #name)].toString ().trimmed ().toInt ()
714
- #define GETHEX (name ) \
715
- this ->m_ ##name = map[QStringLiteral (" m_" #name)].toString ().trimmed ().mid (2 ).toInt (nullptr , 16 )
686
+ #define GETSTR (name ) this ->m_##name = map[QStringLiteral(" m_" #name)].toString()
687
+ #define GETINT (name ) this ->m_##name = map[QStringLiteral(" m_" #name)].toString().trimmed().toInt()
688
+ #define GETHEX (name ) this ->m_##name = map[QStringLiteral(" m_" #name)].toString().trimmed().mid(2 ).toInt(nullptr , 16 )
716
689
717
690
GETINT (ushSongID);
718
691
GETINT (iVersion);
@@ -744,12 +717,9 @@ QVariantMap RmeSong::RmePapaSongClientItemStruct::toMap() const
744
717
{
745
718
QVariantMap map;
746
719
747
- #define SETSTR (name ) \
748
- map[QStringLiteral (" m_" #name)] = this ->m_ ##name
749
- #define SETINT (name ) \
750
- map[QStringLiteral (" m_" #name)] = QString::number (static_cast <int >(this ->m_ ##name)) + QStringLiteral (" " )
751
- #define SETHEX (name ) \
752
- map[QStringLiteral (" m_" #name)] = QStringLiteral (" 0x" ) + QString::number (static_cast <int >(this ->m_ ##name), 16 ) + QStringLiteral (" " )
720
+ #define SETSTR (name ) map[QStringLiteral(" m_" #name)] = this ->m_##name
721
+ #define SETINT (name ) map[QStringLiteral(" m_" #name)] = QString::number(static_cast <int >(this ->m_##name)) + QStringLiteral(" " )
722
+ #define SETHEX (name ) map[QStringLiteral(" m_" #name)] = QStringLiteral(" 0x" ) + QString::number(static_cast <int >(this ->m_##name), 16 ) + QStringLiteral(" " )
753
723
754
724
SETINT (ushSongID);
755
725
SETINT (iVersion);
0 commit comments