~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to mimelib/mimelib/entity.h

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//=============================================================================
2
 
// File:       entity.h
3
 
// Contents:   Declarations for DwEntity
4
 
// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
5
 
// WWW:        http://www.fwb.gulf.net/~dwsauder/mimepp.html
6
 
//
7
 
// Copyright (c) 1996, 1997 Douglas W. Sauder
8
 
// All rights reserved.
9
 
//
10
 
// IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
11
 
// INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
12
 
// THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
13
 
// HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
14
 
//
15
 
// DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
16
 
// NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
17
 
// PARTICULAR PURPOSE.  THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
18
 
// BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
19
 
// SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
20
 
//
21
 
//=============================================================================
22
 
 
23
 
#ifndef DW_ENTITY_H
24
 
#define DW_ENTITY_H
25
 
 
26
 
#ifndef DW_CONFIG_H
27
 
#include <mimelib/config.h>
28
 
#endif
29
 
 
30
 
#ifndef DW_STRING_H
31
 
#include <mimelib/string.h>
32
 
#endif
33
 
 
34
 
#ifndef DW_MSGCMP_H
35
 
#include <mimelib/msgcmp.h>
36
 
#endif
37
 
 
38
 
class DwHeaders;
39
 
class DwBody;
40
 
 
41
 
//=============================================================================
42
 
//+ Name DwEntity -- Abstract class representing a MIME entity
43
 
//+ Description
44
 
//. RFC-2045 defines an {\it entity} as either a {\it message} or a
45
 
//. {\it body part}, both of which have a collection of headers and
46
 
//. a {\it body}.  In MIME++, an entity is represented by the class
47
 
//. {\tt DwEntity}, which contains both a {\tt DwHeaders} object and
48
 
//. a {\tt DwBody} object.
49
 
//.
50
 
//. In the tree (broken-down) representation of message, a {\tt DwEntity}
51
 
//. object may be either a root node, having child nodes but no parent
52
 
//. node, or an intermediate node, having both a parent node and child nodes.
53
 
//. A {\tt DwEntity} object that is a root node must also be a {\tt DwMessage}
54
 
//. object.  If a {\tt DwEntity} object is an intermediate node, its parent
55
 
//. must be a {\tt DwBody} object.  The child nodes of a {\tt DwEntity}
56
 
//. object are the {\tt DwHeaders} and {\tt DwBody} objects it contains.
57
 
//.
58
 
//. Since {\tt DwEntity} is an abstract base class, you cannot create
59
 
//. instances of it directly.  {\tt DwEntity} has two derived classes,
60
 
//. {\tt DwMessage} and {\tt DwBodyPart}, which are concrete classes.
61
 
//.
62
 
//. To access the contained {\tt DwHeaders} object, use the member function
63
 
//. {\tt Headers()}.  To access the contained {\tt DwBody} object, use the
64
 
//. member function {\tt Body()}.
65
 
//=============================================================================
66
 
// Last updated 1997-08-23
67
 
//+ Noentry ~DwEntity mHeaders mBody _PrintDebugInfo
68
 
 
69
 
class DW_EXPORT DwEntity : public DwMessageComponent {
70
 
 
71
 
public:
72
 
 
73
 
    DwEntity();
74
 
    DwEntity(const DwEntity& aEntity);
75
 
    DwEntity(const DwString& aStr, DwMessageComponent* aParent=0);
76
 
    //. The first constructor is the default constructor, which sets the
77
 
    //. {\tt DwEntity} object's string representation to the empty string
78
 
    //. and sets its parent to {\tt NULL}.
79
 
    //.
80
 
    //. The second constructor is the copy constructor, which performs
81
 
    //. a deep copy of {\tt aEntity}.
82
 
    //. The parent of the new {\tt DwEntity} object is set to {\tt NULL}.
83
 
    //.
84
 
    //. The third constructor copies {\tt aStr} to the {\tt DwEntity}
85
 
    //. object's string representation and sets {\tt aParent} as its parent.
86
 
    //. The virtual member function {\tt Parse()} should be called immediately
87
 
    //. after this constructor in order to parse the string representation.
88
 
    //. Unless it is {\tt NULL}, {\tt aParent} should point to an object of
89
 
    //. a class derived from {\tt DwBody}.
90
 
 
91
 
    virtual ~DwEntity();
92
 
 
93
 
    const DwEntity& operator = (const DwEntity& aEntity);
94
 
    //. This is the assignment operator, which performs a deep copy of
95
 
    //. {\tt aEntity}.  The parent node of the {\tt DwEntity} object
96
 
    //. is not changed.
97
 
 
98
 
    virtual void Parse();
99
 
    //. This virtual function, inherited from {\tt DwMessageComponent},
100
 
    //. executes the parse method for {\tt DwEntity} objects.  The parse
101
 
    //. method creates or updates the broken-down representation from the
102
 
    //. string representation.  For {\tt DwEntity} objects, the parse
103
 
    //. method parses the string representation and sets the values of
104
 
    //. the {\tt DwHeaders} and {\tt DwBody} objects it contains. This
105
 
    //. member function also calls the {\tt Parse()} member functions
106
 
    //. of the contained {\tt DwHeaders} and {\tt DwBody} objects.
107
 
    //.
108
 
    //. You should call this member function after you set or modify the
109
 
    //. string representation, and before you access either the contained
110
 
    //. headers or body.
111
 
    //.
112
 
    //. This function clears the is-modified flag.
113
 
 
114
 
    virtual void Assemble(DwHeaders& aHeaders, DwBody& aBody);
115
 
    // Assemble *without* first assembling the Header and the Body.
116
 
    
117
 
    virtual void Assemble();
118
 
    //. This virtual function, inherited from {\tt DwMessageComponent},
119
 
    //. executes the assemble method for {\tt DwEntity} objects.  The
120
 
    //. assemble method creates or updates the string representation from
121
 
    //. the broken-down representation.  In more concrete terms, the
122
 
    //. assemble method builds the string representation from the string
123
 
    //. representations of the contained {\tt DwHeaders} and {\tt DwBody}
124
 
    //. objects.  This member function calls the {\tt Assemble()} member
125
 
    //. functions of its {\tt DwHeaders} and {\tt DwBody} objects.
126
 
    //.
127
 
    //. You should call this member function after you modify either the
128
 
    //. contained headers or body, and before you retrieve the string
129
 
    //. representation.
130
 
    //.
131
 
    //. This function clears the is-modified flag.
132
 
 
133
 
    bool hasHeaders() const { return 0 != mHeaders; }
134
 
 
135
 
    DwHeaders& Headers() const;
136
 
    //. This function returns the {\tt DwHeaders} object contained by
137
 
    //. this object.
138
 
 
139
 
    DwBody& Body() const;
140
 
    //. This function returns the {\tt DwBody} object contained by this object.
141
 
 
142
 
    int BodySize() const;
143
 
    //. Get the size of the Body
144
 
 
145
 
    void SetBodySize( int size ) { mBodySize = size; }
146
 
    //. Explicitly set the size of the Body
147
 
    //. This is needed if the body is empty but you know the size and others 
148
 
    //. should be able to access it
149
 
 
150
 
protected:
151
 
 
152
 
    DwHeaders* mHeaders;
153
 
    DwBody*    mBody;
154
 
 
155
 
private:
156
 
 
157
 
    static const char* const sClassName;
158
 
    int mBodySize; // normally mBody->AsString().length()
159
 
 
160
 
public:
161
 
 
162
 
    virtual void PrintDebugInfo(std::ostream& aStrm, int aDepth=0) const;
163
 
    //. This virtual function, inherited from {\tt DwMessageComponent},
164
 
    //. prints debugging information about this object to {\tt aStrm}.
165
 
    //. It will also call {\tt PrintDebugInfo()} for any of its child
166
 
    //. components down to a level of {\tt aDepth}.
167
 
    //.
168
 
    //. This member function is available only in the debug version of
169
 
    //. the library.
170
 
 
171
 
    virtual void CheckInvariants() const;
172
 
    //. Aborts if one of the invariants of the object fails.  Use this
173
 
    //. member function to track down bugs.
174
 
    //.
175
 
    //. This member function is available only in the debug version of
176
 
    //. the library.
177
 
 
178
 
protected:
179
 
 
180
 
    void _PrintDebugInfo(std::ostream& aStrm) const;
181
 
 
182
 
};
183
 
 
184
 
#endif