File indexing completed on 2024-04-28 05:18:35

0001 /*
0002     SPDX-FileCopyrightText: 2010 Tobias Koenig <tokoe@kde.org>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "kmbox_export.h"
0010 
0011 #include <QList>
0012 #include <QPair>
0013 #include <QSharedDataPointer>
0014 
0015 namespace KMBox
0016 {
0017 class MBoxEntryPrivate;
0018 /**
0019  * @short A class that encapsulates an entry of a MBox.
0020  *
0021  * @author Tobias Koenig <tokoe@kde.org>
0022  * @since 4.6
0023  */
0024 class KMBOX_EXPORT MBoxEntry
0025 {
0026 public:
0027     /**
0028      * Describes a list of mbox entry objects.
0029      */
0030     using List = QList<MBoxEntry>;
0031 
0032     /**
0033      * Describes a pair of mbox entry objects.
0034      */
0035     using Pair = QPair<MBoxEntry, MBoxEntry>;
0036 
0037     /**
0038      * Creates an invalid mbox entry object.
0039      */
0040     MBoxEntry();
0041 
0042     /**
0043      * Creates an mbox entry object.
0044      *
0045      * @param offset The offset of the message the object references.
0046      */
0047     explicit MBoxEntry(quint64 offset);
0048 
0049     /**
0050      * Creates an mbox entry object from an @p other object.
0051      */
0052     MBoxEntry(const MBoxEntry &other);
0053 
0054     /**
0055      * Destroys the mbox entry object.
0056      */
0057     ~MBoxEntry();
0058 
0059     /**
0060      * Replaces this mbox entry object with an @p other object.
0061      */
0062     MBoxEntry &operator=(const MBoxEntry &other);
0063 
0064     /**
0065      * Returns whether this mbox entry object is equal to an @p other.
0066      */
0067     bool operator==(const MBoxEntry &other) const;
0068 
0069     /**
0070      * Returns whether this mbox entry object is not equal to an @p other.
0071      */
0072     bool operator!=(const MBoxEntry &other) const;
0073 
0074     /**
0075      * Returns whether this is a valid mbox entry object.
0076      */
0077     [[nodiscard]] bool isValid() const;
0078 
0079     /**
0080      * Returns the offset of the message that is referenced by this
0081      * mbox entry object.
0082      */
0083     [[nodiscard]] quint64 messageOffset() const;
0084 
0085     /**
0086      * Returns the size of the message that is referenced by this
0087      * mbox entry object.
0088      */
0089     [[nodiscard]] quint64 messageSize() const;
0090 
0091     /**
0092      * Returns the separator size of the message that is referenced by this
0093      * mbox entry object.
0094      */
0095     [[nodiscard]] quint64 separatorSize() const;
0096 
0097 private:
0098     //@cond PRIVATE
0099     friend class MBox;
0100 
0101     QSharedDataPointer<MBoxEntryPrivate> d;
0102     //@endcond
0103 };
0104 }
0105 
0106 Q_DECLARE_TYPEINFO(KMBox::MBoxEntry, Q_RELOCATABLE_TYPE);