Core serialization examples: spacing-only clang-format changes
Marc disagreed with clang-format on some, which are thus excluded. Task-number: QTBUG-111228 Change-Id: I1402274635dba866a8160a68211874cb11dcfa61 Reviewed-by: Marc Mutz <marc.mutz@qt.io> (cherry picked from commit 670f66eed3fd81f4b7c3e6f43d06e5bb79176527) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
253731e84e
commit
4091fe8516
@ -165,7 +165,7 @@ def main(argv, speak):
|
|||||||
struct CborTagDescription
|
struct CborTagDescription
|
||||||
{{
|
{{
|
||||||
QCborTag tag;
|
QCborTag tag;
|
||||||
const char *description; // with space and parentheses
|
const char *description; // with space and parentheses
|
||||||
}};
|
}};
|
||||||
|
|
||||||
// {title}
|
// {title}
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
struct CborTagDescription
|
struct CborTagDescription
|
||||||
{
|
{
|
||||||
QCborTag tag;
|
QCborTag tag;
|
||||||
const char *description; // with space and parentheses
|
const char *description; // with space and parentheses
|
||||||
};
|
};
|
||||||
|
|
||||||
// Concise Binary Object Representation (CBOR) Tags
|
// Concise Binary Object Representation (CBOR) Tags
|
||||||
@ -131,12 +131,12 @@ static const CborTagDescription tagDescriptions[] = {
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
// See RFC 7049 section 2.
|
// See RFC 7049 section 2.
|
||||||
SmallValueBitLength = 5,
|
SmallValueBitLength = 5,
|
||||||
SmallValueMask = (1 << SmallValueBitLength) - 1, /* 0x1f */
|
SmallValueMask = (1 << SmallValueBitLength) - 1, /* 0x1f */
|
||||||
Value8Bit = 24,
|
Value8Bit = 24,
|
||||||
Value16Bit = 25,
|
Value16Bit = 25,
|
||||||
Value32Bit = 26,
|
Value32Bit = 26,
|
||||||
Value64Bit = 27
|
Value64Bit = 27
|
||||||
};
|
};
|
||||||
|
|
||||||
//! [0]
|
//! [0]
|
||||||
@ -381,7 +381,7 @@ void CborDumper::dumpOne(int nestingLevel)
|
|||||||
if (reader.next()) {
|
if (reader.next()) {
|
||||||
printWidthIndicator(quint64(tag));
|
printWidthIndicator(quint64(tag));
|
||||||
printf("(");
|
printf("(");
|
||||||
dumpOne(nestingLevel); // same level!
|
dumpOne(nestingLevel); // same level!
|
||||||
printf(")");
|
printf(")");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -489,7 +489,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
|
|||||||
|
|
||||||
qsizetype size = reader.currentStringChunkSize();
|
qsizetype size = reader.currentStringChunkSize();
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return; // error
|
return; // error
|
||||||
if (size >= ChunkSizeLimit) {
|
if (size >= ChunkSizeLimit) {
|
||||||
fprintf(stderr, "String length too big, %lli\n", qint64(size));
|
fprintf(stderr, "String length too big, %lli\n", qint64(size));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
@ -534,7 +534,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
|
|||||||
printf(" %s%s", indent.constData(), section.toHex(' ').constData());
|
printf(" %s%s", indent.constData(), section.toHex(' ').constData());
|
||||||
|
|
||||||
// print the decode
|
// 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());
|
printf("%s # \"", spaces.constData());
|
||||||
auto ptr = reinterpret_cast<const uchar *>(section.constData());
|
auto ptr = reinterpret_cast<const uchar *>(section.constData());
|
||||||
for (int j = 0; j < section.size(); ++j)
|
for (int j = 0; j < section.size(); ++j)
|
||||||
@ -546,7 +546,7 @@ void CborDumper::dumpOneDetailed(int nestingLevel)
|
|||||||
// get the next chunk
|
// get the next chunk
|
||||||
size = reader.currentStringChunkSize();
|
size = reader.currentStringChunkSize();
|
||||||
if (size < 0)
|
if (size < 0)
|
||||||
return; // error
|
return; // error
|
||||||
if (size >= ChunkSizeLimit) {
|
if (size >= ChunkSizeLimit) {
|
||||||
fprintf(stderr, "String length too big, %lli\n", qint64(size));
|
fprintf(stderr, "String length too big, %lli\n", qint64(size));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -56,11 +56,11 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
|
|||||||
result = QLatin1String("Map {");
|
result = QLatin1String("Map {");
|
||||||
for (const auto &pair : map) {
|
for (const auto &pair : map) {
|
||||||
result += indented + dumpVariant(pair.first, indented);
|
result += indented + dumpVariant(pair.first, indented);
|
||||||
result.chop(1); // remove comma
|
result.chop(1); // remove comma
|
||||||
result += QLatin1String(" => ") + dumpVariant(pair.second, indented);
|
result += QLatin1String(" => ") + dumpVariant(pair.second, indented);
|
||||||
|
|
||||||
}
|
}
|
||||||
result.chop(1); // remove comma
|
result.chop(1); // remove comma
|
||||||
result += indent + QLatin1String("},");
|
result += indent + QLatin1String("},");
|
||||||
} else if (type == QMetaType::QVariantList) {
|
} else if (type == QMetaType::QVariantList) {
|
||||||
const QVariantList list = v.toList();
|
const QVariantList list = v.toList();
|
||||||
@ -68,7 +68,7 @@ static QString dumpVariant(const QVariant &v, const QString &indent = QLatin1Str
|
|||||||
result = QLatin1String("List [");
|
result = QLatin1String("List [");
|
||||||
for (const auto &item : list)
|
for (const auto &item : list)
|
||||||
result += indented + dumpVariant(item, indented);
|
result += indented + dumpVariant(item, indented);
|
||||||
result.chop(1); // remove comma
|
result.chop(1); // remove comma
|
||||||
result += indent + QLatin1String("],");
|
result += indent + QLatin1String("],");
|
||||||
} else {
|
} else {
|
||||||
QDebug debug(&result);
|
QDebug debug(&result);
|
||||||
@ -115,7 +115,7 @@ void DataStreamDumper::saveFile(QIODevice *f, const QVariant &contents, const QS
|
|||||||
{
|
{
|
||||||
Q_UNUSED(options);
|
Q_UNUSED(options);
|
||||||
QString s = dumpVariant(contents);
|
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);
|
QTextStream out(f);
|
||||||
out << s;
|
out << s;
|
||||||
@ -213,7 +213,7 @@ void DataStreamConverter::saveFile(QIODevice *f, const QVariant &contents, const
|
|||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
char c = order == QDataStream::LittleEndian ? 'l' : 'B';
|
char c = order == QDataStream::LittleEndian ? 'l' : 'B';
|
||||||
f->write(signature);
|
f->write(signature);
|
||||||
f->write(&c, 1);
|
f->write(&c, 1);
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include "nullconverter.h"
|
#include "nullconverter.h"
|
||||||
|
|
||||||
static NullConverter nullConverter;
|
static NullConverter nullConverter;
|
||||||
Converter* Converter::null = &nullConverter;
|
Converter *Converter::null = &nullConverter;
|
||||||
|
|
||||||
QString NullConverter::name()
|
QString NullConverter::name()
|
||||||
{
|
{
|
||||||
|
@ -76,7 +76,7 @@ QVariant TextConverter::loadFile(QIODevice *f, Converter *&outputConverter)
|
|||||||
|
|
||||||
QVariantList list;
|
QVariantList list;
|
||||||
QTextStream in(f);
|
QTextStream in(f);
|
||||||
QString line ;
|
QString line;
|
||||||
while (!in.atEnd()) {
|
while (!in.atEnd()) {
|
||||||
in.readLineInto(&line);
|
in.readLineInto(&line);
|
||||||
|
|
||||||
|
@ -76,8 +76,8 @@ bool Game::loadGame(Game::SaveFormat saveFormat)
|
|||||||
QByteArray saveData = loadFile.readAll();
|
QByteArray saveData = loadFile.readAll();
|
||||||
|
|
||||||
QJsonDocument loadDoc(saveFormat == Json
|
QJsonDocument loadDoc(saveFormat == Json
|
||||||
? QJsonDocument::fromJson(saveData)
|
? QJsonDocument::fromJson(saveData)
|
||||||
: QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
|
: QJsonDocument(QCborValue::fromCbor(saveData).toMap().toJsonObject()));
|
||||||
|
|
||||||
read(loadDoc.object());
|
read(loadDoc.object());
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ MainWindow::MainWindow()
|
|||||||
: treeWidget(new QTreeWidget)
|
: treeWidget(new QTreeWidget)
|
||||||
{
|
{
|
||||||
treeWidget->header()->setSectionResizeMode(QHeaderView::Stretch);
|
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)
|
#if QT_CONFIG(clipboard) && QT_CONFIG(contextmenu)
|
||||||
treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
treeWidget->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||||
connect(treeWidget, &QWidget::customContextMenuRequested,
|
connect(treeWidget, &QWidget::customContextMenuRequested,
|
||||||
@ -148,8 +148,8 @@ void MainWindow::saveAs()
|
|||||||
//! [5]
|
//! [5]
|
||||||
void MainWindow::about()
|
void MainWindow::about()
|
||||||
{
|
{
|
||||||
QMessageBox::about(this, tr("About QXmlStream Bookmarks"),
|
QMessageBox::about(this, tr("About QXmlStream Bookmarks"),
|
||||||
tr("The <b>QXmlStream Bookmarks</b> example demonstrates how to use Qt's "
|
tr("The <b>QXmlStream Bookmarks</b> example demonstrates how to use Qt's "
|
||||||
"QXmlStream classes to read and write XML documents."));
|
"QXmlStream classes to read and write XML documents."));
|
||||||
}
|
}
|
||||||
//! [5]
|
//! [5]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user