KMime

kmime_contentindex.h
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 @glossary @anchor RFC3501 @anchor rfc3501 @b RFC @b 3501:
17 RFC that defines the <a href="https://tools.ietf.org/html/rfc3501">
18 Internet Message Access Protocol (IMAP)</a>.
19*/
20
21#pragma once
22
23#include "kmime_export.h"
24
25#include <QSharedDataPointer>
26#include <QString>
27#include <QMetaType>
28
29namespace KMime
30{
31
32/**
33 @brief
34 A class to uniquely identify message parts (Content) in a hierarchy.
35
36 This class is implicitly shared.
37
38 Based on @ref RFC3501 section 6.4.5 and thus compatible with @acronym IMAP.
39*/
40class KMIME_EXPORT ContentIndex
41{
42public:
43 /**
44 Creates an empty content index.
45 */
47
48 /**
49 Creates a content index based on the specified string representation.
50
51 @param index is a string representation of a message part index according
52 to @ref RFC3501 section 6.4.5.
53 */
54 explicit ContentIndex(QStringView index);
55
56 /**
57 Copy constructor.
58 */
60 ContentIndex(ContentIndex &&) noexcept;
61
62 /**
63 Destructor.
64 */
66
67 /**
68 Returns true if this index is non-empty (valid).
69 */
70 [[nodiscard]] bool isValid() const;
71
72 /**
73 Removes and returns the top-most index. Used to recursively
74 descend into the message part hierarchy.
75
76 @see push(), up().
77 */
78 [[nodiscard]] unsigned int pop();
79
80 /**
81 Adds @p index to the content index. Used when ascending the message
82 part hierarchy.
83
84 @param index is the top-most content index part.
85
86 @see pop(), up().
87 */
88 void push(unsigned int index);
89
90 /**
91 Removes and returns the bottom-most index. Used to navigate to
92 the parent part.
93
94 @see push(), pop().
95 */
96 unsigned int up();
97
98 /**
99 Returns a string representation of this content index according
100 to @ref RFC3501 section 6.4.5.
101 */
102 [[nodiscard]] QString toString() const;
103
104 /**
105 Compares this with @p index for equality.
106
107 @param index is the content index to compare.
108 */
109 [[nodiscard]] bool operator==(const ContentIndex &index) const;
110
111 /**
112 Compares this with @p index for inequality.
113
114 @param index is the content index to compare.
115 */
116 [[nodiscard]] bool operator!=(const ContentIndex &index) const;
117
118 /**
119 Assignment operator.
120 */
121 ContentIndex &operator=(const ContentIndex &other);
122 ContentIndex &operator=(ContentIndex &&) noexcept;
123
124private:
125 //@cond PRIVATE
126 class Private;
127 QSharedDataPointer<Private> d;
128 //@endcond
129};
130
131KMIME_EXPORT size_t qHash(const KMime::ContentIndex &, size_t seed = 0) noexcept;
132
133} //namespace KMime
134
135Q_DECLARE_METATYPE(KMime::ContentIndex)
136
A class to uniquely identify message parts (Content) in a hierarchy.
ContentIndex(const ContentIndex &other)
Copy constructor.
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sun Feb 25 2024 18:46:48 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.