KIMAP Library
22 #include <QtCore/QSharedData>
24 using namespace KIMAP;
26 class ImapInterval::Private :
public QSharedData
35 Private(
const Private &other ) :
46 class ImapSet::Private :
public QSharedData
49 Private() : QSharedData() {}
50 Private(
const Private &other ) :
76 ImapInterval::~ ImapInterval()
82 if (
this != &other ) {
90 return ( d->begin == other.d->begin && d->end == other.d->end );
95 if ( !d->begin && !d->end ) {
98 if ( d->begin && !d->end ) {
99 return Q_INT64_C( 0x7FFFFFFFFFFFFFFF ) - d->begin + 1;
101 return d->end - d->begin + 1;
106 return d->begin != 0;
129 Q_ASSERT( value >= 0 );
136 Q_ASSERT( value >= 0 );
147 return QByteArray::number( d->begin );
150 rv += QByteArray::number( d->begin ) +
':';
152 rv += QByteArray::number( d->end );
161 QList<QByteArray> values = sequence.split(
':' );
162 if ( values.isEmpty() || values.size() > 2 ) {
167 Id begin = values[0].toLongLong( &ok );
175 if ( values.size() == 1 ) {
177 }
else if ( values[1] == QByteArray(
"*" ) ) {
181 end = values[1].toLongLong( &ok );
204 add( QList<Id>() << value );
218 if (
this != &other ) {
226 if ( d->intervals.size()!=other.d->intervals.size() ) {
230 foreach (
const ImapInterval &interval, d->intervals ) {
231 if ( !other.d->intervals.contains( interval ) ) {
241 add( QList<Id>() << value );
246 QList<Id> vals = values;
248 for (
int i = 0; i < vals.count(); ++i ) {
249 const int begin = vals[i];
250 Q_ASSERT( begin >= 0 );
251 if ( i == vals.count() - 1 ) {
257 Q_ASSERT( vals[i] >= 0 );
258 if ( vals[i] != ( vals[i - 1] + 1 ) ) {
262 }
while ( i < vals.count() - 1 );
269 d->intervals << interval;
274 QList<QByteArray> rv;
275 foreach (
const ImapInterval &interval, d->intervals ) {
281 if ( !rv.isEmpty() ) {
283 QList<QByteArray>::ConstIterator it = rv.constBegin();
285 for ( ; it != rv.constEnd(); ++it ) {
286 result +=
',' + ( *it );
297 QList<QByteArray>
intervals = sequence.split(
',' );
299 foreach (
const QByteArray &interval,
intervals ) {
300 if ( !interval.isEmpty() ) {
315 return d->intervals.isEmpty();
318 QDebug& operator<<( QDebug &d,
const ImapInterval &interval )
324 QDebug& operator<<( QDebug &d,
const ImapSet &set )
bool hasDefinedBegin() const
Returns true if this interval has a defined begin.
static ImapSet fromImapSequenceSet(const QByteArray &sequence)
Return the set corresponding to the given IMAP-compatible QByteArray representation.
ImapSet & operator=(const ImapSet &other)
Assignment operator.
QByteArray toImapSequence() const
Converts this set into an IMAP compatible sequence.
qint64 Id
Describes the ids stored in the set.
bool operator==(const ImapInterval &other) const
Comparison operator.
Id begin() const
Returns the begin of this interval.
Represents a single interval in an ImapSet.
Represents a set of natural numbers (1-> ) in a as compact as possible form.
ImapInterval::List intervals() const
Returns the intervals this set consists of.
Id size() const
Returns the size of this interval.
qint64 Id
Describes the ids stored in the interval.
QByteArray toImapSequenceSet() const
Returns a IMAP-compatible QByteArray representation of this set.
bool operator==(const ImapSet &other) const
Comparison operator.
Id end() const
Returns the end of this interval.
ImapInterval & operator=(const ImapInterval &other)
Assignment operator.
void setEnd(Id value)
Sets the end of this interval.
static ImapInterval fromImapSequence(const QByteArray &sequence)
Return the interval corresponding to the given IMAP-compatible QByteArray representation.
void setBegin(Id value)
Sets the begin of the interval.
ImapSet()
Constructs an empty set.
bool hasDefinedEnd() const
Returns true if this intercal has been defined.
ImapInterval()
Constructs an interval that covers all positive numbers.
bool isEmpty() const
Returns true if this set doesn't contains any values.
QList< ImapInterval > List
A list of ImapInterval objects.
void add(Id value)
Adds a single positive integer numbers to the set.
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Wed Jan 29 2020 00:00:00 by
doxygen 1.8.17 written
by
Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.