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

KMIME Library

  • sources
  • kde-4.14
  • kdepimlibs
  • 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 }
KMime::ContentIndex::~ContentIndex
~ContentIndex()
Destructor.
Definition: kmime_contentindex.cpp:72
KMime::ContentIndex::operator==
bool operator==(const ContentIndex &index) const
Compares this with index for equality.
Definition: kmime_contentindex.cpp:100
QString::split
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
KMime::ContentIndex::isValid
bool isValid() const
Returns true if this index is non-empty (valid).
Definition: kmime_contentindex.cpp:76
KMime::ContentIndex::pop
unsigned int pop()
Removes and returns the top-most index.
Definition: kmime_contentindex.cpp:81
KMime::ContentIndex::push
void push(unsigned int index)
Adds index to the content index.
Definition: kmime_contentindex.cpp:86
QStringList::join
QString join(const QString &separator) const
KMime::ContentIndex::operator=
ContentIndex & operator=(const ContentIndex &other)
Assignment operator.
Definition: kmime_contentindex.cpp:110
QSharedData
QString::number
QString number(int n, int base)
QList::append
void append(const T &value)
KMime::ContentIndex::operator!=
bool operator!=(const ContentIndex &index) const
Compares this with index for inequality.
Definition: kmime_contentindex.cpp:105
QString
QList< unsigned int >
QStringList
QLatin1Char
QLatin1String
KMime::ContentIndex::toString
QString toString() const
Returns a string representation of this content index according to RFC3501 section 6...
Definition: kmime_contentindex.cpp:91
KMime::ContentIndex::ContentIndex
ContentIndex()
Creates an empty content index.
Definition: kmime_contentindex.cpp:50
kmime_contentindex.h
This file is part of the API for handling MIME data and defines the ContentIndex class.
QString::toUInt
uint toUInt(bool *ok, int base) const
KMime::ContentIndex
A class to uniquely identify message parts (Content) in a hierarchy.
Definition: kmime_contentindex.h:54
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:37:18 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KMIME Library

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

kdepimlibs API Reference

Skip menu "kdepimlibs 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

Search



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