Marble

GeoDataSchema.cpp
1// SPDX-License-Identifier: LGPL-2.1-or-later
2//
3// SPDX-FileCopyrightText: 2014 Abhinav Gangwar <abhgang@gmail.com>
4//
5
6#include "GeoDataSchema.h"
7
8// Qt
9#include <QDataStream>
10
11// Marble
12#include "GeoDataSimpleField.h"
13#include "GeoDataTypes.h"
14
15namespace Marble
16{
17
18class GeoDataSchemaPrivate
19{
20public:
22 QString m_name;
23};
24
25GeoDataSchema::GeoDataSchema()
26 : d(new GeoDataSchemaPrivate)
27{
28}
29
30GeoDataSchema::GeoDataSchema(const QHash<QString, GeoDataSimpleField> &simplefields)
31 : d(new GeoDataSchemaPrivate)
32{
33 d->m_simpleField = simplefields;
34}
35
36GeoDataSchema::GeoDataSchema(const GeoDataSchema &other)
37 : GeoDataObject(other)
38 , d(new GeoDataSchemaPrivate(*other.d))
39{
40}
41
42GeoDataSchema &GeoDataSchema::operator=(const GeoDataSchema &other)
43{
44 GeoDataObject::operator=(other);
45 *d = *other.d;
46 return *this;
47}
48
49bool GeoDataSchema::operator==(const GeoDataSchema &other) const
50{
51 return equals(other) && d->m_name == other.d->m_name && d->m_simpleField == other.d->m_simpleField;
52}
53
54bool GeoDataSchema::operator!=(const GeoDataSchema &other) const
55{
56 return !this->operator==(other);
57}
58
59GeoDataSchema::~GeoDataSchema()
60{
61 delete d;
62}
63
64QString GeoDataSchema::schemaName() const
65{
66 return d->m_name;
67}
68
69void GeoDataSchema::setSchemaName(const QString &name)
70{
71 d->m_name = name;
72}
73
74GeoDataSimpleField &GeoDataSchema::simpleField(const QString &name) const
75{
76 return d->m_simpleField[name];
77}
78
79void GeoDataSchema::addSimpleField(const GeoDataSimpleField &value)
80{
81 d->m_simpleField.insert(value.name(), value);
82}
83
84QList<GeoDataSimpleField> GeoDataSchema::simpleFields() const
85{
86 return d->m_simpleField.values();
87}
88
89const char *GeoDataSchema::nodeType() const
90{
91 return GeoDataTypes::GeoDataSchemaType;
92}
93
94void GeoDataSchema::pack(QDataStream &stream) const
95{
96 stream << d->m_simpleField.size();
97
98 QHash<QString, GeoDataSimpleField>::const_iterator begin = d->m_simpleField.constBegin();
99 QHash<QString, GeoDataSimpleField>::const_iterator end = d->m_simpleField.constEnd();
100
101 for (; begin != end; ++begin) {
102 begin.value().pack(stream);
103 }
104}
105
106void GeoDataSchema::unpack(QDataStream &stream)
107{
108 int size = 0;
109 stream >> size;
110 for (int i = 0; i < size; ++i) {
111 GeoDataSimpleField simpleField;
112 simpleField.unpack(stream);
113 d->m_simpleField.insert(simpleField.name(), simpleField);
114 }
115}
116
117}
QString name(GameStandardAction id)
QAction * end(const QObject *recvr, const char *slot, QObject *parent)
const QList< QKeySequence > & begin()
bool equals(const QVariant &lhs, const QVariant &rhs)
bool operator==(const StyleDelim &l, const StyleDelim &r)
Binds a QML item to a specific geodetic location in screen coordinates.
QString & insert(qsizetype position, QChar ch)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 8 2024 12:02:43 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.