Skip to content

Commit 79086a7

Browse files
committed
import .clang-format file from TouhouKill
1 parent c1dc09a commit 79086a7

18 files changed

+242
-381
lines changed

.clang-format

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
BasedOnStyle: Webkit
2+
3+
AlignAfterOpenBracket: Align
4+
AlignConsecutiveAssignments: false
5+
AlignConsecutiveDeclarations: false
6+
AlignEscapedNewlinesLeft: true
7+
AlignTrailingComments: false
8+
AllowShortBlocksOnASingleLine: false
9+
AllowShortFunctionsOnASingleLine: None
10+
AllowShortIfStatementsOnASingleLine: false
11+
AllowShortLoopsOnASingleLine: false
12+
AllowAllParametersOfDeclarationOnNextLine: true
13+
BinPackArguments: true
14+
BinPackParameters: true
15+
BreakBeforeBraces: Custom
16+
BraceWrapping:
17+
AfterClass: true
18+
AfterControlStatement: false
19+
AfterEnum: true
20+
AfterFunction: true
21+
AfterNamespace: false
22+
AfterStruct: true
23+
AfterUnion: true
24+
BeforeCatch: false
25+
BeforeElse: false
26+
IndentBraces: false
27+
ColumnLimit: 180
28+
Cpp11BracedListStyle: true
29+
ForEachMacros: ['foreach', 'Q_FOREACH', 'forever', 'Q_FOREVER']
30+
# FixNamespaceComments: true
31+
IndentCaseLabels: false
32+
# IndentWidth: 4
33+
KeepEmptyLinesAtTheStartOfBlocks: false
34+
MaxEmptyLinesToKeep: 1
35+
NamespaceIndentation: None
36+
PointerAlignment: Right
37+
ReflowComments: false
38+
SortIncludes: true
39+
SpaceAfterCStyleCast: false
40+
# SpaceAfterTemplateKeyword: false
41+
SpaceBeforeParens: ControlStatements
42+
SpaceInEmptyParentheses: false
43+
SpacesInAngles: false
44+
SpacesInParentheses: false
45+
SpacesInSquareBrackets: false
46+
Standard: Cpp03
47+
UseTab: Never
48+
TabWidth: 4

src/librmessentials/src/rmesongstruct.cpp

+26-56
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
#include "rmesongstruct.h"
1+
#include "rmesongstruct.h"
22
#include "rmeutils.h"
33

44
const QString RmeSong::RmeSongClientHeaderStruct::CreateTime = QStringLiteral(" 0-00-00 00:00:00");
@@ -23,10 +23,8 @@ void RmeSong::RmeSongClientHeaderStruct::parseByteArray(const QByteArray &arr)
2323
Q_ASSERT(arr.length() == 0x88);
2424
const char *data = arr.constData();
2525

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)
3028

3129
GETX(int32_t, Magic, 0x0);
3230
GETX(int32_t, Version, 0x4);
@@ -86,10 +84,8 @@ QByteArray RmeSong::RmeSongClientHeaderStruct::toByteArray() const
8684

8785
void RmeSong::RmeSongClientHeaderStruct::parseMap(const QVariantMap &map)
8886
{
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()
9389

9490
GETINT(Magic);
9591
GETINT(Version);
@@ -109,10 +105,8 @@ QVariantMap RmeSong::RmeSongClientHeaderStruct::toMap() const
109105
{
110106
QVariantMap map;
111107

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(" ")
116110

117111
SETINT(Magic);
118112
SETINT(Version);
@@ -168,10 +162,8 @@ void RmeSong::RmeSongClientItemStruct::parseByteArray(const QByteArray &arr)
168162
Q_ASSERT(arr.length() == 0x33e);
169163
const char *data = arr.constData();
170164

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)
175167

176168
GETX(int16_t, ushSongID, 0x0);
177169
GETX(int32_t, iVersion, 0x2);
@@ -287,12 +279,9 @@ QByteArray RmeSong::RmeSongClientItemStruct::toByteArray() const
287279

288280
void RmeSong::RmeSongClientItemStruct::parseMap(const QVariantMap &map)
289281
{
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)
296285

297286
GETINT(ushSongID);
298287
GETINT(iVersion);
@@ -341,12 +330,9 @@ QVariantMap RmeSong::RmeSongClientItemStruct::toMap() const
341330
{
342331
QVariantMap map;
343332

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(" ")
350336

351337
SETINT(ushSongID);
352338
SETINT(iVersion);
@@ -394,17 +380,9 @@ QVariantMap RmeSong::RmeSongClientItemStruct::toMap() const
394380
}
395381

396382
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")};
408386
}
409387

410388
QJsonObject RmeSong::RmeSongClientItemStruct::createPatch(const RmeSong::RmeSongClientItemStruct &orig, bool userMade) const
@@ -622,10 +600,8 @@ void RmeSong::RmePapaSongClientItemStruct::parseByteArray(const QByteArray &arr)
622600
Q_ASSERT(arr.length() == 0x169);
623601
const char *data = arr.constData();
624602

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)
629605

630606
GETX(int16_t, ushSongID, 0x0);
631607
GETX(int32_t, iVersion, 0x2);
@@ -707,12 +683,9 @@ QByteArray RmeSong::RmePapaSongClientItemStruct::toByteArray() const
707683

708684
void RmeSong::RmePapaSongClientItemStruct::parseMap(const QVariantMap &map)
709685
{
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)
716689

717690
GETINT(ushSongID);
718691
GETINT(iVersion);
@@ -744,12 +717,9 @@ QVariantMap RmeSong::RmePapaSongClientItemStruct::toMap() const
744717
{
745718
QVariantMap map;
746719

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(" ")
753723

754724
SETINT(ushSongID);
755725
SETINT(iVersion);

src/quazip/src/crypt.h

+3-6
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,9 @@ static void init_keys(const char *passwd, unsigned long *pkeys, const z_crc_t FA
7575
}
7676
}
7777

78-
#define zdecode(pkeys, pcrc_32_tab, c) \
79-
(update_keys(pkeys, pcrc_32_tab, c ^= decrypt_byte(pkeys, pcrc_32_tab)))
78+
#define zdecode(pkeys, pcrc_32_tab, c) (update_keys(pkeys, pcrc_32_tab, c ^= decrypt_byte(pkeys, pcrc_32_tab)))
8079

81-
#define zencode(pkeys, pcrc_32_tab, c, t) \
82-
(t = decrypt_byte(pkeys, pcrc_32_tab), update_keys(pkeys, pcrc_32_tab, c), t ^ (c))
80+
#define zencode(pkeys, pcrc_32_tab, c, t) (t = decrypt_byte(pkeys, pcrc_32_tab), update_keys(pkeys, pcrc_32_tab, c), t ^ (c))
8381

8482
#ifdef INCLUDECRYPTINGCODE_IFCRYPTALLOWED
8583

@@ -89,8 +87,7 @@ static void init_keys(const char *passwd, unsigned long *pkeys, const z_crc_t FA
8987
#define ZCR_SEED2 3141592654UL /* use PI as default pattern */
9088
#endif
9189

92-
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting)
93-
const char *passwd; /* password string */
90+
static int crypthead(passwd, buf, bufSize, pkeys, pcrc_32_tab, crcForCrypting) const char *passwd; /* password string */
9491
unsigned char *buf; /* where to write header */
9592
int bufSize;
9693
unsigned long *pkeys;

src/quazip/src/quaadler32.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,7 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
3535
* This class wrappers the adler32 function with the QuaChecksum32 interface.
3636
* See QuaChecksum32 for more info.
3737
*/
38-
class QUAZIP_EXPORT QuaAdler32
39-
: public QuaChecksum32
38+
class QUAZIP_EXPORT QuaAdler32 : public QuaChecksum32
4039
{
4140
public:
4241
QuaAdler32();

src/quazip/src/quacrc32.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ see quazip/(un)zip.h files for details. Basically it's the zlib license.
3232
* This class wrappers the crc32 function with the QuaChecksum32 interface.
3333
* See QuaChecksum32 for more info.
3434
*/
35-
class QUAZIP_EXPORT QuaCrc32
36-
: public QuaChecksum32
35+
class QUAZIP_EXPORT QuaCrc32 : public QuaChecksum32
3736
{
3837
public:
3938
QuaCrc32();

src/quazip/src/quagzipfile.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,7 @@ class QuaGzipFilePrivate;
3636
/**
3737
This class is a wrapper around GZIP file access functions in zlib. Unlike QuaZip classes, it doesn't allow reading from a GZIP file opened as QIODevice, for example, if your GZIP file is in QBuffer. It only provides QIODevice access to a GZIP file contents, but the GZIP file itself must be identified by its name on disk or by descriptor id.
3838
*/
39-
class QUAZIP_EXPORT QuaGzipFile
40-
: public QIODevice
39+
class QUAZIP_EXPORT QuaGzipFile : public QIODevice
4140
{
4241
Q_OBJECT
4342
public:

src/quazip/src/quaziodevice.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ class QuaZIODevicePrivate;
3838
decompress it back. Compressing data sent over a QTcpSocket is a good
3939
example.
4040
*/
41-
class QUAZIP_EXPORT QuaZIODevice
42-
: public QIODevice
41+
class QUAZIP_EXPORT QuaZIODevice : public QIODevice
4342
{
4443
Q_OBJECT
4544
public:

src/quazip/src/quazip.h

+1-2
Original file line numberDiff line numberDiff line change
@@ -128,8 +128,7 @@ class QUAZIP_EXPORT QuaZip
128128
file name case sensitivity for the platform. Otherwise, just
129129
returns the appropriate value from the Qt::CaseSensitivity enum.
130130
*/
131-
static Qt::CaseSensitivity convertCaseSensitivity(
132-
CaseSensitivity cs);
131+
static Qt::CaseSensitivity convertCaseSensitivity(CaseSensitivity cs);
133132

134133
private:
135134
QuaZipPrivate *p;

src/quazip/src/quazipdir.h

+6-15
Original file line numberDiff line numberDiff line change
@@ -116,17 +116,14 @@ class QUAZIP_EXPORT QuaZipDir
116116
accepted.
117117
\param sort Sorting mode.
118118
*/
119-
QList<QuaZipFileInfo> entryInfoList(const QStringList &nameFilters,
120-
QDir::Filters filters = QDir::NoFilter,
121-
QDir::SortFlags sort = QDir::NoSort) const;
119+
QList<QuaZipFileInfo> entryInfoList(const QStringList &nameFilters, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const;
122120
/// Returns the list of the entries in the directory.
123121
/**
124122
\overload
125123
126124
The same as entryInfoList(QStringList(), filters, sort).
127125
*/
128-
QList<QuaZipFileInfo> entryInfoList(QDir::Filters filters = QDir::NoFilter,
129-
QDir::SortFlags sort = QDir::NoSort) const;
126+
QList<QuaZipFileInfo> entryInfoList(QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const;
130127
/// Returns the list of the entries in the directory with zip64 support.
131128
/**
132129
\param nameFilters The list of file patterns to list, uses the same
@@ -135,33 +132,27 @@ class QUAZIP_EXPORT QuaZipDir
135132
accepted.
136133
\param sort Sorting mode.
137134
*/
138-
QList<QuaZipFileInfo64> entryInfoList64(const QStringList &nameFilters,
139-
QDir::Filters filters = QDir::NoFilter,
140-
QDir::SortFlags sort = QDir::NoSort) const;
135+
QList<QuaZipFileInfo64> entryInfoList64(const QStringList &nameFilters, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const;
141136
/// Returns the list of the entries in the directory with zip64 support.
142137
/**
143138
\overload
144139
145140
The same as entryInfoList64(QStringList(), filters, sort).
146141
*/
147-
QList<QuaZipFileInfo64> entryInfoList64(QDir::Filters filters = QDir::NoFilter,
148-
QDir::SortFlags sort = QDir::NoSort) const;
142+
QList<QuaZipFileInfo64> entryInfoList64(QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const;
149143
/// Returns the list of the entry names in the directory.
150144
/**
151145
The same as entryInfoList(nameFilters, filters, sort), but only
152146
returns entry names.
153147
*/
154-
QStringList entryList(const QStringList &nameFilters,
155-
QDir::Filters filters = QDir::NoFilter,
156-
QDir::SortFlags sort = QDir::NoSort) const;
148+
QStringList entryList(const QStringList &nameFilters, QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const;
157149
/// Returns the list of the entry names in the directory.
158150
/**
159151
\overload
160152
161153
The same as entryList(QStringList(), filters, sort).
162154
*/
163-
QStringList entryList(QDir::Filters filters = QDir::NoFilter,
164-
QDir::SortFlags sort = QDir::NoSort) const;
155+
QStringList entryList(QDir::Filters filters = QDir::NoFilter, QDir::SortFlags sort = QDir::NoSort) const;
165156
/// Returns \c true if the entry with the specified name exists.
166157
/**
167158
The &quot;..&quot; is considered to exist if the current directory

src/quazip/src/quazipfile.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,7 @@ class QuaZipFilePrivate;
7171
* this class.
7272
*
7373
**/
74-
class QUAZIP_EXPORT QuaZipFile
75-
: public QIODevice
74+
class QUAZIP_EXPORT QuaZipFile : public QIODevice
7675
{
7776
friend class QuaZipFilePrivate;
7877
Q_OBJECT
@@ -343,7 +342,8 @@ class QUAZIP_EXPORT QuaZipFile
343342
* Arguments \a windowBits, \a memLevel, \a strategy provide zlib
344343
* algorithms tuning. See deflateInit2() in zlib.
345344
**/
346-
bool open(OpenMode mode, const QuaZipNewInfo &info, const char *password = NULL, quint32 crc = 0, int method = Z_DEFLATED, int level = Z_DEFAULT_COMPRESSION, bool raw = false, int windowBits = -MAX_WBITS, int memLevel = DEF_MEM_LEVEL, int strategy = Z_DEFAULT_STRATEGY);
345+
bool open(OpenMode mode, const QuaZipNewInfo &info, const char *password = NULL, quint32 crc = 0, int method = Z_DEFLATED, int level = Z_DEFAULT_COMPRESSION, bool raw = false,
346+
int windowBits = -MAX_WBITS, int memLevel = DEF_MEM_LEVEL, int strategy = Z_DEFAULT_STRATEGY);
347347
/// Returns \c true, but \ref quazipfile-sequential "beware"!
348348
virtual bool isSequential() const;
349349
/// Returns current position in the file.

0 commit comments

Comments
 (0)