KMime

kmime_contentindex.h
Go to the documentation of this file.
1 /*
2  SPDX-FileCopyrightText: 2006-2007 Volker Krause <[email protected]>
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 <[email protected]>
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 
29 namespace 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 */
40 class KMIME_EXPORT ContentIndex
41 {
42 public:
43  /**
44  Creates an empty content index.
45  */
46  ContentIndex();
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(const QString &index);
55 
56  /**
57  Copy constructor.
58  */
59  ContentIndex(const ContentIndex &other);
60 
61  /**
62  Destructor.
63  */
64  ~ContentIndex();
65 
66  /**
67  Returns true if this index is non-empty (valid).
68  */
69  Q_REQUIRED_RESULT bool isValid() const;
70 
71  /**
72  Removes and returns the top-most index. Used to recursively
73  descend into the message part hierarchy.
74 
75  @see push(), up().
76  */
77  Q_REQUIRED_RESULT unsigned int pop();
78 
79  /**
80  Adds @p index to the content index. Used when ascending the message
81  part hierarchy.
82 
83  @param index is the top-most content index part.
84 
85  @see pop(), up().
86  */
87  void push(unsigned int index);
88 
89  /**
90  Removes and returns the bottom-most index. Used to navigate to
91  the parent part.
92 
93  @see push(), pop().
94  */
95  unsigned int up();
96 
97  /**
98  Returns a string representation of this content index according
99  to @ref RFC3501 section 6.4.5.
100  */
101  Q_REQUIRED_RESULT QString toString() const;
102 
103  /**
104  Compares this with @p index for equality.
105 
106  @param index is the content index to compare.
107  */
108  Q_REQUIRED_RESULT bool operator==(const ContentIndex &index) const;
109 
110  /**
111  Compares this with @p index for inequality.
112 
113  @param index is the content index to compare.
114  */
115  Q_REQUIRED_RESULT bool operator!=(const ContentIndex &index) const;
116 
117  /**
118  Assignment operator.
119  */
120  ContentIndex &operator=(const ContentIndex &other);
121 
122 private:
123  //@cond PRIVATE
124  class Private;
126  //@endcond
127 };
128 
129 KMIME_EXPORT uint qHash(const KMime::ContentIndex &);
130 
131 } //namespace KMime
132 
133 Q_DECLARE_METATYPE(KMime::ContentIndex)
134 
KCALENDARCORE_EXPORT uint qHash(const KCalendarCore::Period &key)
A class to uniquely identify message parts (Content) in a hierarchy.
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Sat Sep 25 2021 23:14:46 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.