aboutsummaryrefslogtreecommitdiffstats
path: root/src/plainTextPart.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-07-12 22:28:02 +0000
committerVincent Richard <[email protected]>2005-07-12 22:28:02 +0000
commit681297e10b666e13cc463f6fbb16236f36c3266c (patch)
tree5d2392e2283232ed3475cd9c69e22897b03e8a97 /src/plainTextPart.cpp
parentAdded contentHandler::extractRaw(). (diff)
downloadvmime-681297e10b666e13cc463f6fbb16236f36c3266c.tar.gz
vmime-681297e10b666e13cc463f6fbb16236f36c3266c.zip
Reference counting and smart pointers.
Diffstat (limited to 'src/plainTextPart.cpp')
-rw-r--r--src/plainTextPart.cpp25
1 files changed, 11 insertions, 14 deletions
diff --git a/src/plainTextPart.cpp b/src/plainTextPart.cpp
index 8e065c76..86eb2f67 100644
--- a/src/plainTextPart.cpp
+++ b/src/plainTextPart.cpp
@@ -29,14 +29,13 @@ namespace vmime
plainTextPart::plainTextPart()
- : m_text(new emptyContentHandler)
+ : m_text(vmime::create <emptyContentHandler>())
{
}
plainTextPart::~plainTextPart()
{
- delete (m_text);
}
@@ -55,24 +54,23 @@ const int plainTextPart::getPartCount() const
void plainTextPart::generateIn(bodyPart& /* message */, bodyPart& parent) const
{
// Create a new part
- bodyPart* part = new bodyPart();
+ ref <bodyPart> part = vmime::create <bodyPart>();
parent.getBody()->appendPart(part);
// Set header fields
- part->getHeader()->ContentType().setValue(mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN));
- part->getHeader()->ContentType().setCharset(m_charset);
- part->getHeader()->ContentTransferEncoding().setValue(encoding(encodingTypes::QUOTED_PRINTABLE));
+ part->getHeader()->ContentType()->setValue(mediaType(mediaTypes::TEXT, mediaTypes::TEXT_PLAIN));
+ part->getHeader()->ContentType()->setCharset(m_charset);
+ part->getHeader()->ContentTransferEncoding()->setValue(encoding(encodingTypes::QUOTED_PRINTABLE));
// Set contents
- part->getBody()->setContents(*m_text);
+ part->getBody()->setContents(m_text);
}
void plainTextPart::parse(const bodyPart& /* message */,
const bodyPart& /* parent */, const bodyPart& textPart)
{
- delete (m_text);
- m_text = textPart.getBody()->getContents().clone();
+ m_text = textPart.getBody()->getContents()->clone().dynamicCast <contentHandler>();
try
{
@@ -104,16 +102,15 @@ void plainTextPart::setCharset(const charset& ch)
}
-const contentHandler& plainTextPart::getText() const
+const ref <const contentHandler> plainTextPart::getText() const
{
- return (*m_text);
+ return (m_text);
}
-void plainTextPart::setText(const contentHandler& text)
+void plainTextPart::setText(ref <contentHandler> text)
{
- delete (m_text);
- m_text = text.clone();
+ m_text = text->clone().dynamicCast <contentHandler>();
}