1
//=============================================================================
3
// Contents: Declarations for DwEntity
4
// Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
5
// WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
7
// Copyright (c) 1996, 1997 Douglas W. Sauder
8
// All rights reserved.
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.
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.
21
//=============================================================================
27
#include <mimelib/config.h>
31
#include <mimelib/string.h>
35
#include <mimelib/msgcmp.h>
41
//=============================================================================
42
//+ Name DwEntity -- Abstract class representing a MIME entity
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.
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.
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.
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
69
class DW_EXPORT DwEntity : public DwMessageComponent {
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}.
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}.
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}.
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
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.
108
//. You should call this member function after you set or modify the
109
//. string representation, and before you access either the contained
112
//. This function clears the is-modified flag.
114
virtual void Assemble(DwHeaders& aHeaders, DwBody& aBody);
115
// Assemble *without* first assembling the Header and the Body.
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.
127
//. You should call this member function after you modify either the
128
//. contained headers or body, and before you retrieve the string
131
//. This function clears the is-modified flag.
133
bool hasHeaders() const { return 0 != mHeaders; }
135
DwHeaders& Headers() const;
136
//. This function returns the {\tt DwHeaders} object contained by
139
DwBody& Body() const;
140
//. This function returns the {\tt DwBody} object contained by this object.
142
int BodySize() const;
143
//. Get the size of the Body
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
157
static const char* const sClassName;
158
int mBodySize; // normally mBody->AsString().length()
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}.
168
//. This member function is available only in the debug version of
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.
175
//. This member function is available only in the debug version of
180
void _PrintDebugInfo(std::ostream& aStrm) const;