Core serialization examples: spacing-only clang-format changes

Marc disagreed with clang-format on some, which are thus excluded.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I1402274635dba866a8160a68211874cb11dcfa61
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
This commit is contained in:
Edward Welbourne 2023-08-25 15:32:22 +02:00
parent 30be644053
commit 670f66eed3
7 changed files with 25 additions and 25 deletions

View File

@ -165,7 +165,7 @@ def main(argv, speak):
struct CborTagDescription
{{
QCborTag tag;
const char *description; // with space and parentheses
const char *description; // with space and parentheses
}};
// {title}

View File

@ -27,7 +27,7 @@
struct CborTagDescription
{
QCborTag tag;
const char *description; // with space and parentheses
const char *description; // with space and parentheses
};
// Concise Binary Object Representation (CBOR) Tags
@ -131,12 +131,12 @@ static const CborTagDescription tagDescriptions[] = {
enum {
// See RFC 7049 section 2.
SmallValueBitLength = 5,
SmallValueMask = (1 << SmallValueBitLength) - 1, /* 0x1f */
Value8Bit = 24,
Value16Bit = 25,
Value32Bit = 26,
Value64Bit = 27
SmallValueBitLength = 5,
SmallValueMask = (1 << SmallValueBitLength) - 1, /* 0x1f */
Value8Bit = 24,
Value16Bit = 25,
Value32Bit = 26,
Value64Bit = 27
};
//! [0]
@ -381,7 +381,7 @@ void CborDumper::dumpOne(int nestingLevel)
if (reader.next()) {
printWidthIndicator(quint64(tag));
printf("(");
dumpOne(nestingLevel); // same level!
dumpOne(nestingLevel); // same level!
printf(")");
}
@ -489,7 +489,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
qsizetype size = reader.currentStringChunkSize();
if (size < 0)
return; // error
return; // error
if (size >= ChunkSizeLimit) {
fprintf(stderr, "String length too big, %lli\n", qint64(size));
exit(EXIT_FAILURE);
@ -534,7 +534,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
printf(" %s%s", indent.constData(), section.toHex(' ').constData());
// print the decode
QByteArray spaces(width > 0 ? width - section.size() * 3 + 1: 0, ' ');
QByteArray spaces(width > 0 ? width - section.size() * 3 + 1 : 0, ' ');
printf("%s # \"", spaces.constData());
auto ptr = reinterpret_cast<const uchar *>(section.constData());
for (int j = 0; j < section.size(); ++j)
@ -546,7 +546,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
// get the next chunk
size = reader.currentStringChunkSize();
if (size < 0)
return; // error
return; // error
if (size >= ChunkSizeLimit) {
fprintf(stderr, "String length too big, %lli\n", qint64(size));
exit(EXIT_FAILURE);

View File

@ -56,11 +56,11 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
result = QLatin1String("Map {");
for (const auto &pair : map) {
result += indented + dumpVariant(pair.first, indented);
result.chop(1); // remove comma
result.chop(1); // remove comma
result += QLatin1String(" => ") + dumpVariant(pair.second, indented);
}
result.chop(1); // remove comma
result.chop(1); // remove comma
result += indent + QLatin1String("},");
} else if (type == QMetaType::QVariantList) {
const QVariantList list = v.toList();
@ -68,7 +68,7 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
result = QLatin1String("List [");
for (const auto &item : list)
result += indented + dumpVariant(item, indented);
result.chop(1); // remove comma
result.chop(1); // remove comma
result += indent + QLatin1String("],");
} else {
QDebug debug(&result);
@ -115,7 +115,7 @@ void DataStreamDumper::saveFile(QIODevice *f, const QVariant &contents, const QS
{
Q_UNUSED(options);
QString s = dumpVariant(contents);
s[s.size() - 1] = QLatin1Char('\n'); // replace the comma with newline
s[s.size() - 1] = QLatin1Char('\n'); // replace the comma with newline
QTextStream out(f);
out << s;
@ -213,7 +213,7 @@ void DataStreamConverter::saveFile(QIODevice *f, const QVariant &contents, const
exit(EXIT_FAILURE);
}
char c = order == QDataStream::LittleEndian ? 'l' : 'B';
char c = order == QDataStream::LittleEndian ? 'l' : 'B';
f->write(signature);
f->write(&c, 1);

View File

@ -4,7 +4,7 @@
#include "nullconverter.h"
static NullConverter nullConverter;
Converter* Converter::null = &nullConverter;
Converter *Converter::null = &nullConverter;
QString NullConverter::name()
{

View File

@ -76,7 +76,7 @@ QVariant TextConverter::loadFile(QIODevice *f, Converter *&outputConverter)
QVariantList list;
QTextStream in(f);
QString line ;
QString line;
while (!in.atEnd()) {
in.readLineInto(&line);

View File

@ -76,8 +76,8 @@ bool Game::loadGame(Game::SaveFormat saveFormat)
QByteArray saveData = loadFile.readAll();
QJsonDocument loadDoc(saveFormat == Json
? QJsonDocument::fromJson(saveData)
: QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
? QJsonDocument::fromJson(saveData)
: QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
read(loadDoc.object());

View File

@ -27,7 +27,7 @@ MainWindow::MainWindow()
: treeWidget(new QTreeWidget)
{
treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
treeWidget->setHeaderLabels(QStringList{ tr("Title"), tr("Location") });
treeWidget->setHeaderLabels(QStringList{tr("Title"), tr("Location")});
#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
connect(treeWidget, &QWidget::customContextMenuRequested,
@ -148,8 +148,8 @@ void MainWindow::saveAs()
//! [5]
void MainWindow::about()
{
QMessageBox::about(this, tr("About QXmlStream Bookmarks"),
tr("The <b>QXmlStream Bookmarks</b> example demonstrates how to use Qt's "
"QXmlStream classes to read and write XML documents."));
QMessageBox::about(this, tr("About QXmlStream Bookmarks"),
tr("The <b>QXmlStream Bookmarks</b> example demonstrates how to use Qt's "
"QXmlStream classes to read and write XML documents."));
}
//! [5]