Move Converter class, in eponymous example, to a file of its own

There's more details coming and it's good hygiene anyway.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: Ief3acf6e508bc93eaa8490f6c49300b25c1d3556
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This commit is contained in:
Edward Welbourne 2023-10-31 16:26:04 +01:00
parent d57a78657e
commit 8b8fc42f2c
4 changed files with 27 additions and 22 deletions

View File

@ -20,7 +20,7 @@ qt_standard_project_setup()
qt_add_executable(convert
cborconverter.cpp cborconverter.h
converter.h
converter.cpp converter.h
datastreamconverter.cpp datastreamconverter.h
debugtextdumper.cpp debugtextdumper.h
jsonconverter.cpp jsonconverter.h

View File

@ -11,6 +11,7 @@ target.path = $$[QT_INSTALL_EXAMPLES]/corelib/serialization/convert
INSTALLS += target
SOURCES += main.cpp \
converter.cpp \
cborconverter.cpp \
datastreamconverter.cpp \
debugtextdumper.cpp \

View File

@ -0,0 +1,25 @@
// Copyright (C) 2023 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "converter.h"
Converter::Converter()
{
converters().append(this);
}
Converter::~Converter()
{
converters().removeAll(this);
}
QList<const Converter *> &Converter::converters()
{
Q_CONSTINIT static QList<const Converter *> store;
return store;
}
const QList<const Converter *> &Converter::allConverters()
{
return converters();
}

View File

@ -14,27 +14,6 @@
using namespace Qt::StringLiterals;
Converter::Converter()
{
converters().append(this);
}
Converter::~Converter()
{
converters().removeAll(this);
}
QList<const Converter *> &Converter::converters()
{
Q_CONSTINIT static QList<const Converter *> store;
return store;
}
const QList<const Converter *> &Converter::allConverters()
{
return converters();
}
static const Converter *prepareConverter(QString format, Converter::Direction direction,
QFile *stream)
{