KIO

metadata.h
1/*
2 This file is part of the KDE libraries
3 SPDX-FileCopyrightText: 2000-2005 David Faure <faure@kde.org>
4
5 SPDX-License-Identifier: LGPL-2.0-only
6*/
7#ifndef KIO_METADATA_H
8#define KIO_METADATA_H
9
10#include "kiocore_export.h"
11#include <QMap>
12#include <QString>
13#include <QVariant>
14
15namespace KIO
16{
17/**
18 * @class KIO::MetaData metadata.h <KIO/MetaData>
19 *
20 * MetaData is a simple map of key/value strings.
21 */
22class MetaData : public QMap<QString, QString>
23{
24public:
25 /**
26 * Creates an empty meta data map.
27 */
29 : QMap<QString, QString>()
30 {
31 }
32 /**
33 * Copy constructor.
34 */
36 : QMap<QString, QString>(metaData)
37 {
38 }
39
40 /**
41 * Creates a meta data map from a QVaraint map.
42 * @since 4.3.1
43 */
45
46 /**
47 * Adds the given meta data map to this map.
48 * @param metaData the map to add
49 * @return this map
50 */
52 {
54 for (it = metaData.constBegin(); it != metaData.constEnd(); ++it) {
55 insert(it.key(), it.value());
56 }
57 return *this;
58 }
59
60 /**
61 * Same as above except the value in the map is a QVariant.
62 *
63 * This convenience function allows you to easily assign the values
64 * of a QVariant to this meta data class.
65 *
66 * @param metaData the map to add
67 * @return this map
68 * @since 4.3.1
69 */
71
72 /**
73 * Sets the given meta data map to this map.
74 * @param metaData the map to add
75 * @return this map
76 * @since 4.3.1
77 */
79
80 /**
81 * Returns the contents of the map as a QVariant.
82 *
83 * @return a QVariant representation of the meta data map.
84 * @since 4.3.1
85 */
86 QVariant toVariant() const;
87};
88
90{
91 *this = map;
92}
93
95{
97
98 while (it.hasNext()) {
99 it.next();
100 insert(it.key(), it.value().toString());
101 }
102
103 return *this;
104}
105
107{
108 clear();
109 return (*this += metaData);
110}
111
113{
116
117 while (it.hasNext()) {
118 it.next();
119 map.insert(it.key(), it.value());
120 }
121
122 return QVariant(map);
123}
124
125} // namespace KIO
126
127#endif /* KIO_METADATA_H */
MetaData is a simple map of key/value strings.
MetaData & operator+=(const QMap< QString, QString > &metaData)
Adds the given meta data map to this map.
Definition metadata.h:51
MetaData()
Creates an empty meta data map.
Definition metadata.h:28
MetaData & operator=(const QMap< QString, QVariant > &metaData)
Sets the given meta data map to this map.
Definition metadata.h:106
QVariant toVariant() const
Returns the contents of the map as a QVariant.
Definition metadata.h:112
MetaData(const QMap< QString, QString > &metaData)
Copy constructor.
Definition metadata.h:35
A namespace for KIO globals.
ConstIterator
const_iterator constBegin() const const
const_iterator constEnd() const const
iterator insert(const Key &key, const T &value)
Key key(const T &value, const Key &defaultKey) const const
T value(const Key &key, const T &defaultValue) const const
bool hasNext() const const
const Key & key() const const
const T & value() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:16:27 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.