• Skip to content
  • Skip to link menu
  • KDE API Reference
  • kdepimlibs-4.8.5 API Reference
  • KDE Home
  • Contact Us
 

KMIME Library

kmime_contentindex.cpp
Go to the documentation of this file.
00001 /*
00002     Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
00003 
00004     This library is free software; you can redistribute it and/or modify it
00005     under the terms of the GNU Library General Public License as published by
00006     the Free Software Foundation; either version 2 of the License, or (at your
00007     option) any later version.
00008 
00009     This library is distributed in the hope that it will be useful, but WITHOUT
00010     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00011     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00012     License for more details.
00013 
00014     You should have received a copy of the GNU Library General Public License
00015     along with this library; see the file COPYING.LIB.  If not, write to the
00016     Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
00017     02110-1301, USA.
00018 */
00030 #include "kmime_contentindex.h"
00031 
00032 #include <QHash>
00033 #include <QSharedData>
00034 #include <QtCore/QStringList>
00035 
00036 using namespace KMime;
00037 
00038 class ContentIndex::Private : public QSharedData
00039 {
00040   public:
00041     Private() {}
00042     Private( const Private &other ) : QSharedData( other )
00043     {
00044       index = other.index;
00045     }
00046 
00047     QList<unsigned int> index;
00048 };
00049 
00050 KMime::ContentIndex::ContentIndex() : d( new Private )
00051 {
00052 }
00053 
00054 KMime::ContentIndex::ContentIndex( const QString &index ) : d( new Private )
00055 {
00056   const QStringList l = index.split( QLatin1Char( '.' ) );
00057   foreach ( const QString &s, l ) {
00058     bool ok;
00059     unsigned int i = s.toUInt( &ok );
00060     if ( !ok ) {
00061       d->index.clear();
00062       break;
00063     }
00064     d->index.append( i );
00065   }
00066 }
00067 
00068 ContentIndex::ContentIndex(const ContentIndex & other) : d( other.d )
00069 {
00070 }
00071 
00072 ContentIndex::~ContentIndex()
00073 {
00074 }
00075 
00076 bool KMime::ContentIndex::isValid() const
00077 {
00078   return !d->index.isEmpty();
00079 }
00080 
00081 unsigned int KMime::ContentIndex::pop()
00082 {
00083   return d->index.takeFirst();
00084 }
00085 
00086 void KMime::ContentIndex::push( unsigned int index )
00087 {
00088   d->index.prepend( index );
00089 }
00090 
00091 QString KMime::ContentIndex::toString() const
00092 {
00093   QStringList l;
00094   foreach ( unsigned int i, d->index ) {
00095     l.append( QString::number( i ) );
00096   }
00097   return l.join( QLatin1String( "." ) );
00098 }
00099 
00100 bool KMime::ContentIndex::operator ==( const ContentIndex &index ) const
00101 {
00102   return d->index == index.d->index;
00103 }
00104 
00105 bool KMime::ContentIndex::operator !=( const ContentIndex &index ) const
00106 {
00107   return d->index != index.d->index;
00108 }
00109 
00110 ContentIndex& ContentIndex::operator =(const ContentIndex & other)
00111 {
00112   if ( this != &other )
00113     d = other.d;
00114   return *this;
00115 }
00116 
00117 uint qHash( const KMime::ContentIndex &index )
00118 { 
00119   return qHash( index.toString() );
00120 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2012 The KDE developers.
Generated on Mon Aug 27 2012 22:08:31 by doxygen 1.7.5 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KMIME Library

Skip menu "KMIME Library"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Related Pages

kdepimlibs-4.8.5 API Reference

Skip menu "kdepimlibs-4.8.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal