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:
parent
08ac3ddde7
commit
c78d9bf549
@ -27,6 +27,7 @@ qt_add_executable(convert
|
||||
main.cpp
|
||||
nullconverter.cpp nullconverter.h
|
||||
textconverter.cpp textconverter.h
|
||||
variantorderedmap.h
|
||||
xmlconverter.cpp xmlconverter.h
|
||||
)
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "cborconverter.h"
|
||||
#include "variantorderedmap.h"
|
||||
|
||||
#include <QCborArray>
|
||||
#include <QCborMap>
|
||||
|
@ -27,4 +27,5 @@ HEADERS += \
|
||||
jsonconverter.h \
|
||||
nullconverter.h \
|
||||
textconverter.h \
|
||||
variantorderedmap.h \
|
||||
xmlconverter.h
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
#include "datastreamconverter.h"
|
||||
#include "debugtextdumper.h"
|
||||
#include "variantorderedmap.h"
|
||||
|
||||
#include <QDataStream>
|
||||
|
||||
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "debugtextdumper.h"
|
||||
#include "variantorderedmap.h"
|
||||
|
||||
#include <QDebug>
|
||||
#include <QTextStream>
|
||||
|
24
examples/corelib/serialization/convert/variantorderedmap.h
Normal file
24
examples/corelib/serialization/convert/variantorderedmap.h
Normal 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
|
@ -2,6 +2,7 @@
|
||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||
|
||||
#include "xmlconverter.h"
|
||||
#include "variantorderedmap.h"
|
||||
|
||||
#include <QBitArray>
|
||||
#include <QtCborCommon>
|
||||
|
Loading…
Reference in New Issue
Block a user