1 //=============================================================================
3 // Contents: Definitions for DwMessage
4 // Maintainer: Doug Sauder <dwsauder@fwb.gulf.net>
5 // WWW: http://www.fwb.gulf.net/~dwsauder/mimepp.html
9 // Copyright (c) 1996, 1997 Douglas W. Sauder
10 // All rights reserved.
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.
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.
23 //=============================================================================
25 #define DW_IMPLEMENTATION
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>
35 const char* const DwMessage::sClassName
= "DwMessage";
38 DwMessage
* (*DwMessage::sNewMessage
)(const DwString
&,
39 DwMessageComponent
*) = 0;
42 DwMessage
* DwMessage::NewMessage(const DwString
& aStr
,
43 DwMessageComponent
* aParent
)
46 return sNewMessage(aStr
, aParent
);
49 return new DwMessage(aStr
, aParent
);
54 DwMessage::DwMessage()
56 mClassId
= kCidMessage
;
57 mClassName
= sClassName
;
61 DwMessage::DwMessage(const DwMessage
& aMessage
)
64 mClassId
= kCidMessage
;
65 mClassName
= sClassName
;
69 DwMessage::DwMessage(const DwString
& aStr
, DwMessageComponent
* aParent
)
70 : DwEntity(aStr
, aParent
)
72 mClassId
= kCidMessage
;
73 mClassName
= sClassName
;
77 DwMessage::~DwMessage()
82 DwMessageComponent
* DwMessage::Clone() const
84 return new DwMessage(*this);
88 const DwMessage
& DwMessage::operator = (const DwMessage
& aMessage
)
90 if (this == &aMessage
) return *this;
91 DwEntity::operator = (aMessage
);
96 #if defined(DW_DEBUG_VERSION)
97 void DwMessage::PrintDebugInfo(std::ostream
& aStrm
, int aDepth
) const
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
);
109 void DwMessage::PrintDebugInfo(std::ostream
& , int ) const {}
110 #endif // defined(DW_DEBUG_VERSION)
113 #if defined(DW_DEBUG_VERSION)
114 void DwMessage::_PrintDebugInfo(std::ostream
& aStrm
) const
116 DwEntity::_PrintDebugInfo(aStrm
);
119 void DwMessage::_PrintDebugInfo(std::ostream
& ) const {}
120 #endif // defined(DW_DEBUG_VERSION)