From 681297e10b666e13cc463f6fbb16236f36c3266c Mon Sep 17 00:00:00 2001 From: Vincent Richard Date: Tue, 12 Jul 2005 22:28:02 +0000 Subject: Reference counting and smart pointers. --- examples/example3.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) (limited to 'examples/example3.cpp') diff --git a/examples/example3.cpp b/examples/example3.cpp index 1bfa21c8..c3654545 100644 --- a/examples/example3.cpp +++ b/examples/example3.cpp @@ -48,12 +48,12 @@ int main() mb.setExpeditor(vmime::mailbox("me@somewhere.com")); vmime::addressList to; - to.appendAddress(new vmime::mailbox("you@elsewhere.com")); + to.appendAddress(vmime::create ("you@elsewhere.com")); mb.setRecipients(to); vmime::addressList bcc; - bcc.appendAddress(new vmime::mailbox("you-bcc@nowhere.com")); + bcc.appendAddress(vmime::create ("you-bcc@nowhere.com")); mb.setBlindCopyRecipients(bcc); @@ -65,7 +65,7 @@ int main() // Fill in the text part: the message is available in two formats: HTML and plain text. // HTML text part also includes an inline image (embedded into the message). - vmime::htmlTextPart& textPart = dynamic_cast(*mb.getTextPart()); + vmime::htmlTextPart& textPart = *mb.getTextPart().dynamicCast (); // -- embed an image (the returned "CID" (content identifier) is used to reference // -- the image into HTML content). @@ -73,11 +73,13 @@ int main() vmime::mediaType(vmime::mediaTypes::IMAGE, vmime::mediaTypes::IMAGE_JPEG)); // -- message text - textPart.setText(vmime::stringContentHandler(vmime::string("This is the HTML text.
"))); - textPart.setPlainText(vmime::stringContentHandler("This is the plain text (without HTML formatting).")); + textPart.setText(vmime::create + (vmime::string("This is the HTML text.
"))); + textPart.setPlainText(vmime::create + ("This is the plain text (without HTML formatting).")); // Construction - vmime::message* msg = mb.construct(); + vmime::ref msg = mb.construct(); // Raw text generation vmime::string dataToSend = msg->generate(); @@ -86,9 +88,6 @@ int main() std::cout << "==================" << std::endl; std::cout << std::endl; std::cout << dataToSend << std::endl; - - // Destruction - delete (msg); } // VMime exception catch (vmime::exception& e) -- cgit v1.2.3