KMime

contentindex.cpp
Go to the documentation of this file.
1/*
2 SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6/**
7 @file
8 This file is part of the API for handling @ref MIME data and
9 defines the ContentIndex class.
10
11 @brief
12 Defines the ContentIndex class.
13
14 @authors Volker Krause <vkrause@kde.org>
15*/
16
17#include "contentindex.h"
18
19#include <QList>
20#include <QSharedData>
21#include <QStringList>
22#include <QStringTokenizer>
23
24using namespace KMime;
25
26class ContentIndex::Private : public QSharedData
27{
28public:
29 Private() = default;
30 Private(const Private &other) : QSharedData(other) { index = other.index; }
31
33};
34
36{
37}
38
40{
41 for (auto s : QStringTokenizer{index, QLatin1Char('.')}) {
42 bool ok;
43 unsigned int i = s.toUInt(&ok);
44 if (!ok) {
45 d->index.clear();
46 break;
47 }
48 d->index.append(i);
49 }
50}
51
52ContentIndex::ContentIndex(const ContentIndex &other) = default;
53ContentIndex::ContentIndex(ContentIndex &&) noexcept = default;
54
55ContentIndex::~ContentIndex() = default;
56
57bool KMime::ContentIndex::isValid() const
58{
59 return !d->index.isEmpty();
60}
61
63{
64 return d->index.takeFirst();
65}
66
67void KMime::ContentIndex::push(unsigned int index)
68{
69 d->index.prepend(index);
70}
71
72unsigned int ContentIndex::up()
73{
74 return d->index.takeLast();
75}
76
78{
80 l.reserve(d->index.count());
81 for (unsigned int i : std::as_const(d->index)) {
83 }
84 return l.join(QLatin1Char('.'));
85}
86
88{
89 return d->index == index.d->index;
90}
91
93{
94 return d->index != index.d->index;
95}
96
99
100size_t KMime::qHash(const KMime::ContentIndex &index, size_t seed) noexcept
101{
102 return qHash(index.toString(), seed);
103}
A class to uniquely identify message parts (Content) in a hierarchy.
QString toString() const
Returns a string representation of this content index according to RFC3501 section 6....
bool operator==(const ContentIndex &index) const
Compares this with index for equality.
unsigned int pop()
Removes and returns the top-most index.
ContentIndex()
Creates an empty content index.
bool operator!=(const ContentIndex &index) const
Compares this with index for inequality.
ContentIndex & operator=(const ContentIndex &other)
Assignment operator.
void push(unsigned int index)
Adds index to the content index.
unsigned int up()
Removes and returns the bottom-most index.
This file is part of the API for handling MIME data and defines the ContentIndex class.
void append(QList< T > &&value)
void reserve(qsizetype size)
QString number(double n, char format, int precision)
QString join(QChar separator) const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:18:08 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.