aboutsummaryrefslogtreecommitdiffstats
path: root/src/body.cpp
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2005-01-28 17:50:53 +0000
committerVincent Richard <[email protected]>2005-01-28 17:50:53 +0000
commit4ae97ddb0957c626a01682e24c68710e608bcc43 (patch)
treeb81b4898dbfae5a81a6ca6820c7530bc39acf3e9 /src/body.cpp
parentFixed bug with signed/unsigned char. (diff)
downloadvmime-4ae97ddb0957c626a01682e24c68710e608bcc43.tar.gz
vmime-4ae97ddb0957c626a01682e24c68710e608bcc43.zip
Splitted 'contentHandler' into three classes: 'emptyContentHandler', 'stringContentHandler' and 'streamContentHandler'.
Diffstat (limited to 'src/body.cpp')
-rw-r--r--src/body.cpp35
1 files changed, 21 insertions, 14 deletions
diff --git a/src/body.cpp b/src/body.cpp
index 85e1f4f7..74c3a8e8 100644
--- a/src/body.cpp
+++ b/src/body.cpp
@@ -28,25 +28,31 @@
#include "vmime/parserHelpers.hpp"
+#include "vmime/emptyContentHandler.hpp"
+#include "vmime/stringContentHandler.hpp"
+
namespace vmime
{
body::body()
- : m_part(NULL), m_header(NULL)
+ : m_contents(new emptyContentHandler()), m_part(NULL), m_header(NULL)
{
}
body::body(bodyPart* parentPart)
- : m_part(parentPart), m_header(parentPart != NULL ? parentPart->getHeader() : NULL)
+ : m_contents(new emptyContentHandler()),
+ m_part(parentPart), m_header(parentPart != NULL ? parentPart->getHeader() : NULL)
{
}
body::~body()
{
+ delete (m_contents);
+
removeAllParts();
}
@@ -190,7 +196,7 @@ void body::parse(const string& buffer, const string::size_type position,
pos = buffer.find(boundarySep, partStart);
}
- m_contents.setData("");
+ setContentsImpl(emptyContentHandler());
if (partStart < end)
m_epilogText = string(buffer.begin() + partStart, buffer.begin() + end);
@@ -199,7 +205,7 @@ void body::parse(const string& buffer, const string::size_type position,
else
{
// Extract the (encoded) contents
- m_contents.setData(buffer, position, end, getEncoding());
+ setContentsImpl(stringContentHandler(buffer, position, end, getEncoding()));
}
setParsedBounds(position, end);
@@ -298,7 +304,7 @@ void body::generate(utility::outputStream& os, const string::size_type maxLineLe
else
{
// Generate the contents
- m_contents.generate(os, getEncoding(), maxLineLength);
+ m_contents->generate(os, getEncoding(), maxLineLength);
}
}
@@ -471,7 +477,7 @@ void body::copyFrom(const component& other)
m_prologText = bdy.m_prologText;
m_epilogText = bdy.m_epilogText;
- m_contents = bdy.m_contents;
+ setContentsImpl(*bdy.m_contents);
removeAllParts();
@@ -519,19 +525,13 @@ void body::setEpilogText(const string& epilogText)
const contentHandler& body::getContents() const
{
- return (m_contents);
-}
-
-
-contentHandler& body::getContents()
-{
- return (m_contents);
+ return (*m_contents);
}
void body::setContents(const contentHandler& contents)
{
- m_contents = contents;
+ setContentsImpl(contents);
}
@@ -716,4 +716,11 @@ const std::vector <const component*> body::getChildComponents() const
}
+void body::setContentsImpl(const contentHandler& cts)
+{
+ delete (m_contents);
+ m_contents = cts.clone();
+}
+
+
} // vmime