Split VariantOrderedMap out of Converter's header in example

Although used mostly in the same files, they're separate types, so
define them in separate places.

Pick-to: 6.6 6.5
Task-number: QTBUG-111228
Change-Id: I9e64b382ad48f9a74e432ccd49b6f5fcc9316da3
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
This commit is contained in:
Edward Welbourne 2023-09-04 15:14:41 +02:00
parent 08ac3ddde7
commit c78d9bf549
8 changed files with 31 additions and 15 deletions

View File

@ -27,6 +27,7 @@ qt_add_executable(convert
main.cpp
nullconverter.cpp nullconverter.h
textconverter.cpp textconverter.h
variantorderedmap.h
xmlconverter.cpp xmlconverter.h
)

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "cborconverter.h"
#include "variantorderedmap.h"
#include <QCborArray>
#include <QCborMap>

View File

@ -27,4 +27,5 @@ HEADERS += \
jsonconverter.h \
nullconverter.h \
textconverter.h \
variantorderedmap.h \
xmlconverter.h

View File

@ -5,22 +5,8 @@
#define CONVERTER_H
#include <QIODevice>
#include <QList>
#include <QPair>
#include <QStringList>
#include <QVariant>
#include <QVariantMap>
class VariantOrderedMap : public QList<QPair<QVariant, QVariant>>
{
public:
VariantOrderedMap() = default;
VariantOrderedMap(const QVariantMap &map)
{
reserve(map.size());
for (auto it = map.begin(); it != map.end(); ++it)
append({it.key(), it.value()});
}
};
class Converter
{

View File

@ -3,6 +3,7 @@
#include "datastreamconverter.h"
#include "debugtextdumper.h"
#include "variantorderedmap.h"
#include <QDataStream>

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "debugtextdumper.h"
#include "variantorderedmap.h"
#include <QDebug>
#include <QTextStream>

View File

@ -0,0 +1,24 @@
// Copyright (C) 2018 Intel Corporation.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#ifndef VARIANTORDEREDMAP_H
#define VARIANTORDEREDMAP_H
#include <QList>
#include <QPair>
#include <QVariant>
#include <QVariantMap>
class VariantOrderedMap : public QList<QPair<QVariant, QVariant>>
{
public:
VariantOrderedMap() = default;
VariantOrderedMap(const QVariantMap &map)
{
reserve(map.size());
for (auto it = map.begin(); it != map.end(); ++it)
append({it.key(), it.value()});
}
};
#endif // VARIANTORDEREDMAP_H

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include "xmlconverter.h"
#include "variantorderedmap.h"
#include <QBitArray>
#include <QtCborCommon>