KIMAP2

imapset.h
1 /*
2  Copyright (c) 2007 Volker Krause <[email protected]>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #ifndef KIMAP2_IMAPSET_H
21 #define KIMAP2_IMAPSET_H
22 
23 #include "kimap2_export.h"
24 
25 #include <QtCore/QByteArray>
26 #include <QtCore/QDebug>
27 #include <QtCore/QList>
28 #include <QtCore/QMetaType>
29 #include <QtCore/QSharedDataPointer>
30 
31 namespace KIMAP2
32 {
33 
38 class KIMAP2_EXPORT ImapInterval
39 {
40 public:
44  typedef qint64 Id;
45 
50 
54  ImapInterval();
55 
59  ImapInterval(const ImapInterval &other);
60 
66  explicit ImapInterval(Id begin, Id end = 0);
67 
71  ~ImapInterval();
72 
76  ImapInterval &operator=(const ImapInterval &other);
77 
81  bool operator==(const ImapInterval &other) const;
82 
87  Id size() const;
88 
92  bool hasDefinedBegin() const;
93 
98  Id begin() const;
99 
103  bool hasDefinedEnd() const;
104 
109  Id end() const;
110 
114  void setBegin(Id value);
115 
119  void setEnd(Id value);
120 
124  QByteArray toImapSequence() const;
125 
129  static ImapInterval fromImapSequence(const QByteArray &sequence);
130 
131 private:
132  class Private;
134 };
135 
141 class KIMAP2_EXPORT ImapSet
142 {
143 public:
147  typedef qint64 Id;
148 
152  ImapSet();
153 
157  ImapSet(Id begin, Id end);
158 
162  explicit ImapSet(Id value);
163 
167  ImapSet(const ImapSet &other);
168 
172  ~ImapSet();
173 
177  ImapSet &operator=(const ImapSet &other);
178 
182  bool operator==(const ImapSet &other) const;
183 
190  void add(Id value);
191 
198  void add(const QVector<Id> &values);
199 
205  void add(const ImapInterval &interval);
206 
210  QByteArray toImapSequenceSet() const;
211 
215  static ImapSet fromImapSequenceSet(const QByteArray &sequence);
216 
220  ImapInterval::List intervals() const;
221 
225  bool isEmpty() const;
226 
234  void optimize();
235 
236 private:
237  class Private;
239 };
240 
241 }
242 
243 KIMAP2_EXPORT QDebug &operator<<(QDebug &d, const KIMAP2::ImapInterval &interval);
244 KIMAP2_EXPORT QDebug &operator<<(QDebug &d, const KIMAP2::ImapSet &set);
245 
246 Q_DECLARE_METATYPE(KIMAP2::ImapInterval)
247 Q_DECLARE_METATYPE(KIMAP2::ImapInterval::List)
248 Q_DECLARE_METATYPE(KIMAP2::ImapSet)
249 
250 #endif
qint64 Id
Describes the ids stored in the set.
Definition: imapset.h:147
Represents a single interval in an ImapSet.
Definition: imapset.h:38
qint64 Id
Describes the ids stored in the interval.
Definition: imapset.h:44
Represents a set of natural numbers (1->∞) in a as compact as possible form.
Definition: imapset.h:141
QList< ImapInterval > List
A list of ImapInterval objects.
Definition: imapset.h:49
Definition: acl.cpp:25
QDataStream & operator<<(QDataStream &out, const KDateTime::Spec &spec)
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Fri Sep 25 2020 23:09:00 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.