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.5 Task-number: QTBUG-111228 Change-Id: I9e64b382ad48f9a74e432ccd49b6f5fcc9316da3 Reviewed-by: Ivan Solovev <ivan.solovev@qt.io> (cherry picked from commit c78d9bf54900df71768ab4653320deeeddde2748)
This commit is contained in:
parent
c6011e07c1
commit
e62633333a
@ -27,6 +27,7 @@ qt_add_executable(convert
|
|||||||
main.cpp
|
main.cpp
|
||||||
nullconverter.cpp nullconverter.h
|
nullconverter.cpp nullconverter.h
|
||||||
textconverter.cpp textconverter.h
|
textconverter.cpp textconverter.h
|
||||||
|
variantorderedmap.h
|
||||||
xmlconverter.cpp xmlconverter.h
|
xmlconverter.cpp xmlconverter.h
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
#include "cborconverter.h"
|
#include "cborconverter.h"
|
||||||
|
#include "variantorderedmap.h"
|
||||||
|
|
||||||
#include <QCborArray>
|
#include <QCborArray>
|
||||||
#include <QCborMap>
|
#include <QCborMap>
|
||||||
|
@ -27,4 +27,5 @@ HEADERS += \
|
|||||||
jsonconverter.h \
|
jsonconverter.h \
|
||||||
nullconverter.h \
|
nullconverter.h \
|
||||||
textconverter.h \
|
textconverter.h \
|
||||||
|
variantorderedmap.h \
|
||||||
xmlconverter.h
|
xmlconverter.h
|
||||||
|
@ -5,22 +5,8 @@
|
|||||||
#define CONVERTER_H
|
#define CONVERTER_H
|
||||||
|
|
||||||
#include <QIODevice>
|
#include <QIODevice>
|
||||||
#include <QList>
|
#include <QStringList>
|
||||||
#include <QPair>
|
|
||||||
#include <QVariant>
|
#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
|
class Converter
|
||||||
{
|
{
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
#include "datastreamconverter.h"
|
#include "datastreamconverter.h"
|
||||||
#include "debugtextdumper.h"
|
#include "debugtextdumper.h"
|
||||||
|
#include "variantorderedmap.h"
|
||||||
|
|
||||||
#include <QDataStream>
|
#include <QDataStream>
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
#include "debugtextdumper.h"
|
#include "debugtextdumper.h"
|
||||||
|
#include "variantorderedmap.h"
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QTextStream>
|
#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
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
|
||||||
|
|
||||||
#include "xmlconverter.h"
|
#include "xmlconverter.h"
|
||||||
|
#include "variantorderedmap.h"
|
||||||
|
|
||||||
#include <QBitArray>
|
#include <QBitArray>
|
||||||
#include <QtCborCommon>
|
#include <QtCborCommon>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user