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

KMIME Library

  • kmime
kmime_contentindex.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
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 */
30 #include "kmime_contentindex.h"
31 
32 #include <QHash>
33 #include <QSharedData>
34 #include <QtCore/QStringList>
35 
36 using namespace KMime;
37 
38 class ContentIndex::Private : public QSharedData
39 {
40  public:
41  Private() {}
42  Private( const Private &other ) : QSharedData( other )
43  {
44  index = other.index;
45  }
46 
47  QList<unsigned int> index;
48 };
49 
50 KMime::ContentIndex::ContentIndex() : d( new Private )
51 {
52 }
53 
54 KMime::ContentIndex::ContentIndex( const QString &index ) : d( new Private )
55 {
56  const QStringList l = index.split( QLatin1Char( '.' ) );
57  foreach ( const QString &s, l ) {
58  bool ok;
59  unsigned int i = s.toUInt( &ok );
60  if ( !ok ) {
61  d->index.clear();
62  break;
63  }
64  d->index.append( i );
65  }
66 }
67 
68 ContentIndex::ContentIndex(const ContentIndex & other) : d( other.d )
69 {
70 }
71 
72 ContentIndex::~ContentIndex()
73 {
74 }
75 
76 bool KMime::ContentIndex::isValid() const
77 {
78  return !d->index.isEmpty();
79 }
80 
81 unsigned int KMime::ContentIndex::pop()
82 {
83  return d->index.takeFirst();
84 }
85 
86 void KMime::ContentIndex::push( unsigned int index )
87 {
88  d->index.prepend( index );
89 }
90 
91 QString KMime::ContentIndex::toString() const
92 {
93  QStringList l;
94  foreach ( unsigned int i, d->index ) {
95  l.append( QString::number( i ) );
96  }
97  return l.join( QLatin1String( "." ) );
98 }
99 
100 bool KMime::ContentIndex::operator ==( const ContentIndex &index ) const
101 {
102  return d->index == index.d->index;
103 }
104 
105 bool KMime::ContentIndex::operator !=( const ContentIndex &index ) const
106 {
107  return d->index != index.d->index;
108 }
109 
110 ContentIndex& ContentIndex::operator =(const ContentIndex & other)
111 {
112  if ( this != &other ) {
113  d = other.d;
114  }
115  return *this;
116 }
117 
118 uint qHash( const KMime::ContentIndex &index )
119 {
120  return qHash( index.toString() );
121 }
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:25:45 by doxygen 1.8.3.1 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.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • 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