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*/
19/**
20 @file
21 This file is part of the API for handling @ref MIME data and
22 defines the ContentIndex class.
23
24 @brief
25 Defines the ContentIndex class.
26
27 @authors Volker Krause \<vkrause@kde.org\>
28
29 @glossary @anchor RFC3501 @anchor rfc3501 @b RFC @b 3501:
30 RFC that defines the <a href="http://tools.ietf.org/html/rfc3501">
31 Internet Message Access Protocol (IMAP)</a>.
32*/
33
34#ifndef KMIME_CONTENTINDEX_H
35#define KMIME_CONTENTINDEX_H
36
37#include "kmime_export.h"
38
39#include <QtCore/QList>
40#include <QtCore/QSharedDataPointer>
41#include <QtCore/QString>
42
43
44namespace KMime {
45
46/**
47 @brief
48 A class to uniquely identify message parts (Content) in a hierarchy.
49
50 This class is implicitly shared.
51
52 Based on @ref RFC3501 section 6.4.5 and thus compatible with @acronym IMAP.
53*/
54class KMIME_EXPORT ContentIndex
55{
56 public:
57 /**
58 Creates an empty content index.
59 */
60 ContentIndex();
61
62 /**
63 Creates a content index based on the specified string representation.
64
65 @param index is a string representation of a message part index according
66 to @ref RFC3501 section 6.4.5.
67 */
68 explicit ContentIndex( const QString &index );
69
70 /**
71 Copy constructor.
72 */
73 ContentIndex( const ContentIndex &other );
74
75 /**
76 Destructor.
77 */
78 ~ContentIndex();
79
80 /**
81 Returns true if this index is non-empty (valid).
82 */
83 bool isValid() const;
84
85 /**
86 Removes and returns the top-most index. Used to recursively
87 descend into the message part hierarchy.
88
89 @see push().
90 */
91 unsigned int pop();
92
93 /**
94 Adds @p index to the content index. Used when ascending the message
95 part hierarchy.
96
97 @param index is the top-most content index part.
98
99 @see pop().
100 */
101 void push( unsigned int index );
102
103 /**
104 Returns a string representation of this content index according
105 to @ref RFC3501 section 6.4.5.
106 */
107 QString toString() const;
108
109 /**
110 Compares this with @p index for equality.
111
112 @param index is the content index to compare.
113 */
114 bool operator==( const ContentIndex &index ) const;
115
116 /**
117 Compares this with @p index for inequality.
118
119 @param index is the content index to compare.
120 */
121 bool operator!=( const ContentIndex &index ) const;
122
123 /**
124 Assignment operator.
125 */
126 ContentIndex& operator=( const ContentIndex &other );
127
128 private:
129 //@cond PRIVATE
130 class Private;
131 QSharedDataPointer<Private> d;
132 //@endcond
133};
134
135} //namespace KMime
136
137KMIME_EXPORT uint qHash( const KMime::ContentIndex& );
138
139#endif
140