File indexing completed on 2022-11-29 19:53:37

0001 /*
0002     SPDX-FileCopyrightText: 2006-2007 Volker Krause <vkrause@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 /**
0007   @file
0008   This file is part of the API for handling @ref MIME data and
0009   defines the ContentIndex class.
0010 
0011   @brief
0012   Defines the ContentIndex class.
0013 
0014   @authors Volker Krause \<vkrause@kde.org\>
0015 
0016   @glossary @anchor RFC3501 @anchor rfc3501 @b RFC @b 3501:
0017   RFC that defines the <a href="https://tools.ietf.org/html/rfc3501">
0018   Internet Message Access Protocol (IMAP)</a>.
0019 */
0020 
0021 #pragma once
0022 
0023 #include "kmime_export.h"
0024 
0025 #include <QSharedDataPointer>
0026 #include <QString>
0027 #include <QMetaType>
0028 
0029 namespace KMime
0030 {
0031 
0032 /**
0033   @brief
0034   A class to uniquely identify message parts (Content) in a hierarchy.
0035 
0036   This class is implicitly shared.
0037 
0038   Based on @ref RFC3501 section 6.4.5 and thus compatible with @acronym IMAP.
0039 */
0040 class KMIME_EXPORT ContentIndex
0041 {
0042 public:
0043     /**
0044       Creates an empty content index.
0045     */
0046     ContentIndex();
0047 
0048     /**
0049       Creates a content index based on the specified string representation.
0050 
0051       @param index is a string representation of a message part index according
0052       to @ref RFC3501 section 6.4.5.
0053     */
0054     explicit ContentIndex(const QString &index);
0055 
0056     /**
0057       Copy constructor.
0058     */
0059     ContentIndex(const ContentIndex &other);
0060 
0061     /**
0062       Destructor.
0063     */
0064     ~ContentIndex();
0065 
0066     /**
0067       Returns true if this index is non-empty (valid).
0068     */
0069     Q_REQUIRED_RESULT bool isValid() const;
0070 
0071     /**
0072       Removes and returns the top-most index. Used to recursively
0073       descend into the message part hierarchy.
0074 
0075       @see push(), up().
0076     */
0077     Q_REQUIRED_RESULT unsigned int pop();
0078 
0079     /**
0080       Adds @p index to the content index. Used when ascending the message
0081       part hierarchy.
0082 
0083       @param index is the top-most content index part.
0084 
0085       @see pop(), up().
0086     */
0087     void push(unsigned int index);
0088 
0089     /**
0090       Removes and returns the bottom-most index. Used to navigate to
0091       the parent part.
0092 
0093       @see push(), pop().
0094     */
0095     unsigned int up();
0096 
0097     /**
0098       Returns a string representation of this content index according
0099       to @ref RFC3501 section 6.4.5.
0100     */
0101     Q_REQUIRED_RESULT QString toString() const;
0102 
0103     /**
0104       Compares this with @p index for equality.
0105 
0106       @param index is the content index to compare.
0107     */
0108     Q_REQUIRED_RESULT bool operator==(const ContentIndex &index) const;
0109 
0110     /**
0111       Compares this with @p index for inequality.
0112 
0113       @param index is the content index to compare.
0114     */
0115     Q_REQUIRED_RESULT bool operator!=(const ContentIndex &index) const;
0116 
0117     /**
0118       Assignment operator.
0119     */
0120     ContentIndex &operator=(const ContentIndex &other);
0121 
0122 private:
0123     //@cond PRIVATE
0124     class Private;
0125     QSharedDataPointer<Private> d;
0126     //@endcond
0127 };
0128 
0129 KMIME_EXPORT uint qHash(const KMime::ContentIndex &);
0130 
0131 }  //namespace KMime
0132 
0133 Q_DECLARE_METATYPE(KMime::ContentIndex)
0134