00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef KIMAP_IMAPSET_H
00021 #define KIMAP_IMAPSET_H
00022
00023 #include "kimap_export.h"
00024
00025 #include <QtCore/QByteArray>
00026 #include <QtCore/QDebug>
00027 #include <QtCore/QList>
00028 #include <QtCore/QMetaType>
00029 #include <QtCore/QSharedDataPointer>
00030
00031 namespace KIMAP {
00032
00037 class KIMAP_EXPORT ImapInterval
00038 {
00039 public:
00043 typedef qint64 Id;
00044
00048 typedef QList<ImapInterval> List;
00049
00053 ImapInterval();
00054
00058 ImapInterval( const ImapInterval &other );
00059
00065 explicit ImapInterval( Id begin, Id end = 0 );
00066
00070 ~ImapInterval();
00071
00075 ImapInterval& operator=( const ImapInterval &other );
00076
00080 bool operator==( const ImapInterval &other ) const;
00081
00086 Id size() const;
00087
00091 bool hasDefinedBegin() const;
00092
00097 Id begin() const;
00098
00102 bool hasDefinedEnd() const;
00103
00108 Id end() const;
00109
00113 void setBegin( Id value );
00114
00118 void setEnd( Id value );
00119
00123 QByteArray toImapSequence() const;
00124
00128 static ImapInterval fromImapSequence( const QByteArray &sequence );
00129
00130 private:
00131 class Private;
00132 QSharedDataPointer<Private> d;
00133 };
00134
00140 class KIMAP_EXPORT ImapSet
00141 {
00142 public:
00146 typedef qint64 Id;
00147
00151 ImapSet();
00152
00156 ImapSet( Id begin, Id end );
00157
00161 explicit ImapSet( Id value );
00162
00166 ImapSet( const ImapSet &other );
00167
00171 ~ImapSet();
00172
00176 ImapSet& operator=( const ImapSet &other );
00177
00181 bool operator==( const ImapSet &other ) const;
00182
00189 void add( Id value );
00190
00197 void add( const QList<Id> &values );
00198
00203 void add( const ImapInterval &interval );
00204
00208 QByteArray toImapSequenceSet() const;
00209
00213 static ImapSet fromImapSequenceSet( const QByteArray &sequence );
00214
00218 ImapInterval::List intervals() const;
00219
00223 bool isEmpty() const;
00224
00225 private:
00226 class Private;
00227 QSharedDataPointer<Private> d;
00228 };
00229
00230 }
00231
00232 KIMAP_EXPORT QDebug& operator<<( QDebug& d, const KIMAP::ImapInterval &interval );
00233 KIMAP_EXPORT QDebug& operator<<( QDebug& d, const KIMAP::ImapSet &set );
00234
00235 Q_DECLARE_METATYPE( KIMAP::ImapInterval )
00236 Q_DECLARE_METATYPE( KIMAP::ImapInterval::List )
00237 Q_DECLARE_METATYPE( KIMAP::ImapSet )
00238
00239 #endif