1 //=============================================================================
2 // File: message.cpp
3 // Contents: Definitions for DwMessage
4 // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
5 // WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
6 // $Revision: 1.6 $
7 // $Date: 1997/09/27 11:54:07 $
8 //
9 // Copyright (c) 1996, 1997 Douglas W. Sauder
10 // All rights reserved.
11 //
12 // IN NO EVENT SHALL DOUGLAS W. SAUDER BE LIABLE TO ANY PARTY FOR DIRECT,
13 // INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF
14 // THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF DOUGLAS W. SAUDER
15 // HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
16 //
17 // DOUGLAS W. SAUDER SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT
18 // NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
19 // PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS"
20 // BASIS, AND DOUGLAS W. SAUDER HAS NO OBLIGATION TO PROVIDE MAINTENANCE,
21 // SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
22 //
23 //=============================================================================
24
25 #define DW_IMPLEMENTATION
26
27 #include <mimelib/config.h>
28 #include <mimelib/debug.h>
29 #include <mimelib/string.h>
30 #include <mimelib/message.h>
31 #include <mimelib/headers.h>
32 #include <mimelib/body.h>
33
34
35 const char* const DwMessage::sClassName = "DwMessage";
36
37
38 DwMessage* (*DwMessage::sNewMessage)(const DwString&,
39 DwMessageComponent*) = 0;
40
41
NewMessage(const DwString & aStr,DwMessageComponent * aParent)42 DwMessage* DwMessage::NewMessage(const DwString& aStr,
43 DwMessageComponent* aParent)
44 {
45 if (sNewMessage) {
46 return sNewMessage(aStr, aParent);
47 }
48 else {
49 return new DwMessage(aStr, aParent);
50 }
51 }
52
53
DwMessage()54 DwMessage::DwMessage()
55 {
56 mClassId = kCidMessage;
57 mClassName = sClassName;
58 }
59
60
DwMessage(const DwMessage & aMessage)61 DwMessage::DwMessage(const DwMessage& aMessage)
62 : DwEntity(aMessage)
63 {
64 mClassId = kCidMessage;
65 mClassName = sClassName;
66 }
67
68
DwMessage(const DwString & aStr,DwMessageComponent * aParent)69 DwMessage::DwMessage(const DwString& aStr, DwMessageComponent* aParent)
70 : DwEntity(aStr, aParent)
71 {
72 mClassId = kCidMessage;
73 mClassName = sClassName;
74 }
75
76
~DwMessage()77 DwMessage::~DwMessage()
78 {
79 }
80
81
Clone() const82 DwMessageComponent* DwMessage::Clone() const
83 {
84 return new DwMessage(*this);
85 }
86
87
operator =(const DwMessage & aMessage)88 const DwMessage& DwMessage::operator = (const DwMessage& aMessage)
89 {
90 if (this == &aMessage) return *this;
91 DwEntity::operator = (aMessage);
92 return *this;
93 }
94
95
PrintDebugInfo(ostream & aStrm,int aDepth) const96 void DwMessage::PrintDebugInfo(ostream& aStrm, int aDepth) const
97 {
98 #if defined(DW_DEBUG_VERSION)
99 aStrm << "------------ Debug info for DwMessage class ------------\n";
100 _PrintDebugInfo(aStrm);
101 int depth = aDepth - 1;
102 depth = (depth >= 0) ? depth : 0;
103 if (aDepth == 0 || depth > 0) {
104 mHeaders->PrintDebugInfo(aStrm, depth);
105 mBody->PrintDebugInfo(aStrm, depth);
106 }
107 #endif // defined(DW_DEBUG_VERSION)
108 }
109
110
_PrintDebugInfo(ostream & aStrm) const111 void DwMessage::_PrintDebugInfo(ostream& aStrm) const
112 {
113 #if defined(DW_DEBUG_VERSION)
114 DwEntity::_PrintDebugInfo(aStrm);
115 #endif // defined(DW_DEBUG_VERSION)
116 }
117
118