aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVincent Richard <[email protected]>2013-11-21 21:16:57 +0000
committerVincent Richard <[email protected]>2013-11-21 21:16:57 +0000
commitf9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8 (patch)
tree2bdc90e361a8f6e0a81164cf67afec9f78f9b959
parentPer-protocol include files. (diff)
downloadvmime-f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8.tar.gz
vmime-f9913fa28a27f23fde2d4956c62cbb2fb2bc2ee8.zip
Boost/C++11 shared pointers.
-rw-r--r--.gitignore2
-rw-r--r--CMakeLists.txt81
-rw-r--r--README.refcounting105
-rw-r--r--SConstruct3
-rw-r--r--cmake/cmake-cxx11/.gitignore1
-rw-r--r--cmake/cmake-cxx11/MERGE-TODO7
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake142
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp8
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp12
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp7
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp8
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp21
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp25
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp19
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp11
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp10
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp27
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp5
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp7
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp6
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp6
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp26
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp57
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp14
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp9
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp5
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp5
-rw-r--r--cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp23
-rw-r--r--cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt33
-rw-r--r--cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx57
-rw-r--r--cmake/config.hpp.cmake2
-rw-r--r--doc/book/basics.tex110
-rw-r--r--doc/book/building.tex43
-rw-r--r--doc/book/msg.tex88
-rw-r--r--doc/book/net.tex80
-rw-r--r--examples/example1.cpp8
-rw-r--r--examples/example2.cpp10
-rw-r--r--examples/example3.cpp24
-rw-r--r--examples/example6.cpp73
-rw-r--r--examples/example7.cpp10
-rw-r--r--examples/viewer/viewer.cpp8
-rw-r--r--src/address.cpp13
-rw-r--r--src/addressList.cpp66
-rw-r--r--src/attachmentHelper.cpp71
-rw-r--r--src/base.cpp8
-rw-r--r--src/body.cpp163
-rw-r--r--src/bodyPart.cpp70
-rw-r--r--src/bodyPartAttachment.cpp28
-rw-r--r--src/charset.cpp12
-rw-r--r--src/charsetConverter.cpp4
-rw-r--r--src/charsetConverter_iconv.cpp8
-rw-r--r--src/charsetConverter_icu.cpp8
-rw-r--r--src/charsetConverter_idna.cpp4
-rw-r--r--src/component.cpp30
-rw-r--r--src/contentDisposition.cpp8
-rw-r--r--src/dateTime.cpp8
-rw-r--r--src/defaultAttachment.cpp26
-rw-r--r--src/disposition.cpp8
-rw-r--r--src/emailAddress.cpp14
-rw-r--r--src/emptyContentHandler.cpp4
-rw-r--r--src/encoding.cpp16
-rw-r--r--src/fileAttachment.cpp20
-rw-r--r--src/fileContentHandler.cpp8
-rw-r--r--src/generatedMessageAttachment.cpp16
-rw-r--r--src/header.cpp82
-rw-r--r--src/headerField.cpp34
-rw-r--r--src/headerFieldFactory.cpp12
-rw-r--r--src/htmlTextPart.cpp106
-rw-r--r--src/mailbox.cpp8
-rw-r--r--src/mailboxField.cpp8
-rw-r--r--src/mailboxGroup.cpp54
-rw-r--r--src/mailboxList.cpp54
-rw-r--r--src/mdn/MDNHelper.cpp82
-rw-r--r--src/mdn/receivedMDNInfos.cpp17
-rw-r--r--src/mdn/sendableMDNInfos.cpp4
-rw-r--r--src/mediaType.cpp8
-rw-r--r--src/messageBuilder.cpp34
-rw-r--r--src/messageId.cpp14
-rw-r--r--src/messageIdSequence.cpp46
-rw-r--r--src/messageParser.cpp64
-rw-r--r--src/misc/importanceHelper.cpp26
-rw-r--r--src/net/events.cpp24
-rw-r--r--src/net/folder.cpp14
-rw-r--r--src/net/imap/IMAPConnection.cpp96
-rw-r--r--src/net/imap/IMAPFolder.cpp211
-rw-r--r--src/net/imap/IMAPFolderStatus.cpp4
-rw-r--r--src/net/imap/IMAPMessage.cpp98
-rw-r--r--src/net/imap/IMAPMessagePart.cpp32
-rw-r--r--src/net/imap/IMAPMessagePartContentHandler.cpp32
-rw-r--r--src/net/imap/IMAPMessageStructure.cpp12
-rw-r--r--src/net/imap/IMAPSStore.cpp2
-rw-r--r--src/net/imap/IMAPStore.cpp41
-rw-r--r--src/net/imap/IMAPUtils.cpp4
-rw-r--r--src/net/maildir/format/courierMaildirFormat.cpp50
-rw-r--r--src/net/maildir/format/kmailMaildirFormat.cpp46
-rw-r--r--src/net/maildir/maildirFolder.cpp238
-rw-r--r--src/net/maildir/maildirFolderStatus.cpp4
-rw-r--r--src/net/maildir/maildirFormat.cpp20
-rw-r--r--src/net/maildir/maildirMessage.cpp66
-rw-r--r--src/net/maildir/maildirMessagePart.cpp18
-rw-r--r--src/net/maildir/maildirMessageStructure.cpp16
-rw-r--r--src/net/maildir/maildirStore.cpp38
-rw-r--r--src/net/maildir/maildirUtils.cpp6
-rw-r--r--src/net/message.cpp4
-rw-r--r--src/net/messageSet.cpp8
-rw-r--r--src/net/pop3/POP3Command.cpp40
-rw-r--r--src/net/pop3/POP3Connection.cpp104
-rw-r--r--src/net/pop3/POP3Folder.cpp134
-rw-r--r--src/net/pop3/POP3FolderStatus.cpp4
-rw-r--r--src/net/pop3/POP3Message.cpp32
-rw-r--r--src/net/pop3/POP3Response.cpp22
-rw-r--r--src/net/pop3/POP3SStore.cpp2
-rw-r--r--src/net/pop3/POP3Store.cpp37
-rw-r--r--src/net/pop3/POP3Utils.cpp2
-rw-r--r--src/net/sendmail/sendmailTransport.cpp9
-rw-r--r--src/net/service.cpp32
-rw-r--r--src/net/serviceFactory.cpp32
-rw-r--r--src/net/serviceInfos.cpp2
-rw-r--r--src/net/serviceRegistration.inl10
-rw-r--r--src/net/session.cpp57
-rw-r--r--src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp6
-rw-r--r--src/net/smtp/SMTPCommand.cpp30
-rw-r--r--src/net/smtp/SMTPCommandSet.cpp20
-rw-r--r--src/net/smtp/SMTPConnection.cpp82
-rw-r--r--src/net/smtp/SMTPResponse.cpp8
-rw-r--r--src/net/smtp/SMTPSTransport.cpp2
-rw-r--r--src/net/smtp/SMTPTransport.cpp26
-rw-r--r--src/net/tls/TLSSecuredConnectionInfos.cpp4
-rw-r--r--src/net/tls/gnutls/TLSProperties_GnuTLS.cpp10
-rw-r--r--src/net/tls/gnutls/TLSSession_GnuTLS.cpp12
-rw-r--r--src/net/tls/gnutls/TLSSocket_GnuTLS.cpp38
-rw-r--r--src/net/tls/openssl/OpenSSLInitializer.cpp4
-rw-r--r--src/net/tls/openssl/TLSProperties_OpenSSL.cpp10
-rw-r--r--src/net/tls/openssl/TLSSession_OpenSSL.cpp12
-rw-r--r--src/net/tls/openssl/TLSSocket_OpenSSL.cpp32
-rw-r--r--src/net/transport.cpp52
-rw-r--r--src/object.cpp50
-rw-r--r--src/parameter.cpp14
-rw-r--r--src/parameterizedHeaderField.cpp64
-rw-r--r--src/parsedMessageAttachment.cpp20
-rw-r--r--src/path.cpp8
-rw-r--r--src/plainTextPart.cpp22
-rw-r--r--src/platform.cpp14
-rw-r--r--src/platforms/posix/posixChildProcess.cpp19
-rw-r--r--src/platforms/posix/posixFile.cpp34
-rw-r--r--src/platforms/posix/posixHandler.cpp16
-rw-r--r--src/platforms/posix/posixSocket.cpp12
-rw-r--r--src/platforms/windows/windowsFile.cpp32
-rw-r--r--src/platforms/windows/windowsHandler.cpp14
-rw-r--r--src/platforms/windows/windowsSocket.cpp12
-rw-r--r--src/propertySet.cpp32
-rw-r--r--src/relay.cpp8
-rw-r--r--src/security/cert/certificateChain.cpp4
-rw-r--r--src/security/cert/defaultCertificateVerifier.cpp32
-rw-r--r--src/security/cert/gnutls/X509Certificate_GnuTLS.cpp28
-rw-r--r--src/security/cert/openssl/X509Certificate_OpenSSL.cpp32
-rw-r--r--src/security/defaultAuthenticator.cpp8
-rw-r--r--src/security/digest/messageDigestFactory.cpp2
-rw-r--r--src/security/sasl/SASLContext.cpp24
-rw-r--r--src/security/sasl/SASLMechanismFactory.cpp8
-rw-r--r--src/security/sasl/SASLSession.cpp26
-rw-r--r--src/security/sasl/SASLSocket.cpp2
-rw-r--r--src/security/sasl/builtinSASLMechanism.cpp8
-rw-r--r--src/security/sasl/defaultSASLAuthenticator.cpp24
-rw-r--r--src/streamContentHandler.cpp20
-rw-r--r--src/stringContentHandler.cpp12
-rw-r--r--src/text.cpp70
-rw-r--r--src/textPartFactory.cpp2
-rw-r--r--src/utility/encoder/encoderFactory.cpp18
-rw-r--r--src/utility/parserInputStreamAdapter.cpp4
-rw-r--r--src/utility/seekableInputStreamRegionAdapter.cpp2
-rw-r--r--src/utility/smartPtr.cpp41
-rw-r--r--src/utility/smartPtrInt.cpp295
-rw-r--r--src/word.cpp23
-rw-r--r--src/wordEncoder.cpp6
-rw-r--r--tests/misc/importanceHelperTest.cpp8
-rw-r--r--tests/net/imap/IMAPParserTest.cpp13
-rw-r--r--tests/net/imap/IMAPTagTest.cpp16
-rw-r--r--tests/net/maildir/maildirStoreTest.cpp86
-rw-r--r--tests/net/pop3/POP3CommandTest.cpp47
-rw-r--r--tests/net/pop3/POP3ResponseTest.cpp80
-rw-r--r--tests/net/pop3/POP3StoreTest.cpp14
-rw-r--r--tests/net/pop3/POP3TestUtils.hpp15
-rw-r--r--tests/net/pop3/POP3UtilsTest.cpp10
-rw-r--r--tests/net/smtp/SMTPCommandSetTest.cpp28
-rw-r--r--tests/net/smtp/SMTPCommandTest.cpp44
-rw-r--r--tests/net/smtp/SMTPResponseTest.cpp70
-rw-r--r--tests/net/smtp/SMTPTransportTest.cpp80
-rw-r--r--tests/net/smtp/SMTPTransportTestUtils.hpp22
-rw-r--r--tests/parser/attachmentHelperTest.cpp70
-rw-r--r--tests/parser/bodyPartTest.cpp42
-rw-r--r--tests/parser/bodyTest.cpp4
-rw-r--r--tests/parser/charsetFilteredOutputStreamTest.cpp20
-rw-r--r--tests/parser/fileContentHandlerTest.cpp6
-rw-r--r--tests/parser/headerFieldTest.cpp19
-rw-r--r--tests/parser/headerTest.cpp54
-rw-r--r--tests/parser/htmlTextPartTest.cpp12
-rw-r--r--tests/parser/mailboxGroupTest.cpp4
-rw-r--r--tests/parser/mailboxTest.cpp9
-rw-r--r--tests/parser/messageIdSequenceTest.cpp6
-rw-r--r--tests/parser/messageTest.cpp6
-rw-r--r--tests/parser/parameterTest.cpp44
-rw-r--r--tests/parser/streamContentHandlerTest.cpp36
-rw-r--r--tests/parser/textTest.cpp20
-rw-r--r--tests/security/digest/md5Test.cpp2
-rw-r--r--tests/security/digest/sha1Test.cpp2
-rw-r--r--tests/testUtils.cpp4
-rw-r--r--tests/testUtils.hpp10
-rw-r--r--tests/utility/encoder/encoderTestUtils.hpp8
-rw-r--r--tests/utility/outputStreamSocketAdapterTest.cpp6
-rw-r--r--tests/utility/seekableInputStreamRegionAdapterTest.cpp30
-rw-r--r--tests/utility/smartPtrTest.cpp241
-rw-r--r--vmime/address.hpp4
-rw-r--r--vmime/addressList.hpp28
-rw-r--r--vmime/attachment.hpp8
-rw-r--r--vmime/attachmentHelper.hpp22
-rw-r--r--vmime/base.hpp129
-rw-r--r--vmime/body.hpp49
-rw-r--r--vmime/bodyPart.hpp49
-rw-r--r--vmime/bodyPartAttachment.hpp22
-rw-r--r--vmime/charset.hpp4
-rw-r--r--vmime/charsetConverter.hpp6
-rw-r--r--vmime/charsetConverter_iconv.hpp2
-rw-r--r--vmime/charsetConverter_icu.hpp2
-rw-r--r--vmime/charsetConverter_idna.hpp2
-rw-r--r--vmime/component.hpp12
-rw-r--r--vmime/contentDisposition.hpp4
-rw-r--r--vmime/contentDispositionField.hpp2
-rw-r--r--vmime/contentHandler.hpp3
-rw-r--r--vmime/contentTypeField.hpp2
-rw-r--r--vmime/dateTime.hpp4
-rw-r--r--vmime/defaultAttachment.hpp16
-rw-r--r--vmime/disposition.hpp4
-rw-r--r--vmime/emailAddress.hpp4
-rw-r--r--vmime/emptyContentHandler.hpp2
-rw-r--r--vmime/encoding.hpp10
-rw-r--r--vmime/fileAttachment.hpp10
-rw-r--r--vmime/fileContentHandler.hpp8
-rw-r--r--vmime/generatedMessageAttachment.hpp16
-rw-r--r--vmime/header.hpp68
-rw-r--r--vmime/headerField.hpp40
-rw-r--r--vmime/headerFieldFactory.hpp14
-rw-r--r--vmime/htmlTextPart.hpp36
-rw-r--r--vmime/mailbox.hpp4
-rw-r--r--vmime/mailboxField.hpp2
-rw-r--r--vmime/mailboxGroup.hpp26
-rw-r--r--vmime/mailboxList.hpp26
-rw-r--r--vmime/mdn/MDNHelper.hpp20
-rw-r--r--vmime/mdn/MDNInfos.hpp2
-rw-r--r--vmime/mdn/receivedMDNInfos.hpp6
-rw-r--r--vmime/mdn/sendableMDNInfos.hpp6
-rw-r--r--vmime/mediaType.hpp4
-rw-r--r--vmime/messageAttachment.hpp2
-rw-r--r--vmime/messageBuilder.hpp20
-rw-r--r--vmime/messageId.hpp6
-rw-r--r--vmime/messageIdSequence.hpp26
-rw-r--r--vmime/messageParser.hpp22
-rw-r--r--vmime/misc/importanceHelper.hpp12
-rw-r--r--vmime/net/events.hpp30
-rw-r--r--vmime/net/folder.hpp30
-rw-r--r--vmime/net/folderStatus.hpp2
-rw-r--r--vmime/net/imap/IMAPConnection.hpp28
-rw-r--r--vmime/net/imap/IMAPFolder.hpp37
-rw-r--r--vmime/net/imap/IMAPFolderStatus.hpp2
-rw-r--r--vmime/net/imap/IMAPMessage.hpp36
-rw-r--r--vmime/net/imap/IMAPMessagePart.hpp28
-rw-r--r--vmime/net/imap/IMAPMessagePartContentHandler.hpp8
-rw-r--r--vmime/net/imap/IMAPMessageStructure.hpp10
-rw-r--r--vmime/net/imap/IMAPParser.hpp40
-rw-r--r--vmime/net/imap/IMAPSStore.hpp2
-rw-r--r--vmime/net/imap/IMAPStore.hpp16
-rw-r--r--vmime/net/imap/IMAPUtils.hpp4
-rw-r--r--vmime/net/maildir/format/courierMaildirFormat.hpp2
-rw-r--r--vmime/net/maildir/format/kmailMaildirFormat.hpp2
-rw-r--r--vmime/net/maildir/maildirFolder.hpp34
-rw-r--r--vmime/net/maildir/maildirFolderStatus.hpp2
-rw-r--r--vmime/net/maildir/maildirFormat.hpp16
-rw-r--r--vmime/net/maildir/maildirMessage.hpp31
-rw-r--r--vmime/net/maildir/maildirMessagePart.hpp16
-rw-r--r--vmime/net/maildir/maildirMessageStructure.hpp14
-rw-r--r--vmime/net/maildir/maildirStore.hpp16
-rw-r--r--vmime/net/maildir/maildirUtils.hpp2
-rw-r--r--vmime/net/message.hpp26
-rw-r--r--vmime/net/pop3/POP3Command.hpp40
-rw-r--r--vmime/net/pop3/POP3Connection.hpp26
-rw-r--r--vmime/net/pop3/POP3Folder.hpp34
-rw-r--r--vmime/net/pop3/POP3FolderStatus.hpp2
-rw-r--r--vmime/net/pop3/POP3Message.hpp27
-rw-r--r--vmime/net/pop3/POP3Response.hpp16
-rw-r--r--vmime/net/pop3/POP3SStore.hpp2
-rw-r--r--vmime/net/pop3/POP3Store.hpp14
-rw-r--r--vmime/net/pop3/POP3Utils.hpp2
-rw-r--r--vmime/net/sendmail/sendmailTransport.hpp4
-rw-r--r--vmime/net/service.hpp36
-rw-r--r--vmime/net/serviceFactory.hpp30
-rw-r--r--vmime/net/serviceInfos.hpp4
-rw-r--r--vmime/net/session.hpp28
-rw-r--r--vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp6
-rw-r--r--vmime/net/smtp/SMTPCommand.hpp30
-rw-r--r--vmime/net/smtp/SMTPCommandSet.hpp14
-rw-r--r--vmime/net/smtp/SMTPConnection.hpp30
-rw-r--r--vmime/net/smtp/SMTPResponse.hpp10
-rw-r--r--vmime/net/smtp/SMTPSTransport.hpp2
-rw-r--r--vmime/net/smtp/SMTPTransport.hpp10
-rw-r--r--vmime/net/socket.hpp4
-rw-r--r--vmime/net/store.hpp8
-rw-r--r--vmime/net/timeoutHandler.hpp2
-rw-r--r--vmime/net/tls/TLSProperties.hpp2
-rw-r--r--vmime/net/tls/TLSSecuredConnectionInfos.hpp8
-rw-r--r--vmime/net/tls/TLSSession.hpp6
-rw-r--r--vmime/net/tls/TLSSocket.hpp6
-rw-r--r--vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp10
-rw-r--r--vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp14
-rw-r--r--vmime/net/tls/openssl/OpenSSLInitializer.hpp4
-rw-r--r--vmime/net/tls/openssl/TLSSession_OpenSSL.hpp10
-rw-r--r--vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp14
-rw-r--r--vmime/net/transport.hpp10
-rw-r--r--vmime/object.hpp49
-rw-r--r--vmime/parameter.hpp8
-rw-r--r--vmime/parameterizedHeaderField.hpp30
-rw-r--r--vmime/parsedMessageAttachment.hpp16
-rw-r--r--vmime/path.hpp4
-rw-r--r--vmime/plainTextPart.hpp10
-rw-r--r--vmime/platform.hpp16
-rw-r--r--vmime/platforms/posix/posixChildProcess.hpp10
-rw-r--r--vmime/platforms/posix/posixFile.hpp16
-rw-r--r--vmime/platforms/posix/posixHandler.hpp14
-rw-r--r--vmime/platforms/posix/posixSocket.hpp8
-rw-r--r--vmime/platforms/windows/windowsFile.hpp16
-rw-r--r--vmime/platforms/windows/windowsHandler.hpp12
-rw-r--r--vmime/platforms/windows/windowsSocket.hpp8
-rw-r--r--vmime/propertySet.hpp18
-rw-r--r--vmime/relay.hpp4
-rw-r--r--vmime/security/authenticator.hpp2
-rw-r--r--vmime/security/cert/X509Certificate.hpp8
-rw-r--r--vmime/security/cert/certificate.hpp2
-rw-r--r--vmime/security/cert/certificateChain.hpp6
-rw-r--r--vmime/security/cert/certificateVerifier.hpp2
-rw-r--r--vmime/security/cert/defaultCertificateVerifier.hpp12
-rw-r--r--vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp12
-rw-r--r--vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp16
-rw-r--r--vmime/security/defaultAuthenticator.hpp6
-rw-r--r--vmime/security/digest/messageDigestFactory.hpp12
-rw-r--r--vmime/security/sasl/SASLAuthenticator.hpp10
-rw-r--r--vmime/security/sasl/SASLContext.hpp10
-rw-r--r--vmime/security/sasl/SASLMechanism.hpp6
-rw-r--r--vmime/security/sasl/SASLMechanismFactory.hpp14
-rw-r--r--vmime/security/sasl/SASLSession.hpp18
-rw-r--r--vmime/security/sasl/SASLSocket.hpp6
-rw-r--r--vmime/security/sasl/builtinSASLMechanism.hpp10
-rw-r--r--vmime/security/sasl/defaultSASLAuthenticator.hpp24
-rw-r--r--vmime/streamContentHandler.hpp8
-rw-r--r--vmime/stringContentHandler.hpp2
-rw-r--r--vmime/text.hpp26
-rw-r--r--vmime/textPart.hpp8
-rw-r--r--vmime/textPartFactory.hpp8
-rw-r--r--vmime/types.hpp56
-rw-r--r--vmime/utility/childProcess.hpp6
-rw-r--r--vmime/utility/encoder/encoderFactory.hpp28
-rw-r--r--vmime/utility/file.hpp16
-rw-r--r--vmime/utility/parserInputStreamAdapter.hpp6
-rw-r--r--vmime/utility/seekableInputStreamRegionAdapter.hpp4
-rw-r--r--vmime/utility/smartPtr.hpp550
-rw-r--r--vmime/utility/smartPtrInt.hpp113
-rw-r--r--vmime/utility/sync/autoLock.hpp4
-rw-r--r--vmime/word.hpp8
-rw-r--r--vmime/wordEncoder.hpp2
367 files changed, 4422 insertions, 5168 deletions
diff --git a/.gitignore b/.gitignore
index 9976ce0d..8b955403 100644
--- a/.gitignore
+++ b/.gitignore
@@ -30,6 +30,8 @@ cmake_install.cmake
/COPYING.txt
build/
Makefile
+export-shared.hpp
+export-static.hpp
# Outsourced build test
/_build/
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 0e925136..74f6c62f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -22,6 +22,7 @@ INCLUDE(CheckFunctionExists)
INCLUDE(CheckSymbolExists)
INCLUDE(CheckTypeSize)
INCLUDE(CheckLibraryExists)
+INCLUDE(CheckCXXSourceCompiles)
# CMake configuration
@@ -796,6 +797,57 @@ ENDIF()
##############################################################################
+# Language features
+
+# C++11
+INCLUDE(cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake)
+
+# Smart pointers
+CHECK_CXX_SOURCE_COMPILES(
+ "
+ #include <memory>
+ struct A { int foo; };
+ int main() {
+ std::shared_ptr <A> a = std::make_shared <A>(a);
+ return 0;
+ }
+ "
+ VMIME_HAS_CXX11_SHARED_PTR
+)
+
+IF(CXX11_COMPILER_FLAGS AND VMIME_HAS_CXX11_SHARED_PTR)
+
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS}")
+
+ IF("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
+ SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++")
+ ENDIF()
+
+ MESSAGE(STATUS "Checking support for shared_ptr<>: built-in (C++11)")
+
+ SET(VMIME_SHARED_PTR_USE_CXX ON)
+ SET(VMIME_SHARED_PTR_USE_BOOST OFF)
+
+ELSE()
+
+ # Depends on Boost library if C++11 is not supported
+ FIND_PACKAGE(Boost)
+
+ IF(Boost_FOUND)
+ INCLUDE_DIRECTORIES(${Boost_INCLUDE_DIRS})
+ ELSE()
+ MESSAGE(FATAL_ERROR "Boost library is required for shared_ptr<>, unless you compile using C++11")
+ ENDIF()
+
+ MESSAGE(STATUS "Checking support for shared_ptr<>: boost library")
+
+ SET(VMIME_SHARED_PTR_USE_CXX OFF)
+ SET(VMIME_SHARED_PTR_USE_BOOST ON)
+
+ENDIF()
+
+
+##############################################################################
# Platform
SET(VMIME_PLATFORM_IS_POSIX OFF)
@@ -941,20 +993,27 @@ ENDIF()
##############################################################################
# Documentation
-FIND_PACKAGE(Doxygen)
+OPTION(
+ VMIME_BUILD_DOCUMENTATION
+ "Build documentation"
+ ON
+)
-IF(DOXYGEN_FOUND)
- CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
+IF(VMIME_BUILD_DOCUMENTATION)
+ FIND_PACKAGE(Doxygen)
- # Make a target so that documentation can be generated by running "make doc"
- ADD_CUSTOM_TARGET(
- doc
- ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
- WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
- COMMENT "Generating API documentation with Doxygen" VERBATIM
- )
-ENDIF(DOXYGEN_FOUND)
+ IF(DOXYGEN_FOUND)
+ CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/Doxyfile.in ${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
+ # Make a target so that documentation can be generated by running "make doc"
+ ADD_CUSTOM_TARGET(
+ doc
+ ${DOXYGEN_EXECUTABLE} ${CMAKE_BINARY_DIR}/Doxyfile
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ COMMENT "Generating API documentation with Doxygen" VERBATIM
+ )
+ ENDIF(DOXYGEN_FOUND)
+ENDIF(VMIME_BUILD_DOCUMENTATION)
##############################################################################
# Sanity checks
diff --git a/README.refcounting b/README.refcounting
deleted file mode 100644
index 33dbd74e..00000000
--- a/README.refcounting
+++ /dev/null
@@ -1,105 +0,0 @@
-==============================================
-Reference counting and smart pointers in VMime
-==============================================
-
-
-I. Introduction
-===============
-
-Since version 0.7.2cvs, VMime has been modified to use smart pointers and
-reference counting instead of raw pointers.
-
-This simplifies a lot using VMime objects as you don't have to worry about
-freeing memory occupied by objects, or even wondering which of your program
-or VMime is responsible for deleting the object.
-
-This is also convenient when a function returns a list of objects. Before,
-you wrote:
-
- std::vector <vmime::messaging::folder*> subFolders = folder->getFolders();
-
- ...do something with result...
-
- for (std::vector <vmime::messaging::folder*>::iterator
- it = subFolders.begin() ; it != subFolders.end() ; ++it)
- {
- delete *it;
- }
-
-Now, you can simply write:
-
- std::vector <ref <vmime::messaging::folder > > subFolders = folder->getFolders();
-
- ...do something with result...
-
-and nothing more!
-
-Two new template classes were introduced:
-
- - vmime::ref <> holds a strong reference to an object. When there is no
- more strong reference pointing to an object, the object is deleted.
-
- - vmime::weak_ref <> holds a weak reference to an object. A weak reference
- automatically points to NULL when the last strong reference is released.
- It can be used to bypass the problems with circular references: A holds
- a strong reference to B, which holds a strong reference back to A.
-
-
-II. Creating objects
-====================
-
-You should not use 'new' to allocate VMime objects anymore. Instead, you
-should use the vmime::create() helper function:
-
- vmime::ref <vmime::mailbox> mbox =
- vmime::create <vmime::mailbox>("[email protected]");
-
-
-III. Casting
-============
-
-Like raw C++ pointers, you can cast VMime references. Implicit downcast is
-also supported.
-
-To do a dynamic cast, write:
-
- vmime::ref <vmime::component> foo = ...
- vmime::ref <vmime::mailbox> mbox = foo.dynamicCast <vmime::mailbox>()
-
-then 'mbox' will be set to null ref if the dynamic cast failed (ie. if dynamic
-type of 'foo' is not/is not derived from 'vmime::mailbox').
-
-The same thing is possible with static cast:
-
- vmime::ref <vmime::component> foo = ...
- vmime::ref <vmime::mailbox> mbox = foo.staticCast <vmime::mailbox>()
-
-Like in standard C++, if 'foo' is not really a 'vmime::mailbox', the 'mbox'
-reference can point to anything (ie. "invalid"), so be careful...
-
-Finally, const cast is also supported:
-
- vmime::ref <const vmime::component> foo_const = ...
- vmime::ref <vmime::component> foo = foo_const.constCast();
-
-
-IV. Upgrading your code from version <= 0.7.1
-=============================================
-
-1. vmime::text
---------------
-
-In v0.7.1 and below:
-
- vmime::text t1;
- vmime::newFromString("blah blah", vmime::charset(...), &t1);
-
- vmime::text* t2 = vmime::newFromString("foo", vmime::charset(...));
-
-In v0.7.2:
-
- vmime::text t1;
- t1.createFromString("blah blah", vmime::charset(...));
-
- vmime::ref <vmime::text> t2 = vmime::newFromString("foo", vmime::charset(...));
-
diff --git a/SConstruct b/SConstruct
index 2da57e1f..88a42154 100644
--- a/SConstruct
+++ b/SConstruct
@@ -121,8 +121,6 @@ libvmime_sources = [
'utility/path.cpp', 'utility/path.hpp',
'utility/progressListener.cpp', 'utility/progressListener.hpp',
'utility/random.cpp', 'utility/random.hpp',
- 'utility/smartPtr.cpp', 'utility/smartPtr.hpp',
- 'utility/smartPtrInt.cpp', 'utility/smartPtrInt.hpp',
'utility/stream.cpp', 'utility/stream.hpp',
'utility/streamUtils.cpp', 'utility/streamUtils.hpp',
'utility/filteredStream.cpp', 'utility/filteredStream.hpp',
@@ -406,7 +404,6 @@ libvmimetest_sources = [
'tests/utility/stringUtilsTest.cpp',
'tests/utility/pathTest.cpp',
'tests/utility/urlTest.cpp',
- 'tests/utility/smartPtrTest.cpp',
'tests/utility/encoder/qpEncoderTest.cpp',
'tests/utility/encoder/b64EncoderTest.cpp',
'tests/utility/outputStreamStringAdapterTest.cpp',
diff --git a/cmake/cmake-cxx11/.gitignore b/cmake/cmake-cxx11/.gitignore
new file mode 100644
index 00000000..378eac25
--- /dev/null
+++ b/cmake/cmake-cxx11/.gitignore
@@ -0,0 +1 @@
+build
diff --git a/cmake/cmake-cxx11/MERGE-TODO b/cmake/cmake-cxx11/MERGE-TODO
new file mode 100644
index 00000000..dc2ce480
--- /dev/null
+++ b/cmake/cmake-cxx11/MERGE-TODO
@@ -0,0 +1,7 @@
+These things need to be changed when this module is merged into CMake:
+
+-change include(CheckCXXCompilerFlag) in CheckCXX11Features.cmake to
+ include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXCompilerFlag.cmake)
+-remove the setting of CMAKE_MODULE_PATH from the testcase CMakeLists.txt
+-change all tabs to spaces in the cpp files
+
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake b/cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake
new file mode 100644
index 00000000..05c986ce
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features.cmake
@@ -0,0 +1,142 @@
+# - Check which parts of the C++11 standard the compiler supports
+#
+# When found it will set the following variables
+#
+# CXX11_COMPILER_FLAGS - the compiler flags needed to get C++11 features
+#
+# HAS_CXX11_AUTO - auto keyword
+# HAS_CXX11_AUTO_RET_TYPE - function declaration with deduced return types
+# HAS_CXX11_CLASS_OVERRIDE - override and final keywords for classes and methods
+# HAS_CXX11_CONSTEXPR - constexpr keyword
+# HAS_CXX11_CSTDINT_H - cstdint header
+# HAS_CXX11_DECLTYPE - decltype keyword
+# HAS_CXX11_FUNC - __func__ preprocessor constant
+# HAS_CXX11_INITIALIZER_LIST - initializer list
+# HAS_CXX11_LAMBDA - lambdas
+# HAS_CXX11_LIB_REGEX - regex library
+# HAS_CXX11_LONG_LONG - long long signed & unsigned types
+# HAS_CXX11_NULLPTR - nullptr
+# HAS_CXX11_RVALUE_REFERENCES - rvalue references
+# HAS_CXX11_SIZEOF_MEMBER - sizeof() non-static members
+# HAS_CXX11_STATIC_ASSERT - static_assert()
+# HAS_CXX11_VARIADIC_TEMPLATES - variadic templates
+
+#=============================================================================
+# Copyright 2011,2012 Rolf Eike Beer <[email protected]>
+# Copyright 2012 Andreas Weis
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+# (To distribute this file outside of CMake, substitute the full
+# License text for the above reference.)
+
+#
+# Each feature may have up to 3 checks, every one of them in it's own file
+# FEATURE.cpp - example that must build and return 0 when run
+# FEATURE_fail.cpp - example that must build, but may not return 0 when run
+# FEATURE_fail_compile.cpp - example that must fail compilation
+#
+# The first one is mandatory, the latter 2 are optional and do not depend on
+# each other (i.e. only one may be present).
+#
+
+if (NOT CMAKE_CXX_COMPILER_LOADED)
+ message(FATAL_ERROR "CheckCXX11Features modules only works if language CXX is enabled")
+endif ()
+
+cmake_minimum_required(VERSION 2.8.3)
+
+#
+### Check for needed compiler flags
+#
+include(CheckCXXCompilerFlag)
+check_cxx_compiler_flag("-std=c++11" _HAS_CXX11_FLAG)
+if (NOT _HAS_CXX11_FLAG)
+ check_cxx_compiler_flag("-std=c++0x" _HAS_CXX0X_FLAG)
+endif ()
+
+if (_HAS_CXX11_FLAG)
+ set(CXX11_COMPILER_FLAGS "-std=c++11")
+elseif (_HAS_CXX0X_FLAG)
+ set(CXX11_COMPILER_FLAGS "-std=c++0x")
+endif ()
+
+function(cxx11_check_feature FEATURE_NAME RESULT_VAR)
+ if (NOT DEFINED ${RESULT_VAR})
+ set(_bindir "${CMAKE_CURRENT_BINARY_DIR}/cxx11_${FEATURE_NAME}")
+
+ set(_SRCFILE_BASE ${CMAKE_CURRENT_LIST_DIR}/CheckCXX11Features/cxx11-test-${FEATURE_NAME})
+ set(_LOG_NAME "\"${FEATURE_NAME}\"")
+ message(STATUS "Checking C++11 support for ${_LOG_NAME}")
+
+ set(_SRCFILE "${_SRCFILE_BASE}.cpp")
+ set(_SRCFILE_FAIL "${_SRCFILE_BASE}_fail.cpp")
+ set(_SRCFILE_FAIL_COMPILE "${_SRCFILE_BASE}_fail_compile.cpp")
+
+ if (CROSS_COMPILING)
+ try_compile(${RESULT_VAR} "${_bindir}" "${_SRCFILE}"
+ COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+ if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+ try_compile(${RESULT_VAR} "${_bindir}_fail" "${_SRCFILE_FAIL}"
+ COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+ endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+ else (CROSS_COMPILING)
+ try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+ "${_bindir}" "${_SRCFILE}"
+ COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+ if (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+ set(${RESULT_VAR} TRUE)
+ else (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+ set(${RESULT_VAR} FALSE)
+ endif (_COMPILE_RESULT_VAR AND NOT _RUN_RESULT_VAR)
+ if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+ try_run(_RUN_RESULT_VAR _COMPILE_RESULT_VAR
+ "${_bindir}_fail" "${_SRCFILE_FAIL}"
+ COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+ if (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+ set(${RESULT_VAR} TRUE)
+ else (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+ set(${RESULT_VAR} FALSE)
+ endif (_COMPILE_RESULT_VAR AND _RUN_RESULT_VAR)
+ endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL})
+ endif (CROSS_COMPILING)
+ if (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+ try_compile(_TMP_RESULT "${_bindir}_fail_compile" "${_SRCFILE_FAIL_COMPILE}"
+ COMPILE_DEFINITIONS "${CXX11_COMPILER_FLAGS}")
+ if (_TMP_RESULT)
+ set(${RESULT_VAR} FALSE)
+ else (_TMP_RESULT)
+ set(${RESULT_VAR} TRUE)
+ endif (_TMP_RESULT)
+ endif (${RESULT_VAR} AND EXISTS ${_SRCFILE_FAIL_COMPILE})
+
+ if (${RESULT_VAR})
+ message(STATUS "Checking C++11 support for ${_LOG_NAME}: works")
+ else (${RESULT_VAR})
+ message(STATUS "Checking C++11 support for ${_LOG_NAME}: not supported")
+ endif (${RESULT_VAR})
+ set(${RESULT_VAR} ${${RESULT_VAR}} CACHE INTERNAL "C++11 support for ${_LOG_NAME}")
+ endif (NOT DEFINED ${RESULT_VAR})
+endfunction(cxx11_check_feature)
+
+cxx11_check_feature("__func__" HAS_CXX11_FUNC)
+cxx11_check_feature("auto" HAS_CXX11_AUTO)
+cxx11_check_feature("auto_ret_type" HAS_CXX11_AUTO_RET_TYPE)
+cxx11_check_feature("class_override_final" HAS_CXX11_CLASS_OVERRIDE)
+cxx11_check_feature("constexpr" HAS_CXX11_CONSTEXPR)
+cxx11_check_feature("cstdint" HAS_CXX11_CSTDINT_H)
+cxx11_check_feature("decltype" HAS_CXX11_DECLTYPE)
+cxx11_check_feature("initializer_list" HAS_CXX11_INITIALIZER_LIST)
+cxx11_check_feature("lambda" HAS_CXX11_LAMBDA)
+cxx11_check_feature("long_long" HAS_CXX11_LONG_LONG)
+cxx11_check_feature("nullptr" HAS_CXX11_NULLPTR)
+cxx11_check_feature("regex" HAS_CXX11_LIB_REGEX)
+cxx11_check_feature("rvalue-references" HAS_CXX11_RVALUE_REFERENCES)
+cxx11_check_feature("sizeof_member" HAS_CXX11_SIZEOF_MEMBER)
+cxx11_check_feature("static_assert" HAS_CXX11_STATIC_ASSERT)
+cxx11_check_feature("variadic_templates" HAS_CXX11_VARIADIC_TEMPLATES)
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp
new file mode 100644
index 00000000..3bfd8a89
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-__func__.cpp
@@ -0,0 +1,8 @@
+int main(void)
+{
+ if (!__func__)
+ return 1;
+ if (!(*__func__))
+ return 1;
+ return 0;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp
new file mode 100644
index 00000000..948648e9
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto.cpp
@@ -0,0 +1,12 @@
+
+int main()
+{
+ auto i = 5;
+ auto f = 3.14159f;
+ auto d = 3.14159;
+ bool ret = (
+ (sizeof(f) < sizeof(d)) &&
+ (sizeof(i) == sizeof(int))
+ );
+ return ret ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp
new file mode 100644
index 00000000..3c0e3f2e
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_fail_compile.cpp
@@ -0,0 +1,7 @@
+int main(void)
+{
+ // must fail because there is no initializer
+ auto i;
+
+ return 0;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp
new file mode 100644
index 00000000..937b6835
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-auto_ret_type.cpp
@@ -0,0 +1,8 @@
+auto foo(int i) -> int {
+ return i - 1;
+}
+
+int main()
+{
+ return foo(1);
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp
new file mode 100644
index 00000000..f5870b19
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final.cpp
@@ -0,0 +1,21 @@
+class base {
+public:
+ virtual int foo(int a)
+ { return 4 + a; }
+ int bar(int a) final
+ { return a - 2; }
+};
+
+class sub final : public base {
+public:
+ virtual int foo(int a) override
+ { return 8 + 2 * a; };
+};
+
+int main(void)
+{
+ base b;
+ sub s;
+
+ return (b.foo(2) * 2 == s.foo(2)) ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp
new file mode 100644
index 00000000..bc00b278
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-class_override_final_fail_compile.cpp
@@ -0,0 +1,25 @@
+class base {
+public:
+ virtual int foo(int a)
+ { return 4 + a; }
+ virtual int bar(int a) final
+ { return a - 2; }
+};
+
+class sub final : public base {
+public:
+ virtual int foo(int a) override
+ { return 8 + 2 * a; };
+ virtual int bar(int a)
+ { return a; }
+};
+
+class impossible : public sub { };
+
+int main(void)
+{
+ base b;
+ sub s;
+
+ return 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp
new file mode 100644
index 00000000..ed624512
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-constexpr.cpp
@@ -0,0 +1,19 @@
+constexpr int square(int x)
+{
+ return x*x;
+}
+
+constexpr int the_answer()
+{
+ return 42;
+}
+
+int main()
+{
+ int test_arr[square(3)];
+ bool ret = (
+ (square(the_answer()) == 1764) &&
+ (sizeof(test_arr)/sizeof(test_arr[0]) == 9)
+ );
+ return ret ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp
new file mode 100644
index 00000000..ca2c72dd
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-cstdint.cpp
@@ -0,0 +1,11 @@
+#include <cstdint>
+
+int main()
+{
+ bool test =
+ (sizeof(int8_t) == 1) &&
+ (sizeof(int16_t) == 2) &&
+ (sizeof(int32_t) == 4) &&
+ (sizeof(int64_t) == 8);
+ return test ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp
new file mode 100644
index 00000000..0dbb1cc5
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-decltype.cpp
@@ -0,0 +1,10 @@
+bool check_size(int i)
+{
+ return sizeof(int) == sizeof(decltype(i));
+}
+
+int main()
+{
+ bool ret = check_size(42);
+ return ret ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp
new file mode 100644
index 00000000..35e6c384
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-initializer_list.cpp
@@ -0,0 +1,27 @@
+#include <vector>
+
+class seq {
+public:
+ seq(std::initializer_list<int> list);
+
+ int length() const;
+private:
+ std::vector<int> m_v;
+};
+
+seq::seq(std::initializer_list<int> list)
+ : m_v(list)
+{
+}
+
+int seq::length() const
+{
+ return m_v.size();
+}
+
+int main(void)
+{
+ seq a = {18, 20, 2, 0, 4, 7};
+
+ return (a.length() == 6) ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp
new file mode 100644
index 00000000..4c33ed58
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-lambda.cpp
@@ -0,0 +1,5 @@
+int main()
+{
+ int ret = 0;
+ return ([&ret]() -> int { return ret; })();
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp
new file mode 100644
index 00000000..09111275
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-long_long.cpp
@@ -0,0 +1,7 @@
+int main(void)
+{
+ long long l;
+ unsigned long long ul;
+
+ return ((sizeof(l) >= 8) && (sizeof(ul) >= 8)) ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp
new file mode 100644
index 00000000..9f410715
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr.cpp
@@ -0,0 +1,6 @@
+int main(void)
+{
+ void *v = nullptr;
+
+ return v ? 1 : 0;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp
new file mode 100644
index 00000000..6a002bcb
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-nullptr_fail_compile.cpp
@@ -0,0 +1,6 @@
+int main(void)
+{
+ int i = nullptr;
+
+ return 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp
new file mode 100644
index 00000000..2fe01c4f
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-regex.cpp
@@ -0,0 +1,26 @@
+#include <algorithm>
+#include <regex>
+
+int parse_line(std::string const& line)
+{
+ std::string tmp;
+ if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+//(-)?(\\d)+(\\s)+"))) {
+ tmp = std::regex_replace(line, std::regex("(-)?(\\d)+//(-)?(\\d)+"), std::string("V"));
+ } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
+ tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
+ } else if(std::regex_search(line, std::regex("(\\s)+(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+(\\s)+"))) {
+ tmp = std::regex_replace(line, std::regex("(-)?(\\d)+/(-)?(\\d)+/(-)?(\\d)+"), std::string("V"));
+ } else {
+ tmp = std::regex_replace(line, std::regex("(-)?(\\d)+"), std::string("V"));
+ }
+ return static_cast<int>(std::count(tmp.begin(), tmp.end(), 'V'));
+}
+
+int main()
+{
+ bool test = (parse_line("f 7/7/7 -3/3/-3 2/-2/2") == 3) &&
+ (parse_line("f 7//7 3//-3 -2//2") == 3) &&
+ (parse_line("f 7/7 3/-3 -2/2") == 3) &&
+ (parse_line("f 7 3 -2") == 3);
+ return test ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp
new file mode 100644
index 00000000..e6e7e5a9
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-rvalue-references.cpp
@@ -0,0 +1,57 @@
+#include <cassert>
+
+class rvmove {
+public:
+ void *ptr;
+ char *array;
+
+ rvmove()
+ : ptr(0),
+ array(new char[10])
+ {
+ ptr = this;
+ }
+
+ rvmove(rvmove &&other)
+ : ptr(other.ptr),
+ array(other.array)
+ {
+ other.array = 0;
+ other.ptr = 0;
+ }
+
+ ~rvmove()
+ {
+ assert(((ptr != 0) && (array != 0)) || ((ptr == 0) && (array == 0)));
+ delete[] array;
+ }
+
+ rvmove &operator=(rvmove &&other)
+ {
+ delete[] array;
+ ptr = other.ptr;
+ array = other.array;
+ other.array = 0;
+ other.ptr = 0;
+ return *this;
+ }
+
+ static rvmove create()
+ {
+ return rvmove();
+ }
+private:
+ rvmove(const rvmove &);
+ rvmove &operator=(const rvmove &);
+};
+
+int main()
+{
+ rvmove mine;
+ if (mine.ptr != &mine)
+ return 1;
+ mine = rvmove::create();
+ if (mine.ptr == &mine)
+ return 1;
+ return 0;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp
new file mode 100644
index 00000000..4902fc73
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member.cpp
@@ -0,0 +1,14 @@
+struct foo {
+ char bar;
+ int baz;
+};
+
+int main(void)
+{
+ bool ret = (
+ (sizeof(foo::bar) == 1) &&
+ (sizeof(foo::baz) >= sizeof(foo::bar)) &&
+ (sizeof(foo) >= sizeof(foo::bar) + sizeof(foo::baz))
+ );
+ return ret ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp
new file mode 100644
index 00000000..0348c2ce
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-sizeof_member_fail.cpp
@@ -0,0 +1,9 @@
+struct foo {
+ int baz;
+ double bar;
+};
+
+int main(void)
+{
+ return (sizeof(foo::bar) == 4) ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp
new file mode 100644
index 00000000..47c2fefb
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert.cpp
@@ -0,0 +1,5 @@
+int main(void)
+{
+ static_assert(0 < 1, "your ordering of integers is screwed");
+ return 0;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp
new file mode 100644
index 00000000..362fcdde
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-static_assert_fail_compile.cpp
@@ -0,0 +1,5 @@
+int main(void)
+{
+ static_assert(1 < 0, "your ordering of integers is screwed");
+ return 0;
+}
diff --git a/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp
new file mode 100644
index 00000000..4518e886
--- /dev/null
+++ b/cmake/cmake-cxx11/Modules/CheckCXX11Features/cxx11-test-variadic_templates.cpp
@@ -0,0 +1,23 @@
+int Accumulate()
+{
+ return 0;
+}
+
+template<typename T, typename... Ts>
+int Accumulate(T v, Ts... vs)
+{
+ return v + Accumulate(vs...);
+}
+
+template<int... Is>
+int CountElements()
+{
+ return sizeof...(Is);
+}
+
+int main()
+{
+ int acc = Accumulate(1, 2, 3, 4, -5);
+ int count = CountElements<1,2,3,4,5>();
+ return ((acc == 5) && (count == 5)) ? 0 : 1;
+}
diff --git a/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt b/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt
new file mode 100644
index 00000000..f117eb16
--- /dev/null
+++ b/cmake/cmake-cxx11/Tests/Module/CXX11Features/CMakeLists.txt
@@ -0,0 +1,33 @@
+cmake_minimum_required(VERSION 2.8.3 FATAL_ERROR)
+project(Cxx11Features CXX)
+
+list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/../../../Modules")
+
+include(CheckCXX11Features)
+
+foreach (flag IN ITEMS
+ HAS_CXX11_AUTO
+ HAS_CXX11_AUTO_RET_TYPE
+ HAS_CXX11_CLASS_OVERRIDE
+ HAS_CXX11_CONSTEXPR
+ HAS_CXX11_CSTDINT_H
+ HAS_CXX11_DECLTYPE
+ HAS_CXX11_FUNC
+ HAS_CXX11_INITIALIZER_LIST
+ HAS_CXX11_LAMBDA
+ HAS_CXX11_LIB_REGEX
+ HAS_CXX11_LONG_LONG
+ HAS_CXX11_NULLPTR
+ HAS_CXX11_RVALUE_REFERENCES
+ HAS_CXX11_SIZEOF_MEMBER
+ HAS_CXX11_STATIC_ASSERT
+ HAS_CXX11_VARIADIC_TEMPLATES
+ )
+ if (${flag})
+ add_definitions("-D${flag}")
+ message(STATUS "Compiler C++11 support flag ${flag} set")
+ endif ()
+endforeach (flag)
+
+set(CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS} ${CXX11_COMPILER_FLAGS})
+add_executable(CXX11Features cxx11features.cxx)
diff --git a/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx b/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx
new file mode 100644
index 00000000..c09038fb
--- /dev/null
+++ b/cmake/cmake-cxx11/Tests/Module/CXX11Features/cxx11features.cxx
@@ -0,0 +1,57 @@
+#if defined(HAS_CXX0X_CSTDINT_H)
+#include <cstdint>
+#endif
+
+#include <sys/types.h>
+
+struct thing {
+ unsigned char one;
+#if defined(HAS_CXX0X_CSTDINT_H)
+ uint32_t four;
+#endif
+#if defined(HAS_CXX0X_LONG_LONG)
+ long long eight;
+#endif
+};
+
+#include <stdio.h>
+
+int main()
+{
+#if defined (HAS_CXX0X_NULLPTR)
+ void *nix = nullptr;
+#else /* HAS_CXX0X_NULLPTR */
+ void *nix = 0;
+#endif /* HAS_CXX0X_NULLPTR */
+
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(1 < 42, "Your C++ compiler is b0rked");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+
+#if defined(HAS_CXX0X_FUNC)
+ const char *funcname = __func__;
+ printf("the name of main() function is: %s\n", funcname);
+#endif /* HAS_CXX0X_FUNC */
+
+#if defined(HAS_CXX0X_SIZEOF_MEMBER)
+ size_t onesize = sizeof(thing::one);
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(sizeof(thing::one) == 1, "Your char is not one byte long");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+
+#if defined(HAS_CXX0X_CSTDINT_H)
+ size_t foursize = sizeof(thing::four);
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(sizeof(thing::four) == 4, "Your uint32_t is not 32 bit long");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+#endif /* HAS_CXX0X_CSTDINT_H */
+#if defined(HAS_CXX0X_LONG_LONG)
+ size_t eightsize = sizeof(thing::eight);
+#if defined(HAS_CXX0X_STATIC_ASSERT)
+ static_assert(sizeof(thing::eight) == 8, "Your long long is not 64 bit long");
+#endif /* HAS_CXX0X_STATIC_ASSERT */
+#endif /* HAS_CXX0X_LONG_LONG */
+#endif /* HAS_CXX0X_SIZEOF_MEMBER */
+
+ return 0;
+}
diff --git a/cmake/config.hpp.cmake b/cmake/config.hpp.cmake
index afae3d16..a9edc34f 100644
--- a/cmake/config.hpp.cmake
+++ b/cmake/config.hpp.cmake
@@ -83,6 +83,8 @@ typedef unsigned @VMIME_64BIT_TYPE@ vmime_uint64;
#cmakedefine01 VMIME_HAVE_LOCALTIME_S
#cmakedefine01 VMIME_HAVE_LOCALTIME_R
#cmakedefine01 VMIME_HAVE_MLANG
+#cmakedefine01 VMIME_SHARED_PTR_USE_CXX
+#cmakedefine01 VMIME_SHARED_PTR_USE_BOOST
#define VMIME_SENDMAIL_PATH "@VMIME_SENDMAIL_PATH@"
diff --git a/doc/book/basics.tex b/doc/book/basics.tex
index 9c129912..ac66959e 100644
--- a/doc/book/basics.tex
+++ b/doc/book/basics.tex
@@ -6,7 +6,7 @@
\subsection{Introduction} % --------------------------------------------------
Since version 0.7.2cvs, VMime use smart pointers to simplify memory
-management. VMime's smart pointer implementation relies on
+management. Smart pointers rely on
RAII\footnote{Ressource Allocation is Initialisation} so that we do not need
to bother with deleting an object (freeing memory) when it is not used
anymore.
@@ -21,8 +21,20 @@ An object is destroyed as soon as the last strong reference to it is released.
At the same tine, all weak references (if any) are automatically set to point
to \vnull.
-In VMime, these two types of references are known as {\vcode vmime::ref}
-and {\vcode vmime::weak\_ref}, respectively.
+In VMime, these two types of references are known as {\vcode vmime::shared\_ptr}
+and {\vcode vmime::weak\_ptr}, respectively.
+
+\vnote{since November 2013, we switched from an old, intrusive implementation
+of smart pointers to a more standard one: either Boost {\vcode shared\_ptr<>}
+implementation or standard C++ one if we are compiling in C++11. Here are the
+changes:
+
+{\vcode vmime::ref <>} is replaced with {\vcode vmime::shared\_ptr <>}
+
+{\vcode vmime::weak\_ref <>} is replaced with {\vcode vmime::weak\_ptr <>}
+
+{\vcode vmime::create <>} is replaced with {\vcode vmime::make\_shared <>}
+}
\subsection{Instanciating reference-counted objects} % -----------------------
@@ -30,7 +42,7 @@ In VMime, all objects that support reference counting inherit from the
{\vcode vmime::object} class, which is responsible for
incrementing/decrementing the counter and managing the object's life cycle.
If you want to create a smart pointer to a new object instance, you should
-use the function {\vcode vmime::create} instead of the {\vcode new}
+use the function {\vcode vmime::make\_shared} instead of the {\vcode new}
operator.
\begin{lstlisting}[caption={Smarts pointers and creating objects}]
@@ -55,8 +67,8 @@ private:
int main()
{
- vmime::ref <myObject> obj =
- vmime::create <myObject>("world");
+ vmime::shared_ptr <myObject> obj =
+ vmime::make_shared <myObject>("world");
obj->sayHello();
@@ -72,20 +84,20 @@ you would use normal ("raw") C++ pointers (eg. you can write
\lstinline{!ptr, ptr != NULL, ptr->method(), *ptr}...).
Type safety is also guaranteed, and you can type cast smart pointers using
-the {\vcode staticCast()}, {\vcode dynamicCast()} and {\vcode constCast()}
-equivalents on {\vcode vmime::ref} and {\vcode vmime::weak\_ref} objects:
+the {\vcode static\_cast()}, {\vcode dynamic\_cast()} and {\vcode const\_cast()}
+equivalents on {\vcode vmime::shared\_ptr} and {\vcode vmime::weak\_ptr} objects:
\begin{lstlisting}[caption={Casting smart pointers}]
class myBase : public vmime::object { }
class myObject : public myBase { }
-vmime::ref <myObject> obj = vmime::create <myObject>();
+vmime::shared_ptr <myObject> obj = vmime::make_shared <myObject>();
// Implicit downcast
-vmime::ref <myBase> base = obj;
+vmime::shared_ptr <myBase> base = obj;
// Explicit upcast
-vmime::ref <myObject> obj2 = base.dynamicCast <myObject>();
+vmime::shared_ptr <myObject> obj2 = vmime::dynamicCast <myObject>(base);
\end{lstlisting}
Weak references are used to resolve reference cycles (an object which refers
@@ -97,34 +109,34 @@ class parent : public vmime::object
{
public:
- void createChild(vmime::ref <child> c)
+ void createChild(vmime::shared_ptr <child> c)
{
m_child = c;
}
private:
- vmime::ref <child> m_child;
+ vmime::shared_ptr <child> m_child;
};
class child : public vmime::object
{
public:
- child(vmime::ref <parent> p)
+ child(vmime::shared_ptr <parent> p)
: m_parent(p)
{
}
private:
- vmime::ref <parent> m_parent;
+ vmime::shared_ptr <parent> m_parent;
};
int main()
{
- vmime::ref <parent> p = vmime::create <parent>();
- vmime::ref <child> c = vmime::create <child>();
+ vmime::shared_ptr <parent> p = vmime::make_shared <parent>();
+ vmime::shared_ptr <child> c = vmime::make_shared <child>();
p->setChild(c);
}
@@ -136,7 +148,7 @@ exiting {\vcode main()}. That's because {\vcode p} indirectly points to itself
reference to the parent:
\begin{lstlisting}
-vmime::weak_ref <parent> m_parent;
+vmime::weak_ptr <parent> m_parent;
\end{lstlisting}
The decision to make the parent or the child a weak reference is purely
@@ -216,7 +228,7 @@ provides additional functions to get some information about the parsing
process or the structure (methods {\vcode getParsedOffset()},
{\vcode getParsedLength()} and {\vcode getChildComponents()}).
-Vmime also provides a set of classes corresponding to the basic types found
+VMime also provides a set of classes corresponding to the basic types found
in a message; for example a mailbox, a mailbox list, date/time information,
media type, etc. They all inherit from {\vcode component} too.
@@ -284,12 +296,12 @@ an email address (mandatory) and possibly a name. A mailbox group is simply
a named list of mailboxes (see Figure \ref{uml_addr_mbox_mboxgroup}).
\begin{lstlisting}[caption={Using mailboxes and mailbox groups}]
-vmime::ref <vmime::mailbox> mbox1 = vmime::create <vmime::mailbox>
+vmime::shared_ptr <vmime::mailbox> mbox1 = vmime::make_shared <vmime::mailbox>
(/* name */ vmime::text("John Doe"), /* email */ "[email protected]");
-vmime::ref <vmime::mailbox> mbox2 = vmime::create <vmime::mailbox>
+vmime::shared_ptr <vmime::mailbox> mbox2 = vmime::make_shared <vmime::mailbox>
(/* no name, email only */ "[email protected]");
-vmime::ref <vmime::mailboxGroup> grp = vmime::create <vmime::mailboxGroup>();
+vmime::shared_ptr <vmime::mailboxGroup> grp = vmime::make_shared <vmime::mailboxGroup>();
grp->appendMailbox(mbox1);
grp->appendMailbox(mbox2);
\end{lstlisting}
@@ -402,12 +414,11 @@ convert automatically from basic types to text, and \emph{vice versa}. The
following example illustrates it:
\begin{lstlisting}[caption={Getting and setting parameter value in fields}]
-vmime::ref <vmime::parameterizedField> field =
- header->findField("X-Field-That-Contains-Parameters")
- .dynamicCast <vmime::parameterizedField>();
+vmime::shared_ptr <vmime::parameterizedField> field =
+ header->findField <vmime::parameterizedField>("X-Field-That-Contains-Parameters");
// Use setValue() to convert from a basic type to 'text'
-vmime::ref <vmime::parameter> prm = field->getParameter("my-date-param");
+vmime::shared_ptr <vmime::parameter> prm = field->getParameter("my-date-param");
prm->setValue(vmime::datetime::now());
// Use getValueAs() to convert from 'text' to a basic type
@@ -421,12 +432,11 @@ Table \ref{standard-prm-fields}). This avoids finding the parameter and
illustrates how to use it:
\begin{lstlisting}
-vmime::ref <vmime::contentTypeField> field =
- header->getField(vmime::fields::CONTENT_TYPE)
- .dynamicCast <vmime::contentTypeField>();
+vmime::shared_ptr <vmime::contentTypeField> field =
+ header->getField <vmime::contentTypeField>(vmime::fields::CONTENT_TYPE);
// 1. First solution: the "hard" way
-vmime::ref <vmime::parameter> prm = field->findParameter("charset");
+vmime::shared_ptr <vmime::parameter> prm = field->findParameter("charset");
const charset ch1 = prm->getValueAs <vmime::charset>();
// 2. Second solution: the simple way
@@ -541,11 +551,11 @@ writing it to the standard output with charset conversion:
\begin{lstlisting}[caption={Using content handlers to extract body text from
a message}]
// Suppose we already have a message
-vmime::ref <vmime::message> msg;
+vmime::shared_ptr <vmime::message> msg;
// Obtains a reference to the body contents
-vmime::ref <vmime::body> body = msg->getBody();
-vmime::ref <vmime::contentHandler> cts = body->getContents();
+vmime::shared_ptr <vmime::body> body = msg->getBody();
+vmime::shared_ptr <vmime::contentHandler> cts = body->getContents();
vmime::utility::outputStreamAdapter out(std::cout);
cts->extract(out);
@@ -563,11 +573,11 @@ if you want to set the contents of a body part. The following code snippet
shows how to set the body text of a part from a string:
\begin{lstlisting}[caption={Setting the contents of a body part}]
-vmime::ref <vmime::bodyPart> part; // suppose we have a body part
+vmime::shared_ptr <vmime::bodyPart> part; // suppose we have a body part
// Create a new content handler from a string
-vmime::ref <vmime::contentHandler> cth =
- vmime::create <vmime::stringContentHandler>("Put body contents here");
+vmime::shared_ptr <vmime::contentHandler> cth =
+ vmime::make_shared <vmime::stringContentHandler>("Put body contents here");
// Set the contents
part->getBody()->setContents(cth);
@@ -585,18 +595,18 @@ fileStream->open("/home/vincent/paris.jpg", std::ios::binary);
if (!*fileStream)
// handle error
-vmime::ref <utility::stream> dataStream =
- vmime::create <vmime::utility::inputStreamPointerAdapter>(fileStream);
+vmime::shared_ptr <utility::stream> dataStream =
+ vmime::make_shared <vmime::utility::inputStreamPointerAdapter>(fileStream);
// NOTE: 'fileStream' will be automatically deleted
// when 'dataStream' is deleted
// Create a new content handler
-vmime::ref <contentHandler> data =
- vmime::create <vmime::streamContentHandler>(dataStream, 0);
+vmime::shared_ptr <contentHandler> data =
+ vmime::make_shared <vmime::streamContentHandler>(dataStream, 0);
// Now create the attachment
-ref <vmime::attachment> att = vmime::create <vmime::defaultAttachment>
+ref <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
(
/* attachment data */ data,
/* content type */ vmime::mediaType("image/jpeg"),
@@ -627,11 +637,11 @@ to UTF-8 charset:
\begin{lstlisting}[caption={Extracting and converting body contents to a
specified charset}]
-vmime::ref <vmime::message> msg; // we have a message
+vmime::shared_ptr <vmime::message> msg; // we have a message
// Obtain the content handler first
-vmime::ref <vmime::body> body = msg->getBody();
-vmime::ref <const vmime::contentHandler> cth = body->getContents();
+vmime::shared_ptr <vmime::body> body = msg->getBody();
+vmime::shared_ptr <const vmime::contentHandler> cth = body->getContents();
// Then, extract and convert the contents
vmime::utility::outputStreamAdapter out(std::cout);
@@ -676,7 +686,7 @@ outText.createFromString(inText, inCharset);
// . <utf-8> "t�l�phone "
// . <us-ascii> "mobile"
-vmime::ref <vmime::header> header = myMessage->getHeader();
+vmime::shared_ptr <vmime::header> header = myMessage->getHeader();
header->Subject()->setValue(outText);
\end{lstlisting}
@@ -707,7 +717,7 @@ text stored in the Subject field of a message:
\begin{lstlisting}[caption={Converting data in a {\vcode vmime::text} to a
specified charset}]
-vmime::ref <vmime::message> msg; // we have a message
+vmime::shared_ptr <vmime::message> msg; // we have a message
vmime::text subject = msg->getHeader()->Subject()->getValue();
@@ -739,7 +749,7 @@ The following example creates an instance of the Base64 encoder to encode
some data:
\begin{lstlisting}[caption={A simple example of using an encoder}]
-vmime::ref <vmime::utility::encoder::encoder> enc =
+vmime::shared_ptr <vmime::utility::encoder::encoder> enc =
vmime::utility::encoder::encoderFactory::getInstance()->create("base64");
vmime::string inString("Some data to encode");
@@ -761,7 +771,7 @@ an excerpt from {\vexample example6}} enumerates available encoders and the
supported properties for each of them:
\begin{lstlisting}[caption={Enumerating encoders and their properties}]
-vmime::utility::encoder::encoderFactory* ef =
+vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
vmime::utility::encoder::encoderFactory::getInstance();
std::cout << "Available encoders:" << std::endl;
@@ -769,13 +779,13 @@ std::cout << "Available encoders:" << std::endl;
for (int i = 0 ; i < ef->getEncoderCount() ; ++i)
{
// Output encoder name
- vmime::ref <const vmime::utility::encoder::encoderFactory::registeredEncoder>
+ vmime::shared_ptr <const vmime::utility::encoder::encoderFactory::registeredEncoder>
enc = ef->getEncoderAt(i);
std::cout << " * " << enc->getName() << std::endl;
// Create an instance of the encoder to get its properties
- vmime::ref <vmime::utility::encoder::encoder> e = enc->create();
+ vmime::shared_ptr <vmime::utility::encoder::encoder> e = enc->create();
std::vector <vmime::string> props = e->getAvailableProperties();
std::vector <vmime::string>::const_iterator it;
diff --git a/doc/book/building.tex b/doc/book/building.tex
index c96e95db..a34db5ba 100644
--- a/doc/book/building.tex
+++ b/doc/book/building.tex
@@ -16,13 +16,16 @@ To build VMime from the sources, you will need the following:
\item a working C++ compiler with good STL implementation and also a good
support for templates (for example, \href{http://gcc.gnu.org/}{GNU GCC}) ;
\item \href{http://www.cmake.org/}{CMake} build system ;
-\item an usable iconv() implementation (see
+\item either \href{http://www.icu-project.org}{ICU library} or an usable
+{\vcode iconv()} implementation (see
\href{http://www.gnu.org/software/libiconv/}{libiconv of GNU Project}) ;
\item the \href{http://www.gnu.org/software/gsasl/}{GNU SASL Library} if you
want SASL\footnote{Simple Authentication and Security Layer} support ;
\item either the \href{http://www.openssl.org}{OpenSSL library} or the
\href{http://www.gnu.org/software/gnutls/}{GNU TLS Library} if you
want SSL and TLS\footnote{Transport Layer Security} support ;
+\item the \href{http://www.boost.org}{Boost C++ library} if you are not using
+C++11 (or your compiler does not support it), for {\vcode shared\_ptr<>}.
\end{itemize}
% ============================================================================
@@ -113,3 +116,41 @@ the library into the default location (ie: /usr/lib and /usr/include).}
Now, you are done! You can jump to the next chapter to know how to use VMime
in your program...
+% ============================================================================
+\section{Build options}
+
+Some options can be given to CMake to control the build:
+
+\begin{table}[!ht]
+\noindent\begin{tabularx}{1.0\textwidth}{|l|X|}
+\hline
+ {\bf Option name} &
+ {\bf Description} \\
+\hline
+\hline
+VMIME\_BUILD\_SHARED\_LIBRARY &
+Set to ON to build a shared version (.so) of the library (default is ON). \\
+\hline
+VMIME\_BUILD\_STATIC\_LIBRARY &
+Set to ON to build a static version (.a) of the library (default is ON). \\
+\hline
+VMIME\_BUILD\_TESTS &
+Set to ON to build unit tests (default is OFF). \\
+\hline
+VMIME\_TLS\_SUPPORT\_LIB\_IS\_OPENSSL \\ VMIME\_TLS\_SUPPORT\_LIB\_IS\_GNUTLS &
+Set either the one or the other (but not both) to ON to force using either OpenSSL
+or GNU TLS as the SSL library (default depends on which libraries are available on
+your system). \\
+\hline
+VMIME\_CHARSETCONV\_LIB\_IS\_ICONV \\ VMIME\_CHARSETCONV\_LIB\_IS\_ICU &
+Set either the one or the other (but not both) to ON to force using either iconv
+or ICU as the charset conversion library (default depends on which libraries are
+available on your system). \\
+\hline
+CMAKE\_BUILD\_TYPE &
+Set the build type: either "Release" or "Debug". In Debug build, optimizations
+are disabled and debugging information are enabled. \\
+\hline
+\end{tabularx}
+\caption{CMake build options}
+\end{table}
diff --git a/doc/book/msg.tex b/doc/book/msg.tex
index 384aab74..50344b62 100644
--- a/doc/book/msg.tex
+++ b/doc/book/msg.tex
@@ -36,22 +36,22 @@ vmime::utility::outputStreamStringAdapter os(data);
vmime::utility::bufferedStreamCopy(is, os);
// Actually parse the message
-vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
-vmime::ref <vmime::header> hdr = msg->getHeader();
-vmime::ref <vmime::body> bdy = msg->getBody();
+vmime::shared_ptr <vmime::header> hdr = msg->getHeader();
+vmime::shared_ptr <vmime::body> bdy = msg->getBody();
// Now, you can extract some of its components
vmime::charset ch(vmime::charsets::UTF_8);
std::cout
<< "The subject of the message is: "
- << hdr->Subject()->getValue().dynamicCast <vmime::text>()->getConvertedText(ch)
+ << hdr->Subject()->getValue <vmime::text>()->getConvertedText(ch)
<< std::endl
<< "It was sent by: "
- << hdr->From()->getValue().dynamicCast <vmime::mailbox>()->getName().getConvertedText(ch)
- << " (email: " << hdr->From()->getValue().dynamicCast<vmime::mailbox>()->getEmail() << ")"
+ << hdr->From()->getValue <vmime::mailbox>()->getName().getConvertedText(ch)
+ << " (email: " << hdr->From()->getValue <vmime::mailbox>()->getEmail() << ")"
<< std::endl;
\end{lstlisting}
@@ -84,7 +84,7 @@ vmime::utility::outputStreamStringAdapter os(data);
vmime::utility::bufferedStreamCopy(is, os);
// Actually parse the message
-vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
// Here start the differences with the previous example
@@ -96,7 +96,7 @@ std::cout << "Message has " << mp.getAttachmentCount()
for (int i = 0 ; i < mp.getAttachmentCount() ; ++i)
{
- vmime::ref <const vmime::attachment> att = mp.getAttachmentAt(i);
+ vmime::shared_ptr <const vmime::attachment> att = mp.getAttachmentAt(i);
std::cout << " - " << att->getType().generate() << std::endl;
}
@@ -106,13 +106,13 @@ std::cout << "Message has " << mp.getTextPartCount()
for (int i = 0 ; i < mp.getTextPartCount() ; ++i)
{
- vmime::ref <const vmime::textPart> tp = mp.getTextPartAt(i);
+ vmime::shared_ptr <const vmime::textPart> tp = mp.getTextPartAt(i);
// text/html
if (tp->getType().getSubType() == vmime::mediaTypes::TEXT_HTML)
{
- vmime::ref <const vmime::htmlTextPart> htp =
- tp.dynamicCast <const vmime::htmlTextPart>();
+ vmime::shared_ptr <const vmime::htmlTextPart> htp =
+ vmime::dynamicCast <const vmime::htmlTextPart>(tp);
// HTML text is in tp->getText()
// Plain text is in tp->getPlainText()
@@ -120,7 +120,7 @@ for (int i = 0 ; i < mp.getTextPartCount() ; ++i)
// Enumerate embedded objects
for (int j = 0 ; j < htp->getObjectCount() ; ++j)
{
- vmime::ref <const vmime::htmlTextPart::embeddedObject> obj =
+ vmime::shared_ptr <const vmime::htmlTextPart::embeddedObject> obj =
htp->getObjectAt(j);
// Identifier (Content-Id or Content-Location) is obj->getId()
@@ -146,51 +146,51 @@ objects that compose it (parts, fields, etc.). The following is an example of
how to achieve it:
\begin{lstlisting}[caption={Building a simple message from scratch}]
-vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
-vmime::ref <vmime::header> hdr = msg->getHeader();
-vmime::ref <vmime::body> bdy = msg->getBody();
+vmime::shared_ptr <vmime::header> hdr = msg->getHeader();
+vmime::shared_ptr <vmime::body> bdy = msg->getBody();
-vmime::headerFieldFactory* hfFactory =
+vmime::shared_ptr <vmime::headerFieldFactory> hfFactory =
vmime::headerFieldFactory::getInstance();
// Append a 'Date:' field
-vmime::ref <vmime::headerField> dateField =
+vmime::shared_ptr <vmime::headerField> dateField =
hfFactory->create(vmime::fields::DATE);
dateField->setValue(vmime::datetime::now());
hdr->appendField(dateField);
// Append a 'Subject:' field
-vmime::ref <vmime::headerField> subjectField =
+vmime::shared_ptr <vmime::headerField> subjectField =
hfFactory->create(vmime::fields::SUBJECT);
subjectField->setValue(vmime::text("Message subject"));
hdr->appendField(subjectField);
// Append a 'From:' field
-vmime::ref <vmime::headerField> fromField =
+vmime::shared_ptr <vmime::headerField> fromField =
hfFactory->create(vmime::fields::FROM);
fromField->setValue
- (vmime::create <vmime::mailbox>("[email protected]"));
+ (vmime::make_shared <vmime::mailbox>("[email protected]"));
hdr->appendField(fromField);
// Append a 'To:' field
-vmime::ref <vmime::headerField> toField =
+vmime::shared_ptr <vmime::headerField> toField =
hfFactory->create(vmime::fields::TO);
-vmime::ref <vmime::mailboxList> recipients =
- vmime::create <vmime::mailboxList>();
+vmime::shared_ptr <vmime::mailboxList> recipients =
+ vmime::make_shared <vmime::mailboxList>();
recipients->appendMailbox
- (vmime::create <vmime::mailbox>("[email protected]"));
+ (vmime::make_shared <vmime::mailbox>("[email protected]"));
toField->setValue(recipients);
hdr->appendField(toField);
// Set the body contents
-bdy->setContents(vmime::create <vmime::stringContentHandler>
+bdy->setContents(vmime::make_shared <vmime::stringContentHandler>
("This is the text of your message..."));
// Output raw message data to standard output
@@ -215,14 +215,14 @@ try
mb.setSubject(vmime::text("Message subject"));
mb.setExpeditor(vmime::mailbox("[email protected]"));
mb.getRecipients().appendAddress
- (vmime::create <vmime::mailbox>("[email protected]"));
+ (vmime::make_shared <vmime::mailbox>("[email protected]"));
mb.getTextPart()->setCharset(vmime::charsets::ISO8859_15);
- mb.getTextPart()->setText(vmime::create <vmime::stringContentHandler>
+ mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>
("This is the text of your message..."));
// Message construction
- vmime::ref <vmime::message> msg = mb.construct();
+ vmime::shared_ptr <vmime::message> msg = mb.construct();
// Output raw message data to standard output
vmime::utility::outputStreamAdapter out(std::cout);
@@ -249,8 +249,8 @@ previous example to attach a file to the message:
\begin{lstlisting}[caption={Building a message with an attachment using
{\vcode vmime::messageBuilder}}]
// Create an attachment
-vmime::ref <vmime::fileAttachment> att =
- vmime::create <vmime::fileAttachment>
+vmime::shared_ptr <vmime::fileAttachment> att =
+ vmime::make_shared <vmime::fileAttachment>
(
/* full path to file */ "/home/vincent/paris.jpg",
/* content type */ vmime::mediaType("image/jpeg),
@@ -284,7 +284,7 @@ using the {\vcode vmime::messageBuilder}}]
mb.setSubject(vmime::text("An HTML message"));
mb.setExpeditor(vmime::mailbox("[email protected]"));
mb.getRecipients().appendAddress
- (vmime::create <vmime::mailbox>("[email protected]"));
+ (vmime::make_shared <vmime::mailbox>("[email protected]"));
// Set the content-type to "text/html": a text part factory must be
// available for the type you are using. The following code will make
@@ -294,8 +294,8 @@ mb.constructTextPart(vmime::mediaType
// Set contents of the text parts; the message is available in two formats:
// HTML and plain text. The HTML format also includes an embedded image.
-vmime::ref <vmime::htmlTextPart> textPart =
- mb.getTextPart().dynamicCast <vmime::htmlTextPart>();
+vmime::shared_ptr <vmime::htmlTextPart> textPart =
+ vmime::dynamicCast <vmime::htmlTextPart>(mb.getTextPart());
// -- Add the JPEG image (the returned identifier is used to identify the
// -- embedded object in the HTML text, the famous "CID", or "Content-Id").
@@ -306,11 +306,11 @@ const vmime::string id = textPart->addObject("<...image data...>",
// -- Set the text
textPart->setCharset(vmime::charsets::ISO8859_15);
-textPart->setText(vmime::create <vmime::stringContentHandler>
+textPart->setText(vmime::make_shared <vmime::stringContentHandler>
("This is the <b>HTML text</b>, and the image:<br/>"
"<img src=\"") + id + vmime::string("\"/>"));
-textPart->setPlainText(vmime::create <vmime::stringContentHandler>
+textPart->setPlainText(vmime::make_shared <vmime::stringContentHandler>
("This is the plain text."));
\end{lstlisting}
@@ -332,11 +332,11 @@ input stream, then add an embedded object:
vmime::utility::fileSystemFactory* fs =
vmime::platform::getHandler()->getFileSystemFactory();
-vmime::ref <vmime::utility::file> imageFile =
+vmime::shared_ptr <vmime::utility::file> imageFile =
fs->create(fs->stringToPath("/path/to/image.jpg"));
-vmime::ref <vmime::contentHandler> imageCts =
- vmime::create <vmime::streamContentHandler>
+vmime::shared_ptr <vmime::contentHandler> imageCts =
+ vmime::make_shared <vmime::streamContentHandler>
(imageFile->getFileReader()->getInputStream(), imageFile->getLength());
const vmime::string cid = textPart.addObject(imageCts,
@@ -359,12 +359,12 @@ The following code snippet tests if a body part is an attachment, and if so,
extract its contents to the standard output:
\begin{lstlisting}[caption={Testing if a body part is an attachment}]
-vmime::ref <vmime::bodyPart> part; // suppose we have a body part
+vmime::shared_ptr <vmime::bodyPart> part; // suppose we have a body part
if (vmime::attachmentHelper::isBodyPartAnAttachment(part))
{
// The body part contains an attachment, get it
- vmime::ref <const vmime::attachment> attach =
+ vmime::shared_ptr <const vmime::attachment> attach =
attachmentHelper::getBodyPartAttachment(part);
// Extract attachment data to standard output
@@ -376,7 +376,7 @@ if (vmime::attachmentHelper::isBodyPartAnAttachment(part))
You can also easily extract all attachments from a message:
\begin{lstlisting}[caption={Extracting all attachments from a message}]
-vmime::ref <vmime::message> msg; // suppose we have a message
+vmime::shared_ptr <vmime::message> msg; // suppose we have a message
const std::vector <ref <const attachment> > atts =
attachmentHelper::findAttachmentsInMessage(msg);
@@ -390,11 +390,11 @@ exists in the message). Simply call the {\vcode addAttachment}
function:
\begin{lstlisting}[caption={Adding an attachment to an existing message}]
-vmime::ref <vmime::message> msg; // suppose we have a message
+vmime::shared_ptr <vmime::message> msg; // suppose we have a message
// Create an attachment
-vmime::ref <vmime::fileAttachment> att =
- vmime::create <vmime::fileAttachment>
+vmime::shared_ptr <vmime::fileAttachment> att =
+ vmime::make_shared <vmime::fileAttachment>
(
/* full path to file */ "/home/vincent/paris.jpg",
/* content type */ vmime::mediaType("image/jpeg),
diff --git a/doc/book/net.tex b/doc/book/net.tex
index 88249c1c..05145cf5 100644
--- a/doc/book/net.tex
+++ b/doc/book/net.tex
@@ -68,7 +68,7 @@ services. Before using a messaging service, you must create and
initialize a session object:
\begin{lstlisting}
-vmime::ref <net::session> theSession = vmime::create <net::session>();
+vmime::shared_ptr <net::session> theSession = vmime::make_shared <net::session>();
\end{lstlisting}
Session properties include:
@@ -251,14 +251,14 @@ Depending on the type of service, you will use either {\vcode getStore()} or
\begin{lstlisting}
vmime::utility:url url("imap://user:[email protected]");
-vmime::ref <vmime::net::store> st = sess->getStore(url);
+vmime::shared_ptr <vmime::net::store> st = sess->getStore(url);
\end{lstlisting}
and for transport services:
\begin{lstlisting}
vmime::utility:url url("smtp://smtp.example.com");
-vmime::ref <vmime::net::transport> tr = sess->getTransport(url);
+vmime::shared_ptr <vmime::net::transport> tr = sess->getTransport(url);
\end{lstlisting}
@@ -271,7 +271,7 @@ properties or by using a custom authenticator (callback).
\begin{lstlisting}[caption={Setting user credentials using session
properties}]
-vmime::ref <vmime::net::session> sess; // Suppose we have a session
+vmime::shared_ptr <vmime::net::session> sess; // Suppose we have a session
sess->getProperties()["store.imap.auth.username"] = "vincent";
sess->getProperties()["store.imap.auth.password"] = "my-password";
@@ -328,13 +328,13 @@ This is how to use it:
\begin{lstlisting}
// First, create a session
-vmime::ref <vmime::net::session> sess =
- vmime::create <vmime::net::session>();
+vmime::shared_ptr <vmime::net::session> sess =
+ vmime::make_shared <vmime::net::session>();
// Next, initialize a service which will use our authenticator
-vmime::ref <vmime::net::store> st =
+vmime::shared_ptr <vmime::net::store> st =
sess->getStore(vmime::utility::url("imap://imap.example.com"),
- /* use our authenticator */ vmime::create <myAuthenticator>());
+ /* use our authenticator */ vmime::make_shared <myAuthenticator>());
\end{lstlisting}
\vnote{An authenticator object should be used with one and only one service
@@ -359,9 +359,9 @@ class mySASLAuthenticator : public vmime::security::sasl::defaultSASLAuthenticat
{
typedef vmime::security::sasl::SASLMechanism mechanism; // save us typing
- const std::vector <vmime::ref <mechanism > getAcceptableMechanisms
- (const std::vector <vmime::ref <mechanism> >& available,
- vmime::ref <mechanism> suggested) const
+ const std::vector <vmime::shared_ptr <mechanism> > getAcceptableMechanisms
+ (const std::vector <vmime::shared_ptr <mechanism> >& available,
+ vmime::shared_ptr <mechanism> suggested) const
{
// Here, you can sort the SASL mechanisms in the order they will be
// tried. If no SASL mechanism is acceptable (ie. for example, not
@@ -373,7 +373,7 @@ class mySASLAuthenticator : public vmime::security::sasl::defaultSASLAuthenticat
getAcceptableMechanisms(available, suggested);
}
- void setSASLMechanism(vmime::ref <mechanism> mech)
+ void setSASLMechanism(vmime::shared_ptr <mechanism> mech)
{
// This is called when the authentication process is going to
// try the specified mechanism.
@@ -417,11 +417,11 @@ const vmime::string msgData =
// Create a new session
vmime::utility::url url("smtp://example.com");
-vmime::ref <vmime::net::session> sess =
- vmime::create <vmime::net::session>();
+vmime::shared_ptr <vmime::net::session> sess =
+ vmime::make_shared <vmime::net::session>();
// Create an instance of the transport service
-vmime::ref <vmime::net::transport> tr = sess->getTransport(url);
+vmime::shared_ptr <vmime::net::transport> tr = sess->getTransport(url);
// Connect it
tr->connect();
@@ -431,7 +431,7 @@ vmime::utility::inputStreamStringAdapter is(msgData);
vmime::mailbox from("[email protected]");
vmime::mailboxList to;
-to.appendMailbox(vmime::create <vmime::mailbox>("[email protected]"));
+to.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]"));
tr->send(
/* expeditor */ from,
@@ -471,11 +471,11 @@ store service:
// Create a new session
vmime::utility::url url("imap://vincent:password@imap:example.org");
-vmime::ref <vmime::net::session> sess =
- vmime::create <vmime::net::session>();
+vmime::shared_ptr <vmime::net::session> sess =
+ vmime::make_shared <vmime::net::session>();
// Create an instance of the transport service
-vmime::ref <vmime::net::store> store = sess->getStore(url);
+vmime::shared_ptr <vmime::net::store> store = sess->getStore(url);
// Connect it
store->connect();
@@ -514,7 +514,7 @@ vmime::net::folder::path path;
path /= vmime::net::folder::path::component("foo");
path /= vmime::net::folder::path::component("bar");
-vmime::ref <vmime::net::folder> fld = store->getFolder(path);
+vmime::shared_ptr <vmime::net::folder> fld = store->getFolder(path);
fld->open(vmime::net::folder::MODE_READ_WRITE);
\end{lstlisting}
@@ -565,7 +565,7 @@ folder->fetchMessages(allMessages,
for (unsigned int i = 0 ; i < allMessages.size() ; ++i)
{
- vmime::ref <vmime::net::message> msg = allMessages[i];
+ vmime::shared_ptr <vmime::net::message> msg = allMessages[i];
const int flags = msg->getFlags();
@@ -576,7 +576,7 @@ for (unsigned int i = 0 ; i < allMessages.size() ; ++i)
if (flags & vmime::net::message::FLAG_DELETED)
std::cout << " - is deleted" << std::endl;
- vmime::ref <const vmime::header> hdr = msg->getHeader();
+ vmime::shared_ptr <const vmime::header> hdr = msg->getHeader();
std::cout << " - sent on " << hdr->Date()->generate() << std::endl;
std::cout << " - sent by " << hdr->From()->generate() << std::endl;
@@ -606,8 +606,8 @@ following example extracts the first message in the default folder:
\begin{lstlisting}[caption={Extracting messages}]
// Get a reference to the folder and to its first message
-vmime::ref <vmime::net::folder> folder = store->getDefaultFolder();
-vmime::ref <vmime::net::message> msg = folder->getMessage(1);
+vmime::shared_ptr <vmime::net::folder> folder = store->getDefaultFolder();
+vmime::shared_ptr <vmime::net::message> msg = folder->getMessage(1);
// Write the message contents to the standard output
vmime::utility::outputStreamAdapter out(std::cout);
@@ -643,7 +643,7 @@ The following example will delete the second and the third message from the
store.
\begin{lstlisting}[caption={Deleting messages}]
-vmime::ref <vmime::net::folder> folder = store->getDefaultFolder();
+vmime::shared_ptr <vmime::net::folder> folder = store->getDefaultFolder();
folder->deleteMessages(vmime::net::messageSet::byNumber(/* from */ 2, /* to */ 3));
@@ -785,7 +785,7 @@ public:
ref <timeoutHandler> create()
{
- return vmime::create <myTimeoutHandler>();
+ return vmime::make_shared <myTimeoutHandler>();
}
};
\end{lstlisting}
@@ -794,7 +794,7 @@ Then, call the {\vcode setTimeoutHandlerFactory()} method on the service object
to set the time-out handler factory to use during the session:
\begin{lstlisting}
-theService->setTimeoutHandlerFactory(vmime::create <myTimeoutHandlerFactory>());
+theService->setTimeoutHandlerFactory(vmime::make_shared <myTimeoutHandlerFactory>());
\end{lstlisting}
@@ -846,7 +846,7 @@ to connect to the server (eg. \emph{imaps} instead of \emph{imap}). This is
currently available for SMTP, POP3 and IMAP.
\begin{lstlisting}
-vmime::ref <vmime::net::store> store =
+vmime::shared_ptr <vmime::net::store> store =
theSession->getStore(vmime::utility::url("imaps://example.org"));
\end{lstlisting}
@@ -913,7 +913,7 @@ at the current time;
First, we need some code to load existing X.509 certificates:
\begin{lstlisting}[caption={Reading a X.509 certificate from a file}]
-vmime::ref <vmime::security::cert::X509Certificate>
+vmime::shared_ptr <vmime::security::cert::X509Certificate>
loadX509CertificateFromFile(const std::string& path)
{
std::ifstream certFile;
@@ -925,7 +925,7 @@ vmime::ref <vmime::security::cert::X509Certificate>
}
vmime::utility::inputStreamAdapter is(certFile);
- vmime::ref <vmime::security::cert::X509Certificate> cert;
+ vmime::shared_ptr <vmime::security::cert::X509Certificate> cert;
// Try DER format
cert = vmime::security::cert::X509Certificate::import
@@ -947,11 +947,11 @@ Then, we can use the {\vcode loadX509CertificateFromFile} function to load
certificates and initialize the certificate verifier:
\begin{lstlisting}[caption={Using the default certificate verifier}]
-vmime::ref <vmime::security::cert::defaultCertificateVerifier> vrf =
- vmime::create <vmime::security::cert::defaultCertificateVerifier>();
+vmime::shared_ptr <vmime::security::cert::defaultCertificateVerifier> vrf =
+ vmime::make_shared <vmime::security::cert::defaultCertificateVerifier>();
// Load root CAs (such as Verisign or Thawte)
-std::vector <vmime::ref <vmime::security::cert::X509Certificate> > rootCAs;
+std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> > rootCAs;
rootCAs.push_back(loadX509CertificateFromFile("/path/to/root-ca1.cer");
rootCAs.push_back(loadX509CertificateFromFile("/path/to/root-ca2.cer");
@@ -960,7 +960,7 @@ rootCAs.push_back(loadX509CertificateFromFile("/path/to/root-ca3.cer");
vrf->setX509RootCAs(rootCAs);
// Then, load certificates that the user explicitely chose to trust
-std::vector <vmime::ref <vmime::security::cert::X509Certificate> > trusted;
+std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> > trusted;
trusted.push_back(loadX509CertificateFromFile("/path/to/trusted-site1.cer");
trusted.push_back(loadX509CertificateFromFile("/path/to/trusted-site2.cer");
@@ -988,10 +988,10 @@ class myCertVerifier : public vmime::security::cert::certificateVerifier
{
public:
- void verify(vmime::ref <certificateChain> certs)
+ void verify(vmime::shared_ptr <certificateChain> certs)
{
// Obtain the subject's certificate
- vmime::ref <vmime::security::cert::certificate> cert = chain->getAt(0);
+ vmime::shared_ptr <vmime::security::cert::certificate> cert = chain->getAt(0);
std::cout << std::endl;
std::cout << "Server sent a '" << cert->getType() << "'"
@@ -1018,7 +1018,7 @@ a basic cache implementation.}
Finally, to make the service use your own certificate verifier, simply write:
\begin{lstlisting}
-theService->setCertificateVerifier(vmime::create <myCertVerifier>());
+theService->setCertificateVerifier(vmime::make_shared <myCertVerifier>());
\end{lstlisting}
\subsection{SSL/TLS Properties} % --------------------------------------------
@@ -1032,10 +1032,10 @@ the session), or they will not be used.
The following example shows how to set the cipher suite preferences for TLS:
\begin{lstlisting}[caption={Setting TLS cipher suite preferences}]
-vmime::ref <vmime::net::session> sess = /* ... */;
+vmime::shared_ptr <vmime::net::session> sess = /* ... */;
-vmime::ref <vmime::net::tls::TLSProperties> tlsProps =
- vmime::create <vmime::net::tls::TLSProperties>();
+vmime::shared_ptr <vmime::net::tls::TLSProperties> tlsProps =
+ vmime::make_shared <vmime::net::tls::TLSProperties>();
// for OpenSSL
tlsProps->setCipherString("HIGH:!ADH:@STRENGTH");
diff --git a/examples/example1.cpp b/examples/example1.cpp
index 851f681a..9948d606 100644
--- a/examples/example1.cpp
+++ b/examples/example1.cpp
@@ -52,24 +52,24 @@ int main()
mb.setExpeditor(vmime::mailbox("[email protected]"));
vmime::addressList to;
- to.appendAddress(vmime::create <vmime::mailbox>("[email protected]"));
+ to.appendAddress(vmime::make_shared <vmime::mailbox>("[email protected]"));
mb.setRecipients(to);
vmime::addressList bcc;
- bcc.appendAddress(vmime::create <vmime::mailbox>("[email protected]"));
+ bcc.appendAddress(vmime::make_shared <vmime::mailbox>("[email protected]"));
mb.setBlindCopyRecipients(bcc);
mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder"));
// Message body
- mb.getTextPart()->setText(vmime::create <vmime::stringContentHandler>(
+ mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>(
"I'm writing this short text to test message construction " \
"using the vmime::messageBuilder component."));
// Construction
- vmime::ref <vmime::message> msg = mb.construct();
+ vmime::shared_ptr <vmime::message> msg = mb.construct();
// Raw text generation
std::cout << "Generated message:" << std::endl;
diff --git a/examples/example2.cpp b/examples/example2.cpp
index d09a597c..56f01b03 100644
--- a/examples/example2.cpp
+++ b/examples/example2.cpp
@@ -52,24 +52,24 @@ int main()
mb.setExpeditor(vmime::mailbox("[email protected]"));
vmime::addressList to;
- to.appendAddress(vmime::create <vmime::mailbox>("[email protected]"));
+ to.appendAddress(vmime::make_shared <vmime::mailbox>("[email protected]"));
mb.setRecipients(to);
vmime::addressList bcc;
- bcc.appendAddress(vmime::create <vmime::mailbox>("[email protected]"));
+ bcc.appendAddress(vmime::make_shared <vmime::mailbox>("[email protected]"));
mb.setBlindCopyRecipients(bcc);
mb.setSubject(vmime::text("My first message generated with vmime::messageBuilder"));
// Message body
- mb.getTextPart()->setText(vmime::create <vmime::stringContentHandler>(
+ mb.getTextPart()->setText(vmime::make_shared <vmime::stringContentHandler>(
"I'm writing this short text to test message construction " \
"with attachment, using the vmime::messageBuilder component."));
// Adding an attachment
- vmime::ref <vmime::fileAttachment> a = vmime::create <vmime::fileAttachment>
+ vmime::shared_ptr <vmime::fileAttachment> a = vmime::make_shared <vmime::fileAttachment>
(
"./example2.cpp", // full path to file
vmime::mediaType("application/octet-stream"), // content type
@@ -82,7 +82,7 @@ int main()
mb.attach(a);
// Construction
- vmime::ref <vmime::message> msg = mb.construct();
+ vmime::shared_ptr <vmime::message> msg = mb.construct();
// Raw text generation
vmime::string dataToSend = msg->generate();
diff --git a/examples/example3.cpp b/examples/example3.cpp
index 31e26534..56b3c7e7 100644
--- a/examples/example3.cpp
+++ b/examples/example3.cpp
@@ -52,12 +52,12 @@ int main()
mb.setExpeditor(vmime::mailbox("[email protected]"));
vmime::addressList to;
- to.appendAddress(vmime::create <vmime::mailbox>("[email protected]"));
+ to.appendAddress(vmime::make_shared <vmime::mailbox>("[email protected]"));
mb.setRecipients(to);
vmime::addressList bcc;
- bcc.appendAddress(vmime::create <vmime::mailbox>("[email protected]"));
+ bcc.appendAddress(vmime::make_shared <vmime::mailbox>("[email protected]"));
mb.setBlindCopyRecipients(bcc);
@@ -69,35 +69,35 @@ 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 = *mb.getTextPart().dynamicCast <vmime::htmlTextPart>();
+ vmime::htmlTextPart& textPart = *vmime::dynamicCast <vmime::htmlTextPart>(mb.getTextPart());
// -- embed an image (the returned "CID" (content identifier) is used to reference
// -- the image into HTML content).
- vmime::ref <vmime::utility::fileSystemFactory> fs =
+ vmime::shared_ptr <vmime::utility::fileSystemFactory> fs =
vmime::platform::getHandler()->getFileSystemFactory();
- vmime::ref <vmime::utility::file> imageFile =
+ vmime::shared_ptr <vmime::utility::file> imageFile =
fs->create(fs->stringToPath("/path/to/image.jpg"));
- vmime::ref <vmime::utility::fileReader> fileReader =
+ vmime::shared_ptr <vmime::utility::fileReader> fileReader =
imageFile->getFileReader();
- vmime::ref <vmime::contentHandler> imageCts =
- vmime::create <vmime::streamContentHandler>
+ vmime::shared_ptr <vmime::contentHandler> imageCts =
+ vmime::make_shared <vmime::streamContentHandler>
(fileReader->getInputStream(), imageFile->getLength());
- vmime::ref <const vmime::htmlTextPart::embeddedObject> obj = textPart.addObject
+ vmime::shared_ptr <const vmime::htmlTextPart::embeddedObject> obj = textPart.addObject
(imageCts, vmime::mediaType(vmime::mediaTypes::IMAGE, vmime::mediaTypes::IMAGE_JPEG));
// -- message text
- textPart.setText(vmime::create <vmime::stringContentHandler>
+ textPart.setText(vmime::make_shared <vmime::stringContentHandler>
(vmime::string("This is the <b>HTML text</b>.<br/>"
"<img src=\"") + obj->getReferenceId() + vmime::string("\"/>")));
- textPart.setPlainText(vmime::create <vmime::stringContentHandler>
+ textPart.setPlainText(vmime::make_shared <vmime::stringContentHandler>
("This is the plain text (without HTML formatting)."));
// Construction
- vmime::ref <vmime::message> msg = mb.construct();
+ vmime::shared_ptr <vmime::message> msg = mb.construct();
// Raw text generation
vmime::string dataToSend = msg->generate();
diff --git a/examples/example6.cpp b/examples/example6.cpp
index 721f7624..d2206e7a 100644
--- a/examples/example6.cpp
+++ b/examples/example6.cpp
@@ -31,8 +31,8 @@
// Global session object
-static vmime::ref <vmime::net::session> g_session
- = vmime::create <vmime::net::session>();
+static vmime::shared_ptr <vmime::net::session> g_session
+ = vmime::make_shared <vmime::net::session>();
#if VMIME_HAVE_SASL_SUPPORT
@@ -40,9 +40,9 @@ static vmime::ref <vmime::net::session> g_session
// SASL authentication handler
class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthenticator
{
- const std::vector <vmime::ref <vmime::security::sasl::SASLMechanism> > getAcceptableMechanisms
- (const std::vector <vmime::ref <vmime::security::sasl::SASLMechanism> >& available,
- vmime::ref <vmime::security::sasl::SASLMechanism> suggested) const
+ const std::vector <vmime::shared_ptr <vmime::security::sasl::SASLMechanism> > getAcceptableMechanisms
+ (const std::vector <vmime::shared_ptr <vmime::security::sasl::SASLMechanism> >& available,
+ vmime::shared_ptr <vmime::security::sasl::SASLMechanism> suggested) const
{
std::cout << std::endl << "Available SASL mechanisms:" << std::endl;
@@ -59,7 +59,7 @@ class interactiveAuthenticator : public vmime::security::sasl::defaultSASLAuthen
return defaultSASLAuthenticator::getAcceptableMechanisms(available, suggested);
}
- void setSASLMechanism(vmime::ref <vmime::security::sasl::SASLMechanism> mech)
+ void setSASLMechanism(vmime::shared_ptr <vmime::security::sasl::SASLMechanism> mech)
{
std::cout << "Trying '" << mech->getName() << "' authentication mechanism" << std::endl;
@@ -147,7 +147,7 @@ class interactiveCertificateVerifier : public vmime::security::cert::defaultCert
{
public:
- void verify(vmime::ref <vmime::security::cert::certificateChain> chain, const vmime::string& hostname)
+ void verify(vmime::shared_ptr <vmime::security::cert::certificateChain> chain, const vmime::string& hostname)
{
try
{
@@ -158,7 +158,7 @@ public:
catch (vmime::exceptions::certificate_verification_exception&)
{
// Obtain subject's certificate
- vmime::ref <vmime::security::cert::certificate> cert = chain->getAt(0);
+ vmime::shared_ptr <vmime::security::cert::certificate> cert = chain->getAt(0);
std::cout << std::endl;
std::cout << "Server sent a '" << cert->getType() << "'" << " certificate." << std::endl;
@@ -174,8 +174,8 @@ public:
// Accept it, and remember user's choice for later
if (cert->getType() == "X.509")
{
- m_trustedCerts.push_back(cert.dynamicCast
- <vmime::security::cert::X509Certificate>());
+ m_trustedCerts.push_back(vmime::dynamicCast
+ <vmime::security::cert::X509Certificate>(cert));
setX509TrustedCerts(m_trustedCerts);
defaultCertificateVerifier::verify(chain, hostname);
@@ -191,11 +191,11 @@ public:
private:
- static std::vector <vmime::ref <vmime::security::cert::X509Certificate> > m_trustedCerts;
+ static std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> > m_trustedCerts;
};
-std::vector <vmime::ref <vmime::security::cert::X509Certificate> >
+std::vector <vmime::shared_ptr <vmime::security::cert::X509Certificate> >
interactiveCertificateVerifier::m_trustedCerts;
#endif // VMIME_HAVE_TLS_SUPPORT
@@ -208,7 +208,8 @@ std::vector <vmime::ref <vmime::security::cert::X509Certificate> >
*/
static const std::string findAvailableProtocols(const vmime::net::service::Type type)
{
- vmime::net::serviceFactory* sf = vmime::net::serviceFactory::getInstance();
+ vmime::shared_ptr <vmime::net::serviceFactory> sf =
+ vmime::net::serviceFactory::getInstance();
std::ostringstream res;
int count = 0;
@@ -292,11 +293,11 @@ static std::ostream& operator<<(std::ostream& os, const vmime::exception& e)
* @param s structure object
* @param level current depth
*/
-static void printStructure(vmime::ref <const vmime::net::messageStructure> s, const int level = 0)
+static void printStructure(vmime::shared_ptr <const vmime::net::messageStructure> s, const int level = 0)
{
for (int i = 0 ; i < s->getPartCount() ; ++i)
{
- vmime::ref <const vmime::net::messagePart> part = s->getPartAt(i);
+ vmime::shared_ptr <const vmime::net::messagePart> part = s->getPartAt(i);
for (int j = 0 ; j < level * 2 ; ++j)
std::cout << " ";
@@ -311,7 +312,7 @@ static void printStructure(vmime::ref <const vmime::net::messageStructure> s, co
}
-static const vmime::string getFolderPathString(vmime::ref <vmime::net::folder> f)
+static const vmime::string getFolderPathString(vmime::shared_ptr <vmime::net::folder> f)
{
const vmime::string n = f->getName().getBuffer();
@@ -321,7 +322,7 @@ static const vmime::string getFolderPathString(vmime::ref <vmime::net::folder> f
}
else
{
- vmime::ref <vmime::net::folder> p = f->getParent();
+ vmime::shared_ptr <vmime::net::folder> p = f->getParent();
return getFolderPathString(p) + n + "/";
}
}
@@ -331,14 +332,14 @@ static const vmime::string getFolderPathString(vmime::ref <vmime::net::folder> f
*
* @param folder current folder
*/
-static void printFolders(vmime::ref <vmime::net::folder> folder, const int level = 0)
+static void printFolders(vmime::shared_ptr <vmime::net::folder> folder, const int level = 0)
{
for (int j = 0 ; j < level * 2 ; ++j)
std::cout << " ";
std::cout << getFolderPathString(folder) << std::endl;
- std::vector <vmime::ref <vmime::net::folder> > subFolders = folder->getFolders(false);
+ std::vector <vmime::shared_ptr <vmime::net::folder> > subFolders = folder->getFolders(false);
for (unsigned int i = 0 ; i < subFolders.size() ; ++i)
printFolders(subFolders[i], level + 1);
@@ -395,8 +396,8 @@ static void sendMessage()
vmime::utility::url url(urlString);
- vmime::ref <vmime::net::transport> tr =
- g_session->getTransport(url, vmime::create <interactiveAuthenticator>());
+ vmime::shared_ptr <vmime::net::transport> tr =
+ g_session->getTransport(url, vmime::make_shared <interactiveAuthenticator>());
#if VMIME_HAVE_TLS_SUPPORT
@@ -406,7 +407,7 @@ static void sendMessage()
// Set the object responsible for verifying certificates, in the
// case a secured connection is used (TLS/SSL)
tr->setCertificateVerifier
- (vmime::create <interactiveCertificateVerifier>());
+ (vmime::make_shared <interactiveCertificateVerifier>());
#endif // VMIME_HAVE_TLS_SUPPORT
@@ -435,7 +436,7 @@ static void sendMessage()
cont = (toString.size() != 0);
if (cont)
- to.appendMailbox(vmime::create <vmime::mailbox>(toString));
+ to.appendMailbox(vmime::make_shared <vmime::mailbox>(toString));
}
std::cout << "Enter message data, including headers (end with '.' on a single line):" << std::endl;
@@ -505,10 +506,10 @@ static void connectStore()
// If no authenticator is given in argument to getStore(), a default one
// is used. Its behaviour is to get the user credentials from the
// session properties "auth.username" and "auth.password".
- vmime::ref <vmime::net::store> st;
+ vmime::shared_ptr <vmime::net::store> st;
if (url.getUsername().empty() || url.getPassword().empty())
- st = g_session->getStore(url, vmime::create <interactiveAuthenticator>());
+ st = g_session->getStore(url, vmime::make_shared <interactiveAuthenticator>());
else
st = g_session->getStore(url);
@@ -520,7 +521,7 @@ static void connectStore()
// Set the object responsible for verifying certificates, in the
// case a secured connection is used (TLS/SSL)
st->setCertificateVerifier
- (vmime::create <interactiveCertificateVerifier>());
+ (vmime::make_shared <interactiveCertificateVerifier>());
#endif // VMIME_HAVE_TLS_SUPPORT
@@ -528,15 +529,15 @@ static void connectStore()
st->connect();
// Display some information about the connection
- vmime::ref <vmime::net::connectionInfos> ci = st->getConnectionInfos();
+ vmime::shared_ptr <vmime::net::connectionInfos> ci = st->getConnectionInfos();
std::cout << std::endl;
std::cout << "Connected to '" << ci->getHost() << "' (port " << ci->getPort() << ")" << std::endl;
std::cout << "Connection is " << (st->isSecuredConnection() ? "" : "NOT ") << "secured." << std::endl;
// Open the default folder in this store
- vmime::ref <vmime::net::folder> f = st->getDefaultFolder();
-// vmime::ref <vmime::net::folder> f = st->getFolder(vmime::utility::path("a"));
+ vmime::shared_ptr <vmime::net::folder> f = st->getDefaultFolder();
+// vmime::shared_ptr <vmime::net::folder> f = st->getFolder(vmime::utility::path("a"));
f->open(vmime::net::folder::MODE_READ_WRITE);
@@ -547,7 +548,7 @@ static void connectStore()
for (bool cont = true ; cont ; )
{
- typedef std::map <int, vmime::ref <vmime::net::message> > MessageList;
+ typedef std::map <int, vmime::shared_ptr <vmime::net::message> > MessageList;
MessageList msgList;
try
@@ -567,7 +568,7 @@ static void connectStore()
const int choice = printMenu(choices);
// Request message number
- vmime::ref <vmime::net::message> msg;
+ vmime::shared_ptr <vmime::net::message> msg;
if (choice != 6 && choice != 7 && choice != 8)
{
@@ -677,7 +678,7 @@ static void connectStore()
// List folders
case 7:
{
- vmime::ref <vmime::net::folder>
+ vmime::shared_ptr <vmime::net::folder>
root = st->getRootFolder();
printFolders(root);
@@ -692,7 +693,7 @@ static void connectStore()
std::string path;
std::getline(std::cin, path);
- vmime::ref <vmime::net::folder> newFolder = st->getRootFolder();
+ vmime::shared_ptr <vmime::net::folder> newFolder = st->getRootFolder();
for (std::string::size_type s = 0, p = 0 ; ; s = p + 1)
{
@@ -744,16 +745,16 @@ static void connectStore()
// Folder renaming
{
- vmime::ref <vmime::net::folder> f = st->getFolder(vmime::net::folder::path("c"));
+ vmime::shared_ptr <vmime::net::folder> f = st->getFolder(vmime::net::folder::path("c"));
f->rename(vmime::net::folder::path("c2"));
- vmime::ref <vmime::net::folder> g = st->getFolder(vmime::net::folder::path("c2"));
+ vmime::shared_ptr <vmime::net::folder> g = st->getFolder(vmime::net::folder::path("c2"));
g->rename(vmime::net::folder::path("c"));
}
// Message copy: copy all messages from 'f' to 'g'
{
- vmime::ref <vmime::net::folder> g = st->getFolder(vmime::net::folder::path("TEMP"));
+ vmime::shared_ptr <vmime::net::folder> g = st->getFolder(vmime::net::folder::path("TEMP"));
if (!g->exists())
g->create(vmime::net::folder::TYPE_CONTAINS_MESSAGES);
diff --git a/examples/example7.cpp b/examples/example7.cpp
index ec7d2b86..241b4d33 100644
--- a/examples/example7.cpp
+++ b/examples/example7.cpp
@@ -43,18 +43,19 @@ int main()
vmime::platform::setHandler<vmime::platforms::posix::posixHandler>();
// Enumerate encoders
- vmime::utility::encoder::encoderFactory* ef = vmime::utility::encoder::encoderFactory::getInstance();
+ vmime::shared_ptr <vmime::utility::encoder::encoderFactory> ef =
+ vmime::utility::encoder::encoderFactory::getInstance();
std::cout << "Available encoders:" << std::endl;
for (int i = 0 ; i < ef->getEncoderCount() ; ++i)
{
- vmime::ref <const vmime::utility::encoder::encoderFactory::registeredEncoder>
+ vmime::shared_ptr <const vmime::utility::encoder::encoderFactory::registeredEncoder>
enc = ef->getEncoderAt(i);
std::cout << " * " << enc->getName() << std::endl;
- vmime::ref <vmime::utility::encoder::encoder> e =
+ vmime::shared_ptr <vmime::utility::encoder::encoder> e =
vmime::utility::encoder::encoderFactory::getInstance()->create(enc->getName());
std::vector <vmime::string> props = e->getAvailableProperties();
@@ -66,7 +67,8 @@ int main()
std::cout << std::endl;
// Enumerate messaging services and their properties
- vmime::net::serviceFactory* sf = vmime::net::serviceFactory::getInstance();
+ vmime::shared_ptr <vmime::net::serviceFactory> sf =
+ vmime::net::serviceFactory::getInstance();
std::cout << "Available messaging services:" << std::endl;
diff --git a/examples/viewer/viewer.cpp b/examples/viewer/viewer.cpp
index 5290758a..1d6daa05 100644
--- a/examples/viewer/viewer.cpp
+++ b/examples/viewer/viewer.cpp
@@ -49,18 +49,18 @@ GtkWidget* textArea = NULL;
GtkTreeStore* treeModel = NULL;
-vmime::ref <vmime::message> currentMessage = NULL;
+vmime::shared_ptr <vmime::message> currentMessage;
-void insertRowInModel(GtkTreeStore* model, vmime::ref <vmime::component> comp, GtkTreeIter* parent = NULL)
+void insertRowInModel(GtkTreeStore* model, vmime::shared_ptr <vmime::component> comp, GtkTreeIter* parent = NULL)
{
GtkTreeIter iter;
gtk_tree_store_append(model, &iter, parent);
gtk_tree_store_set(model, &iter, 0, typeid(*comp).name(), 1, comp.get(), -1);
- const std::vector <vmime::ref <vmime::component> > children = comp->getChildComponents();
+ const std::vector <vmime::shared_ptr <vmime::component> > children = comp->getChildComponents();
for (int i = 0 ; i < children.size() ; ++i)
{
@@ -139,7 +139,7 @@ void openFile(const std::string& filename)
}
while (file.gcount());
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
currentMessage = msg;
diff --git a/src/address.cpp b/src/address.cpp
index b57892d5..08a478ec 100644
--- a/src/address.cpp
+++ b/src/address.cpp
@@ -66,7 +66,7 @@ address-list = (address *("," address)) / obs-addr-list
*/
-ref <address> address::parseNext
+shared_ptr <address> address::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition, bool *isLastAddressOfGroup)
{
@@ -196,9 +196,12 @@ ref <address> address::parseNext
// Parse extracted address (mailbox or group)
if (pos != start)
{
- ref <address> parsedAddress = isGroup
- ? create <mailboxGroup>().dynamicCast <address>()
- : create <mailbox>().dynamicCast <address>();
+ shared_ptr <address> parsedAddress;
+
+ if (isGroup)
+ parsedAddress = make_shared <mailboxGroup>();
+ else
+ parsedAddress = make_shared <mailbox>();
parsedAddress->parse(ctx, buffer, start, pos, NULL);
parsedAddress->setParsedBounds(start, pos);
@@ -206,7 +209,7 @@ ref <address> address::parseNext
return (parsedAddress);
}
- return (NULL);
+ return null;
}
diff --git a/src/addressList.cpp b/src/addressList.cpp
index 326a54e3..957be503 100644
--- a/src/addressList.cpp
+++ b/src/addressList.cpp
@@ -60,7 +60,7 @@ void addressList::parseImpl
while (pos < end)
{
- ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
if (parsedAddress != NULL)
m_list.push_back(parsedAddress);
@@ -84,7 +84,7 @@ void addressList::generateImpl
if (!m_list.empty())
{
- for (std::vector <ref <address> >::const_iterator i = m_list.begin() ; ; )
+ for (std::vector <shared_ptr <address> >::const_iterator i = m_list.begin() ; ; )
{
(*i)->generate(ctx, os, pos, &pos);
@@ -107,10 +107,10 @@ void addressList::copyFrom(const component& other)
removeAllAddresses();
- for (std::vector <ref <address> >::const_iterator it = addrList.m_list.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = addrList.m_list.begin() ;
it != addrList.m_list.end() ; ++it)
{
- m_list.push_back((*it)->clone().dynamicCast <address>());
+ m_list.push_back(vmime::clone(*it));
}
}
@@ -127,27 +127,27 @@ addressList& addressList::operator=(const mailboxList& other)
removeAllAddresses();
for (size_t i = 0 ; i < other.getMailboxCount() ; ++i)
- m_list.push_back(other.getMailboxAt(i)->clone().dynamicCast <address>());
+ m_list.push_back(dynamicCast <address>(other.getMailboxAt(i)->clone()));
return (*this);
}
-ref <component> addressList::clone() const
+shared_ptr <component> addressList::clone() const
{
- return vmime::create <addressList>(*this);
+ return make_shared <addressList>(*this);
}
-void addressList::appendAddress(ref <address> addr)
+void addressList::appendAddress(shared_ptr <address> addr)
{
m_list.push_back(addr);
}
-void addressList::insertAddressBefore(ref <address> beforeAddress, ref <address> addr)
+void addressList::insertAddressBefore(shared_ptr <address> beforeAddress, shared_ptr <address> addr)
{
- const std::vector <ref <address> >::iterator it = std::find
+ const std::vector <shared_ptr <address> >::iterator it = std::find
(m_list.begin(), m_list.end(), beforeAddress);
if (it == m_list.end())
@@ -157,15 +157,15 @@ void addressList::insertAddressBefore(ref <address> beforeAddress, ref <address>
}
-void addressList::insertAddressBefore(const size_t pos, ref <address> addr)
+void addressList::insertAddressBefore(const size_t pos, shared_ptr <address> addr)
{
m_list.insert(m_list.begin() + pos, addr);
}
-void addressList::insertAddressAfter(ref <address> afterAddress, ref <address> addr)
+void addressList::insertAddressAfter(shared_ptr <address> afterAddress, shared_ptr <address> addr)
{
- const std::vector <ref <address> >::iterator it = std::find
+ const std::vector <shared_ptr <address> >::iterator it = std::find
(m_list.begin(), m_list.end(), afterAddress);
if (it == m_list.end())
@@ -175,15 +175,15 @@ void addressList::insertAddressAfter(ref <address> afterAddress, ref <address> a
}
-void addressList::insertAddressAfter(const size_t pos, ref <address> addr)
+void addressList::insertAddressAfter(const size_t pos, shared_ptr <address> addr)
{
m_list.insert(m_list.begin() + pos + 1, addr);
}
-void addressList::removeAddress(ref <address> addr)
+void addressList::removeAddress(shared_ptr <address> addr)
{
- const std::vector <ref <address> >::iterator it = std::find
+ const std::vector <shared_ptr <address> >::iterator it = std::find
(m_list.begin(), m_list.end(), addr);
if (it == m_list.end())
@@ -195,7 +195,7 @@ void addressList::removeAddress(ref <address> addr)
void addressList::removeAddress(const size_t pos)
{
- const std::vector <ref <address> >::iterator it = m_list.begin() + pos;
+ const std::vector <shared_ptr <address> >::iterator it = m_list.begin() + pos;
m_list.erase(it);
}
@@ -219,25 +219,25 @@ bool addressList::isEmpty() const
}
-ref <address> addressList::getAddressAt(const size_t pos)
+shared_ptr <address> addressList::getAddressAt(const size_t pos)
{
return (m_list[pos]);
}
-const ref <const address> addressList::getAddressAt(const size_t pos) const
+const shared_ptr <const address> addressList::getAddressAt(const size_t pos) const
{
return (m_list[pos]);
}
-const std::vector <ref <const address> > addressList::getAddressList() const
+const std::vector <shared_ptr <const address> > addressList::getAddressList() const
{
- std::vector <ref <const address> > list;
+ std::vector <shared_ptr <const address> > list;
list.reserve(m_list.size());
- for (std::vector <ref <address> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
list.push_back(*it);
@@ -247,15 +247,15 @@ const std::vector <ref <const address> > addressList::getAddressList() const
}
-const std::vector <ref <address> > addressList::getAddressList()
+const std::vector <shared_ptr <address> > addressList::getAddressList()
{
return (m_list);
}
-const std::vector <ref <component> > addressList::getChildComponents()
+const std::vector <shared_ptr <component> > addressList::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_list, list);
@@ -263,21 +263,21 @@ const std::vector <ref <component> > addressList::getChildComponents()
}
-ref <mailboxList> addressList::toMailboxList() const
+shared_ptr <mailboxList> addressList::toMailboxList() const
{
- ref <mailboxList> res = vmime::create <mailboxList>();
+ shared_ptr <mailboxList> res = make_shared <mailboxList>();
- for (std::vector <ref <address> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
- ref <const address> addr = *it;
+ shared_ptr <const address> addr = *it;
if (addr->isGroup())
{
- const std::vector <ref <const mailbox> > mailboxes =
- addr.dynamicCast <const mailboxGroup>()->getMailboxList();
+ const std::vector <shared_ptr <const mailbox> > mailboxes =
+ dynamicCast <const mailboxGroup>(addr)->getMailboxList();
- for (std::vector <ref <const mailbox> >::const_iterator jt = mailboxes.begin() ;
+ for (std::vector <shared_ptr <const mailbox> >::const_iterator jt = mailboxes.begin() ;
jt != mailboxes.end() ; ++jt)
{
res->appendMailbox(vmime::clone(*jt));
@@ -285,7 +285,7 @@ ref <mailboxList> addressList::toMailboxList() const
}
else
{
- res->appendMailbox(addr->clone().dynamicCast <mailbox>());
+ res->appendMailbox(dynamicCast <mailbox>(addr->clone()));
}
}
diff --git a/src/attachmentHelper.cpp b/src/attachmentHelper.cpp
index 16e42bd4..7168fd93 100644
--- a/src/attachmentHelper.cpp
+++ b/src/attachmentHelper.cpp
@@ -39,15 +39,14 @@ namespace vmime
// static
bool attachmentHelper::isBodyPartAnAttachment
- (ref <const bodyPart> part, const unsigned int options)
+ (shared_ptr <const bodyPart> part, const unsigned int options)
{
try
{
- const contentDispositionField& cdf = dynamic_cast<contentDispositionField&>
- (*part->getHeader()->findField(fields::CONTENT_DISPOSITION));
+ const contentDispositionField& cdf =
+ *part->getHeader()->findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
- const contentDisposition disp = *cdf.getValue()
- .dynamicCast <const contentDisposition>();
+ const contentDisposition disp = *cdf.getValue <const contentDisposition>();
if (disp.getName() != contentDispositionTypes::INLINE)
return true;
@@ -80,10 +79,10 @@ bool attachmentHelper::isBodyPartAnAttachment
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*part->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- type = *ctf.getValue().dynamicCast <const mediaType>();
+ type = *ctf.getValue <const mediaType>();
if (ctf.hasParameter("name"))
hasContentTypeName = true;
@@ -125,20 +124,20 @@ bool attachmentHelper::isBodyPartAnAttachment
// static
-ref <const attachment> attachmentHelper::getBodyPartAttachment
- (ref <const bodyPart> part, const unsigned int options)
+shared_ptr <const attachment> attachmentHelper::getBodyPartAttachment
+ (shared_ptr <const bodyPart> part, const unsigned int options)
{
if (!isBodyPartAnAttachment(part, options))
- return NULL;
+ return null;
mediaType type;
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*part->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- type = *ctf.getValue().dynamicCast <const mediaType>();
+ type = *ctf.getValue <mediaType>();
}
catch (exceptions::no_such_field&)
{
@@ -150,30 +149,30 @@ ref <const attachment> attachmentHelper::getBodyPartAttachment
if (type.getType() == mediaTypes::MESSAGE &&
type.getSubType() == mediaTypes::MESSAGE_RFC822)
{
- return vmime::create <generatedMessageAttachment>(part);
+ return make_shared <generatedMessageAttachment>(part);
}
else
{
- return vmime::create <bodyPartAttachment>(part);
+ return make_shared <bodyPartAttachment>(part);
}
}
// static
-const std::vector <ref <const attachment> >
+const std::vector <shared_ptr <const attachment> >
attachmentHelper::findAttachmentsInMessage
- (ref <const message> msg, const unsigned int options)
+ (shared_ptr <const message> msg, const unsigned int options)
{
return findAttachmentsInBodyPart(msg, options);
}
// static
-const std::vector <ref <const attachment> >
+const std::vector <shared_ptr <const attachment> >
attachmentHelper::findAttachmentsInBodyPart
- (ref <const bodyPart> part, const unsigned int options)
+ (shared_ptr <const bodyPart> part, const unsigned int options)
{
- std::vector <ref <const attachment> > atts;
+ std::vector <shared_ptr <const attachment> > atts;
// Test this part
if (isBodyPartAnAttachment(part, options))
@@ -183,11 +182,11 @@ const std::vector <ref <const attachment> >
// Find in sub-parts
else
{
- ref <const body> bdy = part->getBody();
+ shared_ptr <const body> bdy = part->getBody();
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
{
- std::vector <ref <const attachment> > partAtts =
+ std::vector <shared_ptr <const attachment> > partAtts =
findAttachmentsInBodyPart(bdy->getPartAt(i), options);
std::copy(partAtts.begin(), partAtts.end(), std::back_inserter(atts));
@@ -199,7 +198,7 @@ const std::vector <ref <const attachment> >
// static
-void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
+void attachmentHelper::addAttachment(shared_ptr <message> msg, shared_ptr <attachment> att)
{
// We simply search for a "multipart/mixed" part. If no one exists,
// create it in the root part. This (very simple) algorithm should
@@ -208,7 +207,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
vmime::mediaType mpMixed(vmime::mediaTypes::MULTIPART,
vmime::mediaTypes::MULTIPART_MIXED);
- ref <bodyPart> part = findBodyPart(msg, mpMixed);
+ shared_ptr <bodyPart> part = findBodyPart(msg, mpMixed);
if (part == NULL) // create it
{
@@ -216,7 +215,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
{
// Create a new container part for the parts that were in
// the root part of the message
- ref <bodyPart> container = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> container = make_shared <bodyPart>();
try
{
@@ -238,7 +237,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
}
// Move parts from the root part to this new part
- const std::vector <ref <bodyPart> > partList =
+ const std::vector <shared_ptr <bodyPart> > partList =
msg->getBody()->getPartList();
msg->getBody()->removeAllParts();
@@ -253,7 +252,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
// The message is a simple (RFC-822) message, and do not
// contains any MIME part. Move the contents from the
// root to a new child part.
- ref <bodyPart> child = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> child = make_shared <bodyPart>();
if (msg->getHeader()->hasField(fields::CONTENT_TYPE))
{
@@ -268,7 +267,7 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
}
child->getBody()->setContents(msg->getBody()->getContents());
- msg->getBody()->setContents(vmime::create <emptyContentHandler>());
+ msg->getBody()->setContents(make_shared <emptyContentHandler>());
msg->getBody()->appendPart(child);
}
@@ -288,32 +287,32 @@ void attachmentHelper::addAttachment(ref <message> msg, ref <attachment> att)
// static
-ref <bodyPart> attachmentHelper::findBodyPart
- (ref <bodyPart> part, const mediaType& type)
+shared_ptr <bodyPart> attachmentHelper::findBodyPart
+ (shared_ptr <bodyPart> part, const mediaType& type)
{
if (part->getBody()->getContentType() == type)
return part;
// Try in sub-parts
- ref <body> bdy = part->getBody();
+ shared_ptr <body> bdy = part->getBody();
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
{
- ref <bodyPart> found =
+ shared_ptr <bodyPart> found =
findBodyPart(bdy->getPartAt(i), type);
if (found != NULL)
return found;
}
- return NULL;
+ return null;
}
// static
-void attachmentHelper::addAttachment(ref <message> msg, ref <message> amsg)
+void attachmentHelper::addAttachment(shared_ptr <message> msg, shared_ptr <message> amsg)
{
- ref <attachment> att = vmime::create <parsedMessageAttachment>(amsg);
+ shared_ptr <attachment> att = make_shared <parsedMessageAttachment>(amsg);
addAttachment(msg, att);
}
diff --git a/src/base.cpp b/src/base.cpp
index d5f3e787..f7985376 100644
--- a/src/base.cpp
+++ b/src/base.cpp
@@ -98,9 +98,13 @@ const string CRLF = "\r\n";
const string SUPPORTED_MIME_VERSION = "1.0";
-/** Null reference.
+#ifndef VMIME_BUILDING_DOC
+
+/** Null shared pointer.
*/
-const null_ref null = null_ref();
+nullPtrType null;
+
+#endif // VMIME_BUILDING_DOC
// Line length limits
diff --git a/src/body.cpp b/src/body.cpp
index f1a8cc0f..8d6bab3f 100644
--- a/src/body.cpp
+++ b/src/body.cpp
@@ -44,7 +44,7 @@ namespace vmime
body::body()
- : m_contents(create <emptyContentHandler>()), m_part(NULL), m_header(NULL)
+ : m_contents(make_shared <emptyContentHandler>())
{
}
@@ -56,7 +56,7 @@ body::~body()
// static
utility::stream::size_type body::findNextBoundaryPosition
- (ref <utility::parserInputStreamAdapter> parser, const string& boundary,
+ (shared_ptr <utility::parserInputStreamAdapter> parser, const string& boundary,
const utility::stream::size_type position, const utility::stream::size_type end,
utility::stream::size_type* boundaryStart, utility::stream::size_type* boundaryEnd)
{
@@ -129,7 +129,7 @@ utility::stream::size_type body::findNextBoundaryPosition
void body::parseImpl
(const parsingContext& /* ctx */,
- ref <utility::parserInputStreamAdapter> parser,
+ shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition)
@@ -156,10 +156,10 @@ void body::parseImpl
try
{
- const ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ const shared_ptr <const contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf->getValue <mediaType>();
if (type.getType() == mediaTypes::MULTIPART)
{
@@ -302,7 +302,7 @@ void body::parseImpl
}
else // index > 0
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = m_part->createChildPart();
// End before start may happen on empty bodyparts (directly
// successive boundaries without even a line-break)
@@ -310,7 +310,6 @@ void body::parseImpl
std::swap(partStart, partEnd);
part->parse(parser, partStart, partEnd, NULL);
- part->m_parent = m_part;
m_parts.push_back(part);
}
@@ -322,12 +321,12 @@ void body::parseImpl
(parser, boundary, boundaryEnd, end, &boundaryStart, &boundaryEnd);
}
- m_contents = vmime::create <emptyContentHandler>();
+ m_contents = make_shared <emptyContentHandler>();
// Last part was not found: recover from missing boundary
if (!lastPart && pos == utility::stream::npos)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = m_part->createChildPart();
try
{
@@ -338,8 +337,6 @@ void body::parseImpl
throw;
}
- part->m_parent = m_part;
-
m_parts.push_back(part);
}
// Treat remaining text as epilog
@@ -358,10 +355,10 @@ void body::parseImpl
try
{
- const ref <const headerField> cef =
- m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING);
+ const shared_ptr <headerField> cef =
+ m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING);
- enc = *cef->getValue().dynamicCast <const encoding>();
+ enc = *cef->getValue <encoding>();
}
catch (exceptions::no_such_field&)
{
@@ -372,11 +369,11 @@ void body::parseImpl
// Extract the (encoded) contents
const utility::stream::size_type length = end - position;
- ref <utility::inputStream> contentStream =
- vmime::create <utility::seekableInputStreamRegionAdapter>
+ shared_ptr <utility::inputStream> contentStream =
+ make_shared <utility::seekableInputStreamRegionAdapter>
(parser->getUnderlyingStream(), position, length);
- m_contents = vmime::create <streamContentHandler>(contentStream, length, enc);
+ m_contents = make_shared <streamContentHandler>(contentStream, length, enc);
}
setParsedBounds(position, end);
@@ -429,7 +426,7 @@ void body::generateImpl
{
string boundary;
- if (m_header.acquire() == NULL)
+ if (!m_part)
{
boundary = generateRandomBoundaryString();
}
@@ -437,9 +434,8 @@ void body::generateImpl
{
try
{
- ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE)
- .dynamicCast <const contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
boundary = ctf->getBoundary();
}
@@ -494,7 +490,7 @@ void body::generateImpl
else
{
// Generate the contents
- ref <contentHandler> contents = m_contents->clone();
+ shared_ptr <contentHandler> contents = m_contents->clone();
contents->setContentTypeHint(getContentType());
contents->generate(os, getEncoding(), ctx.getMaxLineLength());
@@ -548,8 +544,8 @@ utility::stream::size_type body::getGeneratedSize(const generationContext& ctx)
// Simple body
else
{
- ref <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder();
- ref <utility::encoder::encoder> dstEncoder = getEncoding().getEncoder();
+ shared_ptr <utility::encoder::encoder> srcEncoder = m_contents->getEncoding().getEncoder();
+ shared_ptr <utility::encoder::encoder> dstEncoder = getEncoding().getEncoder();
return dstEncoder->getEncodedSize(srcEncoder->getDecodedSize(m_contents->getLength()));
}
@@ -646,7 +642,8 @@ bool body::isValidBoundary(const string& boundary)
void body::setContentType(const mediaType& type, const charset& chset)
{
- ref <contentTypeField> ctf = m_header.acquire()->ContentType().dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ dynamicCast <contentTypeField>(m_part->getHeader()->ContentType());
ctf->setValue(type);
ctf->setCharset(chset);
@@ -655,7 +652,7 @@ void body::setContentType(const mediaType& type, const charset& chset)
void body::setContentType(const mediaType& type)
{
- m_header.acquire()->ContentType()->setValue(type);
+ m_part->getHeader()->ContentType()->setValue(type);
}
@@ -663,10 +660,10 @@ const mediaType body::getContentType() const
{
try
{
- ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <const contentTypeField>();
+ shared_ptr <const contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- return (*ctf->getValue().dynamicCast <const mediaType>());
+ return (*ctf->getValue <mediaType>());
}
catch (exceptions::no_such_field&)
{
@@ -681,8 +678,8 @@ void body::setCharset(const charset& chset)
// If a Content-Type field exists, set charset
try
{
- ref <contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
ctf->setCharset(chset);
}
@@ -699,8 +696,8 @@ const charset body::getCharset() const
{
try
{
- const ref <const contentTypeField> ctf =
- m_header.acquire()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ const shared_ptr <const contentTypeField> ctf =
+ m_part->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
return (ctf->getCharset());
}
@@ -719,7 +716,7 @@ const charset body::getCharset() const
void body::setEncoding(const encoding& enc)
{
- m_header.acquire()->ContentTransferEncoding()->setValue(enc);
+ m_part->getHeader()->ContentTransferEncoding()->setValue(enc);
}
@@ -727,10 +724,10 @@ const encoding body::getEncoding() const
{
try
{
- const ref <const headerField> cef =
- m_header.acquire()->findField(fields::CONTENT_TRANSFER_ENCODING);
+ const shared_ptr <const headerField> cef =
+ m_part->getHeader()->findField(fields::CONTENT_TRANSFER_ENCODING);
- return (*cef->getValue().dynamicCast <const encoding>());
+ return *cef->getValue <encoding>();
}
catch (exceptions::no_such_field&)
{
@@ -747,30 +744,28 @@ const encoding body::getEncoding() const
}
-void body::setParentPart(ref <bodyPart> parent)
+void body::setParentPart(bodyPart* parent)
{
m_part = parent;
- m_header = (parent != NULL ? parent->getHeader() : NULL);
- for (std::vector <ref <bodyPart> >::iterator it = m_parts.begin() ;
+ for (std::vector <shared_ptr <bodyPart> >::iterator it = m_parts.begin() ;
it != m_parts.end() ; ++it)
{
- ref <bodyPart> childPart = *it;
- childPart->m_parent = parent;
+ shared_ptr <bodyPart> childPart = *it;
+ parent->importChildPart(childPart);
}
}
bool body::isRootPart() const
{
- ref <const bodyPart> part = m_part.acquire();
- return (part == NULL || part->getParentPart() == NULL);
+ return (m_part == NULL || m_part->getParentPart() == NULL);
}
-ref <component> body::clone() const
+shared_ptr <component> body::clone() const
{
- ref <body> bdy = vmime::create <body>();
+ shared_ptr <body> bdy = make_shared <body>();
bdy->copyFrom(*this);
@@ -791,9 +786,9 @@ void body::copyFrom(const component& other)
for (size_t p = 0 ; p < bdy.getPartCount() ; ++p)
{
- ref <bodyPart> part = bdy.getPartAt(p)->clone().dynamicCast <bodyPart>();
+ shared_ptr <bodyPart> part = m_part->createChildPart();
- part->m_parent = m_part;
+ part->copyFrom(*bdy.getPartAt(p));
m_parts.push_back(part);
}
@@ -831,19 +826,19 @@ void body::setEpilogText(const string& epilogText)
}
-const ref <const contentHandler> body::getContents() const
+const shared_ptr <const contentHandler> body::getContents() const
{
return (m_contents);
}
-void body::setContents(ref <const contentHandler> contents)
+void body::setContents(shared_ptr <const contentHandler> contents)
{
m_contents = contents;
}
-void body::setContents(ref <const contentHandler> contents, const mediaType& type)
+void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type)
{
m_contents = contents;
@@ -851,7 +846,7 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
}
-void body::setContents(ref <const contentHandler> contents, const mediaType& type, const charset& chset)
+void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type, const charset& chset)
{
m_contents = contents;
@@ -859,7 +854,7 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
}
-void body::setContents(ref <const contentHandler> contents, const mediaType& type,
+void body::setContents(shared_ptr <const contentHandler> contents, const mediaType& type,
const charset& chset, const encoding& enc)
{
m_contents = contents;
@@ -869,19 +864,25 @@ void body::setContents(ref <const contentHandler> contents, const mediaType& typ
}
-void body::initNewPart(ref <bodyPart> part)
+void body::initNewPart(shared_ptr <bodyPart> part)
{
- part->m_parent = m_part;
-
- ref <header> hdr = m_header.acquire();
+ // A part can be in only one body at the same time: if part is
+ // already attached to a parent part, remove it from the current
+ // parent part
+ if (part->getParentPart())
+ part->getParentPart()->getBody()->removePart(part);
- if (hdr != NULL)
+ if (m_part != NULL)
{
+ m_part->importChildPart(part);
+
+ shared_ptr <header> hdr = m_part->getHeader();
+
// Check whether we have a boundary string
try
{
- ref <contentTypeField> ctf =
- hdr->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ hdr->findField <contentTypeField>(fields::CONTENT_TYPE);
try
{
@@ -896,7 +897,7 @@ void body::initNewPart(ref <bodyPart> part)
ctf->setBoundary(generateRandomBoundaryString());
}
- if (ctf->getValue().dynamicCast <const mediaType>()->getType() != mediaTypes::MULTIPART)
+ if (ctf->getValue <mediaType>()->getType() != mediaTypes::MULTIPART)
{
// Warning: multi-part body but the Content-Type is
// not specified as "multipart/..."
@@ -906,8 +907,8 @@ void body::initNewPart(ref <bodyPart> part)
{
// No "Content-Type" field: create a new one and generate
// a random boundary string.
- ref <contentTypeField> ctf =
- hdr->getField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ shared_ptr <contentTypeField> ctf =
+ hdr->getField <contentTypeField>(fields::CONTENT_TYPE);
ctf->setValue(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED));
ctf->setBoundary(generateRandomBoundaryString());
@@ -916,7 +917,7 @@ void body::initNewPart(ref <bodyPart> part)
}
-void body::appendPart(ref <bodyPart> part)
+void body::appendPart(shared_ptr <bodyPart> part)
{
initNewPart(part);
@@ -924,11 +925,11 @@ void body::appendPart(ref <bodyPart> part)
}
-void body::insertPartBefore(ref <bodyPart> beforePart, ref <bodyPart> part)
+void body::insertPartBefore(shared_ptr <bodyPart> beforePart, shared_ptr <bodyPart> part)
{
initNewPart(part);
- const std::vector <ref <bodyPart> >::iterator it = std::find
+ const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
(m_parts.begin(), m_parts.end(), beforePart);
if (it == m_parts.end())
@@ -938,7 +939,7 @@ void body::insertPartBefore(ref <bodyPart> beforePart, ref <bodyPart> part)
}
-void body::insertPartBefore(const size_t pos, ref <bodyPart> part)
+void body::insertPartBefore(const size_t pos, shared_ptr <bodyPart> part)
{
initNewPart(part);
@@ -946,11 +947,11 @@ void body::insertPartBefore(const size_t pos, ref <bodyPart> part)
}
-void body::insertPartAfter(ref <bodyPart> afterPart, ref <bodyPart> part)
+void body::insertPartAfter(shared_ptr <bodyPart> afterPart, shared_ptr <bodyPart> part)
{
initNewPart(part);
- const std::vector <ref <bodyPart> >::iterator it = std::find
+ const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
(m_parts.begin(), m_parts.end(), afterPart);
if (it == m_parts.end())
@@ -960,7 +961,7 @@ void body::insertPartAfter(ref <bodyPart> afterPart, ref <bodyPart> part)
}
-void body::insertPartAfter(const size_t pos, ref <bodyPart> part)
+void body::insertPartAfter(const size_t pos, shared_ptr <bodyPart> part)
{
initNewPart(part);
@@ -968,9 +969,9 @@ void body::insertPartAfter(const size_t pos, ref <bodyPart> part)
}
-void body::removePart(ref <bodyPart> part)
+void body::removePart(shared_ptr <bodyPart> part)
{
- const std::vector <ref <bodyPart> >::iterator it = std::find
+ const std::vector <shared_ptr <bodyPart> >::iterator it = std::find
(m_parts.begin(), m_parts.end(), part);
if (it == m_parts.end())
@@ -1004,25 +1005,25 @@ bool body::isEmpty() const
}
-ref <bodyPart> body::getPartAt(const size_t pos)
+shared_ptr <bodyPart> body::getPartAt(const size_t pos)
{
return (m_parts[pos]);
}
-const ref <const bodyPart> body::getPartAt(const size_t pos) const
+const shared_ptr <const bodyPart> body::getPartAt(const size_t pos) const
{
return (m_parts[pos]);
}
-const std::vector <ref <const bodyPart> > body::getPartList() const
+const std::vector <shared_ptr <const bodyPart> > body::getPartList() const
{
- std::vector <ref <const bodyPart> > list;
+ std::vector <shared_ptr <const bodyPart> > list;
list.reserve(m_parts.size());
- for (std::vector <ref <bodyPart> >::const_iterator it = m_parts.begin() ;
+ for (std::vector <shared_ptr <bodyPart> >::const_iterator it = m_parts.begin() ;
it != m_parts.end() ; ++it)
{
list.push_back(*it);
@@ -1032,15 +1033,15 @@ const std::vector <ref <const bodyPart> > body::getPartList() const
}
-const std::vector <ref <bodyPart> > body::getPartList()
+const std::vector <shared_ptr <bodyPart> > body::getPartList()
{
return (m_parts);
}
-const std::vector <ref <component> > body::getChildComponents()
+const std::vector <shared_ptr <component> > body::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_parts, list);
diff --git a/src/bodyPart.cpp b/src/bodyPart.cpp
index f63fd670..be5b8e3a 100644
--- a/src/bodyPart.cpp
+++ b/src/bodyPart.cpp
@@ -29,26 +29,17 @@ namespace vmime
bodyPart::bodyPart()
- : m_header(vmime::create <header>()),
- m_body(vmime::create <body>()),
- m_parent(NULL)
+ : m_header(make_shared <header>()),
+ m_body(make_shared <body>()),
+ m_parent()
{
- m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
-}
-
-
-bodyPart::bodyPart(weak_ref <vmime::bodyPart> parentPart)
- : m_header(vmime::create <header>()),
- m_body(vmime::create <body>()),
- m_parent(parentPart)
-{
- m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
+ m_body->setParentPart(this);
}
void bodyPart::parseImpl
(const parsingContext& ctx,
- ref <utility::parserInputStreamAdapter> parser,
+ shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition)
@@ -88,11 +79,11 @@ utility::stream::size_type bodyPart::getGeneratedSize(const generationContext& c
}
-ref <component> bodyPart::clone() const
+shared_ptr <component> bodyPart::clone() const
{
- ref <bodyPart> p = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> p = make_shared <bodyPart>();
- p->m_parent = null;
+ p->m_parent = NULL;
p->m_header->copyFrom(*m_header);
p->m_body->copyFrom(*m_body);
@@ -117,64 +108,79 @@ bodyPart& bodyPart::operator=(const bodyPart& other)
}
-const ref <const header> bodyPart::getHeader() const
+const shared_ptr <const header> bodyPart::getHeader() const
{
return (m_header);
}
-ref <header> bodyPart::getHeader()
+shared_ptr <header> bodyPart::getHeader()
{
return (m_header);
}
-void bodyPart::setHeader(ref <header> h)
+void bodyPart::setHeader(shared_ptr <header> h)
{
m_header = h;
}
-const ref <const body> bodyPart::getBody() const
+const shared_ptr <const body> bodyPart::getBody() const
{
return (m_body);
}
-ref <body> bodyPart::getBody()
+shared_ptr <body> bodyPart::getBody()
{
return (m_body);
}
-void bodyPart::setBody(ref <body> b)
+void bodyPart::setBody(shared_ptr <body> b)
{
- ref <bodyPart> oldPart = b->m_part.acquire();
+ bodyPart* oldPart = b->m_part;
m_body = b;
- m_body->setParentPart(thisRef().dynamicCast <bodyPart>());
+ m_body->setParentPart(this);
// A body is associated to one and only one part
if (oldPart != NULL)
- oldPart->setBody(vmime::create <body>());
+ oldPart->setBody(make_shared <body>());
}
-ref <bodyPart> bodyPart::getParentPart()
+bodyPart* bodyPart::getParentPart()
{
- return m_parent.acquire();
+ return m_parent;
+}
+
+
+const bodyPart* bodyPart::getParentPart() const
+{
+ return m_parent;
+}
+
+
+shared_ptr <bodyPart> bodyPart::createChildPart()
+{
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
+ part->m_parent = this;
+
+ return part;
}
-ref <const bodyPart> bodyPart::getParentPart() const
+void bodyPart::importChildPart(shared_ptr <bodyPart> part)
{
- return m_parent.acquire();
+ part->m_parent = this;
}
-const std::vector <ref <component> > bodyPart::getChildComponents()
+const std::vector <shared_ptr <component> > bodyPart::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
list.push_back(m_header);
list.push_back(m_body);
diff --git a/src/bodyPartAttachment.cpp b/src/bodyPartAttachment.cpp
index 5ae433ad..c8361238 100644
--- a/src/bodyPartAttachment.cpp
+++ b/src/bodyPartAttachment.cpp
@@ -28,7 +28,7 @@ namespace vmime
{
-bodyPartAttachment::bodyPartAttachment(ref <const bodyPart> part)
+bodyPartAttachment::bodyPartAttachment(shared_ptr <const bodyPart> part)
: m_part(part)
{
}
@@ -40,7 +40,7 @@ const mediaType bodyPartAttachment::getType() const
try
{
- type = *getContentType()->getValue().dynamicCast <const mediaType>();
+ type = *getContentType()->getValue <mediaType>();
}
catch (exceptions::no_such_field&)
{
@@ -76,7 +76,7 @@ const word bodyPartAttachment::getName() const
{
try
{
- ref <parameter> prm = getContentType()->findParameter("name");
+ shared_ptr <parameter> prm = getContentType()->findParameter("name");
if (prm != NULL)
name = prm->getValue();
@@ -101,10 +101,10 @@ const text bodyPartAttachment::getDescription() const
try
{
- ref <const headerField> cd =
+ shared_ptr <const headerField> cd =
getHeader()->findField(fields::CONTENT_DESCRIPTION);
- description = *cd->getValue().dynamicCast <const text>();
+ description = *cd->getValue <text>();
}
catch (exceptions::no_such_field&)
{
@@ -121,39 +121,37 @@ const encoding bodyPartAttachment::getEncoding() const
}
-const ref <const contentHandler> bodyPartAttachment::getData() const
+const shared_ptr <const contentHandler> bodyPartAttachment::getData() const
{
return m_part->getBody()->getContents();
}
-ref <const object> bodyPartAttachment::getPart() const
+shared_ptr <const object> bodyPartAttachment::getPart() const
{
return m_part;
}
-ref <const header> bodyPartAttachment::getHeader() const
+shared_ptr <const header> bodyPartAttachment::getHeader() const
{
return m_part->getHeader();
}
-ref <const contentDispositionField> bodyPartAttachment::getContentDisposition() const
+shared_ptr <const contentDispositionField> bodyPartAttachment::getContentDisposition() const
{
- return getHeader()->findField(fields::CONTENT_DISPOSITION).
- dynamicCast <const contentDispositionField>();
+ return getHeader()->findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
}
-ref <const contentTypeField> bodyPartAttachment::getContentType() const
+shared_ptr <const contentTypeField> bodyPartAttachment::getContentType() const
{
- return getHeader()->findField(fields::CONTENT_TYPE).
- dynamicCast <const contentTypeField>();
+ return getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
}
-void bodyPartAttachment::generateIn(ref <bodyPart> /* parent */) const
+void bodyPartAttachment::generateIn(shared_ptr <bodyPart> /* parent */) const
{
// Not used
}
diff --git a/src/charset.cpp b/src/charset.cpp
index f68c7c4f..03c7b6a9 100644
--- a/src/charset.cpp
+++ b/src/charset.cpp
@@ -90,7 +90,7 @@ void charset::convert(utility::inputStream& in, utility::outputStream& out,
const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
- ref <charsetConverter> conv = charsetConverter::create(source, dest, opts);
+ shared_ptr <charsetConverter> conv = charsetConverter::create(source, dest, opts);
conv->convert(in, out);
}
@@ -104,7 +104,7 @@ void charset::convert(const string& in, string& out, const charset& source, cons
return;
}
- ref <charsetConverter> conv = charsetConverter::create(source, dest, opts);
+ shared_ptr <charsetConverter> conv = charsetConverter::create(source, dest, opts);
conv->convert(in, out);
}
@@ -134,9 +134,9 @@ bool charset::operator!=(const charset& value) const
}
-ref <component> charset::clone() const
+shared_ptr <component> charset::clone() const
{
- return vmime::create <charset>(m_name);
+ return make_shared <charset>(m_name);
}
@@ -152,9 +152,9 @@ void charset::copyFrom(const component& other)
}
-const std::vector <ref <component> > charset::getChildComponents()
+const std::vector <shared_ptr <component> > charset::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/charsetConverter.cpp b/src/charsetConverter.cpp
index 5d3ab626..87886823 100644
--- a/src/charsetConverter.cpp
+++ b/src/charsetConverter.cpp
@@ -31,12 +31,12 @@ namespace vmime
// static
-ref <charsetConverter> charsetConverter::create
+shared_ptr <charsetConverter> charsetConverter::create
(const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
if (source == "idna" || dest == "idna")
- return vmime::create <charsetConverter_idna>(source, dest, opts);
+ return make_shared <charsetConverter_idna>(source, dest, opts);
else
return createGenericConverter(source, dest, opts);
}
diff --git a/src/charsetConverter_iconv.cpp b/src/charsetConverter_iconv.cpp
index 43556298..0efa8445 100644
--- a/src/charsetConverter_iconv.cpp
+++ b/src/charsetConverter_iconv.cpp
@@ -89,11 +89,11 @@ namespace vmime
// static
-ref <charsetConverter> charsetConverter::createGenericConverter
+shared_ptr <charsetConverter> charsetConverter::createGenericConverter
(const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
- return vmime::create <charsetConverter_iconv>(source, dest, opts);
+ return make_shared <charsetConverter_iconv>(source, dest, opts);
}
@@ -222,9 +222,9 @@ void charsetConverter_iconv::convert(const string& in, string& out)
}
-ref <utility::charsetFilteredOutputStream> charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os)
+shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_iconv::getFilteredOutputStream(utility::outputStream& os)
{
- return vmime::create <utility::charsetFilteredOutputStream_iconv>(m_source, m_dest, &os);
+ return make_shared <utility::charsetFilteredOutputStream_iconv>(m_source, m_dest, &os);
}
diff --git a/src/charsetConverter_icu.cpp b/src/charsetConverter_icu.cpp
index 581d933b..a641d5ee 100644
--- a/src/charsetConverter_icu.cpp
+++ b/src/charsetConverter_icu.cpp
@@ -53,11 +53,11 @@ namespace vmime
// static
-ref <charsetConverter> charsetConverter::createGenericConverter
+shared_ptr <charsetConverter> charsetConverter::createGenericConverter
(const charset& source, const charset& dest,
const charsetConverterOptions& opts)
{
- return vmime::create <charsetConverter_icu>(source, dest, opts);
+ return make_shared <charsetConverter_icu>(source, dest, opts);
}
@@ -195,9 +195,9 @@ void charsetConverter_icu::convert(const string& in, string& out)
}
-ref <utility::charsetFilteredOutputStream> charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os)
+shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_icu::getFilteredOutputStream(utility::outputStream& os)
{
- return vmime::create <utility::charsetFilteredOutputStream_icu>(m_source, m_dest, &os);
+ return make_shared <utility::charsetFilteredOutputStream_icu>(m_source, m_dest, &os);
}
diff --git a/src/charsetConverter_idna.cpp b/src/charsetConverter_idna.cpp
index cde2209a..a6b339b6 100644
--- a/src/charsetConverter_idna.cpp
+++ b/src/charsetConverter_idna.cpp
@@ -159,9 +159,9 @@ void charsetConverter_idna::convert(const string& in, string& out)
}
-ref <utility::charsetFilteredOutputStream> charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */)
+shared_ptr <utility::charsetFilteredOutputStream> charsetConverter_idna::getFilteredOutputStream(utility::outputStream& /* os */)
{
- return NULL;
+ return null;
}
diff --git a/src/component.cpp b/src/component.cpp
index d2138b60..cb013899 100644
--- a/src/component.cpp
+++ b/src/component.cpp
@@ -47,14 +47,14 @@ component::~component()
void component::parse
- (ref <utility::inputStream> inputStream, const utility::stream::size_type length)
+ (shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type length)
{
parse(inputStream, 0, length, NULL);
}
void component::parse
- (ref <utility::inputStream> inputStream, const utility::stream::size_type position,
+ (shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
{
parse(parsingContext::getDefaultContext(), inputStream, position, end, newPosition);
@@ -63,13 +63,13 @@ void component::parse
void component::parse
(const parsingContext& ctx,
- ref <utility::inputStream> inputStream, const utility::stream::size_type position,
+ shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
{
m_parsedOffset = m_parsedLength = 0;
- ref <utility::seekableInputStream> seekableStream =
- inputStream.dynamicCast <utility::seekableInputStream>();
+ shared_ptr <utility::seekableInputStream> seekableStream =
+ dynamicCast <utility::seekableInputStream>(inputStream);
if (seekableStream == NULL || end == 0)
{
@@ -84,8 +84,8 @@ void component::parse
}
else
{
- ref <utility::parserInputStreamAdapter> parser =
- vmime::create <utility::parserInputStreamAdapter>(seekableStream);
+ shared_ptr <utility::parserInputStreamAdapter> parser =
+ make_shared <utility::parserInputStreamAdapter>(seekableStream);
parseImpl(ctx, parser, position, end, newPosition);
}
@@ -136,7 +136,7 @@ void component::offsetParsedBounds(const utility::stream::size_type offset)
m_parsedOffset += offset;
// Offset parsed bounds of our children
- std::vector <ref <component> > children = getChildComponents();
+ std::vector <shared_ptr <component> > children = getChildComponents();
for (size_t i = 0, n = children.size() ; i < n ; ++i)
children[i]->offsetParsedBounds(offset);
@@ -144,7 +144,7 @@ void component::offsetParsedBounds(const utility::stream::size_type offset)
void component::parseImpl
- (const parsingContext& ctx, ref <utility::parserInputStreamAdapter> parser,
+ (const parsingContext& ctx, shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end, utility::stream::size_type* newPosition)
{
@@ -169,11 +169,11 @@ void component::parseImpl
// This is the default implementation for parsing from a string:
// actually, we encapsulate the string buffer in an input stream, then use
// the "parse from input stream" implementation
- ref <utility::seekableInputStream> stream =
- vmime::create <utility::inputStreamStringAdapter>(buffer);
+ shared_ptr <utility::seekableInputStream> stream =
+ make_shared <utility::inputStreamStringAdapter>(buffer);
- ref <utility::parserInputStreamAdapter> parser =
- vmime::create <utility::parserInputStreamAdapter>(stream);
+ shared_ptr <utility::parserInputStreamAdapter> parser =
+ make_shared <utility::parserInputStreamAdapter>(stream);
parseImpl(ctx, parser, position, end, newPosition);
}
@@ -235,10 +235,10 @@ void component::setParsedBounds(const string::size_type start, const string::siz
utility::stream::size_type component::getGeneratedSize(const generationContext& ctx)
{
- std::vector <ref <component> > children = getChildComponents();
+ std::vector <shared_ptr <component> > children = getChildComponents();
utility::stream::size_type totalSize = 0;
- for (std::vector <ref <component> >::iterator it = children.begin() ; it != children.end() ; ++it)
+ for (std::vector <shared_ptr <component> >::iterator it = children.begin() ; it != children.end() ; ++it)
totalSize += (*it)->getGeneratedSize(ctx);
return totalSize;
diff --git a/src/contentDisposition.cpp b/src/contentDisposition.cpp
index 300d4ee3..aa9b4fe3 100644
--- a/src/contentDisposition.cpp
+++ b/src/contentDisposition.cpp
@@ -91,9 +91,9 @@ bool contentDisposition::operator!=(const contentDisposition& value) const
}
-ref <component> contentDisposition::clone() const
+shared_ptr <component> contentDisposition::clone() const
{
- return vmime::create <contentDisposition>(*this);
+ return make_shared <contentDisposition>(*this);
}
@@ -124,9 +124,9 @@ void contentDisposition::setName(const string& name)
}
-const std::vector <ref <component> > contentDisposition::getChildComponents()
+const std::vector <shared_ptr <component> > contentDisposition::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/dateTime.cpp b/src/dateTime.cpp
index a0c03ede..2c045e6d 100644
--- a/src/dateTime.cpp
+++ b/src/dateTime.cpp
@@ -776,15 +776,15 @@ const datetime datetime::now()
}
-ref <component> datetime::clone() const
+shared_ptr <component> datetime::clone() const
{
- return vmime::create <datetime>(*this);
+ return make_shared <datetime>(*this);
}
-const std::vector <ref <component> > datetime::getChildComponents()
+const std::vector <shared_ptr <component> > datetime::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/defaultAttachment.cpp b/src/defaultAttachment.cpp
index 9076fdb3..8f8ad453 100644
--- a/src/defaultAttachment.cpp
+++ b/src/defaultAttachment.cpp
@@ -37,14 +37,14 @@ defaultAttachment::defaultAttachment()
}
-defaultAttachment::defaultAttachment(ref <const contentHandler> data,
+defaultAttachment::defaultAttachment(shared_ptr <const contentHandler> data,
const encoding& enc, const mediaType& type, const text& desc, const word& name)
: m_type(type), m_desc(desc), m_data(data), m_encoding(enc), m_name(name)
{
}
-defaultAttachment::defaultAttachment(ref <const contentHandler> data,
+defaultAttachment::defaultAttachment(shared_ptr <const contentHandler> data,
const mediaType& type, const text& desc, const word& name)
: m_type(type), m_desc(desc), m_data(data),
m_encoding(encoding::decide(data)), m_name(name)
@@ -54,7 +54,7 @@ defaultAttachment::defaultAttachment(ref <const contentHandler> data,
defaultAttachment::defaultAttachment(const defaultAttachment& attach)
: attachment(), m_type(attach.m_type), m_desc(attach.m_desc),
- m_data(attach.m_data->clone().dynamicCast <contentHandler>()),
+ m_data(vmime::clone(attach.m_data)),
m_encoding(attach.m_encoding), m_name(attach.m_name)
{
}
@@ -70,31 +70,31 @@ defaultAttachment& defaultAttachment::operator=(const defaultAttachment& attach)
m_type = attach.m_type;
m_desc = attach.m_desc;
m_name = attach.m_name;
- m_data = attach.m_data->clone().dynamicCast <contentHandler>();
+ m_data = vmime::clone(attach.m_data);
m_encoding = attach.m_encoding;
return (*this);
}
-void defaultAttachment::generateIn(ref <bodyPart> parent) const
+void defaultAttachment::generateIn(shared_ptr <bodyPart> parent) const
{
// Create and append a new part for this attachment
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
generatePart(part);
}
-void defaultAttachment::generatePart(ref <bodyPart> part) const
+void defaultAttachment::generatePart(shared_ptr <bodyPart> part) const
{
// Set header fields
part->getHeader()->ContentType()->setValue(m_type);
if (!m_desc.isEmpty()) part->getHeader()->ContentDescription()->setValue(m_desc);
part->getHeader()->ContentTransferEncoding()->setValue(m_encoding);
part->getHeader()->ContentDisposition()->setValue(contentDisposition(contentDispositionTypes::ATTACHMENT));
- part->getHeader()->ContentDisposition().dynamicCast <contentDispositionField>()->setFilename(m_name);
+ dynamicCast <contentDispositionField>(part->getHeader()->ContentDisposition())->setFilename(m_name);
// Set contents
part->getBody()->setContents(m_data);
@@ -119,7 +119,7 @@ const word defaultAttachment::getName() const
}
-const ref <const contentHandler> defaultAttachment::getData() const
+const shared_ptr <const contentHandler> defaultAttachment::getData() const
{
return m_data;
}
@@ -131,15 +131,15 @@ const encoding defaultAttachment::getEncoding() const
}
-ref <const object> defaultAttachment::getPart() const
+shared_ptr <const object> defaultAttachment::getPart() const
{
- return NULL;
+ return null;
}
-ref <const header> defaultAttachment::getHeader() const
+shared_ptr <const header> defaultAttachment::getHeader() const
{
- return NULL;
+ return null;
}
diff --git a/src/disposition.cpp b/src/disposition.cpp
index c5da6e30..08e34afc 100644
--- a/src/disposition.cpp
+++ b/src/disposition.cpp
@@ -44,9 +44,9 @@ disposition::disposition(const string& actionMode, const string& sendingMode,
}
-ref <component> disposition::clone() const
+shared_ptr <component> disposition::clone() const
{
- ref <disposition> disp = vmime::create <disposition>();
+ shared_ptr <disposition> disp = make_shared <disposition>();
disp->m_actionMode = m_actionMode;
disp->m_sendingMode = m_sendingMode;
@@ -79,9 +79,9 @@ disposition& disposition::operator=(const disposition& other)
}
-const std::vector <ref <component> > disposition::getChildComponents()
+const std::vector <shared_ptr <component> > disposition::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/emailAddress.cpp b/src/emailAddress.cpp
index c4119aba..eb76e16d 100644
--- a/src/emailAddress.cpp
+++ b/src/emailAddress.cpp
@@ -469,9 +469,9 @@ emailAddress& emailAddress::operator=(const emailAddress& other)
}
-ref <component>emailAddress::clone() const
+shared_ptr <component>emailAddress::clone() const
{
- return vmime::create <emailAddress>(*this);
+ return make_shared <emailAddress>(*this);
}
@@ -499,9 +499,9 @@ void emailAddress::setDomainName(const word& domainName)
}
-const std::vector <ref <component> > emailAddress::getChildComponents()
+const std::vector <shared_ptr <component> > emailAddress::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
@@ -528,9 +528,9 @@ const string emailAddress::toString() const
const text emailAddress::toText() const
{
text txt;
- txt.appendWord(vmime::create <vmime::word>(m_localName));
- txt.appendWord(vmime::create <vmime::word>("@", vmime::charsets::US_ASCII));
- txt.appendWord(vmime::create <vmime::word>(m_domainName));
+ txt.appendWord(make_shared <vmime::word>(m_localName));
+ txt.appendWord(make_shared <vmime::word>("@", vmime::charsets::US_ASCII));
+ txt.appendWord(make_shared <vmime::word>(m_domainName));
return txt;
}
diff --git a/src/emptyContentHandler.cpp b/src/emptyContentHandler.cpp
index 07b53391..f6cdee95 100644
--- a/src/emptyContentHandler.cpp
+++ b/src/emptyContentHandler.cpp
@@ -33,9 +33,9 @@ emptyContentHandler::emptyContentHandler()
}
-ref <contentHandler> emptyContentHandler::clone() const
+shared_ptr <contentHandler> emptyContentHandler::clone() const
{
- return vmime::create <emptyContentHandler>();
+ return make_shared <emptyContentHandler>();
}
diff --git a/src/encoding.cpp b/src/encoding.cpp
index 53f88531..317d441f 100644
--- a/src/encoding.cpp
+++ b/src/encoding.cpp
@@ -92,9 +92,9 @@ void encoding::generateImpl
}
-ref <utility::encoder::encoder> encoding::getEncoder() const
+shared_ptr <utility::encoder::encoder> encoding::getEncoder() const
{
- ref <utility::encoder::encoder> encoder =
+ shared_ptr <utility::encoder::encoder> encoder =
utility::encoder::encoderFactory::getInstance()->create(generate());
// FIXME: this should not be here (move me into QP encoder instead?)
@@ -200,7 +200,7 @@ bool encoding::shouldReencode() const
const encoding encoding::decide
- (ref <const contentHandler> data, const EncodingUsage usage)
+ (shared_ptr <const contentHandler> data, const EncodingUsage usage)
{
// Do not re-encode data if it is already encoded
if (data->isEncoded() && !data->getEncoding().shouldReencode())
@@ -231,7 +231,7 @@ const encoding encoding::decide
}
-const encoding encoding::decide(ref <const contentHandler> data,
+const encoding encoding::decide(shared_ptr <const contentHandler> data,
const charset& chset, const EncodingUsage usage)
{
// Do not re-encode data if it is already encoded
@@ -253,9 +253,9 @@ const encoding encoding::decide(ref <const contentHandler> data,
}
-ref <component> encoding::clone() const
+shared_ptr <component> encoding::clone() const
{
- return vmime::create <encoding>(*this);
+ return make_shared <encoding>(*this);
}
@@ -291,9 +291,9 @@ void encoding::setUsage(const EncodingUsage usage)
}
-const std::vector <ref <component> > encoding::getChildComponents()
+const std::vector <shared_ptr <component> > encoding::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/fileAttachment.cpp b/src/fileAttachment.cpp
index 4f4a87d3..1db1a1a8 100644
--- a/src/fileAttachment.cpp
+++ b/src/fileAttachment.cpp
@@ -79,7 +79,7 @@ fileAttachment::fileAttachment(const string& filepath, const mediaType& type,
}
-fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename, const mediaType& type)
+fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename, const mediaType& type)
{
if (!filename.isEmpty())
m_fileInfo.setFilename(filename);
@@ -92,7 +92,7 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename, c
}
-fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
+fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename,
const mediaType& type, const text& desc)
{
if (!filename.isEmpty())
@@ -107,7 +107,7 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
}
-fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
+fileAttachment::fileAttachment(shared_ptr <contentHandler> cts, const word& filename,
const mediaType& type, const text& desc, const encoding& enc)
{
if (!filename.isEmpty())
@@ -123,15 +123,15 @@ fileAttachment::fileAttachment(ref <contentHandler> cts, const word& filename,
void fileAttachment::setData(const string& filepath)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path path = fsf->stringToPath(filepath);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
if (!file->isFile())
throw exceptions::open_file_error();
- m_data = vmime::create <streamContentHandler>
+ m_data = make_shared <streamContentHandler>
(file->getFileReader()->getInputStream(), file->getLength());
m_fileInfo.setFilename(path.getLastComponent());
@@ -139,7 +139,7 @@ void fileAttachment::setData(const string& filepath)
}
-void fileAttachment::setData(ref <contentHandler> cts)
+void fileAttachment::setData(shared_ptr <contentHandler> cts)
{
m_data = cts;
@@ -147,12 +147,12 @@ void fileAttachment::setData(ref <contentHandler> cts)
}
-void fileAttachment::generatePart(ref <bodyPart> part) const
+void fileAttachment::generatePart(shared_ptr <bodyPart> part) const
{
defaultAttachment::generatePart(part);
- ref <contentDispositionField> cdf = part->getHeader()->ContentDisposition().
- dynamicCast <contentDispositionField>();
+ shared_ptr <contentDispositionField> cdf =
+ dynamicCast <contentDispositionField>(part->getHeader()->ContentDisposition());
if (m_fileInfo.hasSize()) cdf->setSize(utility::stringUtils::toString(m_fileInfo.getSize()));
if (m_fileInfo.hasFilename() && !m_fileInfo.getFilename().isEmpty()) cdf->setFilename(m_fileInfo.getFilename());
diff --git a/src/fileContentHandler.cpp b/src/fileContentHandler.cpp
index 295bc887..53ec9f69 100644
--- a/src/fileContentHandler.cpp
+++ b/src/fileContentHandler.cpp
@@ -35,7 +35,7 @@ fileContentHandler::fileContentHandler()
fileContentHandler::fileContentHandler
- (ref <utility::file> file, const vmime::encoding& enc)
+ (shared_ptr <utility::file> file, const vmime::encoding& enc)
{
setData(file, enc);
}
@@ -61,14 +61,14 @@ fileContentHandler& fileContentHandler::operator=(const fileContentHandler& cts)
}
-ref <contentHandler> fileContentHandler::clone() const
+shared_ptr <contentHandler> fileContentHandler::clone() const
{
- return vmime::create <fileContentHandler>(*this);
+ return make_shared <fileContentHandler>(*this);
}
void fileContentHandler::setData
- (ref <utility::file> file, const vmime::encoding& enc)
+ (shared_ptr <utility::file> file, const vmime::encoding& enc)
{
m_file = file;
m_encoding = enc;
diff --git a/src/generatedMessageAttachment.cpp b/src/generatedMessageAttachment.cpp
index 927d3d43..0473d247 100644
--- a/src/generatedMessageAttachment.cpp
+++ b/src/generatedMessageAttachment.cpp
@@ -30,8 +30,8 @@ namespace vmime
{
-generatedMessageAttachment::generatedMessageAttachment(ref <const bodyPart> part)
- : m_bpa(vmime::create <bodyPartAttachment>(part))
+generatedMessageAttachment::generatedMessageAttachment(shared_ptr <const bodyPart> part)
+ : m_bpa(make_shared <bodyPartAttachment>(part))
{
}
@@ -54,7 +54,7 @@ const word generatedMessageAttachment::getName() const
}
-const ref <const contentHandler> generatedMessageAttachment::getData() const
+const shared_ptr <const contentHandler> generatedMessageAttachment::getData() const
{
return m_bpa->getData();
}
@@ -66,19 +66,19 @@ const encoding generatedMessageAttachment::getEncoding() const
}
-ref <const object> generatedMessageAttachment::getPart() const
+shared_ptr <const object> generatedMessageAttachment::getPart() const
{
return m_bpa->getPart();
}
-ref <const header> generatedMessageAttachment::getHeader() const
+shared_ptr <const header> generatedMessageAttachment::getHeader() const
{
return m_bpa->getHeader();
}
-ref <message> generatedMessageAttachment::getMessage() const
+shared_ptr <message> generatedMessageAttachment::getMessage() const
{
if (m_msg == NULL)
{
@@ -89,7 +89,7 @@ ref <message> generatedMessageAttachment::getMessage() const
getData()->extract(os);
// Parse message
- m_msg = vmime::create <message>();
+ m_msg = make_shared <message>();
m_msg->parse(oss.str());
}
@@ -97,7 +97,7 @@ ref <message> generatedMessageAttachment::getMessage() const
}
-void generatedMessageAttachment::generateIn(ref <bodyPart> /* parent */) const
+void generatedMessageAttachment::generateIn(shared_ptr <bodyPart> /* parent */) const
{
// Not used (see 'parsedMessageAttachment')
}
diff --git a/src/header.cpp b/src/header.cpp
index ec98976f..8e04cadc 100644
--- a/src/header.cpp
+++ b/src/header.cpp
@@ -72,7 +72,7 @@ void header::parseImpl
while (pos < end)
{
- ref <headerField> field = headerField::parseNext(ctx, buffer, pos, end, &pos);
+ shared_ptr <headerField> field = headerField::parseNext(ctx, buffer, pos, end, &pos);
if (field == NULL) break;
m_fields.push_back(field);
@@ -90,7 +90,7 @@ void header::generateImpl
const string::size_type /* curLinePos */, string::size_type* newLinePos) const
{
// Generate the fields
- for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
it != m_fields.end() ; ++it)
{
(*it)->generate(ctx, os);
@@ -108,16 +108,16 @@ utility::stream::size_type header::getGeneratedSize(const generationContext& ctx
}
-ref <component> header::clone() const
+shared_ptr <component> header::clone() const
{
- ref <header> hdr = vmime::create <header>();
+ shared_ptr <header> hdr = make_shared <header>();
hdr->m_fields.reserve(m_fields.size());
- for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
it != m_fields.end() ; ++it)
{
- hdr->m_fields.push_back((*it)->clone().dynamicCast <headerField>());
+ hdr->m_fields.push_back(vmime::clone(*it));
}
return (hdr);
@@ -128,14 +128,14 @@ void header::copyFrom(const component& other)
{
const header& h = dynamic_cast <const header&>(other);
- std::vector <ref <headerField> > fields;
+ std::vector <shared_ptr <headerField> > fields;
fields.reserve(h.m_fields.size());
- for (std::vector <ref <headerField> >::const_iterator it = h.m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = h.m_fields.begin() ;
it != h.m_fields.end() ; ++it)
{
- fields.push_back((*it)->clone().dynamicCast <headerField>());
+ fields.push_back(vmime::clone(*it));
}
m_fields.clear();
@@ -154,7 +154,7 @@ header& header::operator=(const header& other)
bool header::hasField(const string& fieldName) const
{
- std::vector <ref <headerField> >::const_iterator pos =
+ std::vector <shared_ptr <headerField> >::const_iterator pos =
std::find_if(m_fields.begin(), m_fields.end(),
fieldHasName(utility::stringUtils::toLower(fieldName)));
@@ -162,10 +162,10 @@ bool header::hasField(const string& fieldName) const
}
-ref <headerField> header::findField(const string& fieldName) const
+shared_ptr <headerField> header::findField(const string& fieldName) const
{
// Find the first field that matches the specified name
- std::vector <ref <headerField> >::const_iterator pos =
+ std::vector <shared_ptr <headerField> >::const_iterator pos =
std::find_if(m_fields.begin(), m_fields.end(),
fieldHasName(utility::stringUtils::toLower(fieldName)));
@@ -182,10 +182,10 @@ ref <headerField> header::findField(const string& fieldName) const
}
-std::vector <ref <headerField> > header::findAllFields(const string& fieldName)
+std::vector <shared_ptr <headerField> > header::findAllFields(const string& fieldName)
{
- std::vector <ref <headerField> > result;
- std::back_insert_iterator <std::vector <ref <headerField> > > back(result);
+ std::vector <shared_ptr <headerField> > result;
+ std::back_insert_iterator <std::vector <shared_ptr <headerField> > > back(result);
std::remove_copy_if(m_fields.begin(), m_fields.end(), back,
fieldHasNotName(utility::stringUtils::toLower(fieldName)));
@@ -194,13 +194,13 @@ std::vector <ref <headerField> > header::findAllFields(const string& fieldName)
}
-ref <headerField> header::getField(const string& fieldName)
+shared_ptr <headerField> header::getField(const string& fieldName)
{
const string name = utility::stringUtils::toLower(fieldName);
// Find the first field that matches the specified name
- std::vector <ref <headerField> >::const_iterator pos = m_fields.begin();
- const std::vector <ref <headerField> >::const_iterator end = m_fields.end();
+ std::vector <shared_ptr <headerField> >::const_iterator pos = m_fields.begin();
+ const std::vector <shared_ptr <headerField> >::const_iterator end = m_fields.end();
while (pos != end && utility::stringUtils::toLower((*pos)->getName()) != name)
++pos;
@@ -208,7 +208,7 @@ ref <headerField> header::getField(const string& fieldName)
// If no field with this name can be found, create a new one
if (pos == end)
{
- ref <headerField> field = headerFieldFactory::getInstance()->create(fieldName);
+ shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(fieldName);
appendField(field);
@@ -223,15 +223,15 @@ ref <headerField> header::getField(const string& fieldName)
}
-void header::appendField(ref <headerField> field)
+void header::appendField(shared_ptr <headerField> field)
{
m_fields.push_back(field);
}
-void header::insertFieldBefore(ref <headerField> beforeField, ref <headerField> field)
+void header::insertFieldBefore(shared_ptr <headerField> beforeField, shared_ptr <headerField> field)
{
- const std::vector <ref <headerField> >::iterator it = std::find
+ const std::vector <shared_ptr <headerField> >::iterator it = std::find
(m_fields.begin(), m_fields.end(), beforeField);
if (it == m_fields.end())
@@ -241,15 +241,15 @@ void header::insertFieldBefore(ref <headerField> beforeField, ref <headerField>
}
-void header::insertFieldBefore(const size_t pos, ref <headerField> field)
+void header::insertFieldBefore(const size_t pos, shared_ptr <headerField> field)
{
m_fields.insert(m_fields.begin() + pos, field);
}
-void header::insertFieldAfter(ref <headerField> afterField, ref <headerField> field)
+void header::insertFieldAfter(shared_ptr <headerField> afterField, shared_ptr <headerField> field)
{
- const std::vector <ref <headerField> >::iterator it = std::find
+ const std::vector <shared_ptr <headerField> >::iterator it = std::find
(m_fields.begin(), m_fields.end(), afterField);
if (it == m_fields.end())
@@ -259,15 +259,15 @@ void header::insertFieldAfter(ref <headerField> afterField, ref <headerField> fi
}
-void header::insertFieldAfter(const size_t pos, ref <headerField> field)
+void header::insertFieldAfter(const size_t pos, shared_ptr <headerField> field)
{
m_fields.insert(m_fields.begin() + pos + 1, field);
}
-void header::removeField(ref <headerField> field)
+void header::removeField(shared_ptr <headerField> field)
{
- const std::vector <ref <headerField> >::iterator it = std::find
+ const std::vector <shared_ptr <headerField> >::iterator it = std::find
(m_fields.begin(), m_fields.end(), field);
if (it == m_fields.end())
@@ -279,13 +279,13 @@ void header::removeField(ref <headerField> field)
void header::removeField(const size_t pos)
{
- const std::vector <ref <headerField> >::iterator it = m_fields.begin() + pos;
+ const std::vector <shared_ptr <headerField> >::iterator it = m_fields.begin() + pos;
m_fields.erase(it);
}
-void header::replaceField(ref <headerField> field, ref <headerField> newField)
+void header::replaceField(shared_ptr <headerField> field, shared_ptr <headerField> newField)
{
insertFieldBefore(field, newField);
removeField(field);
@@ -300,7 +300,7 @@ void header::removeAllFields()
void header::removeAllFields(const string& fieldName)
{
- std::vector <ref <headerField> > fields = findAllFields(fieldName);
+ std::vector <shared_ptr <headerField> > fields = findAllFields(fieldName);
for (unsigned int i = 0 ; i < fields.size() ; ++i)
removeField(fields[i]);
@@ -319,25 +319,25 @@ bool header::isEmpty() const
}
-const ref <headerField> header::getFieldAt(const size_t pos)
+const shared_ptr <headerField> header::getFieldAt(const size_t pos)
{
return (m_fields[pos]);
}
-const ref <const headerField> header::getFieldAt(const size_t pos) const
+const shared_ptr <const headerField> header::getFieldAt(const size_t pos) const
{
return (m_fields[pos]);
}
-const std::vector <ref <const headerField> > header::getFieldList() const
+const std::vector <shared_ptr <const headerField> > header::getFieldList() const
{
- std::vector <ref <const headerField> > list;
+ std::vector <shared_ptr <const headerField> > list;
list.reserve(m_fields.size());
- for (std::vector <ref <headerField> >::const_iterator it = m_fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator it = m_fields.begin() ;
it != m_fields.end() ; ++it)
{
list.push_back(*it);
@@ -347,15 +347,15 @@ const std::vector <ref <const headerField> > header::getFieldList() const
}
-const std::vector <ref <headerField> > header::getFieldList()
+const std::vector <shared_ptr <headerField> > header::getFieldList()
{
return (m_fields);
}
-const std::vector <ref <component> > header::getChildComponents()
+const std::vector <shared_ptr <component> > header::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_fields, list);
@@ -372,7 +372,7 @@ header::fieldHasName::fieldHasName(const string& name)
{
}
-bool header::fieldHasName::operator() (const ref <const headerField>& field)
+bool header::fieldHasName::operator() (const shared_ptr <const headerField>& field)
{
return utility::stringUtils::toLower(field->getName()) == m_name;
}
@@ -383,7 +383,7 @@ header::fieldHasNotName::fieldHasNotName(const string& name)
{
}
-bool header::fieldHasNotName::operator() (const ref <const headerField>& field)
+bool header::fieldHasNotName::operator() (const shared_ptr <const headerField>& field)
{
return utility::stringUtils::toLower(field->getName()) != m_name;
}
diff --git a/src/headerField.cpp b/src/headerField.cpp
index 7f24e176..c6baa32e 100644
--- a/src/headerField.cpp
+++ b/src/headerField.cpp
@@ -50,9 +50,9 @@ headerField::~headerField()
}
-ref <component> headerField::clone() const
+shared_ptr <component> headerField::clone() const
{
- ref <headerField> field = headerFieldFactory::getInstance()->create(m_name);
+ shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(m_name);
field->copyFrom(*this);
@@ -75,7 +75,7 @@ headerField& headerField::operator=(const headerField& other)
}
-ref <headerField> headerField::parseNext
+shared_ptr <headerField> headerField::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
@@ -93,14 +93,14 @@ ref <headerField> headerField::parseNext
if (newPosition)
*newPosition = pos + 1; // LF: illegal
- return (NULL);
+ return null;
}
else if (c == '\r' && pos + 1 < end && buffer[pos + 1] == '\n')
{
if (newPosition)
*newPosition = pos + 2; // CR+LF
- return (NULL);
+ return null;
}
// This line may be a field description
@@ -230,7 +230,7 @@ ref <headerField> headerField::parseNext
}
// Return a new field
- ref <headerField> field = headerFieldFactory::getInstance()->create(name);
+ shared_ptr <headerField> field = headerFieldFactory::getInstance()->create(name);
field->parse(ctx, buffer, contentsStart, contentsEnd, NULL);
field->setParsedBounds(nameStart, pos);
@@ -253,14 +253,14 @@ ref <headerField> headerField::parseNext
if (newPosition)
*newPosition = pos + 1; // LF: illegal
- return NULL;
+ return null;
}
else if (pos + 1 < end && buffer[pos] == '\r' && buffer[pos + 1] == '\n')
{
if (newPosition)
*newPosition = pos + 2; // CR+LF
- return NULL;
+ return null;
}
// Skip this error and advance to the next line
@@ -275,7 +275,7 @@ ref <headerField> headerField::parseNext
if (newPosition)
*newPosition = pos;
- return (NULL);
+ return null;
}
@@ -321,9 +321,9 @@ bool headerField::isCustom() const
}
-const std::vector <ref <component> > headerField::getChildComponents()
+const std::vector <shared_ptr <component> > headerField::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
if (m_value)
list.push_back(m_value);
@@ -332,19 +332,19 @@ const std::vector <ref <component> > headerField::getChildComponents()
}
-ref <const headerFieldValue> headerField::getValue() const
+shared_ptr <const headerFieldValue> headerField::getValue() const
{
return m_value;
}
-ref <headerFieldValue> headerField::getValue()
+shared_ptr <headerFieldValue> headerField::getValue()
{
return m_value;
}
-void headerField::setValue(ref <headerFieldValue> value)
+void headerField::setValue(shared_ptr <headerFieldValue> value)
{
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value))
throw exceptions::bad_field_value_type(getName());
@@ -354,12 +354,12 @@ void headerField::setValue(ref <headerFieldValue> value)
}
-void headerField::setValueConst(ref <const headerFieldValue> value)
+void headerField::setValueConst(shared_ptr <const headerFieldValue> value)
{
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, *value))
throw exceptions::bad_field_value_type(getName());
- m_value = value->clone().dynamicCast <headerFieldValue>();
+ m_value = vmime::clone(value);
}
@@ -368,7 +368,7 @@ void headerField::setValue(const headerFieldValue& value)
if (!headerFieldFactory::getInstance()->isValueTypeValid(*this, value))
throw exceptions::bad_field_value_type(getName());
- m_value = value.clone().dynamicCast <headerFieldValue>();
+ m_value = vmime::clone(value);
}
diff --git a/src/headerFieldFactory.cpp b/src/headerFieldFactory.cpp
index 7e021f59..5c60543e 100644
--- a/src/headerFieldFactory.cpp
+++ b/src/headerFieldFactory.cpp
@@ -90,18 +90,18 @@ headerFieldFactory::~headerFieldFactory()
}
-headerFieldFactory* headerFieldFactory::getInstance()
+shared_ptr <headerFieldFactory> headerFieldFactory::getInstance()
{
static headerFieldFactory instance;
- return (&instance);
+ return shared_ptr <headerFieldFactory>(&instance, noop_shared_ptr_deleter <headerFieldFactory>());
}
-ref <headerField> headerFieldFactory::create
+shared_ptr <headerField> headerFieldFactory::create
(const string& name, const string& body)
{
NameMap::const_iterator pos = m_nameMap.find(utility::stringUtils::toLower(name));
- ref <headerField> field = NULL;
+ shared_ptr <headerField> field;
if (pos != m_nameMap.end())
field = ((*pos).second)();
@@ -118,12 +118,12 @@ ref <headerField> headerFieldFactory::create
}
-ref <headerFieldValue> headerFieldFactory::createValue(const string& fieldName)
+shared_ptr <headerFieldValue> headerFieldFactory::createValue(const string& fieldName)
{
ValueMap::const_iterator pos = m_valueMap.find
(utility::stringUtils::toLower(fieldName));
- ref <headerFieldValue> value = NULL;
+ shared_ptr <headerFieldValue> value;
if (pos != m_valueMap.end())
value = ((*pos).second.allocFunc)();
diff --git a/src/htmlTextPart.cpp b/src/htmlTextPart.cpp
index ebb6587c..0aabbdc4 100644
--- a/src/htmlTextPart.cpp
+++ b/src/htmlTextPart.cpp
@@ -39,8 +39,8 @@ namespace vmime
htmlTextPart::htmlTextPart()
- : m_plainText(vmime::create <emptyContentHandler>()),
- m_text(vmime::create <emptyContentHandler>())
+ : m_plainText(make_shared <emptyContentHandler>()),
+ m_text(make_shared <emptyContentHandler>())
{
}
@@ -62,13 +62,13 @@ size_t htmlTextPart::getPartCount() const
}
-void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> parent) const
+void htmlTextPart::generateIn(shared_ptr <bodyPart> /* message */, shared_ptr <bodyPart> parent) const
{
// Plain text
if (!m_plainText->isEmpty())
{
// -- Create a new part
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
// -- Set contents
@@ -79,7 +79,7 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
// HTML text
// -- Create a new part
- ref <bodyPart> htmlPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> htmlPart = make_shared <bodyPart>();
// -- Set contents
htmlPart->getBody()->setContents(m_text,
@@ -90,7 +90,7 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
if (!m_objects.empty())
{
// Create a "multipart/related" body part
- ref <bodyPart> relPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> relPart = make_shared <bodyPart>();
parent->getBody()->appendPart(relPart);
relPart->getHeader()->ContentType()->
@@ -100,10 +100,10 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
relPart->getBody()->appendPart(htmlPart);
// Also add objects into this part
- for (std::vector <ref <embeddedObject> >::const_iterator it = m_objects.begin() ;
+ for (std::vector <shared_ptr <embeddedObject> >::const_iterator it = m_objects.begin() ;
it != m_objects.end() ; ++it)
{
- ref <bodyPart> objPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> objPart = make_shared <bodyPart>();
relPart->getBody()->appendPart(objPart);
string id = (*it)->getId();
@@ -129,11 +129,11 @@ void htmlTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> paren
void htmlTextPart::findEmbeddedParts(const bodyPart& part,
- std::vector <ref <const bodyPart> >& cidParts, std::vector <ref <const bodyPart> >& locParts)
+ std::vector <shared_ptr <const bodyPart> >& cidParts, std::vector <shared_ptr <const bodyPart> >& locParts)
{
for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i)
{
- ref <const bodyPart> p = part.getBody()->getPartAt(i);
+ shared_ptr <const bodyPart> p = part.getBody()->getPartAt(i);
// For a part to be an embedded object, it must have a
// Content-Id field or a Content-Location field.
@@ -174,25 +174,25 @@ void htmlTextPart::addEmbeddedObject(const bodyPart& part, const string& id,
try
{
- const ref <const headerField> ctf = part.getHeader()->ContentType();
- type = *ctf->getValue().dynamicCast <const mediaType>();
+ const shared_ptr <const headerField> ctf = part.getHeader()->ContentType();
+ type = *ctf->getValue <mediaType>();
}
catch (exceptions::no_such_field)
{
// No "Content-type" field: assume "application/octet-stream".
}
- m_objects.push_back(vmime::create <embeddedObject>
- (part.getBody()->getContents()->clone().dynamicCast <contentHandler>(),
+ m_objects.push_back(make_shared <embeddedObject>
+ (vmime::clone(part.getBody()->getContents()),
part.getBody()->getEncoding(), id, type, refType));
}
-void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> parent, ref <const bodyPart> textPart)
+void htmlTextPart::parse(shared_ptr <const bodyPart> message, shared_ptr <const bodyPart> parent, shared_ptr <const bodyPart> textPart)
{
// Search for possible embedded objects in the _whole_ message.
- std::vector <ref <const bodyPart> > cidParts;
- std::vector <ref <const bodyPart> > locParts;
+ std::vector <shared_ptr <const bodyPart> > cidParts;
+ std::vector <shared_ptr <const bodyPart> > locParts;
findEmbeddedParts(*message, cidParts, locParts);
@@ -208,8 +208,8 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
try
{
- const ref <const contentTypeField> ctf =
- textPart->getHeader()->findField(fields::CONTENT_TYPE).dynamicCast <contentTypeField>();
+ const shared_ptr <const contentTypeField> ctf =
+ textPart->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
m_charset = ctf->getCharset();
}
@@ -224,12 +224,12 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
// Extract embedded objects. The algorithm is quite simple: for each previously
// found inline part, we check if its CID/Location is contained in the HTML text.
- for (std::vector <ref <const bodyPart> >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p)
+ for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = cidParts.begin() ; p != cidParts.end() ; ++p)
{
- const ref <const headerField> midField =
+ const shared_ptr <const headerField> midField =
(*p)->getHeader()->findField(fields::CONTENT_ID);
- const messageId mid = *midField->getValue().dynamicCast <const messageId>();
+ const messageId mid = *midField->getValue <messageId>();
if (data.find("CID:" + mid.getId()) != string::npos ||
data.find("cid:" + mid.getId()) != string::npos)
@@ -240,12 +240,12 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
}
}
- for (std::vector <ref <const bodyPart> >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p)
+ for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = locParts.begin() ; p != locParts.end() ; ++p)
{
- const ref <const headerField> locField =
+ const shared_ptr <const headerField> locField =
(*p)->getHeader()->findField(fields::CONTENT_LOCATION);
- const text loc = *locField->getValue().dynamicCast <const text>();
+ const text loc = *locField->getValue <text>();
const string locStr = loc.getWholeBuffer();
if (data.find(locStr) != string::npos)
@@ -259,7 +259,7 @@ void htmlTextPart::parse(ref <const bodyPart> message, ref <const bodyPart> pare
// Extract plain text, if any.
if (!findPlainTextPart(*message, *parent, *textPart))
{
- m_plainText = vmime::create <emptyContentHandler>();
+ m_plainText = make_shared <emptyContentHandler>();
}
}
@@ -269,22 +269,22 @@ bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& paren
// We search for the nearest "multipart/alternative" part.
try
{
- const ref <const headerField> ctf =
+ const shared_ptr <const headerField> ctf =
part.getHeader()->findField(fields::CONTENT_TYPE);
- const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf->getValue <mediaType>();
if (type.getType() == mediaTypes::MULTIPART &&
type.getSubType() == mediaTypes::MULTIPART_ALTERNATIVE)
{
- ref <const bodyPart> foundPart = NULL;
+ shared_ptr <const bodyPart> foundPart;
for (size_t i = 0 ; i < part.getBody()->getPartCount() ; ++i)
{
- const ref <const bodyPart> p = part.getBody()->getPartAt(i);
+ const shared_ptr <const bodyPart> p = part.getBody()->getPartAt(i);
- if (p == &parent || // if "text/html" is in "multipart/related"
- p == &textPart) // if not...
+ if (p.get() == &parent || // if "text/html" is in "multipart/related"
+ p.get() == &textPart) // if not...
{
foundPart = p;
}
@@ -297,14 +297,14 @@ bool htmlTextPart::findPlainTextPart(const bodyPart& part, const bodyPart& paren
// Now, search for the alternative plain text part
for (size_t i = 0 ; !found && i < part.getBody()->getPartCount() ; ++i)
{
- const ref <const bodyPart> p = part.getBody()->getPartAt(i);
+ const shared_ptr <const bodyPart> p = part.getBody()->getPartAt(i);
try
{
- const ref <const headerField> ctf =
+ const shared_ptr <const headerField> ctf =
p->getHeader()->findField(fields::CONTENT_TYPE);
- const mediaType type = *ctf->getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf->getValue <mediaType>();
if (type.getType() == mediaTypes::TEXT &&
type.getSubType() == mediaTypes::TEXT_PLAIN)
@@ -354,25 +354,25 @@ void htmlTextPart::setCharset(const charset& ch)
}
-ref <const contentHandler> htmlTextPart::getPlainText() const
+shared_ptr <const contentHandler> htmlTextPart::getPlainText() const
{
return m_plainText;
}
-void htmlTextPart::setPlainText(ref <contentHandler> plainText)
+void htmlTextPart::setPlainText(shared_ptr <contentHandler> plainText)
{
m_plainText = plainText->clone();
}
-const ref <const contentHandler> htmlTextPart::getText() const
+const shared_ptr <const contentHandler> htmlTextPart::getText() const
{
return m_text;
}
-void htmlTextPart::setText(ref <contentHandler> text)
+void htmlTextPart::setText(shared_ptr <contentHandler> text)
{
m_text = text->clone();
}
@@ -384,15 +384,15 @@ size_t htmlTextPart::getObjectCount() const
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::getObjectAt(const size_t pos) const
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::getObjectAt(const size_t pos) const
{
return m_objects[pos];
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string& id) const
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string& id) const
{
- for (std::vector <ref <embeddedObject> >::const_iterator o = m_objects.begin() ;
+ for (std::vector <shared_ptr <embeddedObject> >::const_iterator o = m_objects.begin() ;
o != m_objects.end() ; ++o)
{
if ((*o)->matchesId(id))
@@ -405,7 +405,7 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::findObject(const string&
bool htmlTextPart::hasObject(const string& id) const
{
- for (std::vector <ref <embeddedObject> >::const_iterator o = m_objects.begin() ;
+ for (std::vector <shared_ptr <embeddedObject> >::const_iterator o = m_objects.begin() ;
o != m_objects.end() ; ++o)
{
if ((*o)->matchesId(id))
@@ -416,12 +416,12 @@ bool htmlTextPart::hasObject(const string& id) const
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
- (ref <contentHandler> data, const vmime::encoding& enc, const mediaType& type)
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
+ (shared_ptr <contentHandler> data, const vmime::encoding& enc, const mediaType& type)
{
const messageId mid(messageId::generateId());
- ref <embeddedObject> obj = vmime::create <embeddedObject>
+ shared_ptr <embeddedObject> obj = make_shared <embeddedObject>
(data, enc, mid.getId(), type, embeddedObject::REFERENCED_BY_ID);
m_objects.push_back(obj);
@@ -430,17 +430,17 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
- (ref <contentHandler> data, const mediaType& type)
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
+ (shared_ptr <contentHandler> data, const mediaType& type)
{
return addObject(data, encoding::decide(data), type);
}
-ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
+shared_ptr <const htmlTextPart::embeddedObject> htmlTextPart::addObject
(const string& data, const mediaType& type)
{
- ref <stringContentHandler> cts = vmime::create <stringContentHandler>(data);
+ shared_ptr <stringContentHandler> cts = make_shared <stringContentHandler>(data);
return addObject(cts, encoding::decide(cts), type);
}
@@ -451,15 +451,15 @@ ref <const htmlTextPart::embeddedObject> htmlTextPart::addObject
//
htmlTextPart::embeddedObject::embeddedObject
- (ref <contentHandler> data, const encoding& enc,
+ (shared_ptr <contentHandler> data, const encoding& enc,
const string& id, const mediaType& type, const ReferenceType refType)
- : m_data(data->clone().dynamicCast <contentHandler>()),
+ : m_data(vmime::clone(data)),
m_encoding(enc), m_id(id), m_type(type), m_refType(refType)
{
}
-ref <const contentHandler> htmlTextPart::embeddedObject::getData() const
+shared_ptr <const contentHandler> htmlTextPart::embeddedObject::getData() const
{
return m_data;
}
diff --git a/src/mailbox.cpp b/src/mailbox.cpp
index 1c199a76..a38aada0 100644
--- a/src/mailbox.cpp
+++ b/src/mailbox.cpp
@@ -452,9 +452,9 @@ mailbox& mailbox::operator=(const mailbox& other)
}
-ref <component>mailbox::clone() const
+shared_ptr <component>mailbox::clone() const
{
- return vmime::create <mailbox>(*this);
+ return make_shared <mailbox>(*this);
}
@@ -501,9 +501,9 @@ void mailbox::setEmail(const emailAddress& email)
}
-const std::vector <ref <component> > mailbox::getChildComponents()
+const std::vector <shared_ptr <component> > mailbox::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/mailboxField.cpp b/src/mailboxField.cpp
index 4eb9d734..7d138f3e 100644
--- a/src/mailboxField.cpp
+++ b/src/mailboxField.cpp
@@ -47,12 +47,12 @@ void mailboxField::parse
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
- ref <mailbox> mbox = vmime::create <mailbox>();
+ shared_ptr <mailbox> mbox = make_shared <mailbox>();
// Here, we cannot simply call "m_mailbox.parse()" because it
// may have more than one address specified (even if this field
// should contain only one). We are never too much careful...
- ref <address> parsedAddress = address::parseNext(ctx, buffer, position, end, newPosition, NULL);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, position, end, newPosition, NULL);
if (parsedAddress)
{
@@ -60,7 +60,7 @@ void mailboxField::parse
{
// If it is a group of mailboxes, take the first
// mailbox of the group
- ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
+ shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(parsedAddress);
if (!group->isEmpty())
mbox = group->getMailboxAt(0);
@@ -68,7 +68,7 @@ void mailboxField::parse
else
{
// Parse only if it is a mailbox
- mbox = parsedAddress.staticCast <mailbox>();
+ mbox = dynamicCast <mailbox>(parsedAddress);
}
}
diff --git a/src/mailboxGroup.cpp b/src/mailboxGroup.cpp
index 9da16653..559d8778 100644
--- a/src/mailboxGroup.cpp
+++ b/src/mailboxGroup.cpp
@@ -82,24 +82,24 @@ void mailboxGroup::parseImpl
while (pos < end && !isLastAddressOfGroup)
{
- ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, &isLastAddressOfGroup);
if (parsedAddress)
{
if (parsedAddress->isGroup())
{
- ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
+ shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(parsedAddress);
// Sub-groups are not allowed in mailbox groups: so, we add all
// the contents of the sub-group into this group...
for (size_t i = 0 ; i < group->getMailboxCount() ; ++i)
{
- m_list.push_back(group->getMailboxAt(i)->clone().staticCast <mailbox>());
+ m_list.push_back(vmime::clone(group->getMailboxAt(i)));
}
}
else
{
- m_list.push_back(parsedAddress.staticCast <mailbox>());
+ m_list.push_back(dynamicCast <mailbox>(parsedAddress));
}
}
}
@@ -168,7 +168,7 @@ void mailboxGroup::generateImpl
os << ":";
++pos;
- for (std::vector <ref <mailbox> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <mailbox> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
if (it != m_list.begin())
@@ -201,17 +201,17 @@ void mailboxGroup::copyFrom(const component& other)
removeAllMailboxes();
- for (std::vector <ref <mailbox> >::const_iterator it = source.m_list.begin() ;
+ for (std::vector <shared_ptr <mailbox> >::const_iterator it = source.m_list.begin() ;
it != source.m_list.end() ; ++it)
{
- m_list.push_back((*it)->clone().staticCast <mailbox>());
+ m_list.push_back(vmime::clone(*it));
}
}
-ref <component> mailboxGroup::clone() const
+shared_ptr <component> mailboxGroup::clone() const
{
- return vmime::create <mailboxGroup>(*this);
+ return make_shared <mailboxGroup>(*this);
}
@@ -246,15 +246,15 @@ bool mailboxGroup::isEmpty() const
}
-void mailboxGroup::appendMailbox(ref <mailbox> mbox)
+void mailboxGroup::appendMailbox(shared_ptr <mailbox> mbox)
{
m_list.push_back(mbox);
}
-void mailboxGroup::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox)
{
- const std::vector <ref <mailbox> >::iterator it = std::find
+ const std::vector <shared_ptr <mailbox> >::iterator it = std::find
(m_list.begin(), m_list.end(), beforeMailbox);
if (it == m_list.end())
@@ -264,15 +264,15 @@ void mailboxGroup::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox
}
-void mailboxGroup::insertMailboxBefore(const size_t pos, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insert(m_list.begin() + pos, mbox);
}
-void mailboxGroup::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox)
{
- const std::vector <ref <mailbox> >::iterator it = std::find
+ const std::vector <shared_ptr <mailbox> >::iterator it = std::find
(m_list.begin(), m_list.end(), afterMailbox);
if (it == m_list.end())
@@ -282,15 +282,15 @@ void mailboxGroup::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox>
}
-void mailboxGroup::insertMailboxAfter(const size_t pos, ref <mailbox> mbox)
+void mailboxGroup::insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insert(m_list.begin() + pos + 1, mbox);
}
-void mailboxGroup::removeMailbox(ref <mailbox> mbox)
+void mailboxGroup::removeMailbox(shared_ptr <mailbox> mbox)
{
- const std::vector <ref <mailbox> >::iterator it = std::find
+ const std::vector <shared_ptr <mailbox> >::iterator it = std::find
(m_list.begin(), m_list.end(), mbox);
if (it == m_list.end())
@@ -302,7 +302,7 @@ void mailboxGroup::removeMailbox(ref <mailbox> mbox)
void mailboxGroup::removeMailbox(const size_t pos)
{
- const std::vector <ref <mailbox> >::iterator it = m_list.begin() + pos;
+ const std::vector <shared_ptr <mailbox> >::iterator it = m_list.begin() + pos;
m_list.erase(it);
}
@@ -320,25 +320,25 @@ size_t mailboxGroup::getMailboxCount() const
}
-ref <mailbox> mailboxGroup::getMailboxAt(const size_t pos)
+shared_ptr <mailbox> mailboxGroup::getMailboxAt(const size_t pos)
{
return (m_list[pos]);
}
-const ref <const mailbox> mailboxGroup::getMailboxAt(const size_t pos) const
+const shared_ptr <const mailbox> mailboxGroup::getMailboxAt(const size_t pos) const
{
return (m_list[pos]);
}
-const std::vector <ref <const mailbox> > mailboxGroup::getMailboxList() const
+const std::vector <shared_ptr <const mailbox> > mailboxGroup::getMailboxList() const
{
- std::vector <ref <const mailbox> > list;
+ std::vector <shared_ptr <const mailbox> > list;
list.reserve(m_list.size());
- for (std::vector <ref <mailbox> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <mailbox> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
list.push_back(*it);
@@ -348,15 +348,15 @@ const std::vector <ref <const mailbox> > mailboxGroup::getMailboxList() const
}
-const std::vector <ref <mailbox> > mailboxGroup::getMailboxList()
+const std::vector <shared_ptr <mailbox> > mailboxGroup::getMailboxList()
{
return (m_list);
}
-const std::vector <ref <component> > mailboxGroup::getChildComponents()
+const std::vector <shared_ptr <component> > mailboxGroup::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_list, list);
diff --git a/src/mailboxList.cpp b/src/mailboxList.cpp
index f0f40ca8..0a76c52a 100644
--- a/src/mailboxList.cpp
+++ b/src/mailboxList.cpp
@@ -41,13 +41,13 @@ mailboxList::mailboxList(const mailboxList& mboxList)
}
-void mailboxList::appendMailbox(ref <mailbox> mbox)
+void mailboxList::appendMailbox(shared_ptr <mailbox> mbox)
{
m_list.appendAddress(mbox);
}
-void mailboxList::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox)
+void mailboxList::insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox)
{
try
{
@@ -60,13 +60,13 @@ void mailboxList::insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox>
}
-void mailboxList::insertMailboxBefore(const size_t pos, ref <mailbox> mbox)
+void mailboxList::insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insertAddressBefore(pos, mbox);
}
-void mailboxList::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox)
+void mailboxList::insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox)
{
try
{
@@ -79,13 +79,13 @@ void mailboxList::insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> m
}
-void mailboxList::insertMailboxAfter(const size_t pos, ref <mailbox> mbox)
+void mailboxList::insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox)
{
m_list.insertAddressAfter(pos, mbox);
}
-void mailboxList::removeMailbox(ref <mailbox> mbox)
+void mailboxList::removeMailbox(shared_ptr <mailbox> mbox)
{
try
{
@@ -122,27 +122,27 @@ bool mailboxList::isEmpty() const
}
-ref <mailbox> mailboxList::getMailboxAt(const size_t pos)
+shared_ptr <mailbox> mailboxList::getMailboxAt(const size_t pos)
{
- return m_list.getAddressAt(pos).staticCast <mailbox>();
+ return dynamicCast <mailbox>(m_list.getAddressAt(pos));
}
-const ref <const mailbox> mailboxList::getMailboxAt(const size_t pos) const
+const shared_ptr <const mailbox> mailboxList::getMailboxAt(const size_t pos) const
{
- return m_list.getAddressAt(pos).staticCast <const mailbox>();
+ return dynamicCast <const mailbox>(m_list.getAddressAt(pos));
}
-const std::vector <ref <const mailbox> > mailboxList::getMailboxList() const
+const std::vector <shared_ptr <const mailbox> > mailboxList::getMailboxList() const
{
- const std::vector <ref <const address> > addrList = m_list.getAddressList();
- std::vector <ref <const mailbox> > res;
+ const std::vector <shared_ptr <const address> > addrList = m_list.getAddressList();
+ std::vector <shared_ptr <const mailbox> > res;
- for (std::vector <ref <const address> >::const_iterator it = addrList.begin() ;
+ for (std::vector <shared_ptr <const address> >::const_iterator it = addrList.begin() ;
it != addrList.end() ; ++it)
{
- const ref <const mailbox> mbox = (*it).dynamicCast <const mailbox>();
+ const shared_ptr <const mailbox> mbox = dynamicCast <const mailbox>(*it);
if (mbox != NULL)
res.push_back(mbox);
@@ -152,15 +152,15 @@ const std::vector <ref <const mailbox> > mailboxList::getMailboxList() const
}
-const std::vector <ref <mailbox> > mailboxList::getMailboxList()
+const std::vector <shared_ptr <mailbox> > mailboxList::getMailboxList()
{
- const std::vector <ref <address> > addrList = m_list.getAddressList();
- std::vector <ref <mailbox> > res;
+ const std::vector <shared_ptr <address> > addrList = m_list.getAddressList();
+ std::vector <shared_ptr <mailbox> > res;
- for (std::vector <ref <address> >::const_iterator it = addrList.begin() ;
+ for (std::vector <shared_ptr <address> >::const_iterator it = addrList.begin() ;
it != addrList.end() ; ++it)
{
- const ref <mailbox> mbox = (*it).dynamicCast <mailbox>();
+ const shared_ptr <mailbox> mbox = dynamicCast <mailbox>(*it);
if (mbox != NULL)
res.push_back(mbox);
@@ -170,9 +170,9 @@ const std::vector <ref <mailbox> > mailboxList::getMailboxList()
}
-ref <component> mailboxList::clone() const
+shared_ptr <component> mailboxList::clone() const
{
- return vmime::create <mailboxList>(*this);
+ return make_shared <mailboxList>(*this);
}
@@ -191,7 +191,7 @@ mailboxList& mailboxList::operator=(const mailboxList& other)
}
-const std::vector <ref <component> > mailboxList::getChildComponents()
+const std::vector <shared_ptr <component> > mailboxList::getChildComponents()
{
return (m_list.getChildComponents());
}
@@ -207,13 +207,13 @@ void mailboxList::parseImpl
while (pos < end)
{
- ref <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
+ shared_ptr <address> parsedAddress = address::parseNext(ctx, buffer, pos, end, &pos, NULL);
if (parsedAddress != NULL)
{
if (parsedAddress->isGroup())
{
- ref <mailboxGroup> group = parsedAddress.staticCast <mailboxGroup>();
+ shared_ptr <mailboxGroup> group = dynamicCast <mailboxGroup>(parsedAddress);
for (size_t i = 0 ; i < group->getMailboxCount() ; ++i)
{
@@ -241,9 +241,9 @@ void mailboxList::generateImpl(const generationContext& ctx, utility::outputStre
}
-ref <addressList> mailboxList::toAddressList() const
+shared_ptr <addressList> mailboxList::toAddressList() const
{
- return m_list.clone().dynamicCast <addressList>();
+ return vmime::clone(m_list);
}
diff --git a/src/mdn/MDNHelper.cpp b/src/mdn/MDNHelper.cpp
index a0d48599..1205aef2 100644
--- a/src/mdn/MDNHelper.cpp
+++ b/src/mdn/MDNHelper.cpp
@@ -38,33 +38,33 @@ namespace vmime {
namespace mdn {
-void MDNHelper::attachMDNRequest(ref <message> msg, const mailboxList& mailboxes)
+void MDNHelper::attachMDNRequest(shared_ptr <message> msg, const mailboxList& mailboxes)
{
- ref <header> hdr = msg->getHeader();
+ shared_ptr <header> hdr = msg->getHeader();
hdr->DispositionNotificationTo()->setValue(mailboxes);
}
-void MDNHelper::attachMDNRequest(ref <message> msg, const mailbox& mbox)
+void MDNHelper::attachMDNRequest(shared_ptr <message> msg, const mailbox& mbox)
{
mailboxList mboxList;
- mboxList.appendMailbox(mbox.clone().dynamicCast <mailbox>());
+ mboxList.appendMailbox(vmime::clone(mbox));
attachMDNRequest(msg, mboxList);
}
-const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const message> msg)
+const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const shared_ptr <const message> msg)
{
std::vector <sendableMDNInfos> result;
- const ref <const header> hdr = msg->getHeader();
+ const shared_ptr <const header> hdr = msg->getHeader();
if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO))
{
- const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue()
- .dynamicCast <const mailboxList>();
+ const mailboxList& dnto =
+ *hdr->DispositionNotificationTo()->getValue <mailboxList>();
for (size_t i = 0 ; i < dnto.getMailboxCount() ; ++i)
result.push_back(sendableMDNInfos(msg, *dnto.getMailboxAt(i)));
@@ -74,9 +74,9 @@ const std::vector <sendableMDNInfos> MDNHelper::getPossibleMDNs(const ref <const
}
-bool MDNHelper::isMDN(const ref <const message> msg)
+bool MDNHelper::isMDN(const shared_ptr <const message> msg)
{
- const ref <const header> hdr = msg->getHeader();
+ const shared_ptr <const header> hdr = msg->getHeader();
// A MDN message implies the following:
// - a Content-Type field is present and its value is "multipart/report"
@@ -84,10 +84,9 @@ bool MDNHelper::isMDN(const ref <const message> msg)
// and its value is "disposition-notification"
if (hdr->hasField(fields::CONTENT_TYPE))
{
- const contentTypeField& ctf = *(hdr->ContentType()
- .dynamicCast <const contentTypeField>());
+ const contentTypeField& ctf = *dynamicCast <const contentTypeField>(hdr->ContentType());
- const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf.getValue <mediaType>();
if (type.getType() == vmime::mediaTypes::MULTIPART &&
type.getSubType() == vmime::mediaTypes::MULTIPART_REPORT)
@@ -104,7 +103,7 @@ bool MDNHelper::isMDN(const ref <const message> msg)
}
-receivedMDNInfos MDNHelper::getReceivedMDN(const ref <const message> msg)
+receivedMDNInfos MDNHelper::getReceivedMDN(const shared_ptr <const message> msg)
{
if (!isMDN(msg))
throw exceptions::invalid_argument();
@@ -113,9 +112,9 @@ receivedMDNInfos MDNHelper::getReceivedMDN(const ref <const message> msg)
}
-bool MDNHelper::needConfirmation(const ref <const message> msg)
+bool MDNHelper::needConfirmation(const shared_ptr <const message> msg)
{
- ref <const header> hdr = msg->getHeader();
+ shared_ptr <const header> hdr = msg->getHeader();
// No "Return-Path" field
if (!hdr->hasField(fields::RETURN_PATH))
@@ -124,8 +123,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
// More than one address in Disposition-Notification-To
if (hdr->hasField(fields::DISPOSITION_NOTIFICATION_TO))
{
- const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue()
- .dynamicCast <const mailboxList>();
+ const mailboxList& dnto = *hdr->DispositionNotificationTo()->getValue <mailboxList>();
if (dnto.getMailboxCount() > 1)
return true;
@@ -134,7 +132,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
// Return-Path != Disposition-Notification-To
const mailbox& mbox = *dnto.getMailboxAt(0);
- const path& rp = *hdr->ReturnPath()->getValue().dynamicCast <const path>();
+ const path& rp = *hdr->ReturnPath()->getValue <path>();
if (mbox.getEmail() != rp.getLocalPart() + "@" + rp.getDomain())
return true;
@@ -145,7 +143,7 @@ bool MDNHelper::needConfirmation(const ref <const message> msg)
}
-ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
+shared_ptr <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
const string& text,
const charset& ch,
const mailbox& expeditor,
@@ -155,19 +153,19 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
const std::map <string, string>& fields)
{
// Create a new message
- ref <message> msg = vmime::create <message>();
+ shared_ptr <message> msg = make_shared <message>();
// Fill-in header fields
- ref <header> hdr = msg->getHeader();
+ shared_ptr <header> hdr = msg->getHeader();
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MULTIPART,
vmime::mediaTypes::MULTIPART_REPORT));
- hdr->ContentType().dynamicCast <contentTypeField>()->setReportType("disposition-notification");
+ dynamicCast <contentTypeField>(hdr->ContentType())->setReportType("disposition-notification");
hdr->Disposition()->setValue(dispo);
addressList to;
- to.appendAddress(vmime::create <mailbox>(mdnInfos.getRecipient()));
+ to.appendAddress(make_shared <mailbox>(mdnInfos.getRecipient()));
hdr->To()->setValue(to);
hdr->From()->setValue(expeditor);
@@ -186,36 +184,36 @@ ref <message> MDNHelper::buildMDN(const sendableMDNInfos& mdnInfos,
}
-ref <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
+shared_ptr <bodyPart> MDNHelper::createFirstMDNPart(const sendableMDNInfos& /* mdnInfos */,
const string& text, const charset& ch)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
// Header
- ref <header> hdr = part->getHeader();
+ shared_ptr <header> hdr = part->getHeader();
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT,
vmime::mediaTypes::TEXT_PLAIN));
- hdr->ContentType().dynamicCast <contentTypeField>()->setCharset(ch);
+ dynamicCast <contentTypeField>(hdr->ContentType())->setCharset(ch);
// Body
- part->getBody()->setContents(vmime::create <stringContentHandler>(text));
+ part->getBody()->setContents(make_shared <stringContentHandler>(text));
return (part);
}
-ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
+shared_ptr <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
const disposition& dispo,
const string& reportingUA,
const std::vector <string>& reportingUAProducts,
const std::map <string, string>& additionalFields)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
// Header
- ref <header> hdr = part->getHeader();
+ shared_ptr <header> hdr = part->getHeader();
hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE);
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::MESSAGE,
@@ -257,7 +255,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
ruaText += reportingUAProducts[i];
}
- ref <headerField> rua = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> rua = headerFieldFactory::getInstance()->
create(vmime::fields::REPORTING_UA);
rua->setValue(ruaText);
@@ -266,7 +264,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
}
// -- Final-Recipient
- ref <headerField> fr = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> fr = headerFieldFactory::getInstance()->
create(vmime::fields::FINAL_RECIPIENT);
fr->setValue("rfc822; " + mdnInfos.getRecipient().getEmail().generate());
@@ -291,7 +289,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
it = additionalFields.find(vmime::fields::ERROR);
if (it != additionalFields.end())
{
- ref <headerField> error = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> error = headerFieldFactory::getInstance()->
create(vmime::fields::ERROR);
error->setValue(it->second);
fields.appendField(error);
@@ -300,7 +298,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
it = additionalFields.find(vmime::fields::WARNING);
if (it != additionalFields.end())
{
- ref <headerField> warn = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> warn = headerFieldFactory::getInstance()->
create(vmime::fields::WARNING);
warn->setValue(it->second);
fields.appendField(warn);
@@ -309,7 +307,7 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
it = additionalFields.find(vmime::fields::FAILURE);
if (it != additionalFields.end())
{
- ref <headerField> fail = headerFieldFactory::getInstance()->
+ shared_ptr <headerField> fail = headerFieldFactory::getInstance()->
create(vmime::fields::FAILURE);
fail->setValue(it->second);
fields.appendField(fail);
@@ -322,18 +320,18 @@ ref <bodyPart> MDNHelper::createSecondMDNPart(const sendableMDNInfos& mdnInfos,
fields.generate(vos);
- part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
+ part->getBody()->setContents(make_shared <stringContentHandler>(oss.str()));
return (part);
}
-ref <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
+shared_ptr <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
{
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
// Header
- ref <header> hdr = part->getHeader();
+ shared_ptr <header> hdr = part->getHeader();
hdr->ContentDisposition()->setValue(vmime::contentDispositionTypes::INLINE);
hdr->ContentType()->setValue(mediaType(vmime::mediaTypes::TEXT,
@@ -345,7 +343,7 @@ ref <bodyPart> MDNHelper::createThirdMDNPart(const sendableMDNInfos& mdnInfos)
mdnInfos.getMessage()->getHeader()->generate(vos);
- part->getBody()->setContents(vmime::create <stringContentHandler>(oss.str()));
+ part->getBody()->setContents(make_shared <stringContentHandler>(oss.str()));
return (part);
}
diff --git a/src/mdn/receivedMDNInfos.cpp b/src/mdn/receivedMDNInfos.cpp
index 876ba3d9..1c523be7 100644
--- a/src/mdn/receivedMDNInfos.cpp
+++ b/src/mdn/receivedMDNInfos.cpp
@@ -30,7 +30,7 @@ namespace vmime {
namespace mdn {
-receivedMDNInfos::receivedMDNInfos(const ref <const message> msg)
+receivedMDNInfos::receivedMDNInfos(const shared_ptr <const message> msg)
: m_msg(msg)
{
extract();
@@ -51,7 +51,7 @@ receivedMDNInfos& receivedMDNInfos::operator=(const receivedMDNInfos& other)
}
-const ref <const message> receivedMDNInfos::getMessage() const
+const shared_ptr <const message> receivedMDNInfos::getMessage() const
{
return (m_msg);
}
@@ -86,17 +86,16 @@ void receivedMDNInfos::copyFrom(const receivedMDNInfos& other)
void receivedMDNInfos::extract()
{
- const ref <const body> bdy = m_msg->getBody();
+ const shared_ptr <const body> bdy = m_msg->getBody();
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
{
- const ref <const bodyPart> part = bdy->getPartAt(i);
+ const shared_ptr <const bodyPart> part = bdy->getPartAt(i);
if (!part->getHeader()->hasField(fields::CONTENT_TYPE))
continue;
- const mediaType& type = *part->getHeader()->ContentType()->
- getValue().dynamicCast <const mediaType>();
+ const mediaType& type = *part->getHeader()->ContentType()->getValue <mediaType>();
// Extract from second part (message/disposition-notification)
if (type.getType() == vmime::mediaTypes::MESSAGE &&
@@ -111,15 +110,15 @@ void receivedMDNInfos::extract()
header fields;
fields.parse(oss.str());
- try { m_omid = *fields.OriginalMessageId()->getValue().dynamicCast <const messageId>(); }
+ try { m_omid = *fields.OriginalMessageId()->getValue <messageId>(); }
catch (exceptions::no_such_field&) { /* Ignore */ }
- try { m_disp = *fields.Disposition()->getValue().dynamicCast <const disposition>(); }
+ try { m_disp = *fields.Disposition()->getValue <disposition>(); }
catch (exceptions::no_such_field&) { /* Ignore */ }
try
{
- text t = *fields.findField("Received-content-MIC")->getValue().dynamicCast <const text>();
+ text t = *fields.findField("Received-content-MIC")->getValue <text>();
m_contentMIC = t.generate();
}
catch (exceptions::no_such_field&) { /* Ignore */ }
diff --git a/src/mdn/sendableMDNInfos.cpp b/src/mdn/sendableMDNInfos.cpp
index 44c0515c..c145c3b6 100644
--- a/src/mdn/sendableMDNInfos.cpp
+++ b/src/mdn/sendableMDNInfos.cpp
@@ -28,7 +28,7 @@ namespace vmime {
namespace mdn {
-sendableMDNInfos::sendableMDNInfos(const ref <const message> msg, const mailbox& mbox)
+sendableMDNInfos::sendableMDNInfos(const shared_ptr <const message> msg, const mailbox& mbox)
: m_msg(msg), m_mailbox(mbox)
{
}
@@ -48,7 +48,7 @@ sendableMDNInfos& sendableMDNInfos::operator=(const sendableMDNInfos& other)
}
-const ref <const message> sendableMDNInfos::getMessage() const
+const shared_ptr <const message> sendableMDNInfos::getMessage() const
{
return (m_msg);
}
diff --git a/src/mediaType.cpp b/src/mediaType.cpp
index 123c8cee..2f9ca6b1 100644
--- a/src/mediaType.cpp
+++ b/src/mediaType.cpp
@@ -126,9 +126,9 @@ mediaType& mediaType::operator=(const string& type)
}
-ref <component> mediaType::clone() const
+shared_ptr <component> mediaType::clone() const
{
- return vmime::create <mediaType>(m_type, m_subType);
+ return make_shared <mediaType>(m_type, m_subType);
}
@@ -178,9 +178,9 @@ void mediaType::setFromString(const string& type)
}
-const std::vector <ref <component> > mediaType::getChildComponents()
+const std::vector <shared_ptr <component> > mediaType::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/messageBuilder.cpp b/src/messageBuilder.cpp
index ecd0f5d7..64880483 100644
--- a/src/messageBuilder.cpp
+++ b/src/messageBuilder.cpp
@@ -43,10 +43,10 @@ messageBuilder::~messageBuilder()
}
-ref <message> messageBuilder::construct() const
+shared_ptr <message> messageBuilder::construct() const
{
// Create a new message
- ref <message> msg = vmime::create <message>();
+ shared_ptr <message> msg = make_shared <message>();
// Generate the header fields
msg->getHeader()->Subject()->setValue(m_subject);
@@ -101,7 +101,7 @@ ref <message> messageBuilder::construct() const
(mediaType(mediaTypes::MULTIPART, mediaTypes::MULTIPART_MIXED));
// Create a sub-part "multipart/alternative" for text parts
- ref <bodyPart> subPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> subPart = make_shared <bodyPart>();
msg->getBody()->appendPart(subPart);
subPart->getHeader()->ContentType()->setValue
@@ -133,7 +133,7 @@ ref <message> messageBuilder::construct() const
// Generate the attachments
if (!m_attach.empty())
{
- for (std::vector <ref <attachment> >::const_iterator a = m_attach.begin() ;
+ for (std::vector <shared_ptr <attachment> >::const_iterator a = m_attach.begin() ;
a != m_attach.end() ; ++a)
{
(*a)->generateIn(msg);
@@ -147,12 +147,12 @@ ref <message> messageBuilder::construct() const
const bodyPart& part = *msg->getBody()->getPartAt(0);
// Make a full copy of the body, otherwise the copyFrom() will delete the body we're copying
- ref <body> bodyCopy = part.getBody()->clone().dynamicCast <body>();
+ shared_ptr <body> bodyCopy = vmime::clone(part.getBody());
// First, copy (and replace) the header fields
- const std::vector <ref <const headerField> > fields = part.getHeader()->getFieldList();
+ const std::vector <shared_ptr <const headerField> > fields = part.getHeader()->getFieldList();
- for (std::vector <ref <const headerField> >::const_iterator it = fields.begin() ;
+ for (std::vector <shared_ptr <const headerField> >::const_iterator it = fields.begin() ;
it != fields.end() ; ++it)
{
*(msg->getHeader()->getField((*it)->getName())) = **it;
@@ -167,13 +167,13 @@ ref <message> messageBuilder::construct() const
}
-void messageBuilder::attach(ref <attachment> attach)
+void messageBuilder::attach(shared_ptr <attachment> attach)
{
appendAttachment(attach);
}
-void messageBuilder::appendAttachment(ref <attachment> attach)
+void messageBuilder::appendAttachment(shared_ptr <attachment> attach)
{
m_attach.push_back(attach);
}
@@ -181,7 +181,7 @@ void messageBuilder::appendAttachment(ref <attachment> attach)
void messageBuilder::constructTextPart(const mediaType& type)
{
- ref <textPart> part = NULL;
+ shared_ptr <textPart> part;
try
{
@@ -196,7 +196,7 @@ void messageBuilder::constructTextPart(const mediaType& type)
}
-ref <textPart> messageBuilder::getTextPart()
+shared_ptr <textPart> messageBuilder::getTextPart()
{
return (m_textPart);
}
@@ -286,13 +286,13 @@ void messageBuilder::removeAttachment(const size_t pos)
}
-const ref <const attachment> messageBuilder::getAttachmentAt(const size_t pos) const
+const shared_ptr <const attachment> messageBuilder::getAttachmentAt(const size_t pos) const
{
return (m_attach[pos]);
}
-ref <attachment> messageBuilder::getAttachmentAt(const size_t pos)
+shared_ptr <attachment> messageBuilder::getAttachmentAt(const size_t pos)
{
return (m_attach[pos]);
}
@@ -304,13 +304,13 @@ size_t messageBuilder::getAttachmentCount() const
}
-const std::vector <ref <const attachment> > messageBuilder::getAttachmentList() const
+const std::vector <shared_ptr <const attachment> > messageBuilder::getAttachmentList() const
{
- std::vector <ref <const attachment> > res;
+ std::vector <shared_ptr <const attachment> > res;
res.reserve(m_attach.size());
- for (std::vector <ref <attachment> >::const_iterator it = m_attach.begin() ;
+ for (std::vector <shared_ptr <attachment> >::const_iterator it = m_attach.begin() ;
it != m_attach.end() ; ++it)
{
res.push_back(*it);
@@ -320,7 +320,7 @@ const std::vector <ref <const attachment> > messageBuilder::getAttachmentList()
}
-const std::vector <ref <attachment> > messageBuilder::getAttachmentList()
+const std::vector <shared_ptr <attachment> > messageBuilder::getAttachmentList()
{
return (m_attach);
}
diff --git a/src/messageId.cpp b/src/messageId.cpp
index 6b558e1b..d981f061 100644
--- a/src/messageId.cpp
+++ b/src/messageId.cpp
@@ -146,7 +146,7 @@ void messageId::parseImpl
}
-ref <messageId> messageId::parseNext
+shared_ptr <messageId> messageId::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
@@ -162,7 +162,7 @@ ref <messageId> messageId::parseNext
while (pos < end && !parserHelpers::isSpace(buffer[pos]))
++pos;
- ref <messageId> mid = vmime::create <messageId>();
+ shared_ptr <messageId> mid = make_shared <messageId>();
mid->parse(ctx, buffer, begin, pos, NULL);
if (newPosition != NULL)
@@ -174,7 +174,7 @@ ref <messageId> messageId::parseNext
if (newPosition != NULL)
*newPosition = end;
- return (NULL);
+ return null;
}
@@ -245,9 +245,9 @@ bool messageId::operator!=(const messageId& mid) const
}
-ref <component> messageId::clone() const
+shared_ptr <component> messageId::clone() const
{
- return vmime::create <messageId>(*this);
+ return make_shared <messageId>(*this);
}
@@ -291,9 +291,9 @@ void messageId::setRight(const string& right)
}
-const std::vector <ref <component> > messageId::getChildComponents()
+const std::vector <shared_ptr <component> > messageId::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/messageIdSequence.cpp b/src/messageIdSequence.cpp
index 99c96319..bfd0c30f 100644
--- a/src/messageIdSequence.cpp
+++ b/src/messageIdSequence.cpp
@@ -50,9 +50,9 @@ messageIdSequence::messageIdSequence(const messageIdSequence& midSeq)
}
-ref <component> messageIdSequence::clone() const
+shared_ptr <component> messageIdSequence::clone() const
{
- return vmime::create <messageIdSequence>(*this);
+ return make_shared <messageIdSequence>(*this);
}
@@ -63,7 +63,7 @@ void messageIdSequence::copyFrom(const component& other)
removeAllMessageIds();
for (unsigned int i = 0 ; i < midSeq.m_list.size() ; ++i)
- m_list.push_back(midSeq.m_list[i]->clone().dynamicCast <messageId>());
+ m_list.push_back(vmime::clone(midSeq.m_list[i]));
}
@@ -74,9 +74,9 @@ messageIdSequence& messageIdSequence::operator=(const messageIdSequence& other)
}
-const std::vector <ref <component> > messageIdSequence::getChildComponents()
+const std::vector <shared_ptr <component> > messageIdSequence::getChildComponents()
{
- std::vector <ref <component> > res;
+ std::vector <shared_ptr <component> > res;
copy_vector(m_list, res);
@@ -94,7 +94,7 @@ void messageIdSequence::parseImpl
while (pos < end)
{
- ref <messageId> parsedMid = messageId::parseNext(ctx, buffer, pos, end, &pos);
+ shared_ptr <messageId> parsedMid = messageId::parseNext(ctx, buffer, pos, end, &pos);
if (parsedMid != NULL)
m_list.push_back(parsedMid);
@@ -118,7 +118,7 @@ void messageIdSequence::generateImpl
generationContext tmpCtx(ctx);
tmpCtx.setMaxLineLength(ctx.getMaxLineLength() - 2);
- for (std::vector <ref <messageId> >::const_iterator it = m_list.begin() ; ; )
+ for (std::vector <shared_ptr <messageId> >::const_iterator it = m_list.begin() ; ; )
{
(*it)->generate(ctx, os, pos, &pos);
@@ -135,15 +135,15 @@ void messageIdSequence::generateImpl
}
-void messageIdSequence::appendMessageId(ref <messageId> mid)
+void messageIdSequence::appendMessageId(shared_ptr <messageId> mid)
{
m_list.push_back(mid);
}
-void messageIdSequence::insertMessageIdBefore(ref <messageId> beforeMid, ref <messageId> mid)
+void messageIdSequence::insertMessageIdBefore(shared_ptr <messageId> beforeMid, shared_ptr <messageId> mid)
{
- const std::vector <ref <messageId> >::iterator it = std::find
+ const std::vector <shared_ptr <messageId> >::iterator it = std::find
(m_list.begin(), m_list.end(), beforeMid);
if (it == m_list.end())
@@ -153,15 +153,15 @@ void messageIdSequence::insertMessageIdBefore(ref <messageId> beforeMid, ref <me
}
-void messageIdSequence::insertMessageIdBefore(const size_t pos, ref <messageId> mid)
+void messageIdSequence::insertMessageIdBefore(const size_t pos, shared_ptr <messageId> mid)
{
m_list.insert(m_list.begin() + pos, mid);
}
-void messageIdSequence::insertMessageIdAfter(ref <messageId> afterMid, ref <messageId> mid)
+void messageIdSequence::insertMessageIdAfter(shared_ptr <messageId> afterMid, shared_ptr <messageId> mid)
{
- const std::vector <ref <messageId> >::iterator it = std::find
+ const std::vector <shared_ptr <messageId> >::iterator it = std::find
(m_list.begin(), m_list.end(), afterMid);
if (it == m_list.end())
@@ -171,15 +171,15 @@ void messageIdSequence::insertMessageIdAfter(ref <messageId> afterMid, ref <mess
}
-void messageIdSequence::insertMessageIdAfter(const size_t pos, ref <messageId> mid)
+void messageIdSequence::insertMessageIdAfter(const size_t pos, shared_ptr <messageId> mid)
{
m_list.insert(m_list.begin() + pos + 1, mid);
}
-void messageIdSequence::removeMessageId(ref <messageId> mid)
+void messageIdSequence::removeMessageId(shared_ptr <messageId> mid)
{
- const std::vector <ref <messageId> >::iterator it = std::find
+ const std::vector <shared_ptr <messageId> >::iterator it = std::find
(m_list.begin(), m_list.end(), mid);
if (it == m_list.end())
@@ -191,7 +191,7 @@ void messageIdSequence::removeMessageId(ref <messageId> mid)
void messageIdSequence::removeMessageId(const size_t pos)
{
- const std::vector <ref <messageId> >::iterator it = m_list.begin() + pos;
+ const std::vector <shared_ptr <messageId> >::iterator it = m_list.begin() + pos;
m_list.erase(it);
}
@@ -215,25 +215,25 @@ bool messageIdSequence::isEmpty() const
}
-const ref <messageId> messageIdSequence::getMessageIdAt(const size_t pos)
+const shared_ptr <messageId> messageIdSequence::getMessageIdAt(const size_t pos)
{
return (m_list[pos]);
}
-const ref <const messageId> messageIdSequence::getMessageIdAt(const size_t pos) const
+const shared_ptr <const messageId> messageIdSequence::getMessageIdAt(const size_t pos) const
{
return (m_list[pos]);
}
-const std::vector <ref <const messageId> > messageIdSequence::getMessageIdList() const
+const std::vector <shared_ptr <const messageId> > messageIdSequence::getMessageIdList() const
{
- std::vector <ref <const messageId> > list;
+ std::vector <shared_ptr <const messageId> > list;
list.reserve(m_list.size());
- for (std::vector <ref <messageId> >::const_iterator it = m_list.begin() ;
+ for (std::vector <shared_ptr <messageId> >::const_iterator it = m_list.begin() ;
it != m_list.end() ; ++it)
{
list.push_back(*it);
@@ -243,7 +243,7 @@ const std::vector <ref <const messageId> > messageIdSequence::getMessageIdList()
}
-const std::vector <ref <messageId> > messageIdSequence::getMessageIdList()
+const std::vector <shared_ptr <messageId> > messageIdSequence::getMessageIdList()
{
return (m_list);
}
diff --git a/src/messageParser.cpp b/src/messageParser.cpp
index 1377072c..41be3803 100644
--- a/src/messageParser.cpp
+++ b/src/messageParser.cpp
@@ -39,14 +39,14 @@ namespace vmime
messageParser::messageParser(const string& buffer)
{
- ref <message> msg = vmime::create <message>();
+ shared_ptr <message> msg = make_shared <message>();
msg->parse(buffer);
parse(msg);
}
-messageParser::messageParser(ref <const message> msg)
+messageParser::messageParser(shared_ptr <const message> msg)
{
parse(msg);
}
@@ -57,13 +57,13 @@ messageParser::~messageParser()
}
-void messageParser::parse(ref <const message> msg)
+void messageParser::parse(shared_ptr <const message> msg)
{
// Header fields (if field is present, copy its value, else do nothing)
#ifndef VMIME_BUILDING_DOC
#define TRY_FIELD(var, type, name) \
- try { var = *msg->getHeader()->findField(name)->getValue().dynamicCast <type>(); } \
+ try { var = *msg->getHeader()->findField(name)->getValue <type>(); } \
catch (exceptions::no_such_field) { }
TRY_FIELD(m_from, mailbox, fields::FROM);
@@ -82,14 +82,14 @@ void messageParser::parse(ref <const message> msg)
try
{
const headerField& recv = *msg->getHeader()->findField(fields::RECEIVED);
- m_date = recv.getValue().dynamicCast <const relay>()->getDate();
+ m_date = recv.getValue <relay>()->getDate();
}
catch (vmime::exceptions::no_such_field&)
{
try
{
const headerField& date = *msg->getHeader()->findField(fields::DATE);
- m_date = *date.getValue().dynamicCast <const datetime>();
+ m_date = *date.getValue <datetime>();
}
catch (vmime::exceptions::no_such_field&)
{
@@ -105,13 +105,13 @@ void messageParser::parse(ref <const message> msg)
}
-void messageParser::findAttachments(ref <const message> msg)
+void messageParser::findAttachments(shared_ptr <const message> msg)
{
m_attach = attachmentHelper::findAttachmentsInMessage(msg);
}
-void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart> part)
+void messageParser::findTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> part)
{
// Handle the case in which the message is not multipart: if the body part is
// "text/*", take this part.
@@ -122,11 +122,11 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*msg->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *msg->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
const mediaType ctfType =
- *ctf.getValue().dynamicCast <const mediaType>();
+ *ctf.getValue <mediaType>();
if (ctfType.getType() == mediaTypes::TEXT)
{
@@ -142,7 +142,7 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
if (accept)
{
- ref <textPart> txtPart = textPartFactory::getInstance()->create(type);
+ shared_ptr <textPart> txtPart = textPartFactory::getInstance()->create(type);
txtPart->parse(msg, msg, msg);
m_textParts.push_back(txtPart);
@@ -156,35 +156,35 @@ void messageParser::findTextParts(ref <const bodyPart> msg, ref <const bodyPart>
}
-bool messageParser::findSubTextParts(ref <const bodyPart> msg, ref <const bodyPart> part)
+bool messageParser::findSubTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> part)
{
// In general, all the text parts are contained in parallel in the same
// parent part (or message).
// So, wherever the text parts are, all we have to do is to find the first
// MIME part which is a text part.
- std::vector <ref <const bodyPart> > textParts;
+ std::vector <shared_ptr <const bodyPart> > textParts;
for (size_t i = 0 ; i < part->getBody()->getPartCount() ; ++i)
{
- const ref <const bodyPart> p = part->getBody()->getPartAt(i);
+ const shared_ptr <const bodyPart> p = part->getBody()->getPartAt(i);
try
{
- const contentTypeField& ctf = dynamic_cast <const contentTypeField&>
- (*(p->getHeader()->findField(fields::CONTENT_TYPE)));
+ const contentTypeField& ctf =
+ *p->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf.getValue <mediaType>();
contentDisposition disp; // default should be inline
if (type.getType() == mediaTypes::TEXT)
{
try
{
- ref <const contentDispositionField> cdf = p->getHeader()->
- findField(fields::CONTENT_DISPOSITION).dynamicCast <const contentDispositionField>();
+ shared_ptr <const contentDispositionField> cdf = p->getHeader()->
+ findField <contentDispositionField>(fields::CONTENT_DISPOSITION);
- disp = *cdf->getValue().dynamicCast <const contentDisposition>();
+ disp = *cdf->getValue <contentDisposition>();
}
catch (exceptions::no_such_field&)
{
@@ -204,17 +204,17 @@ bool messageParser::findSubTextParts(ref <const bodyPart> msg, ref <const bodyPa
if (textParts.size())
{
// Okay. So we have found at least one text part
- for (std::vector <ref <const bodyPart> >::const_iterator p = textParts.begin() ;
+ for (std::vector <shared_ptr <const bodyPart> >::const_iterator p = textParts.begin() ;
p != textParts.end() ; ++p)
{
- const contentTypeField& ctf = dynamic_cast <const contentTypeField&>
- (*((*p)->getHeader()->findField(fields::CONTENT_TYPE)));
+ const contentTypeField& ctf =
+ *(*p)->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
- const mediaType type = *ctf.getValue().dynamicCast <const mediaType>();
+ const mediaType type = *ctf.getValue <mediaType>();
try
{
- ref <textPart> txtPart = textPartFactory::getInstance()->create(type);
+ shared_ptr <textPart> txtPart = textPartFactory::getInstance()->create(type);
txtPart->parse(msg, part, *p);
m_textParts.push_back(txtPart);
@@ -273,7 +273,7 @@ const datetime& messageParser::getDate() const
}
-const std::vector <ref <const attachment> > messageParser::getAttachmentList() const
+const std::vector <shared_ptr <const attachment> > messageParser::getAttachmentList() const
{
return m_attach;
}
@@ -285,19 +285,19 @@ size_t messageParser::getAttachmentCount() const
}
-const ref <const attachment> messageParser::getAttachmentAt(const size_t pos) const
+const shared_ptr <const attachment> messageParser::getAttachmentAt(const size_t pos) const
{
return (m_attach[pos]);
}
-const std::vector <ref <const textPart> > messageParser::getTextPartList() const
+const std::vector <shared_ptr <const textPart> > messageParser::getTextPartList() const
{
- std::vector <ref <const textPart> > res;
+ std::vector <shared_ptr <const textPart> > res;
res.reserve(m_textParts.size());
- for (std::vector <ref <textPart> >::const_iterator it = m_textParts.begin() ;
+ for (std::vector <shared_ptr <textPart> >::const_iterator it = m_textParts.begin() ;
it != m_textParts.end() ; ++it)
{
res.push_back(*it);
@@ -313,7 +313,7 @@ size_t messageParser::getTextPartCount() const
}
-const ref <const textPart> messageParser::getTextPartAt(const size_t pos) const
+const shared_ptr <const textPart> messageParser::getTextPartAt(const size_t pos) const
{
return (m_textParts[pos]);
}
diff --git a/src/misc/importanceHelper.cpp b/src/misc/importanceHelper.cpp
index 2cc7ce6a..8066cc5f 100644
--- a/src/misc/importanceHelper.cpp
+++ b/src/misc/importanceHelper.cpp
@@ -31,17 +31,17 @@ namespace vmime {
namespace misc {
-void importanceHelper::resetImportance(ref <message> msg)
+void importanceHelper::resetImportance(shared_ptr <message> msg)
{
resetImportanceHeader(msg->getHeader());
}
-void importanceHelper::resetImportanceHeader(ref <header> hdr)
+void importanceHelper::resetImportanceHeader(shared_ptr <header> hdr)
{
try
{
- ref <headerField> fld = hdr->findField("X-Priority");
+ shared_ptr <headerField> fld = hdr->findField("X-Priority");
hdr->removeField(fld);
}
catch (exceptions::no_such_field)
@@ -51,7 +51,7 @@ void importanceHelper::resetImportanceHeader(ref <header> hdr)
try
{
- ref <headerField> fld = hdr->findField("Importance");
+ shared_ptr <headerField> fld = hdr->findField("Importance");
hdr->removeField(fld);
}
catch (exceptions::no_such_field)
@@ -61,19 +61,19 @@ void importanceHelper::resetImportanceHeader(ref <header> hdr)
}
-importanceHelper::Importance importanceHelper::getImportance(ref <const message> msg)
+importanceHelper::Importance importanceHelper::getImportance(shared_ptr <const message> msg)
{
return getImportanceHeader(msg->getHeader());
}
-importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const header> hdr)
+importanceHelper::Importance importanceHelper::getImportanceHeader(shared_ptr <const header> hdr)
{
// Try "X-Priority" field
try
{
- const ref <const headerField> fld = hdr->findField("X-Priority");
- const string value = fld->getValue().dynamicCast <const text>()->getWholeBuffer();
+ const shared_ptr <const headerField> fld = hdr->findField("X-Priority");
+ const string value = fld->getValue <text>()->getWholeBuffer();
int n = IMPORTANCE_NORMAL;
@@ -98,9 +98,9 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const he
// Try "Importance" field
try
{
- const ref <const headerField> fld = hdr->findField("Importance");
+ const shared_ptr <const headerField> fld = hdr->findField("Importance");
const string value = utility::stringUtils::toLower(utility::stringUtils::trim
- (fld->getValue().dynamicCast <const text>()->getWholeBuffer()));
+ (fld->getValue <text>()->getWholeBuffer()));
if (value == "low")
return (IMPORTANCE_LOWEST);
@@ -121,16 +121,16 @@ importanceHelper::Importance importanceHelper::getImportanceHeader(ref <const he
}
-void importanceHelper::setImportance(ref <message> msg, const Importance i)
+void importanceHelper::setImportance(shared_ptr <message> msg, const Importance i)
{
setImportanceHeader(msg->getHeader(), i);
}
-void importanceHelper::setImportanceHeader(ref <header> hdr, const Importance i)
+void importanceHelper::setImportanceHeader(shared_ptr <header> hdr, const Importance i)
{
// "X-Priority:" Field
- ref <headerField> fld = hdr->getField("X-Priority");
+ shared_ptr <headerField> fld = hdr->getField("X-Priority");
switch (i)
{
diff --git a/src/net/events.cpp b/src/net/events.cpp
index 8cc23706..a19e1738 100644
--- a/src/net/events.cpp
+++ b/src/net/events.cpp
@@ -60,7 +60,7 @@ const char* messageCountEvent::EVENT_CLASS = "messageCountEvent";
messageCountEvent::messageCountEvent
- (ref <folder> folder, const Types type, const std::vector <int>& nums)
+ (shared_ptr <folder> folder, const Types type, const std::vector <int>& nums)
: m_folder(folder), m_type(type)
{
m_nums.resize(nums.size());
@@ -68,7 +68,7 @@ messageCountEvent::messageCountEvent
}
-ref <folder> messageCountEvent::getFolder() const { return (m_folder); }
+shared_ptr <folder> messageCountEvent::getFolder() const { return (m_folder); }
messageCountEvent::Types messageCountEvent::getType() const { return (m_type); }
const std::vector <int>& messageCountEvent::getNumbers() const { return (m_nums); }
@@ -76,9 +76,9 @@ const std::vector <int>& messageCountEvent::getNumbers() const { return (m_nums)
void messageCountEvent::dispatch(messageCountListener* listener)
{
if (m_type == TYPE_ADDED)
- listener->messagesAdded(thisRef().dynamicCast <messageCountEvent>());
+ listener->messagesAdded(dynamicCast <messageCountEvent>(shared_from_this()));
else
- listener->messagesRemoved(thisRef().dynamicCast <messageCountEvent>());
+ listener->messagesRemoved(dynamicCast <messageCountEvent>(shared_from_this()));
}
@@ -96,7 +96,7 @@ const char* messageChangedEvent::EVENT_CLASS = "messageChangedEvent";
messageChangedEvent::messageChangedEvent
- (ref <folder> folder, const Types type, const std::vector <int>& nums)
+ (shared_ptr <folder> folder, const Types type, const std::vector <int>& nums)
: m_folder(folder), m_type(type)
{
m_nums.resize(nums.size());
@@ -104,14 +104,14 @@ messageChangedEvent::messageChangedEvent
}
-ref <folder> messageChangedEvent::getFolder() const { return (m_folder); }
+shared_ptr <folder> messageChangedEvent::getFolder() const { return (m_folder); }
messageChangedEvent::Types messageChangedEvent::getType() const { return (m_type); }
const std::vector <int>& messageChangedEvent::getNumbers() const { return (m_nums); }
void messageChangedEvent::dispatch(messageChangedListener* listener)
{
- listener->messageChanged(thisRef().dynamicCast <messageChangedEvent>());
+ listener->messageChanged(dynamicCast <messageChangedEvent>(shared_from_this()));
}
@@ -129,14 +129,14 @@ const char* folderEvent::EVENT_CLASS = "folderEvent";
folderEvent::folderEvent
- (ref <folder> folder, const Types type,
+ (shared_ptr <folder> folder, const Types type,
const utility::path& oldPath, const utility::path& newPath)
: m_folder(folder), m_type(type), m_oldPath(oldPath), m_newPath(newPath)
{
}
-ref <folder> folderEvent::getFolder() const { return (m_folder); }
+shared_ptr <folder> folderEvent::getFolder() const { return (m_folder); }
folderEvent::Types folderEvent::getType() const { return (m_type); }
@@ -144,9 +144,9 @@ void folderEvent::dispatch(folderListener* listener)
{
switch (m_type)
{
- case TYPE_CREATED: listener->folderCreated(thisRef().dynamicCast <folderEvent>()); break;
- case TYPE_RENAMED: listener->folderRenamed(thisRef().dynamicCast <folderEvent>()); break;
- case TYPE_DELETED: listener->folderDeleted(thisRef().dynamicCast <folderEvent>()); break;
+ case TYPE_CREATED: listener->folderCreated(dynamicCast <folderEvent>(shared_from_this())); break;
+ case TYPE_RENAMED: listener->folderRenamed(dynamicCast <folderEvent>(shared_from_this())); break;
+ case TYPE_DELETED: listener->folderDeleted(dynamicCast <folderEvent>(shared_from_this())); break;
}
}
diff --git a/src/net/folder.cpp b/src/net/folder.cpp
index 1cc618d4..1d6f3140 100644
--- a/src/net/folder.cpp
+++ b/src/net/folder.cpp
@@ -48,7 +48,7 @@ void folder::removeMessageChangedListener(events::messageChangedListener* l)
}
-void folder::notifyMessageChanged(ref <events::messageChangedEvent> event)
+void folder::notifyMessageChanged(shared_ptr <events::messageChangedEvent> event)
{
for (std::list <events::messageChangedListener*>::iterator
it = m_messageChangedListeners.begin() ; it != m_messageChangedListeners.end() ; ++it)
@@ -70,7 +70,7 @@ void folder::removeMessageCountListener(events::messageCountListener* l)
}
-void folder::notifyMessageCount(ref <events::messageCountEvent> event)
+void folder::notifyMessageCount(shared_ptr <events::messageCountEvent> event)
{
for (std::list <events::messageCountListener*>::iterator
it = m_messageCountListeners.begin() ; it != m_messageCountListeners.end() ; ++it)
@@ -92,7 +92,7 @@ void folder::removeFolderListener(events::folderListener* l)
}
-void folder::notifyFolder(ref <events::folderEvent> event)
+void folder::notifyFolder(shared_ptr <events::folderEvent> event)
{
for (std::list <events::folderListener*>::iterator
it = m_folderListeners.begin() ; it != m_folderListeners.end() ; ++it)
@@ -102,19 +102,19 @@ void folder::notifyFolder(ref <events::folderEvent> event)
}
-void folder::notifyEvent(ref <events::event> event)
+void folder::notifyEvent(shared_ptr <events::event> event)
{
if (event->getClass() == events::messageCountEvent::EVENT_CLASS)
{
- notifyMessageCount(event.dynamicCast <events::messageCountEvent>());
+ notifyMessageCount(dynamicCast <events::messageCountEvent>(event));
}
else if (event->getClass() == events::messageChangedEvent::EVENT_CLASS)
{
- notifyMessageChanged(event.dynamicCast <events::messageChangedEvent>());
+ notifyMessageChanged(dynamicCast <events::messageChangedEvent>(event));
}
else if (event->getClass() == events::folderEvent::EVENT_CLASS)
{
- notifyFolder(event.dynamicCast <events::folderEvent>());
+ notifyFolder(dynamicCast <events::folderEvent>(event));
}
}
diff --git a/src/net/imap/IMAPConnection.cpp b/src/net/imap/IMAPConnection.cpp
index 53f8ba9f..0dba1ecc 100644
--- a/src/net/imap/IMAPConnection.cpp
+++ b/src/net/imap/IMAPConnection.cpp
@@ -53,11 +53,11 @@
// Helpers for service properties
#define GET_PROPERTY(type, prop) \
- (m_store.acquire()->getInfos().getPropertyValue <type>(getSession(), \
- dynamic_cast <const IMAPServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().getPropertyValue <type>(getSession(), \
+ dynamic_cast <const IMAPServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
#define HAS_PROPERTY(prop) \
- (m_store.acquire()->getInfos().hasProperty(getSession(), \
- dynamic_cast <const IMAPServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().hasProperty(getSession(), \
+ dynamic_cast <const IMAPServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
namespace vmime {
@@ -65,9 +65,9 @@ namespace net {
namespace imap {
-IMAPConnection::IMAPConnection(ref <IMAPStore> store, ref <security::authenticator> auth)
- : m_store(store), m_auth(auth), m_socket(NULL), m_parser(NULL), m_tag(NULL),
- m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(NULL),
+IMAPConnection::IMAPConnection(shared_ptr <IMAPStore> store, shared_ptr <security::authenticator> auth)
+ : m_store(store), m_auth(auth), m_socket(null), m_parser(null), m_tag(null),
+ m_hierarchySeparator('\0'), m_state(STATE_NONE), m_timeoutHandler(null),
m_secured(false), m_firstTag(true), m_capabilitiesFetched(false), m_noModSeq(false)
{
}
@@ -100,7 +100,7 @@ void IMAPConnection::connect()
const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
// Create the time-out handler
if (store->getTimeoutHandlerFactory())
@@ -112,29 +112,29 @@ void IMAPConnection::connect()
#if VMIME_HAVE_TLS_SUPPORT
if (store->isIMAPS()) // dedicated port/IMAPS
{
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
(store->getCertificateVerifier(),
store->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
m_socket = tlsSocket;
m_secured = true;
- m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
}
else
#endif // VMIME_HAVE_TLS_SUPPORT
{
- m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
+ m_cntInfos = make_shared <defaultConnectionInfos>(address, port);
}
m_socket->connect(address, port);
- m_tag = vmime::create <IMAPTag>();
- m_parser = vmime::create <IMAPParser>(m_tag, m_socket, m_timeoutHandler);
+ m_tag = make_shared <IMAPTag>();
+ m_parser = make_shared <IMAPParser>(m_tag, m_socket, m_timeoutHandler);
setState(STATE_NON_AUTHENTICATED);
@@ -145,7 +145,7 @@ void IMAPConnection::connect()
// eg: C: <connection to server>
// --- S: * OK mydomain.org IMAP4rev1 v12.256 server ready
- utility::auto_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
+ std::auto_ptr <IMAPParser::greeting> greet(m_parser->readGreeting());
bool needAuth = false;
if (greet->resp_cond_bye())
@@ -223,7 +223,7 @@ void IMAPConnection::connect()
void IMAPConnection::authenticate()
{
- getAuthenticator()->setService(m_store.acquire());
+ getAuthenticator()->setService(m_store.lock());
#if VMIME_HAVE_SASL_SUPPORT
// First, try SASL authentication
@@ -262,7 +262,7 @@ void IMAPConnection::authenticate()
send(true, "LOGIN " + IMAPUtils::quoteString(username)
+ " " + IMAPUtils::quoteString(password), true);
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad())
{
@@ -277,7 +277,7 @@ void IMAPConnection::authenticate()
}
// Server capabilities may change when logged in
- if (!processCapabilityResponseData(resp))
+ if (!processCapabilityResponseData(resp.get()))
invalidateCapabilities();
}
@@ -286,7 +286,7 @@ void IMAPConnection::authenticate()
void IMAPConnection::authenticateSASL()
{
- if (!getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>())
+ if (!dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator()))
throw exceptions::authentication_error("No SASL authenticator available.");
const std::vector <string> capa = getCapabilities();
@@ -310,10 +310,10 @@ void IMAPConnection::authenticateSASL()
if (saslMechs.empty())
throw exceptions::authentication_error("No SASL mechanism available.");
- std::vector <ref <security::sasl::SASLMechanism> > mechList;
+ std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
- ref <security::sasl::SASLContext> saslContext =
- vmime::create <security::sasl::SASLContext>();
+ shared_ptr <security::sasl::SASLContext> saslContext =
+ make_shared <security::sasl::SASLContext>();
for (unsigned int i = 0 ; i < saslMechs.size() ; ++i)
{
@@ -332,14 +332,14 @@ void IMAPConnection::authenticateSASL()
throw exceptions::authentication_error("No SASL mechanism available.");
// Try to suggest a mechanism among all those supported
- ref <security::sasl::SASLMechanism> suggestedMech =
+ shared_ptr <security::sasl::SASLMechanism> suggestedMech =
saslContext->suggestMechanism(mechList);
if (!suggestedMech)
throw exceptions::authentication_error("Unable to suggest SASL mechanism.");
// Allow application to choose which mechanisms to use
- mechList = getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>()->
+ mechList = dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator())->
getAcceptableMechanisms(mechList, suggestedMech);
if (mechList.empty())
@@ -348,9 +348,9 @@ void IMAPConnection::authenticateSASL()
// Try each mechanism in the list in turn
for (unsigned int i = 0 ; i < mechList.size() ; ++i)
{
- ref <security::sasl::SASLMechanism> mech = mechList[i];
+ shared_ptr <security::sasl::SASLMechanism> mech = mechList[i];
- ref <security::sasl::SASLSession> saslSession =
+ shared_ptr <security::sasl::SASLSession> saslSession =
saslContext->createSession("imap", getAuthenticator(), mech);
saslSession->init();
@@ -359,7 +359,7 @@ void IMAPConnection::authenticateSASL()
for (bool cont = true ; cont ; )
{
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->response_done() &&
resp->response_done()->response_tagged() &&
@@ -466,7 +466,7 @@ void IMAPConnection::startTLS()
{
send(true, "STARTTLS", true);
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -475,11 +475,11 @@ void IMAPConnection::startTLS()
("STARTTLS", resp->getErrorLog(), "bad response");
}
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
- (m_store.acquire()->getCertificateVerifier(),
- m_store.acquire()->getSession()->getTLSProperties());
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
+ (m_store.lock()->getCertificateVerifier(),
+ m_store.lock()->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
tlsSocket->handshake(m_timeoutHandler);
@@ -488,7 +488,7 @@ void IMAPConnection::startTLS()
m_parser->setSocket(m_socket);
m_secured = true;
- m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
// " Once TLS has been started, the client MUST discard cached
@@ -551,12 +551,12 @@ void IMAPConnection::fetchCapabilities()
{
send(true, "CAPABILITY", true);
- utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->response_done()->response_tagged()->
resp_cond_state()->status() == IMAPParser::resp_cond_state::OK)
{
- processCapabilityResponseData(resp);
+ processCapabilityResponseData(resp.get());
}
}
@@ -604,7 +604,7 @@ void IMAPConnection::processCapabilityResponseData(const IMAPParser::capability_
}
-ref <security::authenticator> IMAPConnection::getAuthenticator()
+shared_ptr <security::authenticator> IMAPConnection::getAuthenticator()
{
return m_auth;
}
@@ -623,7 +623,7 @@ bool IMAPConnection::isSecuredConnection() const
}
-ref <connectionInfos> IMAPConnection::getConnectionInfos() const
+shared_ptr <connectionInfos> IMAPConnection::getConnectionInfos() const
{
return m_cntInfos;
}
@@ -645,15 +645,15 @@ void IMAPConnection::internalDisconnect()
send(true, "LOGOUT", true);
m_socket->disconnect();
- m_socket = NULL;
+ m_socket = null;
}
- m_timeoutHandler = NULL;
+ m_timeoutHandler = null;
m_state = STATE_LOGOUT;
m_secured = false;
- m_cntInfos = NULL;
+ m_cntInfos = null;
}
@@ -661,7 +661,7 @@ void IMAPConnection::initHierarchySeparator()
{
send(true, "LIST \"\" \"\"", true);
- vmime::utility::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_parser->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -769,25 +769,25 @@ char IMAPConnection::hierarchySeparator() const
}
-ref <const IMAPStore> IMAPConnection::getStore() const
+shared_ptr <const IMAPStore> IMAPConnection::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <IMAPStore> IMAPConnection::getStore()
+shared_ptr <IMAPStore> IMAPConnection::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <session> IMAPConnection::getSession()
+shared_ptr <session> IMAPConnection::getSession()
{
- return m_store.acquire()->getSession();
+ return m_store.lock()->getSession();
}
-ref <const socket> IMAPConnection::getSocket() const
+shared_ptr <const socket> IMAPConnection::getSocket() const
{
return m_socket;
}
diff --git a/src/net/imap/IMAPFolder.cpp b/src/net/imap/IMAPFolder.cpp
index 3a3615e6..06d331df 100644
--- a/src/net/imap/IMAPFolder.cpp
+++ b/src/net/imap/IMAPFolder.cpp
@@ -39,7 +39,6 @@
#include "vmime/message.hpp"
#include "vmime/exception.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/utility/outputStreamAdapter.hpp"
@@ -52,20 +51,20 @@ namespace net {
namespace imap {
-IMAPFolder::IMAPFolder(const folder::path& path, ref <IMAPStore> store, const int type, const int flags)
+IMAPFolder::IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> store, const int type, const int flags)
: m_store(store), m_connection(store->connection()), m_path(path),
m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()), m_mode(-1),
m_open(false), m_type(type), m_flags(flags)
{
store->registerFolder(this);
- m_status = vmime::create <IMAPFolderStatus>();
+ m_status = make_shared <IMAPFolderStatus>();
}
IMAPFolder::~IMAPFolder()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (store)
{
@@ -76,7 +75,7 @@ IMAPFolder::~IMAPFolder()
}
else if (m_open)
{
- m_connection = NULL;
+ m_connection = null;
onClose();
}
}
@@ -145,7 +144,7 @@ const folder::path IMAPFolder::getFullPath() const
void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -159,8 +158,8 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
}
// Open a connection for this folder
- ref <IMAPConnection> connection =
- vmime::create <IMAPConnection>(store, store->getAuthenticator());
+ shared_ptr <IMAPConnection> connection =
+ make_shared <IMAPConnection>(store, store->getAuthenticator());
try
{
@@ -193,7 +192,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
connection->send(true, oss.str(), true);
// Read the response
- utility::auto_ptr <IMAPParser::response> resp(connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -259,7 +258,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
}
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
// Check for access mode (read-only or read-write)
const IMAPParser::resp_text_code* respTextCode = resp->response_done()->
@@ -292,7 +291,7 @@ void IMAPFolder::open(const int mode, bool failIfModeIsNotAvailable)
void IMAPFolder::close(const bool expunge)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -300,7 +299,7 @@ void IMAPFolder::close(const bool expunge)
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- ref <IMAPConnection> oldConnection = m_connection;
+ shared_ptr <IMAPConnection> oldConnection = m_connection;
// Emit the "CLOSE" command to expunge messages marked
// as deleted (this is fastest than "EXPUNGE")
@@ -316,12 +315,12 @@ void IMAPFolder::close(const bool expunge)
oldConnection->disconnect();
// Now use default store connection
- m_connection = m_store.acquire()->connection();
+ m_connection = m_store.lock()->connection();
m_open = false;
m_mode = -1;
- m_status = vmime::create <IMAPFolderStatus>();
+ m_status = make_shared <IMAPFolderStatus>();
onClose();
}
@@ -341,7 +340,7 @@ void IMAPFolder::onClose()
void IMAPFolder::create(const int type)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -371,7 +370,7 @@ void IMAPFolder::create(const int type)
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -381,9 +380,9 @@ void IMAPFolder::create(const int type)
}
// Notify folder created
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_CREATED, m_path, m_path);
notifyFolder(event);
@@ -392,7 +391,7 @@ void IMAPFolder::create(const int type)
void IMAPFolder::destroy()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -409,7 +408,7 @@ void IMAPFolder::destroy()
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -419,9 +418,9 @@ void IMAPFolder::destroy()
}
// Notify folder deleted
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_DELETED, m_path, m_path);
notifyFolder(event);
@@ -430,7 +429,7 @@ void IMAPFolder::destroy()
bool IMAPFolder::exists()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!isOpen() && !store)
throw exceptions::illegal_state("Store disconnected");
@@ -470,7 +469,7 @@ int IMAPFolder::testExistAndGetType()
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -517,7 +516,7 @@ bool IMAPFolder::isOpen() const
}
-ref <message> IMAPFolder::getMessage(const int num)
+shared_ptr <message> IMAPFolder::getMessage(const int num)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
@@ -525,28 +524,28 @@ ref <message> IMAPFolder::getMessage(const int num)
if (num < 1 || num > m_status->getMessageCount())
throw exceptions::message_not_found();
- return vmime::create <IMAPMessage>(thisRef().dynamicCast <IMAPFolder>(), num);
+ return make_shared <IMAPMessage>(dynamicCast <IMAPFolder>(shared_from_this()), num);
}
-std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
+std::vector <shared_ptr <message> > IMAPFolder::getMessages(const messageSet& msgs)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
if (msgs.isEmpty())
- return std::vector <ref <message> >();
+ return std::vector <shared_ptr <message> >();
- std::vector <ref <message> > messages;
+ std::vector <shared_ptr <message> > messages;
if (msgs.isNumberSet())
{
const std::vector <int> numbers = IMAPUtils::messageSetToNumberList(msgs);
- ref <IMAPFolder> thisFolder = thisRef().dynamicCast <IMAPFolder>();
+ shared_ptr <IMAPFolder> thisFolder = dynamicCast <IMAPFolder>(shared_from_this());
for (std::vector <int>::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it)
- messages.push_back(vmime::create <IMAPMessage>(thisFolder, *it));
+ messages.push_back(make_shared <IMAPMessage>(thisFolder, *it));
}
else if (msgs.isUIDSet())
{
@@ -566,7 +565,7 @@ std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
m_connection->send(true, cmd.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -613,8 +612,8 @@ std::vector <ref <message> > IMAPFolder::getMessages(const messageSet& msgs)
if (!msgUID.empty())
{
- ref <IMAPFolder> thisFolder = thisRef().dynamicCast <IMAPFolder>();
- messages.push_back(vmime::create <IMAPMessage>(thisFolder, msgNum, msgUID));
+ shared_ptr <IMAPFolder> thisFolder = dynamicCast <IMAPFolder>(shared_from_this());
+ messages.push_back(make_shared <IMAPMessage>(thisFolder, msgNum, msgUID));
}
}
}
@@ -650,20 +649,20 @@ vmime_uint64 IMAPFolder::getHighestModSequence() const
}
-ref <folder> IMAPFolder::getFolder(const folder::path::component& name)
+shared_ptr <folder> IMAPFolder::getFolder(const folder::path::component& name)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
- return vmime::create <IMAPFolder>(m_path / name, store);
+ return make_shared <IMAPFolder>(m_path / name, store);
}
-std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
+std::vector <shared_ptr <folder> > IMAPFolder::getFolders(const bool recursive)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!isOpen() && !store)
throw exceptions::illegal_state("Store disconnected");
@@ -699,7 +698,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
m_connection->send(true, oss.str(), true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -711,7 +710,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
resp->continue_req_or_response_data();
- std::vector <ref <folder> > v;
+ std::vector <shared_ptr <folder> > v;
for (std::vector <IMAPParser::continue_req_or_response_data*>::const_iterator
it = respDataList.begin() ; it != respDataList.end() ; ++it)
@@ -741,7 +740,7 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
const class IMAPParser::mailbox_flag_list* mailbox_flag_list =
mailboxData->mailbox_list()->mailbox_flag_list();
- v.push_back(vmime::create <IMAPFolder>(path, store,
+ v.push_back(make_shared <IMAPFolder>(path, store,
IMAPUtils::folderTypeFromFlags(mailbox_flag_list),
IMAPUtils::folderFlagsFromFlags(mailbox_flag_list)));
}
@@ -751,10 +750,10 @@ std::vector <ref <folder> > IMAPFolder::getFolders(const bool recursive)
}
-void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options,
+void IMAPFolder::fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options,
utility::progressListener* progress)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -765,12 +764,12 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
std::vector <int> list;
list.reserve(msg.size());
- std::map <int, ref <IMAPMessage> > numberToMsg;
+ std::map <int, shared_ptr <IMAPMessage> > numberToMsg;
- for (std::vector <ref <message> >::iterator it = msg.begin() ; it != msg.end() ; ++it)
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ; it != msg.end() ; ++it)
{
list.push_back((*it)->getNumber());
- numberToMsg[(*it)->getNumber()] = (*it).dynamicCast <IMAPMessage>();
+ numberToMsg[(*it)->getNumber()] = dynamicCast <IMAPMessage>(*it);
}
// Send the request
@@ -780,7 +779,7 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
m_connection->send(true, command, true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -819,7 +818,7 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
// Process fetch response for this message
const int num = static_cast <int>(messageData->number());
- std::map <int, ref <IMAPMessage> >::iterator msg = numberToMsg.find(num);
+ std::map <int, shared_ptr <IMAPMessage> >::iterator msg = numberToMsg.find(num);
if (msg != numberToMsg.end())
{
@@ -841,13 +840,13 @@ void IMAPFolder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
if (progress)
progress->stop(total);
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
-void IMAPFolder::fetchMessage(ref <message> msg, const fetchAttributes& options)
+void IMAPFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
{
- std::vector <ref <message> > msgs;
+ std::vector <shared_ptr <message> > msgs;
msgs.push_back(msg);
fetchMessages(msgs, options, /* progress */ NULL);
@@ -863,24 +862,24 @@ int IMAPFolder::getFetchCapabilities() const
}
-ref <folder> IMAPFolder::getParent()
+shared_ptr <folder> IMAPFolder::getParent()
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <IMAPFolder>(m_path.getParent(), m_store.acquire());
+ return make_shared <IMAPFolder>(m_path.getParent(), m_store.lock());
}
-ref <const store> IMAPFolder::getStore() const
+shared_ptr <const store> IMAPFolder::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <store> IMAPFolder::getStore()
+shared_ptr <store> IMAPFolder::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
@@ -902,13 +901,13 @@ void IMAPFolder::unregisterMessage(IMAPMessage* msg)
void IMAPFolder::onStoreDisconnected()
{
- m_store = NULL;
+ m_store.reset();
}
void IMAPFolder::deleteMessages(const messageSet& msgs)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (msgs.isEmpty())
throw exceptions::invalid_argument();
@@ -935,7 +934,7 @@ void IMAPFolder::deleteMessages(const messageSet& msgs)
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -944,7 +943,7 @@ void IMAPFolder::deleteMessages(const messageSet& msgs)
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
@@ -977,7 +976,7 @@ void IMAPFolder::setMessageFlags(const messageSet& msgs, const int flags, const
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -986,12 +985,12 @@ void IMAPFolder::setMessageFlags(const messageSet& msgs, const int flags, const
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
}
-void IMAPFolder::addMessage(ref <vmime::message> msg, const int flags,
+void IMAPFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
vmime::datetime* date, utility::progressListener* progress)
{
std::ostringstream oss;
@@ -1009,7 +1008,7 @@ void IMAPFolder::addMessage(ref <vmime::message> msg, const int flags,
void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int flags,
vmime::datetime* date, utility::progressListener* progress)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1045,7 +1044,7 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
bool ok = false;
const std::vector <IMAPParser::continue_req_or_response_data*>& respList
@@ -1097,7 +1096,7 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
progress->stop(total);
// Get the response
- utility::auto_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> finalResp(m_connection->readResponse());
if (finalResp->isBad() || finalResp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1106,13 +1105,13 @@ void IMAPFolder::addMessage(utility::inputStream& is, const int size, const int
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
void IMAPFolder::expunge()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1125,7 +1124,7 @@ void IMAPFolder::expunge()
m_connection->send(true, "EXPUNGE", true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1134,13 +1133,13 @@ void IMAPFolder::expunge()
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
void IMAPFolder::rename(const folder::path& newPath)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1165,7 +1164,7 @@ void IMAPFolder::rename(const folder::path& newPath)
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1180,9 +1179,9 @@ void IMAPFolder::rename(const folder::path& newPath)
m_path = newPath;
m_name = newPath.getLastComponent();
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
notifyFolder(event);
@@ -1197,22 +1196,22 @@ void IMAPFolder::rename(const folder::path& newPath)
(*it)->m_path.renameParent(oldPath, newPath);
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path);
(*it)->notifyFolder(event);
}
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set)
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1231,7 +1230,7 @@ void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set)
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1240,7 +1239,7 @@ void IMAPFolder::copyMessages(const folder::path& dest, const messageSet& set)
resp->getErrorLog(), "bad response");
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
@@ -1249,16 +1248,16 @@ void IMAPFolder::status(int& count, int& unseen)
count = 0;
unseen = 0;
- ref <folderStatus> status = getStatus();
+ shared_ptr <folderStatus> status = getStatus();
count = status->getMessageCount();
unseen = status->getUnseenCount();
}
-ref <folderStatus> IMAPFolder::getStatus()
+shared_ptr <folderStatus> IMAPFolder::getStatus()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1283,7 +1282,7 @@ ref <folderStatus> IMAPFolder::getStatus()
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1305,7 +1304,7 @@ ref <folderStatus> IMAPFolder::getStatus()
if (responseData->mailbox_data() &&
responseData->mailbox_data()->type() == IMAPParser::mailbox_data::STATUS)
{
- ref <IMAPFolderStatus> status = vmime::create <IMAPFolderStatus>();
+ shared_ptr <IMAPFolderStatus> status = make_shared <IMAPFolderStatus>();
status->updateFromResponse(responseData->mailbox_data());
m_status->updateFromResponse(responseData->mailbox_data());
@@ -1322,14 +1321,14 @@ ref <folderStatus> IMAPFolder::getStatus()
void IMAPFolder::noop()
{
- ref <IMAPStore> store = m_store.acquire();
+ shared_ptr <IMAPStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
m_connection->send(true, "NOOP", true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1337,7 +1336,7 @@ void IMAPFolder::noop()
throw exceptions::command_error("NOOP", resp->getErrorLog());
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
}
@@ -1354,7 +1353,7 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() ||
resp->response_done()->response_tagged()->resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -1393,7 +1392,7 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
}
}
- processStatusUpdate(resp);
+ processStatusUpdate(resp.get());
return v;
}
@@ -1401,9 +1400,9 @@ std::vector <int> IMAPFolder::getMessageNumbersStartingOnUID(const message::uid&
void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
{
- std::vector <ref <events::event> > events;
+ std::vector <shared_ptr <events::event> > events;
- ref <IMAPFolderStatus> oldStatus = m_status->clone().dynamicCast <IMAPFolderStatus>();
+ shared_ptr <IMAPFolderStatus> oldStatus = vmime::clone(m_status);
int expungedMessageCount = 0;
// Process tagged response
@@ -1450,8 +1449,8 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
(*mit)->processFetchResponse(/* options */ 0, msgData);
}
- events.push_back(vmime::create <events::messageChangedEvent>
- (thisRef().dynamicCast <folder>(),
+ events.push_back(make_shared <events::messageChangedEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageChangedEvent::TYPE_FLAGS,
std::vector <int>(1, msgNumber)));
}
@@ -1467,8 +1466,8 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
(*jt)->renumber((*jt)->getNumber() - 1);
}
- events.push_back(vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ events.push_back(make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_REMOVED,
std::vector <int>(1, msgNumber)));
@@ -1488,14 +1487,14 @@ void IMAPFolder::processStatusUpdate(const IMAPParser::response* resp)
newMessageNumbers.push_back(msgNumber);
}
- events.push_back(vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ events.push_back(make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_ADDED,
newMessageNumbers));
}
// Dispatch notifications
- for (std::vector <ref <events::event> >::iterator evit =
+ for (std::vector <shared_ptr <events::event> >::iterator evit =
events.begin() ; evit != events.end() ; ++evit)
{
notifyEvent(*evit);
diff --git a/src/net/imap/IMAPFolderStatus.cpp b/src/net/imap/IMAPFolderStatus.cpp
index c231cb38..25c88b02 100644
--- a/src/net/imap/IMAPFolderStatus.cpp
+++ b/src/net/imap/IMAPFolderStatus.cpp
@@ -94,9 +94,9 @@ vmime_uint64 IMAPFolderStatus::getHighestModSeq() const
}
-ref <folderStatus> IMAPFolderStatus::clone() const
+shared_ptr <folderStatus> IMAPFolderStatus::clone() const
{
- return vmime::create <IMAPFolderStatus>(*this);
+ return make_shared <IMAPFolderStatus>(*this);
}
diff --git a/src/net/imap/IMAPMessage.cpp b/src/net/imap/IMAPMessage.cpp
index d512e752..ae51bfe8 100644
--- a/src/net/imap/IMAPMessage.cpp
+++ b/src/net/imap/IMAPMessage.cpp
@@ -97,17 +97,17 @@ private:
//
-IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num)
+IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
- m_expunged(false), m_modseq(0), m_structure(NULL)
+ m_expunged(false), m_modseq(0), m_structure(null)
{
folder->registerMessage(this);
}
-IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num, const uid& uid)
+IMAPMessage::IMAPMessage(shared_ptr <IMAPFolder> folder, const int num, const uid& uid)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
- m_expunged(false), m_uid(uid), m_modseq(0), m_structure(NULL)
+ m_expunged(false), m_uid(uid), m_modseq(0), m_structure(null)
{
folder->registerMessage(this);
}
@@ -115,7 +115,7 @@ IMAPMessage::IMAPMessage(ref <IMAPFolder> folder, const int num, const uid& uid)
IMAPMessage::~IMAPMessage()
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
@@ -124,7 +124,7 @@ IMAPMessage::~IMAPMessage()
void IMAPMessage::onFolderClosed()
{
- m_folder = NULL;
+ m_folder.reset();
}
@@ -170,7 +170,7 @@ int IMAPMessage::getFlags() const
}
-ref <const messageStructure> IMAPMessage::getStructure() const
+shared_ptr <const messageStructure> IMAPMessage::getStructure() const
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -179,7 +179,7 @@ ref <const messageStructure> IMAPMessage::getStructure() const
}
-ref <messageStructure> IMAPMessage::getStructure()
+shared_ptr <messageStructure> IMAPMessage::getStructure()
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -188,7 +188,7 @@ ref <messageStructure> IMAPMessage::getStructure()
}
-ref <const header> IMAPMessage::getHeader() const
+shared_ptr <const header> IMAPMessage::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -200,20 +200,20 @@ ref <const header> IMAPMessage::getHeader() const
void IMAPMessage::extract(utility::outputStream& os, utility::progressListener* progress,
const int start, const int length, const bool peek) const
{
- ref <const IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <const IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
- extractImpl(NULL, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
+ extractImpl(null, os, progress, start, length, EXTRACT_HEADER | EXTRACT_BODY | (peek ? EXTRACT_PEEK : 0));
}
void IMAPMessage::extractPart
- (ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
+ (shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
const int start, const int length, const bool peek) const
{
- ref <const IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <const IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -222,9 +222,9 @@ void IMAPMessage::extractPart
}
-void IMAPMessage::fetchPartHeader(ref <messagePart> p)
+void IMAPMessage::fetchPartHeader(shared_ptr <messagePart> p)
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -234,15 +234,15 @@ void IMAPMessage::fetchPartHeader(ref <messagePart> p)
extractImpl(p, ossAdapter, NULL, 0, -1, EXTRACT_HEADER | EXTRACT_PEEK);
- p.dynamicCast <IMAPMessagePart>()->getOrCreateHeader().parse(oss.str());
+ dynamicCast <IMAPMessagePart>(p)->getOrCreateHeader().parse(oss.str());
}
-void IMAPMessage::fetchPartHeaderForStructure(ref <messageStructure> str)
+void IMAPMessage::fetchPartHeaderForStructure(shared_ptr <messageStructure> str)
{
for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i)
{
- ref <messagePart> part = str->getPartAt(i);
+ shared_ptr <messagePart> part = str->getPartAt(i);
// Fetch header of current part
fetchPartHeader(part);
@@ -253,11 +253,11 @@ void IMAPMessage::fetchPartHeaderForStructure(ref <messageStructure> str)
}
-void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream& os,
+void IMAPMessage::extractImpl(shared_ptr <const messagePart> p, utility::outputStream& os,
utility::progressListener* progress, const int start,
const int length, const int extractFlags) const
{
- ref <const IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <const IMAPFolder> folder = m_folder.lock();
IMAPMessage_literalHandler literalHandler(os, progress);
@@ -267,7 +267,7 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
if (p != NULL)
{
- ref <const IMAPMessagePart> currentPart = p.dynamicCast <const IMAPMessagePart>();
+ shared_ptr <const IMAPMessagePart> currentPart = dynamicCast <const IMAPMessagePart>(p);
std::vector <int> numbers;
numbers.push_back(currentPart->getNumber());
@@ -344,11 +344,11 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
command << "<" << start << "." << length << ">";
// Send the request
- folder.constCast <IMAPFolder>()->m_connection->send(true, command.str(), true);
+ constCast <IMAPFolder>(folder)->m_connection->send(true, command.str(), true);
// Get the response
- utility::auto_ptr <IMAPParser::response> resp
- (folder.constCast <IMAPFolder>()->m_connection->readResponse(&literalHandler));
+ std::auto_ptr <IMAPParser::response> resp
+ (constCast <IMAPFolder>(folder)->m_connection->readResponse(&literalHandler));
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -368,7 +368,7 @@ void IMAPMessage::extractImpl(ref <const messagePart> p, utility::outputStream&
int IMAPMessage::processFetchResponse
(const fetchAttributes& options, const IMAPParser::message_data* msgData)
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
// Get message attributes
const std::vector <IMAPParser::msg_att_item*> atts = msgData->msg_att()->items();
@@ -406,7 +406,7 @@ int IMAPMessage::processFetchResponse
if (!options.has(fetchAttributes::FULL_HEADER))
{
const IMAPParser::envelope* env = (*it)->envelope();
- ref <vmime::header> hdr = getOrCreateHeader();
+ shared_ptr <vmime::header> hdr = getOrCreateHeader();
// Date
hdr->Date()->setValue(env->env_date()->value());
@@ -463,7 +463,7 @@ int IMAPMessage::processFetchResponse
}
case IMAPParser::msg_att_item::BODY_STRUCTURE:
{
- m_structure = vmime::create <IMAPMessageStructure>((*it)->body());
+ m_structure = make_shared <IMAPMessageStructure>((*it)->body());
break;
}
case IMAPParser::msg_att_item::RFC822_HEADER:
@@ -488,12 +488,12 @@ int IMAPMessage::processFetchResponse
tempHeader.parse((*it)->nstring()->value());
vmime::header& hdr = *getOrCreateHeader();
- std::vector <ref <headerField> > fields = tempHeader.getFieldList();
+ std::vector <shared_ptr <headerField> > fields = tempHeader.getFieldList();
- for (std::vector <ref <headerField> >::const_iterator jt = fields.begin() ;
+ for (std::vector <shared_ptr <headerField> >::const_iterator jt = fields.begin() ;
jt != fields.end() ; ++jt)
{
- hdr.appendField((*jt)->clone().dynamicCast <headerField>());
+ hdr.appendField(vmime::clone(*jt));
}
}
}
@@ -515,18 +515,18 @@ int IMAPMessage::processFetchResponse
}
-ref <header> IMAPMessage::getOrCreateHeader()
+shared_ptr <header> IMAPMessage::getOrCreateHeader()
{
if (m_header != NULL)
return (m_header);
else
- return (m_header = vmime::create <header>());
+ return (m_header = make_shared <header>());
}
void IMAPMessage::setFlags(const int flags, const int mode)
{
- ref <IMAPFolder> folder = m_folder.acquire();
+ shared_ptr <IMAPFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -539,20 +539,20 @@ void IMAPMessage::setFlags(const int flags, const int mode)
void IMAPMessage::constructParsedMessage
- (ref <bodyPart> parentPart, ref <messageStructure> str, int level)
+ (shared_ptr <bodyPart> parentPart, shared_ptr <messageStructure> str, int level)
{
if (level == 0)
{
- ref <messagePart> part = str->getPartAt(0);
+ shared_ptr <messagePart> part = str->getPartAt(0);
// Copy header
- ref <const header> hdr = part->getHeader();
+ shared_ptr <const header> hdr = part->getHeader();
parentPart->getHeader()->copyFrom(*hdr);
// Initialize body
parentPart->getBody()->setContents
- (vmime::create <IMAPMessagePartContentHandler>
- (thisRef().dynamicCast <IMAPMessage>(),
+ (make_shared <IMAPMessagePartContentHandler>
+ (dynamicCast <IMAPMessage>(shared_from_this()),
part, parentPart->getBody()->getEncoding()));
constructParsedMessage(parentPart, part->getStructure(), 1);
@@ -561,18 +561,18 @@ void IMAPMessage::constructParsedMessage
{
for (size_t i = 0, n = str->getPartCount() ; i < n ; ++i)
{
- ref <messagePart> part = str->getPartAt(i);
+ shared_ptr <messagePart> part = str->getPartAt(i);
- ref <bodyPart> childPart = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> childPart = make_shared <bodyPart>();
// Copy header
- ref <const header> hdr = part->getHeader();
+ shared_ptr <const header> hdr = part->getHeader();
childPart->getHeader()->copyFrom(*hdr);
// Initialize body
childPart->getBody()->setContents
- (vmime::create <IMAPMessagePartContentHandler>
- (thisRef().dynamicCast <IMAPMessage>(),
+ (make_shared <IMAPMessagePartContentHandler>
+ (dynamicCast <IMAPMessage>(shared_from_this()),
part, childPart->getBody()->getEncoding()));
// Add child part
@@ -585,10 +585,10 @@ void IMAPMessage::constructParsedMessage
}
-ref <vmime::message> IMAPMessage::getParsedMessage()
+shared_ptr <vmime::message> IMAPMessage::getParsedMessage()
{
// Fetch structure
- ref <messageStructure> structure = NULL;
+ shared_ptr <messageStructure> structure;
try
{
@@ -596,10 +596,10 @@ ref <vmime::message> IMAPMessage::getParsedMessage()
}
catch (exceptions::unfetched_object&)
{
- std::vector <ref <message> > msgs;
- msgs.push_back(thisRef().dynamicCast <IMAPMessage>());
+ std::vector <shared_ptr <message> > msgs;
+ msgs.push_back(dynamicCast <IMAPMessage>(shared_from_this()));
- m_folder.acquire()->fetchMessages
+ m_folder.lock()->fetchMessages
(msgs, fetchAttributes(fetchAttributes::STRUCTURE), /* progress */ NULL);
structure = getStructure();
@@ -609,7 +609,7 @@ ref <vmime::message> IMAPMessage::getParsedMessage()
fetchPartHeaderForStructure(structure);
// Construct message from structure
- ref <vmime::message> msg = vmime::create <vmime::message>();
+ shared_ptr <vmime::message> msg = make_shared <vmime::message>();
constructParsedMessage(msg, structure);
diff --git a/src/net/imap/IMAPMessagePart.cpp b/src/net/imap/IMAPMessagePart.cpp
index 48e063e8..153470cf 100644
--- a/src/net/imap/IMAPMessagePart.cpp
+++ b/src/net/imap/IMAPMessagePart.cpp
@@ -36,16 +36,16 @@ namespace net {
namespace imap {
-IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart)
- : m_parent(parent), m_header(NULL), m_number(number), m_size(0)
+IMAPMessagePart::IMAPMessagePart(shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart)
+ : m_parent(parent), m_header(null), m_number(number), m_size(0)
{
m_mediaType = vmime::mediaType
("multipart", mpart->media_subtype()->value());
}
-IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part)
- : m_parent(parent), m_header(NULL), m_number(number), m_size(0)
+IMAPMessagePart::IMAPMessagePart(shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part)
+ : m_parent(parent), m_header(null), m_number(number), m_size(0)
{
if (part->body_type_text())
{
@@ -70,11 +70,11 @@ IMAPMessagePart::IMAPMessagePart(ref <IMAPMessagePart> parent, const int number,
m_size = part->body_type_basic()->body_fields()->body_fld_octets()->value();
}
- m_structure = NULL;
+ m_structure = null;
}
-ref <const messageStructure> IMAPMessagePart::getStructure() const
+shared_ptr <const messageStructure> IMAPMessagePart::getStructure() const
{
if (m_structure != NULL)
return m_structure;
@@ -83,7 +83,7 @@ ref <const messageStructure> IMAPMessagePart::getStructure() const
}
-ref <messageStructure> IMAPMessagePart::getStructure()
+shared_ptr <messageStructure> IMAPMessagePart::getStructure()
{
if (m_structure != NULL)
return m_structure;
@@ -92,9 +92,9 @@ ref <messageStructure> IMAPMessagePart::getStructure()
}
-ref <const IMAPMessagePart> IMAPMessagePart::getParent() const
+shared_ptr <const IMAPMessagePart> IMAPMessagePart::getParent() const
{
- return m_parent.acquire();
+ return m_parent.lock();
}
@@ -116,7 +116,7 @@ int IMAPMessagePart::getNumber() const
}
-ref <const header> IMAPMessagePart::getHeader() const
+shared_ptr <const header> IMAPMessagePart::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -126,19 +126,19 @@ ref <const header> IMAPMessagePart::getHeader() const
// static
-ref <IMAPMessagePart> IMAPMessagePart::create
- (ref <IMAPMessagePart> parent, const int number, const IMAPParser::body* body)
+shared_ptr <IMAPMessagePart> IMAPMessagePart::create
+ (shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body* body)
{
if (body->body_type_mpart())
{
- ref <IMAPMessagePart> part = vmime::create <IMAPMessagePart>(parent, number, body->body_type_mpart());
- part->m_structure = vmime::create <IMAPMessageStructure>(part, body->body_type_mpart()->list());
+ shared_ptr <IMAPMessagePart> part = make_shared <IMAPMessagePart>(parent, number, body->body_type_mpart());
+ part->m_structure = make_shared <IMAPMessageStructure>(part, body->body_type_mpart()->list());
return part;
}
else
{
- return vmime::create <IMAPMessagePart>(parent, number, body->body_type_1part());
+ return make_shared <IMAPMessagePart>(parent, number, body->body_type_1part());
}
}
@@ -148,7 +148,7 @@ header& IMAPMessagePart::getOrCreateHeader()
if (m_header != NULL)
return *m_header;
else
- return *(m_header = vmime::create <header>());
+ return *(m_header = make_shared <header>());
}
diff --git a/src/net/imap/IMAPMessagePartContentHandler.cpp b/src/net/imap/IMAPMessagePartContentHandler.cpp
index 10c7a040..7112e3d2 100644
--- a/src/net/imap/IMAPMessagePartContentHandler.cpp
+++ b/src/net/imap/IMAPMessagePartContentHandler.cpp
@@ -43,17 +43,17 @@ namespace imap {
IMAPMessagePartContentHandler::IMAPMessagePartContentHandler
- (ref <IMAPMessage> msg, ref <messagePart> part, const vmime::encoding& encoding)
+ (shared_ptr <IMAPMessage> msg, shared_ptr <messagePart> part, const vmime::encoding& encoding)
: m_message(msg), m_part(part), m_encoding(encoding)
{
}
-ref <contentHandler> IMAPMessagePartContentHandler::clone() const
+shared_ptr <contentHandler> IMAPMessagePartContentHandler::clone() const
{
- return create <IMAPMessagePartContentHandler>
- (m_message.acquire().constCast <IMAPMessage>(),
- m_part.acquire().constCast <messagePart>(),
+ return make_shared <IMAPMessagePartContentHandler>
+ (constCast <IMAPMessage>(m_message.lock()),
+ constCast <messagePart>(m_part.lock()),
m_encoding);
}
@@ -61,8 +61,8 @@ ref <contentHandler> IMAPMessagePartContentHandler::clone() const
void IMAPMessagePartContentHandler::generate
(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength) const
{
- ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
- ref <messagePart> part = m_part.acquire().constCast <messagePart>();
+ shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
+ shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
// Data is already encoded
if (isEncoded())
@@ -85,14 +85,14 @@ void IMAPMessagePartContentHandler::generate
std::ostringstream oss2;
utility::outputStreamAdapter tmp2(oss2);
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
theDecoder->decode(in, tmp2);
// Reencode to output stream
string str = oss2.str();
utility::inputStreamStringAdapter tempIn(str);
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -114,7 +114,7 @@ void IMAPMessagePartContentHandler::generate
msg->extractPart(part, tmp, NULL);
// Encode temporary buffer to output stream
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -128,8 +128,8 @@ void IMAPMessagePartContentHandler::generate
void IMAPMessagePartContentHandler::extract
(utility::outputStream& os, utility::progressListener* progress) const
{
- ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
- ref <messagePart> part = m_part.acquire().constCast <messagePart>();
+ shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
+ shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
// No decoding to perform
if (!isEncoded())
@@ -149,7 +149,7 @@ void IMAPMessagePartContentHandler::extract
utility::inputStreamStringAdapter is(oss.str());
utility::progressListenerSizeAdapter plsa(progress, getLength());
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
theDecoder->decode(is, os, &plsa);
}
}
@@ -158,8 +158,8 @@ void IMAPMessagePartContentHandler::extract
void IMAPMessagePartContentHandler::extractRaw
(utility::outputStream& os, utility::progressListener* progress) const
{
- ref <IMAPMessage> msg = m_message.acquire().constCast <IMAPMessage>();
- ref <messagePart> part = m_part.acquire().constCast <messagePart>();
+ shared_ptr <IMAPMessage> msg = constCast <IMAPMessage>(m_message.lock());
+ shared_ptr <messagePart> part = constCast <messagePart>(m_part.lock());
msg->extractPart(part, os, progress);
}
@@ -167,7 +167,7 @@ void IMAPMessagePartContentHandler::extractRaw
string::size_type IMAPMessagePartContentHandler::getLength() const
{
- return m_part.acquire()->getSize();
+ return m_part.lock()->getSize();
}
diff --git a/src/net/imap/IMAPMessageStructure.cpp b/src/net/imap/IMAPMessageStructure.cpp
index 60f26c68..8dc333e9 100644
--- a/src/net/imap/IMAPMessageStructure.cpp
+++ b/src/net/imap/IMAPMessageStructure.cpp
@@ -43,11 +43,11 @@ IMAPMessageStructure::IMAPMessageStructure()
IMAPMessageStructure::IMAPMessageStructure(const IMAPParser::body* body)
{
- m_parts.push_back(IMAPMessagePart::create(NULL, 0, body));
+ m_parts.push_back(IMAPMessagePart::create(null, 0, body));
}
-IMAPMessageStructure::IMAPMessageStructure(ref <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
+IMAPMessageStructure::IMAPMessageStructure(shared_ptr <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list)
{
int number = 0;
@@ -59,13 +59,13 @@ IMAPMessageStructure::IMAPMessageStructure(ref <IMAPMessagePart> parent, const s
}
-ref <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
+shared_ptr <const messagePart> IMAPMessageStructure::getPartAt(const size_t x) const
{
return m_parts[x];
}
-ref <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
+shared_ptr <messagePart> IMAPMessageStructure::getPartAt(const size_t x)
{
return m_parts[x];
}
@@ -78,9 +78,9 @@ size_t IMAPMessageStructure::getPartCount() const
// static
-ref <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
+shared_ptr <IMAPMessageStructure> IMAPMessageStructure::emptyStructure()
{
- static ref <IMAPMessageStructure> emptyStructure = vmime::create <IMAPMessageStructure>();
+ static shared_ptr <IMAPMessageStructure> emptyStructure = make_shared <IMAPMessageStructure>();
return emptyStructure;
}
diff --git a/src/net/imap/IMAPSStore.cpp b/src/net/imap/IMAPSStore.cpp
index b467d13a..c9e64f5b 100644
--- a/src/net/imap/IMAPSStore.cpp
+++ b/src/net/imap/IMAPSStore.cpp
@@ -35,7 +35,7 @@ namespace net {
namespace imap {
-IMAPSStore::IMAPSStore(ref <session> sess, ref <security::authenticator> auth)
+IMAPSStore::IMAPSStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: IMAPStore(sess, auth, true)
{
}
diff --git a/src/net/imap/IMAPStore.cpp b/src/net/imap/IMAPStore.cpp
index eca58ea7..a1a8c9ca 100644
--- a/src/net/imap/IMAPStore.cpp
+++ b/src/net/imap/IMAPStore.cpp
@@ -43,8 +43,8 @@ namespace net {
namespace imap {
-IMAPStore::IMAPStore(ref <session> sess, ref <security::authenticator> auth, const bool secured)
- : store(sess, getInfosInstance(), auth), m_connection(NULL), m_isIMAPS(secured)
+IMAPStore::IMAPStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured)
+ : store(sess, getInfosInstance(), auth), m_connection(null), m_isIMAPS(secured)
{
}
@@ -69,32 +69,35 @@ const string IMAPStore::getProtocolName() const
}
-ref <folder> IMAPStore::getRootFolder()
+shared_ptr <folder> IMAPStore::getRootFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <IMAPFolder>(folder::path(),
- thisRef().dynamicCast <IMAPStore>());
+ return make_shared <IMAPFolder>
+ (folder::path(),
+ dynamicCast <IMAPStore>(shared_from_this()));
}
-ref <folder> IMAPStore::getDefaultFolder()
+shared_ptr <folder> IMAPStore::getDefaultFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <IMAPFolder>(folder::path::component("INBOX"),
- thisRef().dynamicCast <IMAPStore>());
+ return make_shared <IMAPFolder>
+ (folder::path::component("INBOX"),
+ dynamicCast <IMAPStore>(shared_from_this()));
}
-ref <folder> IMAPStore::getFolder(const folder::path& path)
+shared_ptr <folder> IMAPStore::getFolder(const folder::path& path)
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <IMAPFolder>(path, thisRef().dynamicCast <IMAPStore>());
+ return make_shared <IMAPFolder>
+ (path, dynamicCast <IMAPStore>(shared_from_this()));
}
@@ -109,8 +112,8 @@ void IMAPStore::connect()
if (isConnected())
throw exceptions::already_connected();
- m_connection = vmime::create <IMAPConnection>
- (thisRef().dynamicCast <IMAPStore>(), getAuthenticator());
+ m_connection = make_shared <IMAPConnection>
+ (dynamicCast <IMAPStore>(shared_from_this()), getAuthenticator());
try
{
@@ -118,7 +121,7 @@ void IMAPStore::connect()
}
catch (std::exception&)
{
- m_connection = NULL;
+ m_connection = null;
throw;
}
}
@@ -145,16 +148,16 @@ bool IMAPStore::isSecuredConnection() const
}
-ref <connectionInfos> IMAPStore::getConnectionInfos() const
+shared_ptr <connectionInfos> IMAPStore::getConnectionInfos() const
{
if (m_connection == NULL)
- return NULL;
+ return null;
return m_connection->getConnectionInfos();
}
-ref <IMAPConnection> IMAPStore::getConnection()
+shared_ptr <IMAPConnection> IMAPStore::getConnection()
{
return m_connection;
}
@@ -176,7 +179,7 @@ void IMAPStore::disconnect()
m_connection->disconnect();
- m_connection = NULL;
+ m_connection = null;
}
@@ -187,7 +190,7 @@ void IMAPStore::noop()
m_connection->send(true, "NOOP", true);
- utility::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
+ std::auto_ptr <IMAPParser::response> resp(m_connection->readResponse());
if (resp->isBad() || resp->response_done()->response_tagged()->
resp_cond_state()->status() != IMAPParser::resp_cond_state::OK)
@@ -205,7 +208,7 @@ void IMAPStore::noop()
}
-ref <IMAPConnection> IMAPStore::connection()
+shared_ptr <IMAPConnection> IMAPStore::connection()
{
return (m_connection);
}
diff --git a/src/net/imap/IMAPUtils.cpp b/src/net/imap/IMAPUtils.cpp
index caaf6575..bf310414 100644
--- a/src/net/imap/IMAPUtils.cpp
+++ b/src/net/imap/IMAPUtils.cpp
@@ -544,7 +544,7 @@ const string IMAPUtils::dateTime(const vmime::datetime& date)
// static
const string IMAPUtils::buildFetchRequest
- (ref <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options)
+ (shared_ptr <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options)
{
// Example:
// C: A654 FETCH 2:4 (FLAGS BODY[HEADER.FIELDS (DATE FROM)])
@@ -649,7 +649,7 @@ void IMAPUtils::convertAddressList
string email = addr.addr_mailbox()->value()
+ "@" + addr.addr_host()->value();
- dest.appendMailbox(vmime::create <mailbox>(name, email));
+ dest.appendMailbox(make_shared <mailbox>(name, email));
}
}
diff --git a/src/net/maildir/format/courierMaildirFormat.cpp b/src/net/maildir/format/courierMaildirFormat.cpp
index 346b9c67..a948de3e 100644
--- a/src/net/maildir/format/courierMaildirFormat.cpp
+++ b/src/net/maildir/format/courierMaildirFormat.cpp
@@ -41,7 +41,7 @@ namespace maildir {
namespace format {
-courierMaildirFormat::courierMaildirFormat(ref <context> ctx)
+courierMaildirFormat::courierMaildirFormat(shared_ptr <context> ctx)
: maildirFormat(ctx)
{
}
@@ -55,19 +55,19 @@ const string courierMaildirFormat::getName() const
void courierMaildirFormat::createFolder(const folder::path& path)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY)))
throw exceptions::invalid_folder_name();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
rootDir->createDirectory(true);
@@ -76,7 +76,7 @@ void courierMaildirFormat::createFolder(const folder::path& path)
tmpDir->createDirectory(false);
curDir->createDirectory(false);
- ref <utility::file> maildirFile = fsf->create
+ shared_ptr <utility::file> maildirFile = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY)
/ utility::file::path::component("maildirfolder"));
@@ -86,7 +86,7 @@ void courierMaildirFormat::createFolder(const folder::path& path)
void courierMaildirFormat::destroyFolder(const folder::path& path)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
// Recursively delete directories of subfolders
const std::vector <folder::path> folders = listFolders(path, true);
@@ -125,7 +125,7 @@ void courierMaildirFormat::renameFolder
void courierMaildirFormat::renameFolderImpl
(const folder::path& oldPath, const folder::path& newPath)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path oldFSPath =
folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY);
@@ -133,26 +133,26 @@ void courierMaildirFormat::renameFolderImpl
const utility::file::path newFSPath =
folderPathToFileSystemPath(newPath, ROOT_DIRECTORY);
- ref <utility::file> rootDir = fsf->create(oldFSPath);
+ shared_ptr <utility::file> rootDir = fsf->create(oldFSPath);
rootDir->rename(newFSPath);
}
bool courierMaildirFormat::folderExists(const folder::path& path) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
- ref <utility::file> maildirFile = fsf->create
+ shared_ptr <utility::file> maildirFile = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY)
/ utility::file::path::component("maildirfolder"));
@@ -260,9 +260,9 @@ const std::vector <folder::path> courierMaildirFormat::listFolders
bool courierMaildirFormat::listDirectories(const folder::path& root,
std::vector <string>& dirs, const bool onlyTestForExistence) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(getContext()->getStore()->getFileSystemPath());
if (rootDir->exists())
@@ -278,11 +278,11 @@ bool courierMaildirFormat::listDirectories(const folder::path& root,
}
// Enumerate directories
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
{
@@ -502,24 +502,24 @@ const folder::path::component courierMaildirFormat::fromModifiedUTF7(const strin
bool courierMaildirFormat::supports() const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(getContext()->getStore()->getFileSystemPath());
if (rootDir->exists())
{
// Try to find a file named "maildirfolder", which indicates
// the Maildir is in Courier format
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
{
- ref <utility::file> folderFile = fsf->create
+ shared_ptr <utility::file> folderFile = fsf->create
(file->getFullPath() / utility::file::path::component("maildirfolder"));
if (folderFile->exists() && folderFile->isFile())
diff --git a/src/net/maildir/format/kmailMaildirFormat.cpp b/src/net/maildir/format/kmailMaildirFormat.cpp
index 0f81b10a..70c9b909 100644
--- a/src/net/maildir/format/kmailMaildirFormat.cpp
+++ b/src/net/maildir/format/kmailMaildirFormat.cpp
@@ -41,7 +41,7 @@ namespace maildir {
namespace format {
-kmailMaildirFormat::kmailMaildirFormat(ref <context> ctx)
+kmailMaildirFormat::kmailMaildirFormat(shared_ptr <context> ctx)
: maildirFormat(ctx)
{
}
@@ -55,19 +55,19 @@ const string kmailMaildirFormat::getName() const
void kmailMaildirFormat::createFolder(const folder::path& path)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
if (!fsf->isValidPath(folderPathToFileSystemPath(path, ROOT_DIRECTORY)))
throw exceptions::invalid_folder_name();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
rootDir->createDirectory(true);
@@ -81,7 +81,7 @@ void kmailMaildirFormat::createFolder(const folder::path& path)
void kmailMaildirFormat::destroyFolder(const folder::path& path)
{
// Delete 'folder' and '.folder.directory' directories
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
maildirUtils::recursiveFSDelete(fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY))); // root
@@ -93,16 +93,16 @@ void kmailMaildirFormat::destroyFolder(const folder::path& path)
bool kmailMaildirFormat::folderExists(const folder::path& path) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, ROOT_DIRECTORY));
- ref <utility::file> newDir = fsf->create
+ shared_ptr <utility::file> newDir = fsf->create
(folderPathToFileSystemPath(path, NEW_DIRECTORY));
- ref <utility::file> tmpDir = fsf->create
+ shared_ptr <utility::file> tmpDir = fsf->create
(folderPathToFileSystemPath(path, TMP_DIRECTORY));
- ref <utility::file> curDir = fsf->create
+ shared_ptr <utility::file> curDir = fsf->create
(folderPathToFileSystemPath(path, CUR_DIRECTORY));
return rootDir->exists() && rootDir->isDirectory() &&
@@ -183,18 +183,18 @@ const std::vector <folder::path> kmailMaildirFormat::listFolders
void kmailMaildirFormat::listFoldersImpl
(std::vector <folder::path>& list, const folder::path& root, const bool recursive) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root,
+ shared_ptr <utility::file> rootDir = fsf->create(folderPathToFileSystemPath(root,
root.isEmpty() ? ROOT_DIRECTORY : CONTAINER_DIRECTORY));
if (rootDir->exists())
{
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
{
@@ -232,11 +232,11 @@ bool kmailMaildirFormat::isSubfolderDirectory(const utility::file& file)
void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder::path& newPath)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(oldPath, ROOT_DIRECTORY));
- ref <utility::file> contDir = fsf->create
+ shared_ptr <utility::file> contDir = fsf->create
(folderPathToFileSystemPath(oldPath, CONTAINER_DIRECTORY));
try
@@ -283,16 +283,16 @@ void kmailMaildirFormat::renameFolder(const folder::path& oldPath, const folder:
bool kmailMaildirFormat::folderHasSubfolders(const folder::path& path) const
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> rootDir = fsf->create
+ shared_ptr <utility::file> rootDir = fsf->create
(folderPathToFileSystemPath(path, CONTAINER_DIRECTORY));
- ref <utility::fileIterator> it = rootDir->getFiles();
+ shared_ptr <utility::fileIterator> it = rootDir->getFiles();
while (it->hasMoreElements())
{
- ref <utility::file> file = it->nextElement();
+ shared_ptr <utility::file> file = it->nextElement();
if (isSubfolderDirectory(*file))
return true;
diff --git a/src/net/maildir/maildirFolder.cpp b/src/net/maildir/maildirFolder.cpp
index ae4c17e0..f476d98a 100644
--- a/src/net/maildir/maildirFolder.cpp
+++ b/src/net/maildir/maildirFolder.cpp
@@ -35,8 +35,6 @@
#include "vmime/net/maildir/maildirFormat.hpp"
#include "vmime/net/maildir/maildirFolderStatus.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
#include "vmime/message.hpp"
#include "vmime/exception.hpp"
@@ -51,7 +49,7 @@ namespace net {
namespace maildir {
-maildirFolder::maildirFolder(const folder::path& path, ref <maildirStore> store)
+maildirFolder::maildirFolder(const folder::path& path, shared_ptr <maildirStore> store)
: m_store(store), m_path(path),
m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()),
m_mode(-1), m_open(false), m_unreadMessageCount(0), m_messageCount(0)
@@ -62,7 +60,7 @@ maildirFolder::maildirFolder(const folder::path& path, ref <maildirStore> store)
maildirFolder::~maildirFolder()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (store)
{
@@ -80,7 +78,7 @@ maildirFolder::~maildirFolder()
void maildirFolder::onStoreDisconnected()
{
- m_store = NULL;
+ m_store.reset();
}
@@ -106,7 +104,7 @@ int maildirFolder::getFlags()
{
int flags = 0;
- if (m_store.acquire()->getFormat()->folderHasSubfolders(m_path))
+ if (m_store.lock()->getFormat()->folderHasSubfolders(m_path))
flags |= FLAG_CHILDREN; // Contains at least one sub-folder
return (flags);
@@ -127,7 +125,7 @@ const folder::path maildirFolder::getFullPath() const
void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -145,7 +143,7 @@ void maildirFolder::open(const int mode, bool /* failIfModeIsNotAvailable */)
void maildirFolder::close(const bool expunge)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -193,7 +191,7 @@ void maildirFolder::unregisterMessage(maildirMessage* msg)
void maildirFolder::create(const int /* type */)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -215,9 +213,9 @@ void maildirFolder::create(const int /* type */)
}
// Notify folder created
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_CREATED, m_path, m_path);
notifyFolder(event);
@@ -226,7 +224,7 @@ void maildirFolder::create(const int /* type */)
void maildirFolder::destroy()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -244,9 +242,9 @@ void maildirFolder::destroy()
}
// Notify folder deleted
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_DELETED, m_path, m_path);
notifyFolder(event);
@@ -255,7 +253,7 @@ void maildirFolder::destroy()
bool maildirFolder::exists()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
return store->getFormat()->folderExists(m_path);
}
@@ -269,42 +267,42 @@ bool maildirFolder::isOpen() const
void maildirFolder::scanFolder()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
try
{
m_messageCount = 0;
m_unreadMessageCount = 0;
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path newDirPath = store->getFormat()->folderPathToFileSystemPath
(m_path, maildirFormat::NEW_DIRECTORY);
- ref <utility::file> newDir = fsf->create(newDirPath);
+ shared_ptr <utility::file> newDir = fsf->create(newDirPath);
utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath
(m_path, maildirFormat::CUR_DIRECTORY);
- ref <utility::file> curDir = fsf->create(curDirPath);
+ shared_ptr <utility::file> curDir = fsf->create(curDirPath);
// New received messages (new/)
- ref <utility::fileIterator> nit = newDir->getFiles();
+ shared_ptr <utility::fileIterator> nit = newDir->getFiles();
std::vector <utility::file::path::component> newMessageFilenames;
while (nit->hasMoreElements())
{
- ref <utility::file> file = nit->nextElement();
+ shared_ptr <utility::file> file = nit->nextElement();
if (maildirUtils::isMessageFile(*file))
newMessageFilenames.push_back(file->getFullPath().getLastComponent());
}
// Current messages (cur/)
- ref <utility::fileIterator> cit = curDir->getFiles();
+ shared_ptr <utility::fileIterator> cit = curDir->getFiles();
std::vector <utility::file::path::component> curMessageFilenames;
while (cit->hasMoreElements())
{
- ref <utility::file> file = cit->nextElement();
+ shared_ptr <utility::file> file = cit->nextElement();
if (maildirUtils::isMessageFile(*file))
curMessageFilenames.push_back(file->getFullPath().getLastComponent());
@@ -354,7 +352,7 @@ void maildirFolder::scanFolder()
maildirUtils::buildFilename(maildirUtils::extractId(*it), 0);
// Move messages from 'new' to 'cur'
- ref <utility::file> file = fsf->create(newDirPath / *it);
+ shared_ptr <utility::file> file = fsf->create(newDirPath / *it);
file->rename(curDirPath / newFilename);
// Append to message list
@@ -406,7 +404,7 @@ void maildirFolder::scanFolder()
}
-ref <message> maildirFolder::getMessage(const int num)
+shared_ptr <message> maildirFolder::getMessage(const int num)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
@@ -414,12 +412,12 @@ ref <message> maildirFolder::getMessage(const int num)
if (num < 1 || num > m_messageCount)
throw exceptions::message_not_found();
- return vmime::create <maildirMessage>
- (thisRef().dynamicCast <maildirFolder>(), num);
+ return make_shared <maildirMessage>
+ (dynamicCast <maildirFolder>(shared_from_this()), num);
}
-std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs)
+std::vector <shared_ptr <message> > maildirFolder::getMessages(const messageSet& msgs)
{
if (!isOpen())
throw exceptions::illegal_state("Folder not open");
@@ -428,15 +426,15 @@ std::vector <ref <message> > maildirFolder::getMessages(const messageSet& msgs)
{
const std::vector <int> numbers = maildirUtils::messageSetToNumberList(msgs);
- std::vector <ref <message> > messages;
- ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>();
+ std::vector <shared_ptr <message> > messages;
+ shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(shared_from_this());
for (std::vector <int>::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it)
{
if (*it < 1|| *it > m_messageCount)
throw exceptions::message_not_found();
- messages.push_back(vmime::create <maildirMessage>(thisFolder, *it));
+ messages.push_back(make_shared <maildirMessage>(thisFolder, *it));
}
return messages;
@@ -454,25 +452,25 @@ int maildirFolder::getMessageCount()
}
-ref <folder> maildirFolder::getFolder(const folder::path::component& name)
+shared_ptr <folder> maildirFolder::getFolder(const folder::path::component& name)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
- return vmime::create <maildirFolder>(m_path / name, store);
+ return make_shared <maildirFolder>(m_path / name, store);
}
-std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive)
+std::vector <shared_ptr <folder> > maildirFolder::getFolders(const bool recursive)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!isOpen() && !store)
throw exceptions::illegal_state("Store disconnected");
- std::vector <ref <folder> > list;
+ std::vector <shared_ptr <folder> > list;
listFolders(list, recursive);
@@ -480,9 +478,9 @@ std::vector <ref <folder> > maildirFolder::getFolders(const bool recursive)
}
-void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool recursive)
+void maildirFolder::listFolders(std::vector <shared_ptr <folder> >& list, const bool recursive)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
try
{
@@ -493,8 +491,8 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re
for (std::vector <folder::path>::size_type i = 0, n = pathList.size() ; i < n ; ++i)
{
- ref <maildirFolder> subFolder =
- vmime::create <maildirFolder>(pathList[i], store);
+ shared_ptr <maildirFolder> subFolder =
+ make_shared <maildirFolder>(pathList[i], store);
list.push_back(subFolder);
}
@@ -508,7 +506,7 @@ void maildirFolder::listFolders(std::vector <ref <folder> >& list, const bool re
void maildirFolder::rename(const folder::path& newPath)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -533,9 +531,9 @@ void maildirFolder::rename(const folder::path& newPath)
m_path = newPath;
m_name = newPath.getLastComponent();
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
notifyFolder(event);
@@ -549,9 +547,9 @@ void maildirFolder::rename(const folder::path& newPath)
(*it)->m_path = newPath;
(*it)->m_name = newPath.getLastComponent();
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, newPath);
(*it)->notifyFolder(event);
@@ -562,9 +560,9 @@ void maildirFolder::rename(const folder::path& newPath)
(*it)->m_path.renameParent(oldPath, newPath);
- ref <events::folderEvent> event =
- vmime::create <events::folderEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::folderEvent> event =
+ make_shared <events::folderEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::folderEvent::TYPE_RENAMED, oldPath, (*it)->m_path);
(*it)->notifyFolder(event);
@@ -583,7 +581,7 @@ void maildirFolder::deleteMessages(const messageSet& msgs)
void maildirFolder::setMessageFlags
(const messageSet& msgs, const int flags, const int mode)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -597,7 +595,7 @@ void maildirFolder::setMessageFlags
const std::vector <int> nums = maildirUtils::messageSetToNumberList(msgs);
// Change message flags
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path curDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
@@ -610,7 +608,7 @@ void maildirFolder::setMessageFlags
try
{
const utility::file::path::component path = m_messageInfos[num].path;
- ref <utility::file> file = fsf->create(curDirPath / path);
+ shared_ptr <utility::file> file = fsf->create(curDirPath / path);
int newFlags = maildirUtils::extractFlags(path);
@@ -690,9 +688,9 @@ void maildirFolder::setMessageFlags
}
// Notify message flags changed
- ref <events::messageChangedEvent> event =
- vmime::create <events::messageChangedEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageChangedEvent> event =
+ make_shared <events::messageChangedEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageChangedEvent::TYPE_FLAGS, nums);
notifyMessageChanged(event);
@@ -706,7 +704,7 @@ void maildirFolder::setMessageFlags
}
-void maildirFolder::addMessage(ref <vmime::message> msg, const int flags,
+void maildirFolder::addMessage(shared_ptr <vmime::message> msg, const int flags,
vmime::datetime* date, utility::progressListener* progress)
{
std::ostringstream oss;
@@ -724,7 +722,7 @@ void maildirFolder::addMessage(ref <vmime::message> msg, const int flags,
void maildirFolder::addMessage(utility::inputStream& is, const int size,
const int flags, vmime::datetime* /* date */, utility::progressListener* progress)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -733,7 +731,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
else if (m_mode == MODE_READ_ONLY)
throw exceptions::illegal_state("Folder is read-only");
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path tmpDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path,maildirFormat::TMP_DIRECTORY);
@@ -749,7 +747,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
try
{
- ref <utility::file> tmpDir = fsf->create(tmpDirPath);
+ shared_ptr <utility::file> tmpDir = fsf->create(tmpDirPath);
tmpDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -759,7 +757,7 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
try
{
- ref <utility::file> curDir = fsf->create(dstDirPath);
+ shared_ptr <utility::file> curDir = fsf->create(dstDirPath);
curDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -785,9 +783,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
std::vector <int> nums;
nums.push_back(m_messageCount);
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_ADDED, nums);
notifyMessageCount(event);
@@ -804,9 +802,9 @@ void maildirFolder::addMessage(utility::inputStream& is, const int size,
(*it)->m_messageInfos.resize(m_messageInfos.size());
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::messageCountEvent::TYPE_ADDED, nums);
(*it)->notifyMessageCount(event);
@@ -821,9 +819,9 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
utility::inputStream& is, const utility::stream::size_type size,
utility::progressListener* progress)
{
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
- ref <utility::file> file = fsf->create(tmpDirPath / filename);
+ shared_ptr <utility::file> file = fsf->create(tmpDirPath / filename);
if (progress)
progress->start(size);
@@ -833,8 +831,8 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
{
file->createFile();
- ref <utility::fileWriter> fw = file->getFileWriter();
- ref <utility::outputStream> os = fw->getOutputStream();
+ shared_ptr <utility::fileWriter> fw = file->getFileWriter();
+ shared_ptr <utility::outputStream> os = fw->getOutputStream();
utility::stream::value_type buffer[65536];
utility::stream::size_type total = 0;
@@ -863,7 +861,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
// Delete temporary file
try
{
- ref <utility::file> file = fsf->create(tmpDirPath / filename);
+ shared_ptr <utility::file> file = fsf->create(tmpDirPath / filename);
file->remove();
}
catch (exceptions::filesystem_exception&)
@@ -888,7 +886,7 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
try
{
file->remove();
- ref <utility::file> file = fsf->create(dstDirPath / filename);
+ shared_ptr <utility::file> file = fsf->create(dstDirPath / filename);
file->remove();
}
catch (exceptions::filesystem_exception&)
@@ -906,14 +904,14 @@ void maildirFolder::copyMessageImpl(const utility::file::path& tmpDirPath,
void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msgs)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path curDirPath = store->getFormat()->folderPathToFileSystemPath
(m_path, maildirFormat::CUR_DIRECTORY);
@@ -926,7 +924,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
// Create destination directories
try
{
- ref <utility::file> destTmpDir = fsf->create(destTmpDirPath);
+ shared_ptr <utility::file> destTmpDir = fsf->create(destTmpDirPath);
destTmpDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -936,7 +934,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
try
{
- ref <utility::file> destCurDir = fsf->create(destCurDirPath);
+ shared_ptr <utility::file> destCurDir = fsf->create(destCurDirPath);
destCurDir->createDirectory(true);
}
catch (exceptions::filesystem_exception&)
@@ -959,9 +957,9 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
const utility::file::path::component filename =
maildirUtils::buildFilename(maildirUtils::generateId(), flags);
- ref <utility::file> file = fsf->create(curDirPath / msg.path);
- ref <utility::fileReader> fr = file->getFileReader();
- ref <utility::inputStream> is = fr->getInputStream();
+ shared_ptr <utility::file> file = fsf->create(curDirPath / msg.path);
+ shared_ptr <utility::fileReader> fr = file->getFileReader();
+ shared_ptr <utility::inputStream> is = fr->getInputStream();
copyMessageImpl(destTmpDirPath, destCurDirPath,
filename, *is, file->getLength(), NULL);
@@ -979,7 +977,7 @@ void maildirFolder::copyMessages(const folder::path& dest, const messageSet& msg
void maildirFolder::notifyMessagesCopied(const folder::path& dest)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
for (std::list <maildirFolder*>::iterator it = store->m_folders.begin() ;
it != store->m_folders.end() ; ++it)
@@ -1002,22 +1000,22 @@ void maildirFolder::status(int& count, int& unseen)
count = 0;
unseen = 0;
- ref <folderStatus> status = getStatus();
+ shared_ptr <folderStatus> status = getStatus();
count = status->getMessageCount();
unseen = status->getUnseenCount();
}
-ref <folderStatus> maildirFolder::getStatus()
+shared_ptr <folderStatus> maildirFolder::getStatus()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
const int oldCount = m_messageCount;
scanFolder();
- ref <maildirFolderStatus> status = vmime::create <maildirFolderStatus>();
+ shared_ptr <maildirFolderStatus> status = make_shared <maildirFolderStatus>();
status->setMessageCount(m_messageCount);
status->setUnseenCount(m_unreadMessageCount);
@@ -1031,9 +1029,9 @@ ref <folderStatus> maildirFolder::getStatus()
for (int i = oldCount + 1, j = 0 ; i <= m_messageCount ; ++i, ++j)
nums[j] = i;
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_ADDED, nums);
notifyMessageCount(event);
@@ -1050,9 +1048,9 @@ ref <folderStatus> maildirFolder::getStatus()
(*it)->m_messageInfos.resize(m_messageInfos.size());
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::messageCountEvent::TYPE_ADDED, nums);
(*it)->notifyMessageCount(event);
@@ -1066,7 +1064,7 @@ ref <folderStatus> maildirFolder::getStatus()
void maildirFolder::expunge()
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1075,7 +1073,7 @@ void maildirFolder::expunge()
else if (m_mode == MODE_READ_ONLY)
throw exceptions::illegal_state("Folder is read-only");
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
utility::file::path curDirPath = store->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
@@ -1106,7 +1104,7 @@ void maildirFolder::expunge()
// Delete file from file system
try
{
- ref <utility::file> file = fsf->create(curDirPath / infos.path);
+ shared_ptr <utility::file> file = fsf->create(curDirPath / infos.path);
file->remove();
}
catch (exceptions::filesystem_exception& e)
@@ -1126,9 +1124,9 @@ void maildirFolder::expunge()
m_unreadMessageCount -= unreadCount;
// Notify message expunged
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_REMOVED, nums);
notifyMessageCount(event);
@@ -1145,9 +1143,9 @@ void maildirFolder::expunge()
(*it)->m_messageInfos.resize(m_messageInfos.size());
std::copy(m_messageInfos.begin(), m_messageInfos.end(), (*it)->m_messageInfos.begin());
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::messageCountEvent::TYPE_REMOVED, nums);
(*it)->notifyMessageCount(event);
@@ -1156,31 +1154,31 @@ void maildirFolder::expunge()
}
-ref <folder> maildirFolder::getParent()
+shared_ptr <folder> maildirFolder::getParent()
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <maildirFolder>(m_path.getParent(), m_store.acquire());
+ return make_shared <maildirFolder>(m_path.getParent(), m_store.lock());
}
-ref <const store> maildirFolder::getStore() const
+shared_ptr <const store> maildirFolder::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <store> maildirFolder::getStore()
+shared_ptr <store> maildirFolder::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
-void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
+void maildirFolder::fetchMessages(std::vector <shared_ptr <message> >& msg,
const fetchAttributes& options, utility::progressListener* progress)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -1193,12 +1191,12 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
if (progress)
progress->start(total);
- ref <maildirFolder> thisFolder = thisRef().dynamicCast <maildirFolder>();
+ shared_ptr <maildirFolder> thisFolder = dynamicCast <maildirFolder>(shared_from_this());
- for (std::vector <ref <message> >::iterator it = msg.begin() ;
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
it != msg.end() ; ++it)
{
- (*it).dynamicCast <maildirMessage>()->fetch(thisFolder, options);
+ dynamicCast <maildirMessage>(*it)->fetch(thisFolder, options);
if (progress)
progress->progress(++current, total);
@@ -1209,17 +1207,17 @@ void maildirFolder::fetchMessages(std::vector <ref <message> >& msg,
}
-void maildirFolder::fetchMessage(ref <message> msg, const fetchAttributes& options)
+void maildirFolder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
{
- ref <maildirStore> store = m_store.acquire();
+ shared_ptr <maildirStore> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- msg.dynamicCast <maildirMessage>()->fetch
- (thisRef().dynamicCast <maildirFolder>(), options);
+ dynamicCast <maildirMessage>(msg)->fetch
+ (dynamicCast <maildirFolder>(shared_from_this()), options);
}
@@ -1234,7 +1232,7 @@ int maildirFolder::getFetchCapabilities() const
const utility::file::path maildirFolder::getMessageFSPath(const int number) const
{
- utility::file::path curDirPath = m_store.acquire()->getFormat()->
+ utility::file::path curDirPath = m_store.lock()->getFormat()->
folderPathToFileSystemPath(m_path, maildirFormat::CUR_DIRECTORY);
return (curDirPath / m_messageInfos[number - 1].path);
diff --git a/src/net/maildir/maildirFolderStatus.cpp b/src/net/maildir/maildirFolderStatus.cpp
index bc00ba28..9ee84dba 100644
--- a/src/net/maildir/maildirFolderStatus.cpp
+++ b/src/net/maildir/maildirFolderStatus.cpp
@@ -74,9 +74,9 @@ void maildirFolderStatus::setUnseenCount(const unsigned int unseen)
}
-ref <folderStatus> maildirFolderStatus::clone() const
+shared_ptr <folderStatus> maildirFolderStatus::clone() const
{
- return vmime::create <maildirFolderStatus>(*this);
+ return make_shared <maildirFolderStatus>(*this);
}
diff --git a/src/net/maildir/maildirFormat.cpp b/src/net/maildir/maildirFormat.cpp
index f1e9c66e..f7a3c8fe 100644
--- a/src/net/maildir/maildirFormat.cpp
+++ b/src/net/maildir/maildirFormat.cpp
@@ -50,15 +50,15 @@ const utility::file::path::component maildirFormat::NEW_DIR("new", vmime::charse
// maildirFormat::context
//
-maildirFormat::context::context(ref <maildirStore> store)
+maildirFormat::context::context(shared_ptr <maildirStore> store)
: m_store(store)
{
}
-ref <maildirStore> maildirFormat::context::getStore() const
+shared_ptr <maildirStore> maildirFormat::context::getStore() const
{
- return m_store.acquire().constCast <maildirStore>();
+ return constCast <maildirStore>(m_store.lock());
}
@@ -66,37 +66,37 @@ ref <maildirStore> maildirFormat::context::getStore() const
// maildirFormat
//
-maildirFormat::maildirFormat(ref <context> ctx)
+maildirFormat::maildirFormat(shared_ptr <context> ctx)
: m_context(ctx)
{
}
-ref <maildirFormat::context> maildirFormat::getContext()
+shared_ptr <maildirFormat::context> maildirFormat::getContext()
{
return m_context;
}
-ref <const maildirFormat::context> maildirFormat::getContext() const
+shared_ptr <const maildirFormat::context> maildirFormat::getContext() const
{
return m_context;
}
// static
-ref <maildirFormat> maildirFormat::detect(ref <maildirStore> store)
+shared_ptr <maildirFormat> maildirFormat::detect(shared_ptr <maildirStore> store)
{
- ref <context> ctx = create <context>(store);
+ shared_ptr <context> ctx = make_shared <context>(store);
// Try Courier format
- ref <maildirFormat> fmt = create <format::courierMaildirFormat>(ctx);
+ shared_ptr <maildirFormat> fmt = make_shared <format::courierMaildirFormat>(ctx);
if (fmt->supports())
return fmt;
// Default is KMail format
- return create <format::kmailMaildirFormat>(ctx);
+ return make_shared <format::kmailMaildirFormat>(ctx);
}
diff --git a/src/net/maildir/maildirMessage.cpp b/src/net/maildir/maildirMessage.cpp
index d20481d4..88d743b2 100644
--- a/src/net/maildir/maildirMessage.cpp
+++ b/src/net/maildir/maildirMessage.cpp
@@ -47,9 +47,9 @@ namespace net {
namespace maildir {
-maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num)
+maildirMessage::maildirMessage(shared_ptr <maildirFolder> folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_flags(FLAG_UNDEFINED),
- m_expunged(false), m_structure(NULL)
+ m_expunged(false), m_structure(null)
{
folder->registerMessage(this);
}
@@ -57,7 +57,7 @@ maildirMessage::maildirMessage(ref <maildirFolder> folder, const int num)
maildirMessage::~maildirMessage()
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
@@ -66,7 +66,7 @@ maildirMessage::~maildirMessage()
void maildirMessage::onFolderClosed()
{
- m_folder = NULL;
+ m_folder.reset();
}
@@ -97,7 +97,7 @@ bool maildirMessage::isExpunged() const
}
-ref <const messageStructure> maildirMessage::getStructure() const
+shared_ptr <const messageStructure> maildirMessage::getStructure() const
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -106,7 +106,7 @@ ref <const messageStructure> maildirMessage::getStructure() const
}
-ref <messageStructure> maildirMessage::getStructure()
+shared_ptr <messageStructure> maildirMessage::getStructure()
{
if (m_structure == NULL)
throw exceptions::unfetched_object();
@@ -115,7 +115,7 @@ ref <messageStructure> maildirMessage::getStructure()
}
-ref <const header> maildirMessage::getHeader() const
+shared_ptr <const header> maildirMessage::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -135,7 +135,7 @@ int maildirMessage::getFlags() const
void maildirMessage::setFlags(const int flags, const int mode)
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
if (!folder)
throw exceptions::folder_not_found();
@@ -152,11 +152,11 @@ void maildirMessage::extract(utility::outputStream& os,
}
-void maildirMessage::extractPart(ref <const messagePart> p, utility::outputStream& os,
+void maildirMessage::extractPart(shared_ptr <const messagePart> p, utility::outputStream& os,
utility::progressListener* progress, const int start,
const int length, const bool peek) const
{
- ref <const maildirMessagePart> mp = p.dynamicCast <const maildirMessagePart>();
+ shared_ptr <const maildirMessagePart> mp = dynamicCast <const maildirMessagePart>(p);
extractImpl(os, progress, mp->getBodyParsedOffset(), mp->getBodyParsedLength(),
start, length, peek);
@@ -167,15 +167,15 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
const int start, const int length, const int partialStart, const int partialLength,
const bool /* peek */) const
{
- ref <const maildirFolder> folder = m_folder.acquire();
+ shared_ptr <const maildirFolder> folder = m_folder.lock();
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path path = folder->getMessageFSPath(m_num);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
- ref <utility::fileReader> reader = file->getFileReader();
- ref <utility::inputStream> is = reader->getInputStream();
+ shared_ptr <utility::fileReader> reader = file->getFileReader();
+ shared_ptr <utility::inputStream> is = reader->getInputStream();
is->skip(start + partialStart);
@@ -210,19 +210,19 @@ void maildirMessage::extractImpl(utility::outputStream& os, utility::progressLis
}
-void maildirMessage::fetchPartHeader(ref <messagePart> p)
+void maildirMessage::fetchPartHeader(shared_ptr <messagePart> p)
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
- ref <maildirMessagePart> mp = p.dynamicCast <maildirMessagePart>();
+ shared_ptr <maildirMessagePart> mp = dynamicCast <maildirMessagePart>(p);
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path path = folder->getMessageFSPath(m_num);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
- ref <utility::fileReader> reader = file->getFileReader();
- ref <utility::inputStream> is = reader->getInputStream();
+ shared_ptr <utility::fileReader> reader = file->getFileReader();
+ shared_ptr <utility::inputStream> is = reader->getInputStream();
is->skip(mp->getHeaderParsedOffset());
@@ -246,17 +246,17 @@ void maildirMessage::fetchPartHeader(ref <messagePart> p)
}
-void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes& options)
+void maildirMessage::fetch(shared_ptr <maildirFolder> msgFolder, const fetchAttributes& options)
{
- ref <maildirFolder> folder = m_folder.acquire();
+ shared_ptr <maildirFolder> folder = m_folder.lock();
if (folder != msgFolder)
throw exceptions::folder_not_found();
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
const utility::file::path path = folder->getMessageFSPath(m_num);
- ref <utility::file> file = fsf->create(path);
+ shared_ptr <utility::file> file = fsf->create(path);
if (options.has(fetchAttributes::FLAGS))
m_flags = maildirUtils::extractFlags(path.getLastComponent());
@@ -273,8 +273,8 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
{
string contents;
- ref <utility::fileReader> reader = file->getFileReader();
- ref <utility::inputStream> is = reader->getInputStream();
+ shared_ptr <utility::fileReader> reader = file->getFileReader();
+ shared_ptr <utility::inputStream> is = reader->getInputStream();
// Need whole message contents for structure
if (options.has(fetchAttributes::STRUCTURE))
@@ -323,7 +323,7 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
// Extract structure
if (options.has(fetchAttributes::STRUCTURE))
{
- m_structure = vmime::create <maildirMessageStructure>(null, msg);
+ m_structure = make_shared <maildirMessageStructure>(shared_ptr <maildirMessagePart>(), msg);
}
// Extract some header fields or whole header
@@ -338,23 +338,23 @@ void maildirMessage::fetch(ref <maildirFolder> msgFolder, const fetchAttributes&
}
-ref <header> maildirMessage::getOrCreateHeader()
+shared_ptr <header> maildirMessage::getOrCreateHeader()
{
if (m_header != NULL)
return (m_header);
else
- return (m_header = vmime::create <header>());
+ return (m_header = make_shared <header>());
}
-ref <vmime::message> maildirMessage::getParsedMessage()
+shared_ptr <vmime::message> maildirMessage::getParsedMessage()
{
std::ostringstream oss;
utility::outputStreamAdapter os(oss);
extract(os);
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ shared_ptr <vmime::message> msg = make_shared <vmime::message>();
msg->parse(oss.str());
return msg;
diff --git a/src/net/maildir/maildirMessagePart.cpp b/src/net/maildir/maildirMessagePart.cpp
index 75086ec3..683e259e 100644
--- a/src/net/maildir/maildirMessagePart.cpp
+++ b/src/net/maildir/maildirMessagePart.cpp
@@ -36,8 +36,8 @@ namespace net {
namespace maildir {
-maildirMessagePart::maildirMessagePart(ref <maildirMessagePart> parent, const int number, const bodyPart& part)
- : m_parent(parent), m_header(NULL), m_number(number)
+maildirMessagePart::maildirMessagePart(shared_ptr <maildirMessagePart> parent, const int number, const bodyPart& part)
+ : m_parent(parent), m_header(null), m_number(number)
{
m_headerParsedOffset = part.getHeader()->getParsedOffset();
m_headerParsedLength = part.getHeader()->getParsedLength();
@@ -59,17 +59,17 @@ maildirMessagePart::~maildirMessagePart()
void maildirMessagePart::initStructure(const bodyPart& part)
{
if (part.getBody()->getPartList().size() == 0)
- m_structure = NULL;
+ m_structure = null;
else
{
- m_structure = vmime::create <maildirMessageStructure>
- (thisRef().dynamicCast <maildirMessagePart>(),
+ m_structure = make_shared <maildirMessageStructure>
+ (dynamicCast <maildirMessagePart>(shared_from_this()),
part.getBody()->getPartList());
}
}
-ref <const messageStructure> maildirMessagePart::getStructure() const
+shared_ptr <const messageStructure> maildirMessagePart::getStructure() const
{
if (m_structure != NULL)
return m_structure;
@@ -78,7 +78,7 @@ ref <const messageStructure> maildirMessagePart::getStructure() const
}
-ref <messageStructure> maildirMessagePart::getStructure()
+shared_ptr <messageStructure> maildirMessagePart::getStructure()
{
if (m_structure != NULL)
return m_structure;
@@ -105,7 +105,7 @@ int maildirMessagePart::getNumber() const
}
-ref <const header> maildirMessagePart::getHeader() const
+shared_ptr <const header> maildirMessagePart::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -119,7 +119,7 @@ header& maildirMessagePart::getOrCreateHeader()
if (m_header != NULL)
return *m_header;
else
- return *(m_header = vmime::create <header>());
+ return *(m_header = make_shared <header>());
}
diff --git a/src/net/maildir/maildirMessageStructure.cpp b/src/net/maildir/maildirMessageStructure.cpp
index a0473f9e..f3b7cf59 100644
--- a/src/net/maildir/maildirMessageStructure.cpp
+++ b/src/net/maildir/maildirMessageStructure.cpp
@@ -36,7 +36,7 @@ namespace net {
namespace maildir {
-ref <maildirMessageStructure> maildirMessageStructure::m_emptyStructure = vmime::create <maildirMessageStructure>();
+shared_ptr <maildirMessageStructure> maildirMessageStructure::m_emptyStructure = make_shared <maildirMessageStructure>();
maildirMessageStructure::maildirMessageStructure()
@@ -44,20 +44,20 @@ maildirMessageStructure::maildirMessageStructure()
}
-maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent, const bodyPart& part)
+maildirMessageStructure::maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const bodyPart& part)
{
- vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, 0, part);
+ shared_ptr <maildirMessagePart> mpart = make_shared <maildirMessagePart>(parent, 0, part);
mpart->initStructure(part);
m_parts.push_back(mpart);
}
-maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent, const std::vector <ref <const vmime::bodyPart> >& list)
+maildirMessageStructure::maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const std::vector <shared_ptr <const vmime::bodyPart> >& list)
{
for (unsigned int i = 0 ; i < list.size() ; ++i)
{
- vmime::ref <maildirMessagePart> mpart = vmime::create <maildirMessagePart>(parent, i, *list[i]);
+ shared_ptr <maildirMessagePart> mpart = make_shared <maildirMessagePart>(parent, i, *list[i]);
mpart->initStructure(*list[i]);
m_parts.push_back(mpart);
@@ -65,13 +65,13 @@ maildirMessageStructure::maildirMessageStructure(ref <maildirMessagePart> parent
}
-ref <const messagePart> maildirMessageStructure::getPartAt(const size_t x) const
+shared_ptr <const messagePart> maildirMessageStructure::getPartAt(const size_t x) const
{
return m_parts[x];
}
-ref <messagePart> maildirMessageStructure::getPartAt(const size_t x)
+shared_ptr <messagePart> maildirMessageStructure::getPartAt(const size_t x)
{
return m_parts[x];
}
@@ -84,7 +84,7 @@ size_t maildirMessageStructure::getPartCount() const
// static
-ref <maildirMessageStructure> maildirMessageStructure::emptyStructure()
+shared_ptr <maildirMessageStructure> maildirMessageStructure::emptyStructure()
{
return m_emptyStructure;
}
diff --git a/src/net/maildir/maildirStore.cpp b/src/net/maildir/maildirStore.cpp
index 0fad6831..c7ceb6fa 100644
--- a/src/net/maildir/maildirStore.cpp
+++ b/src/net/maildir/maildirStore.cpp
@@ -32,8 +32,6 @@
#include "vmime/net/maildir/maildirFolder.hpp"
#include "vmime/net/maildir/maildirFormat.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
#include "vmime/exception.hpp"
#include "vmime/platform.hpp"
@@ -54,7 +52,7 @@ namespace net {
namespace maildir {
-maildirStore::maildirStore(ref <session> sess, ref <security::authenticator> auth)
+maildirStore::maildirStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: store(sess, getInfosInstance(), auth), m_connected(false)
{
}
@@ -80,33 +78,35 @@ const string maildirStore::getProtocolName() const
}
-ref <folder> maildirStore::getRootFolder()
+shared_ptr <folder> maildirStore::getRootFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <maildirFolder>(folder::path(),
- thisRef().dynamicCast <maildirStore>());
+ return make_shared <maildirFolder>
+ (folder::path(),
+ dynamicCast <maildirStore>(shared_from_this()));
}
-ref <folder> maildirStore::getDefaultFolder()
+shared_ptr <folder> maildirStore::getDefaultFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <maildirFolder>(folder::path::component("inbox"),
- thisRef().dynamicCast <maildirStore>());
+ return make_shared <maildirFolder>
+ (folder::path::component("inbox"),
+ dynamicCast <maildirStore>(shared_from_this()));
}
-ref <folder> maildirStore::getFolder(const folder::path& path)
+shared_ptr <folder> maildirStore::getFolder(const folder::path& path)
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <maildirFolder>(path,
- thisRef().dynamicCast <maildirStore>());
+ return make_shared <maildirFolder>
+ (path, dynamicCast <maildirStore>(shared_from_this()));
}
@@ -138,11 +138,11 @@ void maildirStore::connect()
throw exceptions::already_connected();
// Get root directory
- ref <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
+ shared_ptr <utility::fileSystemFactory> fsf = platform::getHandler()->getFileSystemFactory();
m_fsPath = fsf->stringToPath(GET_PROPERTY(string, PROPERTY_SERVER_ROOTPATH));
- ref <utility::file> rootDir = fsf->create(m_fsPath);
+ shared_ptr <utility::file> rootDir = fsf->create(m_fsPath);
// Try to create the root directory if it does not exist
if (!(rootDir->exists() && rootDir->isDirectory()))
@@ -157,7 +157,7 @@ void maildirStore::connect()
}
}
- m_format = maildirFormat::detect(thisRef().dynamicCast <maildirStore>());
+ m_format = maildirFormat::detect(dynamicCast <maildirStore>(shared_from_this()));
m_connected = true;
}
@@ -175,9 +175,9 @@ bool maildirStore::isSecuredConnection() const
}
-ref <connectionInfos> maildirStore::getConnectionInfos() const
+shared_ptr <connectionInfos> maildirStore::getConnectionInfos() const
{
- return vmime::create <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
+ return make_shared <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
}
@@ -201,13 +201,13 @@ void maildirStore::noop()
}
-ref <maildirFormat> maildirStore::getFormat()
+shared_ptr <maildirFormat> maildirStore::getFormat()
{
return m_format;
}
-ref <const maildirFormat> maildirStore::getFormat() const
+shared_ptr <const maildirFormat> maildirStore::getFormat() const
{
return m_format;
}
diff --git a/src/net/maildir/maildirUtils.cpp b/src/net/maildir/maildirUtils.cpp
index c4ba2857..5a5ac90f 100644
--- a/src/net/maildir/maildirUtils.cpp
+++ b/src/net/maildir/maildirUtils.cpp
@@ -175,14 +175,14 @@ const utility::file::path::component maildirUtils::generateId()
}
-void maildirUtils::recursiveFSDelete(ref <utility::file> dir)
+void maildirUtils::recursiveFSDelete(shared_ptr <utility::file> dir)
{
- ref <utility::fileIterator> files = dir->getFiles();
+ shared_ptr <utility::fileIterator> files = dir->getFiles();
// First, delete files and subdirectories in this directory
while (files->hasMoreElements())
{
- ref <utility::file> file = files->nextElement();
+ shared_ptr <utility::file> file = files->nextElement();
if (file->isDirectory())
{
diff --git a/src/net/message.cpp b/src/net/message.cpp
index 09fe6321..6765e73c 100644
--- a/src/net/message.cpp
+++ b/src/net/message.cpp
@@ -36,13 +36,13 @@ namespace vmime {
namespace net {
-ref <const messagePart> messagePart::getPartAt(const size_t pos) const
+shared_ptr <const messagePart> messagePart::getPartAt(const size_t pos) const
{
return getStructure()->getPartAt(pos);
}
-ref <messagePart> messagePart::getPartAt(const size_t pos)
+shared_ptr <messagePart> messagePart::getPartAt(const size_t pos)
{
return getStructure()->getPartAt(pos);
}
diff --git a/src/net/messageSet.cpp b/src/net/messageSet.cpp
index 04f1debb..71a8a788 100644
--- a/src/net/messageSet.cpp
+++ b/src/net/messageSet.cpp
@@ -314,8 +314,8 @@ messageSet messageSet::byUID(const std::vector <message::uid>& uids)
else
{
set.m_ranges.push_back(new UIDMessageRange
- (static_cast <std::ostringstream*>(&(std::ostringstream() << rangeStart))->str(),
- static_cast <std::ostringstream*>(&(std::ostringstream() << previous))->str()));
+ (utility::stringUtils::toString(rangeStart),
+ utility::stringUtils::toString(previous)));
previous = current;
rangeStart = current;
@@ -324,8 +324,8 @@ messageSet messageSet::byUID(const std::vector <message::uid>& uids)
}
set.m_ranges.push_back(new UIDMessageRange
- (static_cast <std::ostringstream*>(&(std::ostringstream() << rangeStart))->str(),
- static_cast <std::ostringstream*>(&(std::ostringstream() << previous))->str()));
+ (utility::stringUtils::toString(rangeStart),
+ utility::stringUtils::toString(previous)));
return set;
}
diff --git a/src/net/pop3/POP3Command.cpp b/src/net/pop3/POP3Command.cpp
index 6c178891..6fe301ce 100644
--- a/src/net/pop3/POP3Command.cpp
+++ b/src/net/pop3/POP3Command.cpp
@@ -49,21 +49,21 @@ POP3Command::POP3Command(const string& text)
// static
-ref <POP3Command> POP3Command::CAPA()
+shared_ptr <POP3Command> POP3Command::CAPA()
{
return createCommand("CAPA");
}
// static
-ref <POP3Command> POP3Command::NOOP()
+shared_ptr <POP3Command> POP3Command::NOOP()
{
return createCommand("NOOP");
}
// static
-ref <POP3Command> POP3Command::AUTH(const string& mechName)
+shared_ptr <POP3Command> POP3Command::AUTH(const string& mechName)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -74,14 +74,14 @@ ref <POP3Command> POP3Command::AUTH(const string& mechName)
// static
-ref <POP3Command> POP3Command::STLS()
+shared_ptr <POP3Command> POP3Command::STLS()
{
return createCommand("STLS");
}
// static
-ref <POP3Command> POP3Command::APOP(const string& username, const string& digest)
+shared_ptr <POP3Command> POP3Command::APOP(const string& username, const string& digest)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -92,7 +92,7 @@ ref <POP3Command> POP3Command::APOP(const string& username, const string& digest
// static
-ref <POP3Command> POP3Command::USER(const string& username)
+shared_ptr <POP3Command> POP3Command::USER(const string& username)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -103,7 +103,7 @@ ref <POP3Command> POP3Command::USER(const string& username)
// static
-ref <POP3Command> POP3Command::PASS(const string& password)
+shared_ptr <POP3Command> POP3Command::PASS(const string& password)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -114,21 +114,21 @@ ref <POP3Command> POP3Command::PASS(const string& password)
// static
-ref <POP3Command> POP3Command::STAT()
+shared_ptr <POP3Command> POP3Command::STAT()
{
return createCommand("STAT");
}
// static
-ref <POP3Command> POP3Command::LIST()
+shared_ptr <POP3Command> POP3Command::LIST()
{
return createCommand("LIST");
}
// static
-ref <POP3Command> POP3Command::LIST(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::LIST(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -139,14 +139,14 @@ ref <POP3Command> POP3Command::LIST(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::UIDL()
+shared_ptr <POP3Command> POP3Command::UIDL()
{
return createCommand("UIDL");
}
// static
-ref <POP3Command> POP3Command::UIDL(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::UIDL(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -157,7 +157,7 @@ ref <POP3Command> POP3Command::UIDL(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::DELE(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::DELE(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -168,7 +168,7 @@ ref <POP3Command> POP3Command::DELE(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::RETR(const unsigned long msg)
+shared_ptr <POP3Command> POP3Command::RETR(const unsigned long msg)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -179,7 +179,7 @@ ref <POP3Command> POP3Command::RETR(const unsigned long msg)
// static
-ref <POP3Command> POP3Command::TOP(const unsigned long msg, const unsigned long lines)
+shared_ptr <POP3Command> POP3Command::TOP(const unsigned long msg, const unsigned long lines)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -190,23 +190,23 @@ ref <POP3Command> POP3Command::TOP(const unsigned long msg, const unsigned long
// static
-ref <POP3Command> POP3Command::RSET()
+shared_ptr <POP3Command> POP3Command::RSET()
{
return createCommand("RSET");
}
// static
-ref <POP3Command> POP3Command::QUIT()
+shared_ptr <POP3Command> POP3Command::QUIT()
{
return createCommand("QUIT");
}
// static
-ref <POP3Command> POP3Command::createCommand(const string& text)
+shared_ptr <POP3Command> POP3Command::createCommand(const string& text)
{
- return vmime::create <POP3Command>(text);
+ return shared_ptr <POP3Command>(new POP3Command(text));
}
@@ -216,7 +216,7 @@ const string POP3Command::getText() const
}
-void POP3Command::send(ref <POP3Connection> conn)
+void POP3Command::send(shared_ptr <POP3Connection> conn)
{
conn->getSocket()->send(m_text + "\r\n");
}
diff --git a/src/net/pop3/POP3Connection.cpp b/src/net/pop3/POP3Connection.cpp
index dd0024e9..547ef5ef 100644
--- a/src/net/pop3/POP3Connection.cpp
+++ b/src/net/pop3/POP3Connection.cpp
@@ -50,11 +50,11 @@
// Helpers for service properties
#define GET_PROPERTY(type, prop) \
- (m_store.acquire()->getInfos().getPropertyValue <type>(getSession(), \
- dynamic_cast <const POP3ServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().getPropertyValue <type>(getSession(), \
+ dynamic_cast <const POP3ServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
#define HAS_PROPERTY(prop) \
- (m_store.acquire()->getInfos().hasProperty(getSession(), \
- dynamic_cast <const POP3ServiceInfos&>(m_store.acquire()->getInfos()).getProperties().prop))
+ (m_store.lock()->getInfos().hasProperty(getSession(), \
+ dynamic_cast <const POP3ServiceInfos&>(m_store.lock()->getInfos()).getProperties().prop))
namespace vmime {
@@ -63,8 +63,8 @@ namespace pop3 {
-POP3Connection::POP3Connection(ref <POP3Store> store, ref <security::authenticator> auth)
- : m_store(store), m_auth(auth), m_socket(NULL), m_timeoutHandler(NULL),
+POP3Connection::POP3Connection(shared_ptr <POP3Store> store, shared_ptr <security::authenticator> auth)
+ : m_store(store), m_auth(auth), m_socket(null), m_timeoutHandler(null),
m_authenticated(false), m_secured(false), m_capabilitiesFetched(false)
{
}
@@ -94,7 +94,7 @@ void POP3Connection::connect()
const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
// Create the time-out handler
if (store->getTimeoutHandlerFactory())
@@ -106,22 +106,22 @@ void POP3Connection::connect()
#if VMIME_HAVE_TLS_SUPPORT
if (store->isPOP3S()) // dedicated port/POP3S
{
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
(store->getCertificateVerifier(),
store->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
m_socket = tlsSocket;
m_secured = true;
- m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
}
else
#endif // VMIME_HAVE_TLS_SUPPORT
{
- m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
+ m_cntInfos = make_shared <defaultConnectionInfos>(address, port);
}
m_socket->connect(address, port);
@@ -131,8 +131,8 @@ void POP3Connection::connect()
// eg: C: <connection to server>
// --- S: +OK MailSite POP3 Server 5.3.4.0 Ready <[email protected]>
- ref <POP3Response> response = POP3Response::readResponse
- (thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response = POP3Response::readResponse
+ (dynamicCast <POP3Connection>(shared_from_this()));
if (!response->isSuccess())
{
@@ -195,8 +195,8 @@ void POP3Connection::internalDisconnect()
{
try
{
- POP3Command::QUIT()->send(thisRef().dynamicCast <POP3Connection>());
- POP3Response::readResponse(thisRef().dynamicCast <POP3Connection>());
+ POP3Command::QUIT()->send(dynamicCast <POP3Connection>(shared_from_this()));
+ POP3Response::readResponse(dynamicCast <POP3Connection>(shared_from_this()));
}
catch (exception&)
{
@@ -206,21 +206,21 @@ void POP3Connection::internalDisconnect()
m_socket->disconnect();
}
- m_socket = NULL;
+ m_socket = null;
}
- m_timeoutHandler = NULL;
+ m_timeoutHandler = null;
m_authenticated = false;
m_secured = false;
- m_cntInfos = NULL;
+ m_cntInfos = null;
}
void POP3Connection::authenticate(const messageId& randomMID)
{
- getAuthenticator()->setService(m_store.acquire());
+ getAuthenticator()->setService(m_store.lock());
#if VMIME_HAVE_SASL_SUPPORT
// First, try SASL authentication
@@ -262,8 +262,8 @@ void POP3Connection::authenticate(const messageId& randomMID)
const string username = getAuthenticator()->getUsername();
const string password = getAuthenticator()->getPassword();
- ref <POP3Connection> conn = thisRef().dynamicCast <POP3Connection>();
- ref <POP3Response> response;
+ shared_ptr <POP3Connection> conn = dynamicCast <POP3Connection>(shared_from_this());
+ shared_ptr <POP3Response> response;
if (GET_PROPERTY(bool, PROPERTY_OPTIONS_APOP))
{
@@ -271,7 +271,7 @@ void POP3Connection::authenticate(const messageId& randomMID)
randomMID.getRight().length() != 0)
{
// <digest> is the result of MD5 applied to "<message-id>password"
- ref <security::digest::messageDigest> md5 =
+ shared_ptr <security::digest::messageDigest> md5 =
security::digest::messageDigestFactory::getInstance()->create("md5");
md5->update(randomMID.generate() + password);
@@ -361,7 +361,7 @@ void POP3Connection::authenticate(const messageId& randomMID)
void POP3Connection::authenticateSASL()
{
- if (!getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>())
+ if (!dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator()))
throw exceptions::authentication_error("No SASL authenticator available.");
std::vector <string> capa = getCapabilities();
@@ -401,10 +401,10 @@ void POP3Connection::authenticateSASL()
if (saslMechs.empty())
throw exceptions::authentication_error("No SASL mechanism available.");
- std::vector <ref <security::sasl::SASLMechanism> > mechList;
+ std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
- ref <security::sasl::SASLContext> saslContext =
- vmime::create <security::sasl::SASLContext>();
+ shared_ptr <security::sasl::SASLContext> saslContext =
+ make_shared <security::sasl::SASLContext>();
for (unsigned int i = 0 ; i < saslMechs.size() ; ++i)
{
@@ -423,14 +423,14 @@ void POP3Connection::authenticateSASL()
throw exceptions::authentication_error("No SASL mechanism available.");
// Try to suggest a mechanism among all those supported
- ref <security::sasl::SASLMechanism> suggestedMech =
+ shared_ptr <security::sasl::SASLMechanism> suggestedMech =
saslContext->suggestMechanism(mechList);
if (!suggestedMech)
throw exceptions::authentication_error("Unable to suggest SASL mechanism.");
// Allow application to choose which mechanisms to use
- mechList = getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>()->
+ mechList = dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator())->
getAcceptableMechanisms(mechList, suggestedMech);
if (mechList.empty())
@@ -439,19 +439,19 @@ void POP3Connection::authenticateSASL()
// Try each mechanism in the list in turn
for (unsigned int i = 0 ; i < mechList.size() ; ++i)
{
- ref <security::sasl::SASLMechanism> mech = mechList[i];
+ shared_ptr <security::sasl::SASLMechanism> mech = mechList[i];
- ref <security::sasl::SASLSession> saslSession =
+ shared_ptr <security::sasl::SASLSession> saslSession =
saslContext->createSession("pop3", getAuthenticator(), mech);
saslSession->init();
- POP3Command::AUTH(mech->getName())->send(thisRef().dynamicCast <POP3Connection>());
+ POP3Command::AUTH(mech->getName())->send(dynamicCast <POP3Connection>(shared_from_this()));
for (bool cont = true ; cont ; )
{
- ref <POP3Response> response =
- POP3Response::readResponse(thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response =
+ POP3Response::readResponse(dynamicCast <POP3Connection>(shared_from_this()));
switch (response->getCode())
{
@@ -537,19 +537,19 @@ void POP3Connection::startTLS()
{
try
{
- POP3Command::STLS()->send(thisRef().dynamicCast <POP3Connection>());
+ POP3Command::STLS()->send(dynamicCast <POP3Connection>(shared_from_this()));
- ref <POP3Response> response =
- POP3Response::readResponse(thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response =
+ POP3Response::readResponse(dynamicCast <POP3Connection>(shared_from_this()));
if (!response->isSuccess())
throw exceptions::command_error("STLS", response->getFirstLine());
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
- (m_store.acquire()->getCertificateVerifier(),
- m_store.acquire()->getSession()->getTLSProperties());
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
+ (m_store.lock()->getCertificateVerifier(),
+ m_store.lock()->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
tlsSocket->handshake(m_timeoutHandler);
@@ -557,7 +557,7 @@ void POP3Connection::startTLS()
m_socket = tlsSocket;
m_secured = true;
- m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
// " Once TLS has been started, the client MUST discard cached
@@ -601,10 +601,10 @@ void POP3Connection::invalidateCapabilities()
void POP3Connection::fetchCapabilities()
{
- POP3Command::CAPA()->send(thisRef().dynamicCast <POP3Connection>());
+ POP3Command::CAPA()->send(dynamicCast <POP3Connection>(shared_from_this()));
- ref <POP3Response> response =
- POP3Response::readMultilineResponse(thisRef().dynamicCast <POP3Connection>());
+ shared_ptr <POP3Response> response =
+ POP3Response::readMultilineResponse(dynamicCast <POP3Connection>(shared_from_this()));
std::vector <string> res;
@@ -631,37 +631,37 @@ bool POP3Connection::isSecuredConnection() const
}
-ref <connectionInfos> POP3Connection::getConnectionInfos() const
+shared_ptr <connectionInfos> POP3Connection::getConnectionInfos() const
{
return m_cntInfos;
}
-ref <POP3Store> POP3Connection::getStore()
+shared_ptr <POP3Store> POP3Connection::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <session> POP3Connection::getSession()
+shared_ptr <session> POP3Connection::getSession()
{
- return m_store.acquire()->getSession();
+ return m_store.lock()->getSession();
}
-ref <socket> POP3Connection::getSocket()
+shared_ptr <socket> POP3Connection::getSocket()
{
return m_socket;
}
-ref <timeoutHandler> POP3Connection::getTimeoutHandler()
+shared_ptr <timeoutHandler> POP3Connection::getTimeoutHandler()
{
return m_timeoutHandler;
}
-ref <security::authenticator> POP3Connection::getAuthenticator()
+shared_ptr <security::authenticator> POP3Connection::getAuthenticator()
{
return m_auth;
}
diff --git a/src/net/pop3/POP3Folder.cpp b/src/net/pop3/POP3Folder.cpp
index ffff121e..66ace31c 100644
--- a/src/net/pop3/POP3Folder.cpp
+++ b/src/net/pop3/POP3Folder.cpp
@@ -45,7 +45,7 @@ namespace net {
namespace pop3 {
-POP3Folder::POP3Folder(const folder::path& path, ref <POP3Store> store)
+POP3Folder::POP3Folder(const folder::path& path, shared_ptr <POP3Store> store)
: m_store(store), m_path(path),
m_name(path.isEmpty() ? folder::path::component("") : path.getLastComponent()),
m_mode(-1), m_open(false)
@@ -56,7 +56,7 @@ POP3Folder::POP3Folder(const folder::path& path, ref <POP3Store> store)
POP3Folder::~POP3Folder()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (store)
{
@@ -115,7 +115,7 @@ const folder::path POP3Folder::getFullPath() const
void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -134,7 +134,7 @@ void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable)
{
POP3Command::STAT()->send(store->getConnection());
- ref <POP3Response> response = POP3Response::readResponse(store->getConnection());
+ shared_ptr <POP3Response> response = POP3Response::readResponse(store->getConnection());
if (!response->isSuccess())
throw exceptions::command_error("STAT", response->getFirstLine());
@@ -156,7 +156,7 @@ void POP3Folder::open(const int mode, bool failIfModeIsNotAvailable)
void POP3Folder::close(const bool expunge)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -200,7 +200,7 @@ void POP3Folder::destroy()
bool POP3Folder::exists()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -215,9 +215,9 @@ bool POP3Folder::isOpen() const
}
-ref <message> POP3Folder::getMessage(const int num)
+shared_ptr <message> POP3Folder::getMessage(const int num)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -226,13 +226,13 @@ ref <message> POP3Folder::getMessage(const int num)
else if (num < 1 || num > m_messageCount)
throw exceptions::message_not_found();
- return vmime::create <POP3Message>(thisRef().dynamicCast <POP3Folder>(), num);
+ return make_shared <POP3Message>(dynamicCast <POP3Folder>(shared_from_this()), num);
}
-std::vector <ref <message> > POP3Folder::getMessages(const messageSet& msgs)
+std::vector <shared_ptr <message> > POP3Folder::getMessages(const messageSet& msgs)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -243,15 +243,15 @@ std::vector <ref <message> > POP3Folder::getMessages(const messageSet& msgs)
{
const std::vector <int> numbers = POP3Utils::messageSetToNumberList(msgs);
- std::vector <ref <message> > messages;
- ref <POP3Folder> thisFolder = thisRef().dynamicCast <POP3Folder>();
+ std::vector <shared_ptr <message> > messages;
+ shared_ptr <POP3Folder> thisFolder(dynamicCast <POP3Folder>(shared_from_this()));
for (std::vector <int>::const_iterator it = numbers.begin() ; it != numbers.end() ; ++it)
{
if (*it < 1|| *it > m_messageCount)
throw exceptions::message_not_found();
- messages.push_back(vmime::create <POP3Message>(thisFolder, *it));
+ messages.push_back(make_shared <POP3Message>(thisFolder, *it));
}
return messages;
@@ -265,7 +265,7 @@ std::vector <ref <message> > POP3Folder::getMessages(const messageSet& msgs)
int POP3Folder::getMessageCount()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -276,42 +276,42 @@ int POP3Folder::getMessageCount()
}
-ref <folder> POP3Folder::getFolder(const folder::path::component& name)
+shared_ptr <folder> POP3Folder::getFolder(const folder::path::component& name)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
- return vmime::create <POP3Folder>(m_path / name, store);
+ return make_shared <POP3Folder>(m_path / name, store);
}
-std::vector <ref <folder> > POP3Folder::getFolders(const bool /* recursive */)
+std::vector <shared_ptr <folder> > POP3Folder::getFolders(const bool /* recursive */)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
if (m_path.isEmpty())
{
- std::vector <ref <folder> > v;
- v.push_back(vmime::create <POP3Folder>(folder::path::component("INBOX"), store));
+ std::vector <shared_ptr <folder> > v;
+ v.push_back(make_shared <POP3Folder>(folder::path::component("INBOX"), store));
return (v);
}
else
{
- std::vector <ref <folder> > v;
+ std::vector <shared_ptr <folder> > v;
return (v);
}
}
-void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options,
+void POP3Folder::fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options,
utility::progressListener* progress)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
@@ -324,11 +324,11 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
if (progress)
progress->start(total);
- for (std::vector <ref <message> >::iterator it = msg.begin() ;
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
it != msg.end() ; ++it)
{
- (*it).dynamicCast <POP3Message>()->fetch
- (thisRef().dynamicCast <POP3Folder>(), options);
+ dynamicCast <POP3Message>(*it)->fetch
+ (dynamicCast <POP3Folder>(shared_from_this()), options);
if (progress)
progress->progress(++current, total);
@@ -340,7 +340,7 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
POP3Command::LIST()->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readMultilineResponse(store->getConnection());
if (response->isSuccess())
@@ -353,10 +353,10 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
std::map <int, string> result;
POP3Utils::parseMultiListOrUidlResponse(response, result);
- for (std::vector <ref <message> >::iterator it = msg.begin() ;
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
it != msg.end() ; ++it)
{
- ref <POP3Message> m = (*it).dynamicCast <POP3Message>();
+ shared_ptr <POP3Message> m = dynamicCast <POP3Message>(*it);
std::map <int, string>::const_iterator x = result.find(m->m_num);
@@ -380,7 +380,7 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
POP3Command::UIDL()->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readMultilineResponse(store->getConnection());
if (response->isSuccess())
@@ -393,10 +393,10 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
std::map <int, string> result;
POP3Utils::parseMultiListOrUidlResponse(response, result);
- for (std::vector <ref <message> >::iterator it = msg.begin() ;
+ for (std::vector <shared_ptr <message> >::iterator it = msg.begin() ;
it != msg.end() ; ++it)
{
- ref <POP3Message> m = (*it).dynamicCast <POP3Message>();
+ shared_ptr <POP3Message> m = dynamicCast <POP3Message>(*it);
std::map <int, string>::const_iterator x = result.find(m->m_num);
@@ -411,17 +411,17 @@ void POP3Folder::fetchMessages(std::vector <ref <message> >& msg, const fetchAtt
}
-void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
+void POP3Folder::fetchMessage(shared_ptr <message> msg, const fetchAttributes& options)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
else if (!isOpen())
throw exceptions::illegal_state("Folder not open");
- msg.dynamicCast <POP3Message>()->fetch
- (thisRef().dynamicCast <POP3Folder>(), options);
+ dynamicCast <POP3Message>(msg)->fetch
+ (dynamicCast <POP3Folder>(shared_from_this()), options);
if (options.has(fetchAttributes::SIZE))
{
@@ -429,7 +429,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
POP3Command::LIST(msg->getNumber())->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (response->isSuccess())
@@ -451,7 +451,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
std::istringstream iss(string(it, responseText.end()));
iss >> size;
- msg.dynamicCast <POP3Message>()->m_size = size;
+ dynamicCast <POP3Message>(msg)->m_size = size;
}
}
}
@@ -462,7 +462,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
POP3Command::UIDL(msg->getNumber())->send(store->getConnection());
// Get the response
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (response->isSuccess())
@@ -479,7 +479,7 @@ void POP3Folder::fetchMessage(ref <message> msg, const fetchAttributes& options)
if (it != responseText.end())
{
- msg.dynamicCast <POP3Message>()->m_uid =
+ dynamicCast <POP3Message>(msg)->m_uid =
string(it, responseText.end());
}
}
@@ -495,24 +495,24 @@ int POP3Folder::getFetchCapabilities() const
}
-ref <folder> POP3Folder::getParent()
+shared_ptr <folder> POP3Folder::getParent()
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <POP3Folder>(m_path.getParent(), m_store.acquire());
+ return make_shared <POP3Folder>(m_path.getParent(), m_store.lock());
}
-ref <const store> POP3Folder::getStore() const
+shared_ptr <const store> POP3Folder::getStore() const
{
- return m_store.acquire();
+ return m_store.lock();
}
-ref <store> POP3Folder::getStore()
+shared_ptr <store> POP3Folder::getStore()
{
- return m_store.acquire();
+ return m_store.lock();
}
@@ -530,13 +530,13 @@ void POP3Folder::unregisterMessage(POP3Message* msg)
void POP3Folder::onStoreDisconnected()
{
- m_store = NULL;
+ m_store.reset();
}
void POP3Folder::deleteMessages(const messageSet& msgs)
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
const std::vector <int> nums = POP3Utils::messageSetToNumberList(msgs);
@@ -553,7 +553,7 @@ void POP3Folder::deleteMessages(const messageSet& msgs)
{
POP3Command::DELE(*it)->send(store->getConnection());
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (!response->isSuccess())
@@ -579,9 +579,9 @@ void POP3Folder::deleteMessages(const messageSet& msgs)
}
// Notify message flags changed
- ref <events::messageChangedEvent> event =
- vmime::create <events::messageChangedEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageChangedEvent> event =
+ make_shared <events::messageChangedEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageChangedEvent::TYPE_FLAGS, list);
notifyMessageChanged(event);
@@ -601,7 +601,7 @@ void POP3Folder::rename(const folder::path& /* newPath */)
}
-void POP3Folder::addMessage(ref <vmime::message> /* msg */, const int /* flags */,
+void POP3Folder::addMessage(shared_ptr <vmime::message> /* msg */, const int /* flags */,
vmime::datetime* /* date */, utility::progressListener* /* progress */)
{
throw exceptions::operation_not_supported();
@@ -626,23 +626,23 @@ void POP3Folder::status(int& count, int& unseen)
count = 0;
unseen = 0;
- ref <folderStatus> status = getStatus();
+ shared_ptr <folderStatus> status = getStatus();
count = status->getMessageCount();
unseen = status->getUnseenCount();
}
-ref <folderStatus> POP3Folder::getStatus()
+shared_ptr <folderStatus> POP3Folder::getStatus()
{
- ref <POP3Store> store = m_store.acquire();
+ shared_ptr <POP3Store> store = m_store.lock();
if (!store)
throw exceptions::illegal_state("Store disconnected");
POP3Command::STAT()->send(store->getConnection());
- ref <POP3Response> response =
+ shared_ptr <POP3Response> response =
POP3Response::readResponse(store->getConnection());
if (!response->isSuccess())
@@ -654,7 +654,7 @@ ref <folderStatus> POP3Folder::getStatus()
std::istringstream iss(response->getText());
iss >> count;
- ref <POP3FolderStatus> status = vmime::create <POP3FolderStatus>();
+ shared_ptr <POP3FolderStatus> status = make_shared <POP3FolderStatus>();
status->setMessageCount(count);
status->setUnseenCount(count);
@@ -675,9 +675,9 @@ ref <folderStatus> POP3Folder::getStatus()
nums[j] = i;
// Notify message count changed
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- (thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>(shared_from_this()),
events::messageCountEvent::TYPE_ADDED, nums);
notifyMessageCount(event);
@@ -690,9 +690,9 @@ ref <folderStatus> POP3Folder::getStatus()
{
(*it)->m_messageCount = count;
- ref <events::messageCountEvent> event =
- vmime::create <events::messageCountEvent>
- ((*it)->thisRef().dynamicCast <folder>(),
+ shared_ptr <events::messageCountEvent> event =
+ make_shared <events::messageCountEvent>
+ (dynamicCast <folder>((*it)->shared_from_this()),
events::messageCountEvent::TYPE_ADDED, nums);
(*it)->notifyMessageCount(event);
diff --git a/src/net/pop3/POP3FolderStatus.cpp b/src/net/pop3/POP3FolderStatus.cpp
index 64c8d9d1..944379ac 100644
--- a/src/net/pop3/POP3FolderStatus.cpp
+++ b/src/net/pop3/POP3FolderStatus.cpp
@@ -74,9 +74,9 @@ void POP3FolderStatus::setUnseenCount(const unsigned int unseen)
}
-ref <folderStatus> POP3FolderStatus::clone() const
+shared_ptr <folderStatus> POP3FolderStatus::clone() const
{
- return vmime::create <POP3FolderStatus>(*this);
+ return make_shared <POP3FolderStatus>(*this);
}
diff --git a/src/net/pop3/POP3Message.cpp b/src/net/pop3/POP3Message.cpp
index bad25cb9..5f0fb725 100644
--- a/src/net/pop3/POP3Message.cpp
+++ b/src/net/pop3/POP3Message.cpp
@@ -44,7 +44,7 @@ namespace net {
namespace pop3 {
-POP3Message::POP3Message(ref <POP3Folder> folder, const int num)
+POP3Message::POP3Message(shared_ptr <POP3Folder> folder, const int num)
: m_folder(folder), m_num(num), m_size(-1), m_deleted(false)
{
folder->registerMessage(this);
@@ -53,7 +53,7 @@ POP3Message::POP3Message(ref <POP3Folder> folder, const int num)
POP3Message::~POP3Message()
{
- ref <POP3Folder> folder = m_folder.acquire();
+ shared_ptr <POP3Folder> folder = m_folder.lock();
if (folder)
folder->unregisterMessage(this);
@@ -62,7 +62,7 @@ POP3Message::~POP3Message()
void POP3Message::onFolderClosed()
{
- m_folder = NULL;
+ m_folder.reset();
}
@@ -104,19 +104,19 @@ int POP3Message::getFlags() const
}
-ref <const messageStructure> POP3Message::getStructure() const
+shared_ptr <const messageStructure> POP3Message::getStructure() const
{
throw exceptions::operation_not_supported();
}
-ref <messageStructure> POP3Message::getStructure()
+shared_ptr <messageStructure> POP3Message::getStructure()
{
throw exceptions::operation_not_supported();
}
-ref <const header> POP3Message::getHeader() const
+shared_ptr <const header> POP3Message::getHeader() const
{
if (m_header == NULL)
throw exceptions::unfetched_object();
@@ -129,7 +129,7 @@ void POP3Message::extract(utility::outputStream& os,
utility::progressListener* progress, const int start,
const int length, const bool /* peek */) const
{
- ref <const POP3Folder> folder = m_folder.acquire();
+ shared_ptr <const POP3Folder> folder = m_folder.lock();
if (!folder)
throw exceptions::illegal_state("Folder closed");
@@ -140,7 +140,7 @@ void POP3Message::extract(utility::outputStream& os,
throw exceptions::partial_fetch_not_supported();
// Emit the "RETR" command
- ref <POP3Store> store = folder.constCast <POP3Folder>()->m_store.acquire();
+ shared_ptr <POP3Store> store = constCast <POP3Folder>(folder)->m_store.lock();
POP3Command::RETR(m_num)->send(store->getConnection());
@@ -157,7 +157,7 @@ void POP3Message::extract(utility::outputStream& os,
void POP3Message::extractPart
- (ref <const messagePart> /* p */, utility::outputStream& /* os */,
+ (shared_ptr <const messagePart> /* p */, utility::outputStream& /* os */,
utility::progressListener* /* progress */,
const int /* start */, const int /* length */,
const bool /* peek */) const
@@ -166,15 +166,15 @@ void POP3Message::extractPart
}
-void POP3Message::fetchPartHeader(ref <messagePart> /* p */)
+void POP3Message::fetchPartHeader(shared_ptr <messagePart> /* p */)
{
throw exceptions::operation_not_supported();
}
-void POP3Message::fetch(ref <POP3Folder> msgFolder, const fetchAttributes& options)
+void POP3Message::fetch(shared_ptr <POP3Folder> msgFolder, const fetchAttributes& options)
{
- ref <POP3Folder> folder = m_folder.acquire();
+ shared_ptr <POP3Folder> folder = m_folder.lock();
if (folder != msgFolder)
throw exceptions::folder_not_found();
@@ -196,7 +196,7 @@ void POP3Message::fetch(ref <POP3Folder> msgFolder, const fetchAttributes& optio
// fields in particular.
// Emit the "TOP" command
- ref <POP3Store> store = folder->m_store.acquire();
+ shared_ptr <POP3Store> store = folder->m_store.lock();
POP3Command::TOP(m_num, 0)->send(store->getConnection());
@@ -208,7 +208,7 @@ void POP3Message::fetch(ref <POP3Folder> msgFolder, const fetchAttributes& optio
POP3Response::readLargeResponse(store->getConnection(),
bufferStream, /* progress */ NULL, /* predictedSize */ 0);
- m_header = vmime::create <header>();
+ m_header = make_shared <header>();
m_header->parse(buffer);
}
catch (exceptions::command_error& e)
@@ -224,14 +224,14 @@ void POP3Message::setFlags(const int /* flags */, const int /* mode */)
}
-ref <vmime::message> POP3Message::getParsedMessage()
+shared_ptr <vmime::message> POP3Message::getParsedMessage()
{
std::ostringstream oss;
utility::outputStreamAdapter os(oss);
extract(os);
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ shared_ptr <vmime::message> msg = make_shared <vmime::message>();
msg->parse(oss.str());
return msg;
diff --git a/src/net/pop3/POP3Response.cpp b/src/net/pop3/POP3Response.cpp
index 975cd642..e24634c6 100644
--- a/src/net/pop3/POP3Response.cpp
+++ b/src/net/pop3/POP3Response.cpp
@@ -46,17 +46,17 @@ namespace net {
namespace pop3 {
-POP3Response::POP3Response(ref <socket> sok, ref <timeoutHandler> toh)
+POP3Response::POP3Response(shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh)
: m_socket(sok), m_timeoutHandler(toh)
{
}
// static
-ref <POP3Response> POP3Response::readResponse(ref <POP3Connection> conn)
+shared_ptr <POP3Response> POP3Response::readResponse(shared_ptr <POP3Connection> conn)
{
- ref <POP3Response> resp = vmime::create <POP3Response>
- (conn->getSocket(), conn->getTimeoutHandler());
+ shared_ptr <POP3Response> resp = shared_ptr <POP3Response>
+ (new POP3Response(conn->getSocket(), conn->getTimeoutHandler()));
string buffer;
resp->readResponseImpl(buffer, /* multiLine */ false);
@@ -70,10 +70,10 @@ ref <POP3Response> POP3Response::readResponse(ref <POP3Connection> conn)
// static
-ref <POP3Response> POP3Response::readMultilineResponse(ref <POP3Connection> conn)
+shared_ptr <POP3Response> POP3Response::readMultilineResponse(shared_ptr <POP3Connection> conn)
{
- ref <POP3Response> resp = vmime::create <POP3Response>
- (conn->getSocket(), conn->getTimeoutHandler());
+ shared_ptr <POP3Response> resp = shared_ptr <POP3Response>
+ (new POP3Response(conn->getSocket(), conn->getTimeoutHandler()));
string buffer;
resp->readResponseImpl(buffer, /* multiLine */ true);
@@ -96,12 +96,12 @@ ref <POP3Response> POP3Response::readMultilineResponse(ref <POP3Connection> conn
// static
-ref <POP3Response> POP3Response::readLargeResponse
- (ref <POP3Connection> conn, utility::outputStream& os,
+shared_ptr <POP3Response> POP3Response::readLargeResponse
+ (shared_ptr <POP3Connection> conn, utility::outputStream& os,
utility::progressListener* progress, const long predictedSize)
{
- ref <POP3Response> resp = vmime::create <POP3Response>
- (conn->getSocket(), conn->getTimeoutHandler());
+ shared_ptr <POP3Response> resp = shared_ptr <POP3Response>
+ (new POP3Response(conn->getSocket(), conn->getTimeoutHandler()));
string firstLine;
resp->readResponseImpl(firstLine, os, progress, predictedSize);
diff --git a/src/net/pop3/POP3SStore.cpp b/src/net/pop3/POP3SStore.cpp
index f7d17b38..f1c3da74 100644
--- a/src/net/pop3/POP3SStore.cpp
+++ b/src/net/pop3/POP3SStore.cpp
@@ -35,7 +35,7 @@ namespace net {
namespace pop3 {
-POP3SStore::POP3SStore(ref <session> sess, ref <security::authenticator> auth)
+POP3SStore::POP3SStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: POP3Store(sess, auth, true)
{
}
diff --git a/src/net/pop3/POP3Store.cpp b/src/net/pop3/POP3Store.cpp
index 6ff404e2..e6e95b1b 100644
--- a/src/net/pop3/POP3Store.cpp
+++ b/src/net/pop3/POP3Store.cpp
@@ -42,7 +42,7 @@ namespace net {
namespace pop3 {
-POP3Store::POP3Store(ref <session> sess, ref <security::authenticator> auth, const bool secured)
+POP3Store::POP3Store(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured)
: store(sess, getInfosInstance(), auth), m_isPOP3S(secured)
{
}
@@ -68,33 +68,34 @@ const string POP3Store::getProtocolName() const
}
-ref <folder> POP3Store::getDefaultFolder()
+shared_ptr <folder> POP3Store::getDefaultFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <POP3Folder>(folder::path(folder::path::component("INBOX")),
- thisRef().dynamicCast <POP3Store>());
+ return make_shared <POP3Folder>
+ (folder::path(folder::path::component("INBOX")),
+ dynamicCast <POP3Store>(shared_from_this()));
}
-ref <folder> POP3Store::getRootFolder()
+shared_ptr <folder> POP3Store::getRootFolder()
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <POP3Folder>(folder::path(),
- thisRef().dynamicCast <POP3Store>());
+ return make_shared <POP3Folder>
+ (folder::path(), dynamicCast <POP3Store>(shared_from_this()));
}
-ref <folder> POP3Store::getFolder(const folder::path& path)
+shared_ptr <folder> POP3Store::getFolder(const folder::path& path)
{
if (!isConnected())
throw exceptions::illegal_state("Not connected");
- return vmime::create <POP3Folder>(path,
- thisRef().dynamicCast <POP3Store>());
+ return make_shared <POP3Folder>
+ (path, dynamicCast <POP3Store>(shared_from_this()));
}
@@ -109,8 +110,8 @@ void POP3Store::connect()
if (isConnected())
throw exceptions::already_connected();
- m_connection = vmime::create <POP3Connection>
- (thisRef().dynamicCast <POP3Store>(), getAuthenticator());
+ m_connection = make_shared <POP3Connection>
+ (dynamicCast <POP3Store>(shared_from_this()), getAuthenticator());
try
{
@@ -118,7 +119,7 @@ void POP3Store::connect()
}
catch (std::exception&)
{
- m_connection = NULL;
+ m_connection = null;
throw;
}
}
@@ -145,16 +146,16 @@ bool POP3Store::isSecuredConnection() const
}
-ref <connectionInfos> POP3Store::getConnectionInfos() const
+shared_ptr <connectionInfos> POP3Store::getConnectionInfos() const
{
if (m_connection == NULL)
- return NULL;
+ return null;
return m_connection->getConnectionInfos();
}
-ref <POP3Connection> POP3Store::getConnection()
+shared_ptr <POP3Connection> POP3Store::getConnection()
{
return m_connection;
}
@@ -175,7 +176,7 @@ void POP3Store::disconnect()
m_connection->disconnect();
- m_connection = NULL;
+ m_connection = null;
}
@@ -186,7 +187,7 @@ void POP3Store::noop()
POP3Command::NOOP()->send(m_connection);
- ref <POP3Response> response = POP3Response::readResponse(m_connection);
+ shared_ptr <POP3Response> response = POP3Response::readResponse(m_connection);
if (!response->isSuccess())
throw exceptions::command_error("NOOP", response->getFirstLine());
diff --git a/src/net/pop3/POP3Utils.cpp b/src/net/pop3/POP3Utils.cpp
index e2722104..7ba65fff 100644
--- a/src/net/pop3/POP3Utils.cpp
+++ b/src/net/pop3/POP3Utils.cpp
@@ -39,7 +39,7 @@ namespace pop3 {
// static
-void POP3Utils::parseMultiListOrUidlResponse(ref <POP3Response> response, std::map <int, string>& result)
+void POP3Utils::parseMultiListOrUidlResponse(shared_ptr <POP3Response> response, std::map <int, string>& result)
{
std::map <int, string> ids;
diff --git a/src/net/sendmail/sendmailTransport.cpp b/src/net/sendmail/sendmailTransport.cpp
index 82501575..68c96e51 100644
--- a/src/net/sendmail/sendmailTransport.cpp
+++ b/src/net/sendmail/sendmailTransport.cpp
@@ -36,7 +36,6 @@
#include "vmime/utility/filteredStream.hpp"
#include "vmime/utility/childProcess.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/utility/streamUtils.hpp"
@@ -59,7 +58,7 @@ namespace net {
namespace sendmail {
-sendmailTransport::sendmailTransport(ref <session> sess, ref <security::authenticator> auth)
+sendmailTransport::sendmailTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: transport(sess, getInfosInstance(), auth), m_connected(false)
{
}
@@ -109,9 +108,9 @@ bool sendmailTransport::isSecuredConnection() const
}
-ref <connectionInfos> sendmailTransport::getConnectionInfos() const
+shared_ptr <connectionInfos> sendmailTransport::getConnectionInfos() const
{
- return vmime::create <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
+ return make_shared <defaultConnectionInfos>("localhost", static_cast <port_t>(0));
}
@@ -182,7 +181,7 @@ void sendmailTransport::internalSend
const utility::file::path path = vmime::platform::getHandler()->
getFileSystemFactory()->stringToPath(m_sendmailPath);
- ref <utility::childProcess> proc =
+ shared_ptr <utility::childProcess> proc =
vmime::platform::getHandler()->
getChildProcessFactory()->create(path);
diff --git a/src/net/service.cpp b/src/net/service.cpp
index 9ff0c394..c52ba592 100644
--- a/src/net/service.cpp
+++ b/src/net/service.cpp
@@ -46,23 +46,23 @@ namespace vmime {
namespace net {
-service::service(ref <session> sess, const serviceInfos& /* infos */,
- ref <security::authenticator> auth)
+service::service(shared_ptr <session> sess, const serviceInfos& /* infos */,
+ shared_ptr <security::authenticator> auth)
: m_session(sess), m_auth(auth)
{
if (!auth)
{
#if VMIME_HAVE_SASL_SUPPORT
- m_auth = vmime::create
+ m_auth = make_shared
<security::sasl::defaultSASLAuthenticator>();
#else
- m_auth = vmime::create
+ m_auth = make_shared
<security::defaultAuthenticator>();
#endif // VMIME_HAVE_SASL_SUPPORT
}
#if VMIME_HAVE_TLS_SUPPORT
- m_certVerifier = vmime::create <security::cert::defaultCertificateVerifier>();
+ m_certVerifier = make_shared <security::cert::defaultCertificateVerifier>();
#endif // VMIME_HAVE_TLS_SUPPORT
m_socketFactory = platform::getHandler()->getSocketFactory();
@@ -74,31 +74,31 @@ service::~service()
}
-ref <const session> service::getSession() const
+shared_ptr <const session> service::getSession() const
{
return (m_session);
}
-ref <session> service::getSession()
+shared_ptr <session> service::getSession()
{
return (m_session);
}
-ref <const security::authenticator> service::getAuthenticator() const
+shared_ptr <const security::authenticator> service::getAuthenticator() const
{
return (m_auth);
}
-ref <security::authenticator> service::getAuthenticator()
+shared_ptr <security::authenticator> service::getAuthenticator()
{
return (m_auth);
}
-void service::setAuthenticator(ref <security::authenticator> auth)
+void service::setAuthenticator(shared_ptr <security::authenticator> auth)
{
m_auth = auth;
}
@@ -106,13 +106,13 @@ void service::setAuthenticator(ref <security::authenticator> auth)
#if VMIME_HAVE_TLS_SUPPORT
-void service::setCertificateVerifier(ref <security::cert::certificateVerifier> cv)
+void service::setCertificateVerifier(shared_ptr <security::cert::certificateVerifier> cv)
{
m_certVerifier = cv;
}
-ref <security::cert::certificateVerifier> service::getCertificateVerifier()
+shared_ptr <security::cert::certificateVerifier> service::getCertificateVerifier()
{
return m_certVerifier;
}
@@ -120,25 +120,25 @@ ref <security::cert::certificateVerifier> service::getCertificateVerifier()
#endif // VMIME_HAVE_TLS_SUPPORT
-void service::setSocketFactory(ref <socketFactory> sf)
+void service::setSocketFactory(shared_ptr <socketFactory> sf)
{
m_socketFactory = sf;
}
-ref <socketFactory> service::getSocketFactory()
+shared_ptr <socketFactory> service::getSocketFactory()
{
return m_socketFactory;
}
-void service::setTimeoutHandlerFactory(ref <timeoutHandlerFactory> thf)
+void service::setTimeoutHandlerFactory(shared_ptr <timeoutHandlerFactory> thf)
{
m_toHandlerFactory = thf;
}
-ref <timeoutHandlerFactory> service::getTimeoutHandlerFactory()
+shared_ptr <timeoutHandlerFactory> service::getTimeoutHandlerFactory()
{
return m_toHandlerFactory;
}
diff --git a/src/net/serviceFactory.cpp b/src/net/serviceFactory.cpp
index c44cbadc..a16098ce 100644
--- a/src/net/serviceFactory.cpp
+++ b/src/net/serviceFactory.cpp
@@ -49,26 +49,26 @@ serviceFactory::~serviceFactory()
}
-serviceFactory* serviceFactory::getInstance()
+shared_ptr <serviceFactory> serviceFactory::getInstance()
{
static serviceFactory instance;
- return (&instance);
+ return shared_ptr <serviceFactory>(&instance, noop_shared_ptr_deleter <serviceFactory>());
}
-ref <service> serviceFactory::create
- (ref <session> sess, const string& protocol,
- ref <security::authenticator> auth)
+shared_ptr <service> serviceFactory::create
+ (shared_ptr <session> sess, const string& protocol,
+ shared_ptr <security::authenticator> auth)
{
return (getServiceByProtocol(protocol)->create(sess, auth));
}
-ref <service> serviceFactory::create
- (ref <session> sess, const utility::url& u,
- ref <security::authenticator> auth)
+shared_ptr <service> serviceFactory::create
+ (shared_ptr <session> sess, const utility::url& u,
+ shared_ptr <security::authenticator> auth)
{
- ref <service> serv = create(sess, u.getProtocol(), auth);
+ shared_ptr <service> serv = create(sess, u.getProtocol(), auth);
sess->getProperties()[serv->getInfos().getPropertyPrefix() + "server.address"] = u.getHost();
@@ -90,11 +90,11 @@ ref <service> serviceFactory::create
}
-ref <const serviceFactory::registeredService> serviceFactory::getServiceByProtocol(const string& protocol) const
+shared_ptr <const serviceFactory::registeredService> serviceFactory::getServiceByProtocol(const string& protocol) const
{
const string name(utility::stringUtils::toLower(protocol));
- for (std::vector <ref <registeredService> >::const_iterator it = m_services.begin() ;
+ for (std::vector <shared_ptr <registeredService> >::const_iterator it = m_services.begin() ;
it != m_services.end() ; ++it)
{
if ((*it)->getName() == name)
@@ -111,17 +111,17 @@ size_t serviceFactory::getServiceCount() const
}
-ref <const serviceFactory::registeredService> serviceFactory::getServiceAt(const size_t pos) const
+shared_ptr <const serviceFactory::registeredService> serviceFactory::getServiceAt(const size_t pos) const
{
return (m_services[pos]);
}
-const std::vector <ref <const serviceFactory::registeredService> > serviceFactory::getServiceList() const
+const std::vector <shared_ptr <const serviceFactory::registeredService> > serviceFactory::getServiceList() const
{
- std::vector <ref <const registeredService> > res;
+ std::vector <shared_ptr <const registeredService> > res;
- for (std::vector <ref <registeredService> >::const_iterator it = m_services.begin() ;
+ for (std::vector <shared_ptr <registeredService> >::const_iterator it = m_services.begin() ;
it != m_services.end() ; ++it)
{
res.push_back(*it);
@@ -131,7 +131,7 @@ const std::vector <ref <const serviceFactory::registeredService> > serviceFactor
}
-void serviceFactory::registerService(ref <registeredService> reg)
+void serviceFactory::registerService(shared_ptr <registeredService> reg)
{
m_services.push_back(reg);
}
diff --git a/src/net/serviceInfos.cpp b/src/net/serviceInfos.cpp
index 751bae3f..8de0529e 100644
--- a/src/net/serviceInfos.cpp
+++ b/src/net/serviceInfos.cpp
@@ -85,7 +85,7 @@ serviceInfos::~serviceInfos()
}
-bool serviceInfos::hasProperty(ref <session> s, const property& p) const
+bool serviceInfos::hasProperty(shared_ptr <session> s, const property& p) const
{
return s->getProperties().hasProperty(getPropertyPrefix() + p.getName());
}
diff --git a/src/net/serviceRegistration.inl b/src/net/serviceRegistration.inl
index 084aed9e..2366fe01 100644
--- a/src/net/serviceRegistration.inl
+++ b/src/net/serviceRegistration.inl
@@ -41,11 +41,11 @@ public:
{
}
- ref <service> create
- (ref <session> sess,
- ref <security::authenticator> auth) const
+ shared_ptr <service> create
+ (shared_ptr <session> sess,
+ shared_ptr <security::authenticator> auth) const
{
- return vmime::create <S>(sess, auth);
+ return make_shared <S>(sess, auth);
}
const serviceInfos& getInfos() const
@@ -80,7 +80,7 @@ public:
serviceRegisterer(const string& protocol, const service::Type type)
{
serviceFactory::getInstance()->registerService
- (vmime::create <vmime::net::registeredServiceImpl <S> >(protocol, type));
+ (make_shared <registeredServiceImpl <S> >(protocol, type));
}
};
diff --git a/src/net/session.cpp b/src/net/session.cpp
index a444d000..fcc5dd12 100644
--- a/src/net/session.cpp
+++ b/src/net/session.cpp
@@ -39,19 +39,20 @@ namespace net {
session::session()
- : m_tlsProps(vmime::create <tls::TLSProperties>())
+ : m_tlsProps(make_shared <tls::TLSProperties>())
{
}
session::session(const session& sess)
- : object(), m_props(sess.m_props), m_tlsProps(vmime::create <tls::TLSProperties>(*sess.m_tlsProps))
+ : object(), m_props(sess.m_props),
+ m_tlsProps(make_shared <tls::TLSProperties>(*sess.m_tlsProps))
{
}
session::session(const propertySet& props)
- : m_props(props), m_tlsProps(vmime::create <tls::TLSProperties>())
+ : m_props(props), m_tlsProps(make_shared <tls::TLSProperties>())
{
}
@@ -61,67 +62,67 @@ session::~session()
}
-ref <transport> session::getTransport(ref <security::authenticator> auth)
+shared_ptr <transport> session::getTransport(shared_ptr <security::authenticator> auth)
{
return (getTransport(m_props["transport.protocol"], auth));
}
-ref <transport> session::getTransport
- (const string& protocol, ref <security::authenticator> auth)
+shared_ptr <transport> session::getTransport
+ (const string& protocol, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
if (sv->getType() != service::TYPE_TRANSPORT)
throw exceptions::no_service_available();
- return sv.staticCast <transport>();
+ return dynamicCast <transport>(sv);
}
-ref <transport> session::getTransport
- (const utility::url& url, ref <security::authenticator> auth)
+shared_ptr <transport> session::getTransport
+ (const utility::url& url, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
if (sv->getType() != service::TYPE_TRANSPORT)
throw exceptions::no_service_available();
- return sv.staticCast <transport>();
+ return dynamicCast <transport>(sv);
}
-ref <store> session::getStore(ref <security::authenticator> auth)
+shared_ptr <store> session::getStore(shared_ptr <security::authenticator> auth)
{
return (getStore(m_props["store.protocol"], auth));
}
-ref <store> session::getStore
- (const string& protocol, ref <security::authenticator> auth)
+shared_ptr <store> session::getStore
+ (const string& protocol, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, protocol, auth);
if (sv->getType() != service::TYPE_STORE)
throw exceptions::no_service_available();
- return sv.staticCast <store>();
+ return dynamicCast <store>(sv);
}
-ref <store> session::getStore
- (const utility::url& url, ref <security::authenticator> auth)
+shared_ptr <store> session::getStore
+ (const utility::url& url, shared_ptr <security::authenticator> auth)
{
- ref <session> sess = thisRef().dynamicCast <session>();
- ref <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
+ shared_ptr <session> sess(dynamicCast <session>(shared_from_this()));
+ shared_ptr <service> sv = serviceFactory::getInstance()->create(sess, url, auth);
if (sv->getType() != service::TYPE_STORE)
throw exceptions::no_service_available();
- return sv.staticCast <store>();
+ return dynamicCast <store>(sv);
}
@@ -137,13 +138,13 @@ propertySet& session::getProperties()
}
-void session::setTLSProperties(ref <tls::TLSProperties> tlsProps)
+void session::setTLSProperties(shared_ptr <tls::TLSProperties> tlsProps)
{
- m_tlsProps = vmime::create <tls::TLSProperties>(*tlsProps);
+ m_tlsProps = make_shared <tls::TLSProperties>(*tlsProps);
}
-ref <tls::TLSProperties> session::getTLSProperties() const
+shared_ptr <tls::TLSProperties> session::getTLSProperties() const
{
return m_tlsProps;
}
diff --git a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
index 932bd56f..0584f7e6 100644
--- a/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
+++ b/src/net/smtp/SMTPChunkingOutputStreamAdapter.cpp
@@ -40,7 +40,7 @@ namespace net {
namespace smtp {
-SMTPChunkingOutputStreamAdapter::SMTPChunkingOutputStreamAdapter(ref <SMTPConnection> conn)
+SMTPChunkingOutputStreamAdapter::SMTPChunkingOutputStreamAdapter(shared_ptr <SMTPConnection> conn)
: m_connection(conn), m_bufferSize(0), m_chunkCount(0)
{
}
@@ -64,7 +64,7 @@ void SMTPChunkingOutputStreamAdapter::sendChunk
// If PIPELINING is not supported, read one response for this BDAT command
if (!m_connection->hasExtension("PIPELINING"))
{
- ref <SMTPResponse> resp = m_connection->readResponse();
+ shared_ptr <SMTPResponse> resp = m_connection->readResponse();
if (resp->getCode() != 250)
{
@@ -77,7 +77,7 @@ void SMTPChunkingOutputStreamAdapter::sendChunk
else if (last)
{
bool invalidReply = false;
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
for (unsigned int i = 0 ; i < m_chunkCount ; ++i)
{
diff --git a/src/net/smtp/SMTPCommand.cpp b/src/net/smtp/SMTPCommand.cpp
index e40797f2..6b3d1d79 100644
--- a/src/net/smtp/SMTPCommand.cpp
+++ b/src/net/smtp/SMTPCommand.cpp
@@ -47,7 +47,7 @@ SMTPCommand::SMTPCommand(const string& text)
// static
-ref <SMTPCommand> SMTPCommand::EHLO(const string& hostname)
+shared_ptr <SMTPCommand> SMTPCommand::EHLO(const string& hostname)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -58,7 +58,7 @@ ref <SMTPCommand> SMTPCommand::EHLO(const string& hostname)
// static
-ref <SMTPCommand> SMTPCommand::HELO(const string& hostname)
+shared_ptr <SMTPCommand> SMTPCommand::HELO(const string& hostname)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -69,7 +69,7 @@ ref <SMTPCommand> SMTPCommand::HELO(const string& hostname)
// static
-ref <SMTPCommand> SMTPCommand::AUTH(const string& mechName)
+shared_ptr <SMTPCommand> SMTPCommand::AUTH(const string& mechName)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -80,21 +80,21 @@ ref <SMTPCommand> SMTPCommand::AUTH(const string& mechName)
// static
-ref <SMTPCommand> SMTPCommand::STARTTLS()
+shared_ptr <SMTPCommand> SMTPCommand::STARTTLS()
{
return createCommand("STARTTLS");
}
// static
-ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8)
+shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8)
{
return MAIL(mbox, utf8, 0);
}
// static
-ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const unsigned long size)
+shared_ptr <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const unsigned long size)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -123,7 +123,7 @@ ref <SMTPCommand> SMTPCommand::MAIL(const mailbox& mbox, const bool utf8, const
// static
-ref <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8)
+shared_ptr <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -146,21 +146,21 @@ ref <SMTPCommand> SMTPCommand::RCPT(const mailbox& mbox, const bool utf8)
// static
-ref <SMTPCommand> SMTPCommand::RSET()
+shared_ptr <SMTPCommand> SMTPCommand::RSET()
{
return createCommand("RSET");
}
// static
-ref <SMTPCommand> SMTPCommand::DATA()
+shared_ptr <SMTPCommand> SMTPCommand::DATA()
{
return createCommand("DATA");
}
// static
-ref <SMTPCommand> SMTPCommand::BDAT(const unsigned long chunkSize, const bool last)
+shared_ptr <SMTPCommand> SMTPCommand::BDAT(const unsigned long chunkSize, const bool last)
{
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
@@ -174,23 +174,23 @@ ref <SMTPCommand> SMTPCommand::BDAT(const unsigned long chunkSize, const bool la
// static
-ref <SMTPCommand> SMTPCommand::NOOP()
+shared_ptr <SMTPCommand> SMTPCommand::NOOP()
{
return createCommand("NOOP");
}
// static
-ref <SMTPCommand> SMTPCommand::QUIT()
+shared_ptr <SMTPCommand> SMTPCommand::QUIT()
{
return createCommand("QUIT");
}
// static
-ref <SMTPCommand> SMTPCommand::createCommand(const string& text)
+shared_ptr <SMTPCommand> SMTPCommand::createCommand(const string& text)
{
- return vmime::create <SMTPCommand>(text);
+ return shared_ptr <SMTPCommand>(new SMTPCommand(text));
}
@@ -200,7 +200,7 @@ const string SMTPCommand::getText() const
}
-void SMTPCommand::writeToSocket(ref <socket> sok)
+void SMTPCommand::writeToSocket(shared_ptr <socket> sok)
{
sok->send(m_text + "\r\n");
}
diff --git a/src/net/smtp/SMTPCommandSet.cpp b/src/net/smtp/SMTPCommandSet.cpp
index a967c3a6..3e03427c 100644
--- a/src/net/smtp/SMTPCommandSet.cpp
+++ b/src/net/smtp/SMTPCommandSet.cpp
@@ -49,13 +49,13 @@ SMTPCommandSet::SMTPCommandSet(const bool pipeline)
// static
-ref <SMTPCommandSet> SMTPCommandSet::create(const bool pipeline)
+shared_ptr <SMTPCommandSet> SMTPCommandSet::create(const bool pipeline)
{
- return vmime::create <SMTPCommandSet>(pipeline);
+ return shared_ptr <SMTPCommandSet>(new SMTPCommandSet(pipeline));
}
-void SMTPCommandSet::addCommand(ref <SMTPCommand> cmd)
+void SMTPCommandSet::addCommand(shared_ptr <SMTPCommand> cmd)
{
if (m_started)
{
@@ -67,17 +67,17 @@ void SMTPCommandSet::addCommand(ref <SMTPCommand> cmd)
}
-void SMTPCommandSet::writeToSocket(ref <socket> sok)
+void SMTPCommandSet::writeToSocket(shared_ptr <socket> sok)
{
if (m_pipeline)
{
if (!m_started)
{
// Send all commands at once
- for (std::list <ref <SMTPCommand> >::const_iterator it = m_commands.begin() ;
+ for (std::list <shared_ptr <SMTPCommand> >::const_iterator it = m_commands.begin() ;
it != m_commands.end() ; ++it)
{
- ref <SMTPCommand> cmd = *it;
+ shared_ptr <SMTPCommand> cmd = *it;
cmd->writeToSocket(sok);
}
}
@@ -85,7 +85,7 @@ void SMTPCommandSet::writeToSocket(ref <socket> sok)
if (!m_commands.empty())
{
// Advance the pointer to last command sent
- ref <SMTPCommand> cmd = m_commands.front();
+ shared_ptr <SMTPCommand> cmd = m_commands.front();
m_commands.pop_front();
m_lastCommandSent = cmd;
@@ -96,7 +96,7 @@ void SMTPCommandSet::writeToSocket(ref <socket> sok)
if (!m_commands.empty())
{
// Send only one command
- ref <SMTPCommand> cmd = m_commands.front();
+ shared_ptr <SMTPCommand> cmd = m_commands.front();
m_commands.pop_front();
cmd->writeToSocket(sok);
@@ -114,7 +114,7 @@ const string SMTPCommandSet::getText() const
std::ostringstream cmd;
cmd.imbue(std::locale::classic());
- for (std::list <ref <SMTPCommand> >::const_iterator it = m_commands.begin() ;
+ for (std::list <shared_ptr <SMTPCommand> >::const_iterator it = m_commands.begin() ;
it != m_commands.end() ; ++it)
{
cmd << (*it)->getText() << "\r\n";
@@ -130,7 +130,7 @@ bool SMTPCommandSet::isFinished() const
}
-ref <SMTPCommand> SMTPCommandSet::getLastCommandSent() const
+shared_ptr <SMTPCommand> SMTPCommandSet::getLastCommandSent() const
{
return m_lastCommandSent;
}
diff --git a/src/net/smtp/SMTPConnection.cpp b/src/net/smtp/SMTPConnection.cpp
index e831ccfc..9fcacbc1 100644
--- a/src/net/smtp/SMTPConnection.cpp
+++ b/src/net/smtp/SMTPConnection.cpp
@@ -51,11 +51,11 @@
// Helpers for service properties
#define GET_PROPERTY(type, prop) \
- (m_transport.acquire()->getInfos().getPropertyValue <type>(getSession(), \
- dynamic_cast <const SMTPServiceInfos&>(m_transport.acquire()->getInfos()).getProperties().prop))
+ (m_transport.lock()->getInfos().getPropertyValue <type>(getSession(), \
+ dynamic_cast <const SMTPServiceInfos&>(m_transport.lock()->getInfos()).getProperties().prop))
#define HAS_PROPERTY(prop) \
- (m_transport.acquire()->getInfos().hasProperty(getSession(), \
- dynamic_cast <const SMTPServiceInfos&>(m_transport.acquire()->getInfos()).getProperties().prop))
+ (m_transport.lock()->getInfos().hasProperty(getSession(), \
+ dynamic_cast <const SMTPServiceInfos&>(m_transport.lock()->getInfos()).getProperties().prop))
namespace vmime {
@@ -64,8 +64,8 @@ namespace smtp {
-SMTPConnection::SMTPConnection(ref <SMTPTransport> transport, ref <security::authenticator> auth)
- : m_transport(transport), m_auth(auth), m_socket(NULL), m_timeoutHandler(NULL),
+SMTPConnection::SMTPConnection(shared_ptr <SMTPTransport> transport, shared_ptr <security::authenticator> auth)
+ : m_transport(transport), m_auth(auth), m_socket(null), m_timeoutHandler(null),
m_authenticated(false), m_secured(false), m_extendedSMTP(false)
{
}
@@ -95,7 +95,7 @@ void SMTPConnection::connect()
const string address = GET_PROPERTY(string, PROPERTY_SERVER_ADDRESS);
const port_t port = GET_PROPERTY(port_t, PROPERTY_SERVER_PORT);
- ref <SMTPTransport> transport = m_transport.acquire();
+ shared_ptr <SMTPTransport> transport = m_transport.lock();
// Create the time-out handler
if (transport->getTimeoutHandlerFactory())
@@ -107,22 +107,22 @@ void SMTPConnection::connect()
#if VMIME_HAVE_TLS_SUPPORT
if (transport->isSMTPS()) // dedicated port/SMTPS
{
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
(transport->getCertificateVerifier(),
transport->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
m_socket = tlsSocket;
m_secured = true;
- m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>(address, port, tlsSession, tlsSocket);
}
else
#endif // VMIME_HAVE_TLS_SUPPORT
{
- m_cntInfos = vmime::create <defaultConnectionInfos>(address, port);
+ m_cntInfos = make_shared <defaultConnectionInfos>(address, port);
}
m_socket->connect(address, port);
@@ -132,7 +132,7 @@ void SMTPConnection::connect()
// eg: C: <connection to server>
// --- S: 220 smtp.domain.com Service ready
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
if ((resp = readResponse())->getCode() != 220)
{
@@ -199,7 +199,7 @@ void SMTPConnection::helo()
sendRequest(SMTPCommand::EHLO(platform::getHandler()->getHostName()));
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
if ((resp = readResponse())->getCode() != 250)
{
@@ -281,7 +281,7 @@ void SMTPConnection::authenticate()
throw exceptions::command_error("AUTH", "ESMTP not supported.");
}
- getAuthenticator()->setService(m_transport.acquire());
+ getAuthenticator()->setService(m_transport.lock());
#if VMIME_HAVE_SASL_SUPPORT
// First, try SASL authentication
@@ -325,7 +325,7 @@ void SMTPConnection::authenticate()
void SMTPConnection::authenticateSASL()
{
- if (!getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>())
+ if (!dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator()))
throw exceptions::authentication_error("No SASL authenticator available.");
// Obtain SASL mechanisms supported by server from ESMTP extensions
@@ -335,10 +335,10 @@ void SMTPConnection::authenticateSASL()
if (saslMechs.empty())
throw exceptions::authentication_error("No SASL mechanism available.");
- std::vector <ref <security::sasl::SASLMechanism> > mechList;
+ std::vector <shared_ptr <security::sasl::SASLMechanism> > mechList;
- ref <security::sasl::SASLContext> saslContext =
- vmime::create <security::sasl::SASLContext>();
+ shared_ptr <security::sasl::SASLContext> saslContext =
+ make_shared <security::sasl::SASLContext>();
for (unsigned int i = 0 ; i < saslMechs.size() ; ++i)
{
@@ -357,14 +357,14 @@ void SMTPConnection::authenticateSASL()
throw exceptions::authentication_error("No SASL mechanism available.");
// Try to suggest a mechanism among all those supported
- ref <security::sasl::SASLMechanism> suggestedMech =
+ shared_ptr <security::sasl::SASLMechanism> suggestedMech =
saslContext->suggestMechanism(mechList);
if (!suggestedMech)
throw exceptions::authentication_error("Unable to suggest SASL mechanism.");
// Allow application to choose which mechanisms to use
- mechList = getAuthenticator().dynamicCast <security::sasl::SASLAuthenticator>()->
+ mechList = dynamicCast <security::sasl::SASLAuthenticator>(getAuthenticator())->
getAcceptableMechanisms(mechList, suggestedMech);
if (mechList.empty())
@@ -373,9 +373,9 @@ void SMTPConnection::authenticateSASL()
// Try each mechanism in the list in turn
for (unsigned int i = 0 ; i < mechList.size() ; ++i)
{
- ref <security::sasl::SASLMechanism> mech = mechList[i];
+ shared_ptr <security::sasl::SASLMechanism> mech = mechList[i];
- ref <security::sasl::SASLSession> saslSession =
+ shared_ptr <security::sasl::SASLSession> saslSession =
saslContext->createSession("smtp", getAuthenticator(), mech);
saslSession->init();
@@ -384,7 +384,7 @@ void SMTPConnection::authenticateSASL()
for (bool cont = true ; cont ; )
{
- ref <SMTPResponse> response = readResponse();
+ shared_ptr <SMTPResponse> response = readResponse();
switch (response->getCode())
{
@@ -472,7 +472,7 @@ void SMTPConnection::startTLS()
{
sendRequest(SMTPCommand::STARTTLS());
- ref <SMTPResponse> resp = readResponse();
+ shared_ptr <SMTPResponse> resp = readResponse();
if (resp->getCode() != 220)
{
@@ -480,11 +480,11 @@ void SMTPConnection::startTLS()
resp->getCode(), resp->getEnhancedCode());
}
- ref <tls::TLSSession> tlsSession = tls::TLSSession::create
+ shared_ptr <tls::TLSSession> tlsSession = tls::TLSSession::create
(getTransport()->getCertificateVerifier(),
getTransport()->getSession()->getTLSProperties());
- ref <tls::TLSSocket> tlsSocket =
+ shared_ptr <tls::TLSSocket> tlsSocket =
tlsSession->getSocket(m_socket);
tlsSocket->handshake(m_timeoutHandler);
@@ -492,7 +492,7 @@ void SMTPConnection::startTLS()
m_socket = tlsSocket;
m_secured = true;
- m_cntInfos = vmime::create <tls::TLSSecuredConnectionInfos>
+ m_cntInfos = make_shared <tls::TLSSecuredConnectionInfos>
(m_cntInfos->getHost(), m_cntInfos->getPort(), tlsSession, tlsSocket);
}
catch (exceptions::command_error&)
@@ -533,27 +533,27 @@ void SMTPConnection::internalDisconnect()
}
m_socket->disconnect();
- m_socket = NULL;
+ m_socket = null;
- m_timeoutHandler = NULL;
+ m_timeoutHandler = null;
m_authenticated = false;
m_extendedSMTP = false;
m_secured = false;
- m_cntInfos = NULL;
+ m_cntInfos = null;
}
-void SMTPConnection::sendRequest(ref <SMTPCommand> cmd)
+void SMTPConnection::sendRequest(shared_ptr <SMTPCommand> cmd)
{
cmd->writeToSocket(m_socket);
}
-ref <SMTPResponse> SMTPConnection::readResponse()
+shared_ptr <SMTPResponse> SMTPConnection::readResponse()
{
- ref <SMTPResponse> resp = SMTPResponse::readResponse
+ shared_ptr <SMTPResponse> resp = SMTPResponse::readResponse
(m_socket, m_timeoutHandler, m_responseState);
m_responseState = resp->getCurrentState();
@@ -574,37 +574,37 @@ bool SMTPConnection::isSecuredConnection() const
}
-ref <connectionInfos> SMTPConnection::getConnectionInfos() const
+shared_ptr <connectionInfos> SMTPConnection::getConnectionInfos() const
{
return m_cntInfos;
}
-ref <SMTPTransport> SMTPConnection::getTransport()
+shared_ptr <SMTPTransport> SMTPConnection::getTransport()
{
- return m_transport.acquire();
+ return m_transport.lock();
}
-ref <session> SMTPConnection::getSession()
+shared_ptr <session> SMTPConnection::getSession()
{
- return m_transport.acquire()->getSession();
+ return m_transport.lock()->getSession();
}
-ref <socket> SMTPConnection::getSocket()
+shared_ptr <socket> SMTPConnection::getSocket()
{
return m_socket;
}
-ref <timeoutHandler> SMTPConnection::getTimeoutHandler()
+shared_ptr <timeoutHandler> SMTPConnection::getTimeoutHandler()
{
return m_timeoutHandler;
}
-ref <security::authenticator> SMTPConnection::getAuthenticator()
+shared_ptr <security::authenticator> SMTPConnection::getAuthenticator()
{
return m_auth;
}
diff --git a/src/net/smtp/SMTPResponse.cpp b/src/net/smtp/SMTPResponse.cpp
index 9367dcd4..baefc38d 100644
--- a/src/net/smtp/SMTPResponse.cpp
+++ b/src/net/smtp/SMTPResponse.cpp
@@ -43,7 +43,7 @@ namespace net {
namespace smtp {
-SMTPResponse::SMTPResponse(ref <socket> sok, ref <timeoutHandler> toh, const state& st)
+SMTPResponse::SMTPResponse(shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh, const state& st)
: m_socket(sok), m_timeoutHandler(toh),
m_responseBuffer(st.responseBuffer), m_responseContinues(false)
{
@@ -94,10 +94,10 @@ const string SMTPResponse::getText() const
// static
-ref <SMTPResponse> SMTPResponse::readResponse
- (ref <socket> sok, ref <timeoutHandler> toh, const state& st)
+shared_ptr <SMTPResponse> SMTPResponse::readResponse
+ (shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh, const state& st)
{
- ref <SMTPResponse> resp = vmime::create <SMTPResponse>(sok, toh, st);
+ shared_ptr <SMTPResponse> resp = shared_ptr <SMTPResponse>(new SMTPResponse(sok, toh, st));
resp->readResponse();
diff --git a/src/net/smtp/SMTPSTransport.cpp b/src/net/smtp/SMTPSTransport.cpp
index 2e594ce7..ab64d49d 100644
--- a/src/net/smtp/SMTPSTransport.cpp
+++ b/src/net/smtp/SMTPSTransport.cpp
@@ -35,7 +35,7 @@ namespace net {
namespace smtp {
-SMTPSTransport::SMTPSTransport(ref <session> sess, ref <security::authenticator> auth)
+SMTPSTransport::SMTPSTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth)
: SMTPTransport(sess, auth, true)
{
}
diff --git a/src/net/smtp/SMTPTransport.cpp b/src/net/smtp/SMTPTransport.cpp
index 91487ed4..4f409a03 100644
--- a/src/net/smtp/SMTPTransport.cpp
+++ b/src/net/smtp/SMTPTransport.cpp
@@ -51,7 +51,7 @@ namespace net {
namespace smtp {
-SMTPTransport::SMTPTransport(ref <session> sess, ref <security::authenticator> auth, const bool secured)
+SMTPTransport::SMTPTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured)
: transport(sess, getInfosInstance(), auth), m_isSMTPS(secured), m_needReset(false)
{
}
@@ -88,8 +88,8 @@ void SMTPTransport::connect()
if (isConnected())
throw exceptions::already_connected();
- m_connection = vmime::create <SMTPConnection>
- (thisRef().dynamicCast <SMTPTransport>(), getAuthenticator());
+ m_connection = make_shared <SMTPConnection>
+ (dynamicCast <SMTPTransport>(shared_from_this()), getAuthenticator());
try
{
@@ -97,7 +97,7 @@ void SMTPTransport::connect()
}
catch (std::exception&)
{
- m_connection = NULL;
+ m_connection = null;
throw;
}
}
@@ -118,16 +118,16 @@ bool SMTPTransport::isSecuredConnection() const
}
-ref <connectionInfos> SMTPTransport::getConnectionInfos() const
+shared_ptr <connectionInfos> SMTPTransport::getConnectionInfos() const
{
if (m_connection == NULL)
- return NULL;
+ return null;
return m_connection->getConnectionInfos();
}
-ref <SMTPConnection> SMTPTransport::getConnection()
+shared_ptr <SMTPConnection> SMTPTransport::getConnection()
{
return m_connection;
}
@@ -139,7 +139,7 @@ void SMTPTransport::disconnect()
throw exceptions::not_connected();
m_connection->disconnect();
- m_connection = NULL;
+ m_connection = null;
}
@@ -150,7 +150,7 @@ void SMTPTransport::noop()
m_connection->sendRequest(SMTPCommand::NOOP());
- ref <SMTPResponse> resp = m_connection->readResponse();
+ shared_ptr <SMTPResponse> resp = m_connection->readResponse();
if (resp->getCode() != 250)
{
@@ -177,8 +177,8 @@ void SMTPTransport::sendEnvelope
getInfos().getPropertyValue <bool>(getSession(),
dynamic_cast <const SMTPServiceInfos&>(getInfos()).getProperties().PROPERTY_OPTIONS_PIPELINING);
- ref <SMTPResponse> resp;
- ref <SMTPCommandSet> commands = SMTPCommandSet::create(hasPipelining);
+ shared_ptr <SMTPResponse> resp;
+ shared_ptr <SMTPCommandSet> commands = SMTPCommandSet::create(hasPipelining);
// Emit a "RSET" command if we previously sent a message on this connection
if (needReset)
@@ -336,7 +336,7 @@ void SMTPTransport::send
// Send end-of-data delimiter
m_connection->getSocket()->sendRaw("\r\n.\r\n", 5);
- ref <SMTPResponse> resp;
+ shared_ptr <SMTPResponse> resp;
if ((resp = m_connection->readResponse())->getCode() != 250)
{
@@ -349,7 +349,7 @@ void SMTPTransport::send
void SMTPTransport::send
- (ref <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
+ (shared_ptr <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
utility::progressListener* progress, const mailbox& sender)
{
if (!isConnected())
diff --git a/src/net/tls/TLSSecuredConnectionInfos.cpp b/src/net/tls/TLSSecuredConnectionInfos.cpp
index 5060aede..4856e9af 100644
--- a/src/net/tls/TLSSecuredConnectionInfos.cpp
+++ b/src/net/tls/TLSSecuredConnectionInfos.cpp
@@ -38,7 +38,7 @@ namespace tls {
TLSSecuredConnectionInfos::TLSSecuredConnectionInfos
(const string& host, const port_t port,
- ref <TLSSession> tlsSession, ref <TLSSocket> tlsSocket)
+ shared_ptr <TLSSession> tlsSession, shared_ptr <TLSSocket> tlsSocket)
: m_host(host), m_port(port),
m_tlsSession(tlsSession), m_tlsSocket(tlsSocket)
{
@@ -57,7 +57,7 @@ port_t TLSSecuredConnectionInfos::getPort() const
}
-ref <const security::cert::certificateChain> TLSSecuredConnectionInfos::getPeerCertificates() const
+shared_ptr <const security::cert::certificateChain> TLSSecuredConnectionInfos::getPeerCertificates() const
{
return m_tlsSocket->getPeerCertificates();
}
diff --git a/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp b/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp
index 2a161dee..36ab7d7a 100644
--- a/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp
+++ b/src/net/tls/gnutls/TLSProperties_GnuTLS.cpp
@@ -42,7 +42,7 @@ namespace tls {
TLSProperties::TLSProperties()
- : m_data(vmime::create <TLSProperties_GnuTLS>())
+ : m_data(make_shared <TLSProperties_GnuTLS>())
{
setCipherSuite(CIPHERSUITE_DEFAULT);
}
@@ -50,9 +50,9 @@ TLSProperties::TLSProperties()
TLSProperties::TLSProperties(const TLSProperties& props)
: object(),
- m_data(vmime::create <TLSProperties_GnuTLS>())
+ m_data(make_shared <TLSProperties_GnuTLS>())
{
- *m_data.dynamicCast <TLSProperties_GnuTLS>() = *props.m_data.dynamicCast <TLSProperties_GnuTLS>();
+ *dynamicCast <TLSProperties_GnuTLS>(m_data) = *dynamicCast <TLSProperties_GnuTLS>(props.m_data);
}
@@ -86,13 +86,13 @@ void TLSProperties::setCipherSuite(const GenericCipherSuite cipherSuite)
void TLSProperties::setCipherSuite(const string& cipherSuite)
{
- m_data.dynamicCast <TLSProperties_GnuTLS>()->cipherSuite = cipherSuite;
+ dynamicCast <TLSProperties_GnuTLS>(m_data)->cipherSuite = cipherSuite;
}
const string TLSProperties::getCipherSuite() const
{
- return m_data.dynamicCast <TLSProperties_GnuTLS>()->cipherSuite;
+ return dynamicCast <TLSProperties_GnuTLS>(m_data)->cipherSuite;
}
diff --git a/src/net/tls/gnutls/TLSSession_GnuTLS.cpp b/src/net/tls/gnutls/TLSSession_GnuTLS.cpp
index 52fedc78..1c520ed1 100644
--- a/src/net/tls/gnutls/TLSSession_GnuTLS.cpp
+++ b/src/net/tls/gnutls/TLSSession_GnuTLS.cpp
@@ -134,13 +134,13 @@ static TLSGlobal g_gnutlsGlobal;
// static
-ref <TLSSession> TLSSession::create(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+shared_ptr <TLSSession> TLSSession::create(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
{
- return vmime::create <TLSSession_GnuTLS>(cv, props);
+ return make_shared <TLSSession_GnuTLS>(cv, props);
}
-TLSSession_GnuTLS::TLSSession_GnuTLS(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+TLSSession_GnuTLS::TLSSession_GnuTLS(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
: m_certVerifier(cv), m_props(props)
{
int res;
@@ -267,13 +267,13 @@ TLSSession_GnuTLS::~TLSSession_GnuTLS()
}
-ref <TLSSocket> TLSSession_GnuTLS::getSocket(ref <socket> sok)
+shared_ptr <TLSSocket> TLSSession_GnuTLS::getSocket(shared_ptr <socket> sok)
{
- return TLSSocket::wrap(thisRef().dynamicCast <TLSSession>(), sok);
+ return TLSSocket::wrap(dynamicCast <TLSSession>(shared_from_this()), sok);
}
-ref <security::cert::certificateVerifier> TLSSession_GnuTLS::getCertificateVerifier()
+shared_ptr <security::cert::certificateVerifier> TLSSession_GnuTLS::getCertificateVerifier()
{
return m_certVerifier;
}
diff --git a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
index 0a24b720..bb21cb9d 100644
--- a/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
+++ b/src/net/tls/gnutls/TLSSocket_GnuTLS.cpp
@@ -44,14 +44,14 @@ namespace tls {
// static
-ref <TLSSocket> TLSSocket::wrap(ref <TLSSession> session, ref <socket> sok)
+shared_ptr <TLSSocket> TLSSocket::wrap(shared_ptr <TLSSession> session, shared_ptr <socket> sok)
{
- return vmime::create <TLSSocket_GnuTLS>
- (session.dynamicCast <TLSSession_GnuTLS>(), sok);
+ return make_shared <TLSSocket_GnuTLS>
+ (dynamicCast <TLSSession_GnuTLS>(session), sok);
}
-TLSSocket_GnuTLS::TLSSocket_GnuTLS(ref <TLSSession_GnuTLS> session, ref <socket> sok)
+TLSSocket_GnuTLS::TLSSocket_GnuTLS(shared_ptr <TLSSession_GnuTLS> session, shared_ptr <socket> sok)
: m_session(session), m_wrapped(sok), m_connected(false),
m_handshaking(false), m_ex(NULL), m_status(0)
{
@@ -85,7 +85,7 @@ void TLSSocket_GnuTLS::connect(const string& address, const port_t port)
{
m_wrapped->connect(address, port);
- handshake(NULL);
+ handshake(null);
m_connected = true;
}
@@ -219,7 +219,7 @@ unsigned int TLSSocket_GnuTLS::getStatus() const
}
-void TLSSocket_GnuTLS::handshake(ref <timeoutHandler> toHandler)
+void TLSSocket_GnuTLS::handshake(shared_ptr <timeoutHandler> toHandler)
{
if (toHandler)
toHandler->resetTimeOut();
@@ -260,16 +260,16 @@ void TLSSocket_GnuTLS::handshake(ref <timeoutHandler> toHandler)
catch (...)
{
m_handshaking = false;
- m_toHandler = NULL;
+ m_toHandler = null;
throw;
}
m_handshaking = false;
- m_toHandler = NULL;
+ m_toHandler = null;
// Verify server's certificate(s)
- ref <security::cert::certificateChain> certs = getPeerCertificates();
+ shared_ptr <security::cert::certificateChain> certs = getPeerCertificates();
if (certs == NULL)
throw exceptions::tls_exception("No peer certificate.");
@@ -364,14 +364,14 @@ ssize_t TLSSocket_GnuTLS::gnutlsPullFunc
}
-ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() const
+shared_ptr <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() const
{
unsigned int certCount = 0;
const gnutls_datum* rawData = gnutls_certificate_get_peers
(*m_session->m_gnutlsSession, &certCount);
if (rawData == NULL)
- return NULL;
+ return null;
// Try X.509
gnutls_x509_crt* x509Certs = new gnutls_x509_crt[certCount];
@@ -387,12 +387,12 @@ ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() c
{
// XXX more fine-grained error reporting?
delete [] x509Certs;
- return NULL;
+ return null;
}
}
{
- std::vector <ref <security::cert::certificate> > certs;
+ std::vector <shared_ptr <security::cert::certificate> > certs;
bool error = false;
for (unsigned int i = 0 ; i < certCount ; ++i)
@@ -407,7 +407,7 @@ ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() c
gnutls_x509_crt_export(x509Certs[i],
GNUTLS_X509_FMT_DER, &data[0], &dataSize);
- ref <security::cert::X509Certificate> cert =
+ shared_ptr <security::cert::X509Certificate> cert =
security::cert::X509Certificate::import(&data[0], dataSize);
if (cert != NULL)
@@ -421,14 +421,14 @@ ref <security::cert::certificateChain> TLSSocket_GnuTLS::getPeerCertificates() c
delete [] x509Certs;
if (error)
- return NULL;
+ return null;
- return vmime::create <security::cert::certificateChain>(certs);
+ return make_shared <security::cert::certificateChain>(certs);
}
delete [] x509Certs;
- return NULL;
+ return null;
}
@@ -457,7 +457,7 @@ private:
void TLSSocket_GnuTLS::internalThrow()
{
- static std::vector <ref <TLSSocket_DeleteExWrapper> > exToDelete;
+ static std::vector <shared_ptr <TLSSocket_DeleteExWrapper> > exToDelete;
if (m_ex)
{
@@ -467,7 +467,7 @@ void TLSSocket_GnuTLS::internalThrow()
m_ex = NULL;
// To avoid memory leaks
- exToDelete.push_back(vmime::create <TLSSocket_DeleteExWrapper>(ex));
+ exToDelete.push_back(make_shared <TLSSocket_DeleteExWrapper>(ex));
throw *ex;
}
diff --git a/src/net/tls/openssl/OpenSSLInitializer.cpp b/src/net/tls/openssl/OpenSSLInitializer.cpp
index 8238b864..1bbb9ee5 100644
--- a/src/net/tls/openssl/OpenSSLInitializer.cpp
+++ b/src/net/tls/openssl/OpenSSLInitializer.cpp
@@ -49,7 +49,7 @@ namespace net {
namespace tls {
-ref <vmime::utility::sync::criticalSection >* OpenSSLInitializer::sm_mutexes;
+shared_ptr <vmime::utility::sync::criticalSection >* OpenSSLInitializer::sm_mutexes;
OpenSSLInitializer::autoInitializer::autoInitializer()
@@ -93,7 +93,7 @@ void OpenSSLInitializer::initialize()
RAND_seed(seed, SEEDSIZE);
int numMutexes = CRYPTO_num_locks();
- sm_mutexes = new ref <vmime::utility::sync::criticalSection>[numMutexes];
+ sm_mutexes = new shared_ptr <vmime::utility::sync::criticalSection>[numMutexes];
for (int i = 0 ; i < numMutexes ; ++i)
sm_mutexes[i] = vmime::platform::getHandler()->createCriticalSection();
diff --git a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp
index 34e31cf1..932477df 100644
--- a/src/net/tls/openssl/TLSProperties_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSProperties_OpenSSL.cpp
@@ -40,7 +40,7 @@ namespace tls {
TLSProperties::TLSProperties()
- : m_data(vmime::create <TLSProperties_OpenSSL>())
+ : m_data(make_shared <TLSProperties_OpenSSL>())
{
setCipherSuite(CIPHERSUITE_DEFAULT);
}
@@ -48,9 +48,9 @@ TLSProperties::TLSProperties()
TLSProperties::TLSProperties(const TLSProperties& props)
: object(),
- m_data(vmime::create <TLSProperties_OpenSSL>())
+ m_data(make_shared <TLSProperties_OpenSSL>())
{
- *m_data.dynamicCast <TLSProperties_OpenSSL>() = *props.m_data.dynamicCast <TLSProperties_OpenSSL>();
+ *dynamicCast <TLSProperties_OpenSSL>(m_data) = *dynamicCast <TLSProperties_OpenSSL>(props.m_data);
}
@@ -84,13 +84,13 @@ void TLSProperties::setCipherSuite(const GenericCipherSuite cipherSuite)
void TLSProperties::setCipherSuite(const string& cipherSuite)
{
- m_data.dynamicCast <TLSProperties_OpenSSL>()->cipherSuite = cipherSuite;
+ dynamicCast <TLSProperties_OpenSSL>(m_data)->cipherSuite = cipherSuite;
}
const string TLSProperties::getCipherSuite() const
{
- return m_data.dynamicCast <TLSProperties_OpenSSL>()->cipherSuite;
+ return dynamicCast <TLSProperties_OpenSSL>(m_data)->cipherSuite;
}
diff --git a/src/net/tls/openssl/TLSSession_OpenSSL.cpp b/src/net/tls/openssl/TLSSession_OpenSSL.cpp
index 953e4ebc..cf600a63 100644
--- a/src/net/tls/openssl/TLSSession_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSSession_OpenSSL.cpp
@@ -46,13 +46,13 @@ static OpenSSLInitializer::autoInitializer openSSLInitializer;
// static
-ref <TLSSession> TLSSession::create(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+shared_ptr <TLSSession> TLSSession::create(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
{
- return vmime::create <TLSSession_OpenSSL>(cv, props);
+ return make_shared <TLSSession_OpenSSL>(cv, props);
}
-TLSSession_OpenSSL::TLSSession_OpenSSL(ref <vmime::security::cert::certificateVerifier> cv, ref <TLSProperties> props)
+TLSSession_OpenSSL::TLSSession_OpenSSL(shared_ptr <vmime::security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props)
: m_sslctx(0), m_certVerifier(cv), m_props(props)
{
m_sslctx = SSL_CTX_new(SSLv23_client_method());
@@ -76,13 +76,13 @@ TLSSession_OpenSSL::~TLSSession_OpenSSL()
}
-ref <TLSSocket> TLSSession_OpenSSL::getSocket(ref <socket> sok)
+shared_ptr <TLSSocket> TLSSession_OpenSSL::getSocket(shared_ptr <socket> sok)
{
- return TLSSocket::wrap(thisRef().dynamicCast <TLSSession>(), sok);
+ return TLSSocket::wrap(dynamicCast <TLSSession>(shared_from_this()), sok);
}
-ref <security::cert::certificateVerifier> TLSSession_OpenSSL::getCertificateVerifier()
+shared_ptr <security::cert::certificateVerifier> TLSSession_OpenSSL::getCertificateVerifier()
{
return m_certVerifier;
}
diff --git a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
index 7fda1f15..9aec43e5 100644
--- a/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
+++ b/src/net/tls/openssl/TLSSocket_OpenSSL.cpp
@@ -65,14 +65,14 @@ BIO_METHOD TLSSocket_OpenSSL::sm_customBIOMethod =
// static
-ref <TLSSocket> TLSSocket::wrap(ref <TLSSession> session, ref <socket> sok)
+shared_ptr <TLSSocket> TLSSocket::wrap(shared_ptr <TLSSession> session, shared_ptr <socket> sok)
{
- return vmime::create <TLSSocket_OpenSSL>
- (session.dynamicCast <TLSSession_OpenSSL>(), sok);
+ return make_shared <TLSSocket_OpenSSL>
+ (dynamicCast <TLSSession_OpenSSL>(session), sok);
}
-TLSSocket_OpenSSL::TLSSocket_OpenSSL(ref <TLSSession_OpenSSL> session, ref <socket> sok)
+TLSSocket_OpenSSL::TLSSocket_OpenSSL(shared_ptr <TLSSession_OpenSSL> session, shared_ptr <socket> sok)
: m_session(session), m_wrapped(sok), m_connected(false), m_ssl(0), m_ex(NULL)
{
}
@@ -128,7 +128,7 @@ void TLSSocket_OpenSSL::connect(const string& address, const port_t port)
createSSLHandle();
- handshake(NULL);
+ handshake(null);
m_connected = true;
}
@@ -224,7 +224,7 @@ TLSSocket_OpenSSL::size_type TLSSocket_OpenSSL::sendRawNonBlocking(const char* b
}
-void TLSSocket_OpenSSL::handshake(ref <timeoutHandler> toHandler)
+void TLSSocket_OpenSSL::handshake(shared_ptr <timeoutHandler> toHandler)
{
if (toHandler)
toHandler->resetTimeOut();
@@ -245,14 +245,14 @@ void TLSSocket_OpenSSL::handshake(ref <timeoutHandler> toHandler)
{
SSL_free(m_ssl);
m_ssl = 0;
- m_toHandler = NULL;
+ m_toHandler = null;
throw;
}
- m_toHandler = NULL;
+ m_toHandler = null;
// Verify server's certificate(s)
- ref <security::cert::certificateChain> certs = getPeerCertificates();
+ shared_ptr <security::cert::certificateChain> certs = getPeerCertificates();
if (certs == NULL)
throw exceptions::tls_exception("No peer certificate.");
@@ -263,24 +263,24 @@ void TLSSocket_OpenSSL::handshake(ref <timeoutHandler> toHandler)
}
-ref <security::cert::certificateChain> TLSSocket_OpenSSL::getPeerCertificates() const
+shared_ptr <security::cert::certificateChain> TLSSocket_OpenSSL::getPeerCertificates() const
{
STACK_OF(X509)* chain = SSL_get_peer_cert_chain(m_ssl);
if (chain == NULL)
- return NULL;
+ return null;
int certCount = sk_X509_num(chain);
if (certCount == 0)
- return NULL;
+ return null;
bool error = false;
- std::vector <ref <security::cert::certificate> > certs;
+ std::vector <shared_ptr <security::cert::certificate> > certs;
for (int i = 0; i < certCount && !error; i++)
{
- ref <vmime::security::cert::X509Certificate> cert =
+ shared_ptr <vmime::security::cert::X509Certificate> cert =
vmime::security::cert::X509Certificate_OpenSSL::importInternal(sk_X509_value(chain, i));
if (cert)
@@ -290,9 +290,9 @@ ref <security::cert::certificateChain> TLSSocket_OpenSSL::getPeerCertificates()
}
if (error)
- return NULL;
+ return null;
- return vmime::create <security::cert::certificateChain>(certs);
+ return make_shared <security::cert::certificateChain>(certs);
}
diff --git a/src/net/transport.cpp b/src/net/transport.cpp
index 88ea6773..eae4a024 100644
--- a/src/net/transport.cpp
+++ b/src/net/transport.cpp
@@ -43,33 +43,33 @@ namespace vmime {
namespace net {
-transport::transport(ref <session> sess, const serviceInfos& infos, ref <security::authenticator> auth)
+transport::transport(shared_ptr <session> sess, const serviceInfos& infos, shared_ptr <security::authenticator> auth)
: service(sess, infos, auth)
{
}
-ref <headerField> transport::processHeaderField(ref <headerField> field)
+shared_ptr <headerField> transport::processHeaderField(shared_ptr <headerField> field)
{
if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::BCC))
{
// Remove Bcc headers from the message, as required by the RFC.
// Some SMTP server automatically strip this header (Postfix, qmail),
// and others have an option for this (Exim).
- return NULL;
+ return null;
}
else if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::RETURN_PATH))
{
// RFC-2821: Return-Path header is added by the final transport system
// that delivers the message to its recipient. Then, it should not be
// transmitted to MSA.
- return NULL;
+ return null;
}
else if (utility::stringUtils::isStringEqualNoCase(field->getName(), fields::ORIGINAL_RECIPIENT))
{
// RFC-2298: Delivering MTA may add the Original-Recipient header and
// discard existing one; so, no need to send it.
- return NULL;
+ return null;
}
// Leave the header field as is
@@ -77,7 +77,7 @@ ref <headerField> transport::processHeaderField(ref <headerField> field)
}
-void transport::processHeader(ref <header> header)
+void transport::processHeader(shared_ptr <header> header)
{
if (header->getFieldCount() == 0)
return;
@@ -85,8 +85,8 @@ void transport::processHeader(ref <header> header)
// Remove/replace fields
for (size_t idx = header->getFieldCount() ; idx != 0 ; --idx)
{
- ref <headerField> field = header->getFieldAt(idx - 1);
- ref <headerField> newField = processHeaderField(field);
+ shared_ptr <headerField> field = header->getFieldAt(idx - 1);
+ shared_ptr <headerField> newField = processHeaderField(field);
if (newField == NULL)
header->removeField(field);
@@ -114,7 +114,7 @@ static void extractMailboxes
{
for (size_t i = 0 ; i < list.getAddressCount() ; ++i)
{
- ref <mailbox> mbox = list.getAddressAt(i)->clone().dynamicCast <mailbox>();
+ shared_ptr <mailbox> mbox = dynamicCast <mailbox>(list.getAddressAt(i)->clone());
if (mbox != NULL)
recipients.appendMailbox(mbox);
@@ -122,15 +122,15 @@ static void extractMailboxes
}
-void transport::send(ref <vmime::message> msg, utility::progressListener* progress)
+void transport::send(shared_ptr <vmime::message> msg, utility::progressListener* progress)
{
// Extract expeditor
mailbox expeditor;
try
{
- const mailbox& mbox = *msg->getHeader()->findField(fields::FROM)->
- getValue().dynamicCast <const mailbox>();
+ const mailbox& mbox =
+ *msg->getHeader()->findField(fields::FROM)->getValue <mailbox>();
expeditor = mbox;
}
@@ -144,8 +144,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const mailbox& mbox = *msg->getHeader()->findField(fields::SENDER)->
- getValue().dynamicCast <const mailbox>();
+ const mailbox& mbox =
+ *msg->getHeader()->findField(fields::SENDER)->getValue <mailbox>();
sender = mbox;
}
@@ -159,8 +159,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const addressList& to = *msg->getHeader()->findField(fields::TO)->
- getValue().dynamicCast <const addressList>();
+ const addressList& to =
+ *msg->getHeader()->findField(fields::TO)->getValue <addressList>();
extractMailboxes(recipients, to);
}
@@ -168,8 +168,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const addressList& cc = *msg->getHeader()->findField(fields::CC)->
- getValue().dynamicCast <const addressList>();
+ const addressList& cc =
+ *msg->getHeader()->findField(fields::CC)->getValue <addressList>();
extractMailboxes(recipients, cc);
}
@@ -177,8 +177,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
try
{
- const addressList& bcc = *msg->getHeader()->findField(fields::BCC)->
- getValue().dynamicCast <const addressList>();
+ const addressList& bcc =
+ *msg->getHeader()->findField(fields::BCC)->getValue <addressList>();
extractMailboxes(recipients, bcc);
}
@@ -187,7 +187,7 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
// Process message header by removing fields that should be removed
// before transmitting the message to MSA, and adding missing fields
// which are required/recommended by the RFCs.
- ref <header> hdr = msg->getHeader()->clone().dynamicCast <header>();
+ shared_ptr <header> hdr = vmime::clone(msg->getHeader());
processHeader(hdr);
// To avoid cloning message body (too much overhead), use processed
@@ -195,8 +195,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
// Revert it back to original header after.
struct XChangeMsgHeader
{
- XChangeMsgHeader(vmime::ref <vmime::message> _msg,
- vmime::ref <vmime::header> _hdr)
+ XChangeMsgHeader(shared_ptr <vmime::message> _msg,
+ shared_ptr <vmime::header> _hdr)
: msg(_msg), hdr(msg->getHeader())
{
// Set new header
@@ -211,8 +211,8 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
private:
- vmime::ref <vmime::message> msg;
- vmime::ref <vmime::header> hdr;
+ shared_ptr <vmime::message> msg;
+ shared_ptr <vmime::header> hdr;
} headerExchanger(msg, hdr);
send(msg, expeditor, recipients, progress, sender);
@@ -220,7 +220,7 @@ void transport::send(ref <vmime::message> msg, utility::progressListener* progre
void transport::send
- (ref <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
+ (shared_ptr <vmime::message> msg, const mailbox& expeditor, const mailboxList& recipients,
utility::progressListener* progress, const mailbox& sender)
{
// Generate the message, "stream" it and delegate the sending
diff --git a/src/object.cpp b/src/object.cpp
index 1b50c53c..d07c3c19 100644
--- a/src/object.cpp
+++ b/src/object.cpp
@@ -25,79 +25,29 @@
#include "vmime/object.hpp"
-#ifndef VMIME_BUILDING_DOC
-
-
namespace vmime
{
object::object()
- : m_refMgr(utility::refManager::create(this))
{
}
object::object(const object&)
- : m_refMgr(utility::refManager::create(this))
{
}
object& object::operator=(const object&)
{
- // Do _NOT_ copy 'm_refMgr'
return *this;
}
object::~object()
{
- delete m_refMgr;
- m_refMgr = 0;
-}
-
-
-ref <object> object::thisRef()
-{
- m_refMgr->addStrong();
- return ref <object>::fromPtr(this);
-}
-
-
-ref <const object> object::thisRef() const
-{
- m_refMgr->addStrong();
- return ref <const object>::fromPtr(this);
-}
-
-
-weak_ref <object> object::thisWeakRef()
-{
- return weak_ref <object>(thisRef());
-}
-
-
-weak_ref <const object> object::thisWeakRef() const
-{
- return weak_ref <const object>(thisRef());
-}
-
-
-void object::setRefManager(utility::refManager* mgr)
-{
- m_refMgr = mgr;
-}
-
-
-utility::refManager* object::getRefManager() const
-{
- return m_refMgr;
}
} // vmime
-
-
-#endif // VMIME_BUILDING_DOC
-
diff --git a/src/parameter.cpp b/src/parameter.cpp
index 901139e3..d7fcd7d3 100644
--- a/src/parameter.cpp
+++ b/src/parameter.cpp
@@ -36,19 +36,19 @@ namespace vmime
parameter::parameter(const string& name)
- : m_name(name), m_value(vmime::create <word>())
+ : m_name(name), m_value(make_shared <word>())
{
}
parameter::parameter(const string& name, const word& value)
- : m_name(name), m_value(vmime::create <word>(value))
+ : m_name(name), m_value(make_shared <word>(value))
{
}
parameter::parameter(const string& name, const string& value)
- : m_name(name), m_value(vmime::create <word>(value))
+ : m_name(name), m_value(make_shared <word>(value))
{
}
@@ -59,9 +59,9 @@ parameter::parameter(const parameter&)
}
-ref <component> parameter::clone() const
+shared_ptr <component> parameter::clone() const
{
- ref <parameter> p = vmime::create <parameter>(m_name);
+ shared_ptr <parameter> p = make_shared <parameter>(m_name);
p->copyFrom(*this);
return (p);
@@ -589,9 +589,9 @@ void parameter::generateImpl
}
-const std::vector <ref <component> > parameter::getChildComponents()
+const std::vector <shared_ptr <component> > parameter::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
list.push_back(m_value);
diff --git a/src/parameterizedHeaderField.cpp b/src/parameterizedHeaderField.cpp
index c4e0b368..b329d1c1 100644
--- a/src/parameterizedHeaderField.cpp
+++ b/src/parameterizedHeaderField.cpp
@@ -321,7 +321,7 @@ void parameterizedHeaderField::parseImpl
const paramInfo& info = (*it).second;
// Append this parameter to the list
- ref <parameter> param = vmime::create <parameter>((*it).first);
+ shared_ptr <parameter> param = make_shared <parameter>((*it).first);
param->parse(ctx, info.value);
param->setParsedBounds(info.start, info.end);
@@ -345,7 +345,7 @@ void parameterizedHeaderField::generateImpl
headerField::generateImpl(ctx, os, pos, &pos);
// Parameters
- for (std::vector <ref <parameter> >::const_iterator
+ for (std::vector <shared_ptr <parameter> >::const_iterator
it = m_params.begin() ; it != m_params.end() ; ++it)
{
os << "; ";
@@ -367,10 +367,10 @@ void parameterizedHeaderField::copyFrom(const component& other)
removeAllParameters();
- for (std::vector <ref <parameter> >::const_iterator i = source.m_params.begin() ;
+ for (std::vector <shared_ptr <parameter> >::const_iterator i = source.m_params.begin() ;
i != source.m_params.end() ; ++i)
{
- appendParameter((*i)->clone().dynamicCast <parameter>());
+ appendParameter(vmime::clone(*i));
}
}
@@ -386,8 +386,8 @@ bool parameterizedHeaderField::hasParameter(const string& paramName) const
{
const string name = utility::stringUtils::toLower(paramName);
- std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
- const std::vector <ref <parameter> >::const_iterator end = m_params.end();
+ std::vector <shared_ptr <parameter> >::const_iterator pos = m_params.begin();
+ const std::vector <shared_ptr <parameter> >::const_iterator end = m_params.end();
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {}
@@ -395,13 +395,13 @@ bool parameterizedHeaderField::hasParameter(const string& paramName) const
}
-ref <parameter> parameterizedHeaderField::findParameter(const string& paramName) const
+shared_ptr <parameter> parameterizedHeaderField::findParameter(const string& paramName) const
{
const string name = utility::stringUtils::toLower(paramName);
// Find the first parameter that matches the specified name
- std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
- const std::vector <ref <parameter> >::const_iterator end = m_params.end();
+ std::vector <shared_ptr <parameter> >::const_iterator pos = m_params.begin();
+ const std::vector <shared_ptr <parameter> >::const_iterator end = m_params.end();
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {}
@@ -418,20 +418,20 @@ ref <parameter> parameterizedHeaderField::findParameter(const string& paramName)
}
-ref <parameter> parameterizedHeaderField::getParameter(const string& paramName)
+shared_ptr <parameter> parameterizedHeaderField::getParameter(const string& paramName)
{
const string name = utility::stringUtils::toLower(paramName);
// Find the first parameter that matches the specified name
- std::vector <ref <parameter> >::const_iterator pos = m_params.begin();
- const std::vector <ref <parameter> >::const_iterator end = m_params.end();
+ std::vector <shared_ptr <parameter> >::const_iterator pos = m_params.begin();
+ const std::vector <shared_ptr <parameter> >::const_iterator end = m_params.end();
for ( ; pos != end && utility::stringUtils::toLower((*pos)->getName()) != name ; ++pos) {}
// If no parameter with this name can be found, create a new one
if (pos == end)
{
- ref <parameter> param = vmime::create <parameter>(paramName);
+ shared_ptr <parameter> param = make_shared <parameter>(paramName);
appendParameter(param);
@@ -446,15 +446,15 @@ ref <parameter> parameterizedHeaderField::getParameter(const string& paramName)
}
-void parameterizedHeaderField::appendParameter(ref <parameter> param)
+void parameterizedHeaderField::appendParameter(shared_ptr <parameter> param)
{
m_params.push_back(param);
}
-void parameterizedHeaderField::insertParameterBefore(ref <parameter> beforeParam, ref <parameter> param)
+void parameterizedHeaderField::insertParameterBefore(shared_ptr <parameter> beforeParam, shared_ptr <parameter> param)
{
- const std::vector <ref <parameter> >::iterator it = std::find
+ const std::vector <shared_ptr <parameter> >::iterator it = std::find
(m_params.begin(), m_params.end(), beforeParam);
if (it == m_params.end())
@@ -464,15 +464,15 @@ void parameterizedHeaderField::insertParameterBefore(ref <parameter> beforeParam
}
-void parameterizedHeaderField::insertParameterBefore(const size_t pos, ref <parameter> param)
+void parameterizedHeaderField::insertParameterBefore(const size_t pos, shared_ptr <parameter> param)
{
m_params.insert(m_params.begin() + pos, param);
}
-void parameterizedHeaderField::insertParameterAfter(ref <parameter> afterParam, ref <parameter> param)
+void parameterizedHeaderField::insertParameterAfter(shared_ptr <parameter> afterParam, shared_ptr <parameter> param)
{
- const std::vector <ref <parameter> >::iterator it = std::find
+ const std::vector <shared_ptr <parameter> >::iterator it = std::find
(m_params.begin(), m_params.end(), afterParam);
if (it == m_params.end())
@@ -482,15 +482,15 @@ void parameterizedHeaderField::insertParameterAfter(ref <parameter> afterParam,
}
-void parameterizedHeaderField::insertParameterAfter(const size_t pos, ref <parameter> param)
+void parameterizedHeaderField::insertParameterAfter(const size_t pos, shared_ptr <parameter> param)
{
m_params.insert(m_params.begin() + pos + 1, param);
}
-void parameterizedHeaderField::removeParameter(ref <parameter> param)
+void parameterizedHeaderField::removeParameter(shared_ptr <parameter> param)
{
- const std::vector <ref <parameter> >::iterator it = std::find
+ const std::vector <shared_ptr <parameter> >::iterator it = std::find
(m_params.begin(), m_params.end(), param);
if (it == m_params.end())
@@ -502,7 +502,7 @@ void parameterizedHeaderField::removeParameter(ref <parameter> param)
void parameterizedHeaderField::removeParameter(const size_t pos)
{
- const std::vector <ref <parameter> >::iterator it = m_params.begin() + pos;
+ const std::vector <shared_ptr <parameter> >::iterator it = m_params.begin() + pos;
m_params.erase(it);
}
@@ -526,25 +526,25 @@ bool parameterizedHeaderField::isEmpty() const
}
-const ref <parameter> parameterizedHeaderField::getParameterAt(const size_t pos)
+const shared_ptr <parameter> parameterizedHeaderField::getParameterAt(const size_t pos)
{
return (m_params[pos]);
}
-const ref <const parameter> parameterizedHeaderField::getParameterAt(const size_t pos) const
+const shared_ptr <const parameter> parameterizedHeaderField::getParameterAt(const size_t pos) const
{
return (m_params[pos]);
}
-const std::vector <ref <const parameter> > parameterizedHeaderField::getParameterList() const
+const std::vector <shared_ptr <const parameter> > parameterizedHeaderField::getParameterList() const
{
- std::vector <ref <const parameter> > list;
+ std::vector <shared_ptr <const parameter> > list;
list.reserve(m_params.size());
- for (std::vector <ref <parameter> >::const_iterator it = m_params.begin() ;
+ for (std::vector <shared_ptr <parameter> >::const_iterator it = m_params.begin() ;
it != m_params.end() ; ++it)
{
list.push_back(*it);
@@ -554,17 +554,17 @@ const std::vector <ref <const parameter> > parameterizedHeaderField::getParamete
}
-const std::vector <ref <parameter> > parameterizedHeaderField::getParameterList()
+const std::vector <shared_ptr <parameter> > parameterizedHeaderField::getParameterList()
{
return (m_params);
}
-const std::vector <ref <component> > parameterizedHeaderField::getChildComponents()
+const std::vector <shared_ptr <component> > parameterizedHeaderField::getChildComponents()
{
- std::vector <ref <component> > list = headerField::getChildComponents();
+ std::vector <shared_ptr <component> > list = headerField::getChildComponents();
- for (std::vector <ref <parameter> >::iterator it = m_params.begin() ;
+ for (std::vector <shared_ptr <parameter> >::iterator it = m_params.begin() ;
it != m_params.end() ; ++it)
{
list.push_back(*it);
diff --git a/src/parsedMessageAttachment.cpp b/src/parsedMessageAttachment.cpp
index bf58a713..242bfde0 100644
--- a/src/parsedMessageAttachment.cpp
+++ b/src/parsedMessageAttachment.cpp
@@ -33,7 +33,7 @@ namespace vmime
{
-parsedMessageAttachment::parsedMessageAttachment(ref <message> msg)
+parsedMessageAttachment::parsedMessageAttachment(shared_ptr <message> msg)
: m_msg(msg)
{
}
@@ -57,7 +57,7 @@ const word parsedMessageAttachment::getName() const
}
-const ref <const contentHandler> parsedMessageAttachment::getData() const
+const shared_ptr <const contentHandler> parsedMessageAttachment::getData() const
{
if (m_data == NULL)
{
@@ -66,7 +66,7 @@ const ref <const contentHandler> parsedMessageAttachment::getData() const
m_msg->generate(os);
- m_data = vmime::create <stringContentHandler>(oss.str());
+ m_data = make_shared <stringContentHandler>(oss.str());
}
return m_data;
@@ -79,28 +79,28 @@ const encoding parsedMessageAttachment::getEncoding() const
}
-ref <const object> parsedMessageAttachment::getPart() const
+shared_ptr <const object> parsedMessageAttachment::getPart() const
{
- return NULL;
+ return null;
}
-ref <const header> parsedMessageAttachment::getHeader() const
+shared_ptr <const header> parsedMessageAttachment::getHeader() const
{
- return NULL;
+ return null;
}
-ref <message> parsedMessageAttachment::getMessage() const
+shared_ptr <message> parsedMessageAttachment::getMessage() const
{
return m_msg;
}
-void parsedMessageAttachment::generateIn(ref <bodyPart> parent) const
+void parsedMessageAttachment::generateIn(shared_ptr <bodyPart> parent) const
{
// Create and append a new part for this attachment
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
// Set header fields
diff --git a/src/path.cpp b/src/path.cpp
index 3e6e7a84..8722c9a7 100644
--- a/src/path.cpp
+++ b/src/path.cpp
@@ -93,9 +93,9 @@ void path::copyFrom(const component& other)
}
-ref <component> path::clone() const
+shared_ptr <component> path::clone() const
{
- return vmime::create <path>(*this);
+ return make_shared <path>(*this);
}
@@ -106,9 +106,9 @@ path& path::operator=(const path& other)
}
-const std::vector <ref <component> > path::getChildComponents()
+const std::vector <shared_ptr <component> > path::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/plainTextPart.cpp b/src/plainTextPart.cpp
index c26e146e..e1959af1 100644
--- a/src/plainTextPart.cpp
+++ b/src/plainTextPart.cpp
@@ -35,7 +35,7 @@ namespace vmime
plainTextPart::plainTextPart()
- : m_text(vmime::create <emptyContentHandler>())
+ : m_text(make_shared <emptyContentHandler>())
{
}
@@ -57,10 +57,10 @@ size_t plainTextPart::getPartCount() const
}
-void plainTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> parent) const
+void plainTextPart::generateIn(shared_ptr <bodyPart> /* message */, shared_ptr <bodyPart> parent) const
{
// Create a new part
- ref <bodyPart> part = vmime::create <bodyPart>();
+ shared_ptr <bodyPart> part = make_shared <bodyPart>();
parent->getBody()->appendPart(part);
// Set contents
@@ -70,15 +70,15 @@ void plainTextPart::generateIn(ref <bodyPart> /* message */, ref <bodyPart> pare
}
-void plainTextPart::parse(ref <const bodyPart> /* message */,
- ref <const bodyPart> /* parent */, ref <const bodyPart> textPart)
+void plainTextPart::parse(shared_ptr <const bodyPart> /* message */,
+ shared_ptr <const bodyPart> /* parent */, shared_ptr <const bodyPart> textPart)
{
- m_text = textPart->getBody()->getContents()->clone().dynamicCast <contentHandler>();
+ m_text = vmime::clone(textPart->getBody()->getContents());
try
{
- const contentTypeField& ctf = dynamic_cast<contentTypeField&>
- (*textPart->getHeader()->findField(fields::CONTENT_TYPE));
+ const contentTypeField& ctf =
+ *textPart->getHeader()->findField <contentTypeField>(fields::CONTENT_TYPE);
m_charset = ctf.getCharset();
}
@@ -105,15 +105,15 @@ void plainTextPart::setCharset(const charset& ch)
}
-const ref <const contentHandler> plainTextPart::getText() const
+const shared_ptr <const contentHandler> plainTextPart::getText() const
{
return (m_text);
}
-void plainTextPart::setText(ref <contentHandler> text)
+void plainTextPart::setText(shared_ptr <contentHandler> text)
{
- m_text = text->clone().dynamicCast <contentHandler>();
+ m_text = vmime::clone(text);
}
diff --git a/src/platform.cpp b/src/platform.cpp
index 37c7b027..631d5bcf 100644
--- a/src/platform.cpp
+++ b/src/platform.cpp
@@ -32,7 +32,7 @@ namespace vmime
{
-ref <platform::handler> platform::sm_handler = NULL;
+shared_ptr <platform::handler> platform::sm_handler;
platform::handler::~handler()
@@ -41,29 +41,29 @@ platform::handler::~handler()
// static
-ref <platform::handler> platform::getDefaultHandler()
+shared_ptr <platform::handler> platform::getDefaultHandler()
{
#if VMIME_PLATFORM_IS_WINDOWS
- return vmime::create <platforms::windows::windowsHandler>();
+ return make_shared <platforms::windows::windowsHandler>();
#elif VMIME_PLATFORM_IS_POSIX
- return vmime::create <platforms::posix::posixHandler>();
+ return make_shared <platforms::posix::posixHandler>();
#else
- return NULL;
+ return null;
#endif
}
// static
-ref <platform::handler> platform::getHandler()
+shared_ptr <platform::handler> platform::getHandler()
{
// If a custom platform handler is installed, return it
if (sm_handler)
return sm_handler;
// Else, use the default handler for this platform
- ref <handler> defaultHandler = getDefaultHandler();
+ shared_ptr <handler> defaultHandler = getDefaultHandler();
if (defaultHandler)
{
diff --git a/src/platforms/posix/posixChildProcess.cpp b/src/platforms/posix/posixChildProcess.cpp
index 09119996..c4761624 100644
--- a/src/platforms/posix/posixChildProcess.cpp
+++ b/src/platforms/posix/posixChildProcess.cpp
@@ -32,8 +32,6 @@
#include "vmime/exception.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
#include <unistd.h>
#include <string.h>
#include <errno.h>
@@ -49,9 +47,9 @@ namespace posix {
// posixChildProcessFactory
-ref <utility::childProcess> posixChildProcessFactory::create(const utility::file::path& path) const
+shared_ptr <utility::childProcess> posixChildProcessFactory::create(const utility::file::path& path) const
{
- return vmime::create <posixChildProcess>(path);
+ return make_shared <posixChildProcess>(path);
}
@@ -215,7 +213,7 @@ private:
posixChildProcess::posixChildProcess(const utility::file::path& path)
: m_processPath(path), m_started(false),
- m_stdIn(NULL), m_stdOut(NULL), m_pid(0), m_argArray(NULL)
+ m_stdIn(null), m_stdOut(null), m_pid(0), m_argArray(NULL)
{
m_pipe[0] = 0;
m_pipe[1] = 0;
@@ -319,7 +317,7 @@ void posixChildProcess::start(const std::vector <string> args, const int flags)
if (flags & FLAG_REDIRECT_STDIN)
{
- m_stdIn = vmime::create <outputStreamPosixPipeAdapter>(m_pipe[1]);
+ m_stdIn = make_shared <outputStreamPosixPipeAdapter>(m_pipe[1]);
}
else
{
@@ -329,7 +327,7 @@ void posixChildProcess::start(const std::vector <string> args, const int flags)
if (flags & FLAG_REDIRECT_STDOUT)
{
- m_stdOut = vmime::create <inputStreamPosixPipeAdapter>(m_pipe[0]);
+ m_stdOut = make_shared <inputStreamPosixPipeAdapter>(m_pipe[0]);
}
else
{
@@ -342,13 +340,13 @@ void posixChildProcess::start(const std::vector <string> args, const int flags)
}
-ref <utility::outputStream> posixChildProcess::getStdIn()
+shared_ptr <utility::outputStream> posixChildProcess::getStdIn()
{
return (m_stdIn);
}
-ref <utility::inputStream> posixChildProcess::getStdOut()
+shared_ptr <utility::inputStream> posixChildProcess::getStdOut()
{
return (m_stdOut);
}
@@ -377,8 +375,7 @@ void posixChildProcess::waitForFinish()
{
if (WEXITSTATUS(wstat) == 255)
{
- vmime::utility::auto_ptr <posixFileSystemFactory> pfsf
- = new posixFileSystemFactory();
+ std::auto_ptr <posixFileSystemFactory> pfsf(new posixFileSystemFactory());
throw exceptions::system_error("Could not execute '"
+ pfsf->pathToString(m_processPath) + "'");
diff --git a/src/platforms/posix/posixFile.cpp b/src/platforms/posix/posixFile.cpp
index 744f01ff..1e4dd070 100644
--- a/src/platforms/posix/posixFile.cpp
+++ b/src/platforms/posix/posixFile.cpp
@@ -79,9 +79,9 @@ bool posixFileIterator::hasMoreElements() const
}
-ref <vmime::utility::file> posixFileIterator::nextElement()
+shared_ptr <vmime::utility::file> posixFileIterator::nextElement()
{
- ref <posixFile> file = vmime::create <posixFile>
+ shared_ptr <posixFile> file = make_shared <posixFile>
(m_path / vmime::utility::file::path::component(m_dirEntry->d_name));
getNextElement();
@@ -258,14 +258,14 @@ posixFileWriter::posixFileWriter(const vmime::utility::file::path& path, const v
}
-ref <vmime::utility::outputStream> posixFileWriter::getOutputStream()
+shared_ptr <vmime::utility::outputStream> posixFileWriter::getOutputStream()
{
int fd = 0;
if ((fd = ::open(m_nativePath.c_str(), O_WRONLY, 0660)) == -1)
posixFileSystemFactory::reportError(m_path, errno);
- return vmime::create <posixFileWriterOutputStream>(m_path, fd);
+ return make_shared <posixFileWriterOutputStream>(m_path, fd);
}
@@ -280,14 +280,14 @@ posixFileReader::posixFileReader(const vmime::utility::file::path& path, const v
}
-ref <vmime::utility::inputStream> posixFileReader::getInputStream()
+shared_ptr <vmime::utility::inputStream> posixFileReader::getInputStream()
{
int fd = 0;
if ((fd = ::open(m_nativePath.c_str(), O_RDONLY, 0640)) == -1)
posixFileSystemFactory::reportError(m_path, errno);
- return vmime::create <posixFileReaderInputStream>(m_path, fd);
+ return make_shared <posixFileReaderInputStream>(m_path, fd);
}
@@ -417,12 +417,12 @@ bool posixFile::exists() const
}
-ref <vmime::utility::file> posixFile::getParent() const
+shared_ptr <vmime::utility::file> posixFile::getParent() const
{
if (m_path.isEmpty())
- return NULL;
+ return null;
else
- return vmime::create <posixFile>(m_path.getParent());
+ return make_shared <posixFile>(m_path.getParent());
}
@@ -465,24 +465,24 @@ void posixFile::remove()
}
-ref <vmime::utility::fileWriter> posixFile::getFileWriter()
+shared_ptr <vmime::utility::fileWriter> posixFile::getFileWriter()
{
- return vmime::create <posixFileWriter>(m_path, m_nativePath);
+ return make_shared <posixFileWriter>(m_path, m_nativePath);
}
-ref <vmime::utility::fileReader> posixFile::getFileReader()
+shared_ptr <vmime::utility::fileReader> posixFile::getFileReader()
{
- return vmime::create <posixFileReader>(m_path, m_nativePath);
+ return make_shared <posixFileReader>(m_path, m_nativePath);
}
-ref <vmime::utility::fileIterator> posixFile::getFiles() const
+shared_ptr <vmime::utility::fileIterator> posixFile::getFiles() const
{
if (!isDirectory())
throw vmime::exceptions::not_a_directory(m_path);
- return vmime::create <posixFileIterator>(m_path, m_nativePath);
+ return make_shared <posixFileIterator>(m_path, m_nativePath);
}
@@ -508,9 +508,9 @@ void posixFile::createDirectoryImpl(const vmime::utility::file::path& fullPath,
// posixFileSystemFactory
//
-ref <vmime::utility::file> posixFileSystemFactory::create(const vmime::utility::file::path& path) const
+shared_ptr <vmime::utility::file> posixFileSystemFactory::create(const vmime::utility::file::path& path) const
{
- return vmime::create <posixFile>(path);
+ return make_shared <posixFile>(path);
}
diff --git a/src/platforms/posix/posixHandler.cpp b/src/platforms/posix/posixHandler.cpp
index 73005d7e..b5d08ce6 100644
--- a/src/platforms/posix/posixHandler.cpp
+++ b/src/platforms/posix/posixHandler.cpp
@@ -109,11 +109,11 @@ namespace posix {
posixHandler::posixHandler()
{
#if VMIME_HAVE_MESSAGING_FEATURES
- m_socketFactory = vmime::create <posixSocketFactory>();
+ m_socketFactory = make_shared <posixSocketFactory>();
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- m_fileSysFactory = vmime::create <posixFileSystemFactory>();
- m_childProcFactory = vmime::create <posixChildProcessFactory>();
+ m_fileSysFactory = make_shared <posixFileSystemFactory>();
+ m_childProcFactory = make_shared <posixChildProcessFactory>();
#endif
}
@@ -249,7 +249,7 @@ unsigned int posixHandler::getThreadId() const
#if VMIME_HAVE_MESSAGING_FEATURES
-ref <vmime::net::socketFactory> posixHandler::getSocketFactory()
+shared_ptr <vmime::net::socketFactory> posixHandler::getSocketFactory()
{
return m_socketFactory;
}
@@ -259,13 +259,13 @@ ref <vmime::net::socketFactory> posixHandler::getSocketFactory()
#if VMIME_HAVE_FILESYSTEM_FEATURES
-ref <vmime::utility::fileSystemFactory> posixHandler::getFileSystemFactory()
+shared_ptr <vmime::utility::fileSystemFactory> posixHandler::getFileSystemFactory()
{
return m_fileSysFactory;
}
-ref <vmime::utility::childProcessFactory> posixHandler::getChildProcessFactory()
+shared_ptr <vmime::utility::childProcessFactory> posixHandler::getChildProcessFactory()
{
return m_childProcFactory;
}
@@ -308,9 +308,9 @@ void posixHandler::generateRandomBytes(unsigned char* buffer, const unsigned int
}
-ref <utility::sync::criticalSection> posixHandler::createCriticalSection()
+shared_ptr <utility::sync::criticalSection> posixHandler::createCriticalSection()
{
- return vmime::create <posixCriticalSection>();
+ return make_shared <posixCriticalSection>();
}
diff --git a/src/platforms/posix/posixSocket.cpp b/src/platforms/posix/posixSocket.cpp
index bee9f89e..e0bcf03a 100644
--- a/src/platforms/posix/posixSocket.cpp
+++ b/src/platforms/posix/posixSocket.cpp
@@ -59,7 +59,7 @@ namespace posix {
// posixSocket
//
-posixSocket::posixSocket(ref <vmime::net::timeoutHandler> th)
+posixSocket::posixSocket(shared_ptr <vmime::net::timeoutHandler> th)
: m_timeoutHandler(th), m_desc(-1), m_status(0)
{
}
@@ -631,16 +631,16 @@ unsigned int posixSocket::getStatus() const
// posixSocketFactory
//
-ref <vmime::net::socket> posixSocketFactory::create()
+shared_ptr <vmime::net::socket> posixSocketFactory::create()
{
- ref <vmime::net::timeoutHandler> th = NULL;
- return vmime::create <posixSocket>(th);
+ shared_ptr <vmime::net::timeoutHandler> th;
+ return make_shared <posixSocket>(th);
}
-ref <vmime::net::socket> posixSocketFactory::create(ref <vmime::net::timeoutHandler> th)
+shared_ptr <vmime::net::socket> posixSocketFactory::create(shared_ptr <vmime::net::timeoutHandler> th)
{
- return vmime::create <posixSocket>(th);
+ return make_shared <posixSocket>(th);
}
diff --git a/src/platforms/windows/windowsFile.cpp b/src/platforms/windows/windowsFile.cpp
index fd8a9651..8d2a19da 100644
--- a/src/platforms/windows/windowsFile.cpp
+++ b/src/platforms/windows/windowsFile.cpp
@@ -41,9 +41,9 @@ namespace platforms {
namespace windows {
-ref <vmime::utility::file> windowsFileSystemFactory::create(const vmime::utility::file::path& path) const
+shared_ptr <vmime::utility::file> windowsFileSystemFactory::create(const vmime::utility::file::path& path) const
{
- return vmime::create <windowsFile>(path);
+ return make_shared <windowsFile>(path);
}
@@ -307,12 +307,12 @@ bool windowsFile::exists() const
return false;
}
-ref <vmime::utility::file> windowsFile::getParent() const
+shared_ptr <vmime::utility::file> windowsFile::getParent() const
{
if (m_path.isEmpty())
return NULL;
else
- return vmime::create <windowsFile>(m_path.getParent());
+ return make_shared <windowsFile>(m_path.getParent());
}
void windowsFile::rename(const path& newName)
@@ -333,19 +333,19 @@ void windowsFile::remove()
windowsFileSystemFactory::reportError(m_path, GetLastError());
}
-ref <vmime::utility::fileWriter> windowsFile::getFileWriter()
+shared_ptr <vmime::utility::fileWriter> windowsFile::getFileWriter()
{
- return vmime::create <windowsFileWriter>(m_path, m_nativePath);
+ return make_shared <windowsFileWriter>(m_path, m_nativePath);
}
-ref <vmime::utility::fileReader> windowsFile::getFileReader()
+shared_ptr <vmime::utility::fileReader> windowsFile::getFileReader()
{
- return vmime::create <windowsFileReader>(m_path, m_nativePath);
+ return make_shared <windowsFileReader>(m_path, m_nativePath);
}
-ref <vmime::utility::fileIterator> windowsFile::getFiles() const
+shared_ptr <vmime::utility::fileIterator> windowsFile::getFiles() const
{
- return vmime::create <windowsFileIterator>(m_path, m_nativePath);
+ return make_shared <windowsFileIterator>(m_path, m_nativePath);
}
void windowsFile::createDirectoryImpl(const vmime::utility::file::path& fullPath, const vmime::utility::file::path& path, const bool recursive)
@@ -380,9 +380,9 @@ bool windowsFileIterator::hasMoreElements() const
return m_moreElements;
}
-ref <vmime::utility::file> windowsFileIterator::nextElement()
+shared_ptr <vmime::utility::file> windowsFileIterator::nextElement()
{
- ref <vmime::utility::file> pFile = vmime::create <windowsFile>
+ shared_ptr <vmime::utility::file> pFile = make_shared <windowsFile>
(m_path / vmime::utility::file::path::component(m_findData.cFileName));
findNext();
@@ -430,7 +430,7 @@ windowsFileReader::windowsFileReader(const vmime::utility::file::path& path, con
{
}
-ref <vmime::utility::inputStream> windowsFileReader::getInputStream()
+shared_ptr <vmime::utility::inputStream> windowsFileReader::getInputStream()
{
HANDLE hFile = CreateFile(
m_nativePath.c_str(),
@@ -442,7 +442,7 @@ ref <vmime::utility::inputStream> windowsFileReader::getInputStream()
NULL);
if (hFile == INVALID_HANDLE_VALUE)
windowsFileSystemFactory::reportError(m_path, GetLastError());
- return vmime::create <windowsFileReaderInputStream>(m_path, hFile);
+ return make_shared <windowsFileReaderInputStream>(m_path, hFile);
}
windowsFileReaderInputStream::windowsFileReaderInputStream(const vmime::utility::file::path& path, HANDLE hFile)
@@ -505,7 +505,7 @@ windowsFileWriter::windowsFileWriter(const vmime::utility::file::path& path, con
{
}
-ref <vmime::utility::outputStream> windowsFileWriter::getOutputStream()
+shared_ptr <vmime::utility::outputStream> windowsFileWriter::getOutputStream()
{
HANDLE hFile = CreateFile(
m_nativePath.c_str(),
@@ -517,7 +517,7 @@ ref <vmime::utility::outputStream> windowsFileWriter::getOutputStream()
NULL);
if (hFile == INVALID_HANDLE_VALUE)
windowsFileSystemFactory::reportError(m_path, GetLastError());
- return vmime::create <windowsFileWriterOutputStream>(m_path, hFile);
+ return make_shared <windowsFileWriterOutputStream>(m_path, hFile);
}
windowsFileWriterOutputStream::windowsFileWriterOutputStream(const vmime::utility::file::path& path, HANDLE hFile)
diff --git a/src/platforms/windows/windowsHandler.cpp b/src/platforms/windows/windowsHandler.cpp
index d4027801..5b9c37ce 100644
--- a/src/platforms/windows/windowsHandler.cpp
+++ b/src/platforms/windows/windowsHandler.cpp
@@ -57,10 +57,10 @@ windowsHandler::windowsHandler()
WSAStartup(MAKEWORD(1, 1), &wsaData);
#if VMIME_HAVE_MESSAGING_FEATURES
- m_socketFactory = vmime::create <windowsSocketFactory>();
+ m_socketFactory = make_shared <windowsSocketFactory>();
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- m_fileSysFactory = vmime::create <windowsFileSystemFactory>();
+ m_fileSysFactory = make_shared <windowsFileSystemFactory>();
#endif
}
@@ -274,7 +274,7 @@ unsigned int windowsHandler::getThreadId() const
#if VMIME_HAVE_MESSAGING_FEATURES
-ref <vmime::net::socketFactory> windowsHandler::getSocketFactory()
+shared_ptr <vmime::net::socketFactory> windowsHandler::getSocketFactory()
{
return m_socketFactory;
}
@@ -284,13 +284,13 @@ ref <vmime::net::socketFactory> windowsHandler::getSocketFactory()
#if VMIME_HAVE_FILESYSTEM_FEATURES
-ref <vmime::utility::fileSystemFactory> windowsHandler::getFileSystemFactory()
+shared_ptr <vmime::utility::fileSystemFactory> windowsHandler::getFileSystemFactory()
{
return m_fileSysFactory;
}
-ref <vmime::utility::childProcessFactory> windowsHandler::getChildProcessFactory()
+shared_ptr <vmime::utility::childProcessFactory> windowsHandler::getChildProcessFactory()
{
// TODO: Not implemented
return (NULL);
@@ -314,9 +314,9 @@ void windowsHandler::generateRandomBytes(unsigned char* buffer, const unsigned i
}
-ref <utility::sync::criticalSection> windowsHandler::createCriticalSection()
+shared_ptr <utility::sync::criticalSection> windowsHandler::createCriticalSection()
{
- return vmime::create <windowsCriticalSection>();
+ return make_shared <windowsCriticalSection>();
}
diff --git a/src/platforms/windows/windowsSocket.cpp b/src/platforms/windows/windowsSocket.cpp
index dc932965..502d1067 100644
--- a/src/platforms/windows/windowsSocket.cpp
+++ b/src/platforms/windows/windowsSocket.cpp
@@ -45,7 +45,7 @@ namespace windows {
// windowsSocket
//
-windowsSocket::windowsSocket(ref <vmime::net::timeoutHandler> th)
+windowsSocket::windowsSocket(shared_ptr <vmime::net::timeoutHandler> th)
: m_timeoutHandler(th), m_desc(INVALID_SOCKET), m_status(0)
{
WSAData wsaData;
@@ -438,15 +438,15 @@ void windowsSocket::waitForData(const WaitOpType t, bool& timedOut)
// posixSocketFactory
//
-ref <vmime::net::socket> windowsSocketFactory::create()
+shared_ptr <vmime::net::socket> windowsSocketFactory::create()
{
- ref <vmime::net::timeoutHandler> th = NULL;
- return vmime::create <windowsSocket>(th);
+ shared_ptr <vmime::net::timeoutHandler> th = NULL;
+ return make_shared <windowsSocket>(th);
}
-ref <vmime::net::socket> windowsSocketFactory::create(ref <vmime::net::timeoutHandler> th)
+shared_ptr <vmime::net::socket> windowsSocketFactory::create(shared_ptr <vmime::net::timeoutHandler> th)
{
- return vmime::create <windowsSocket>(th);
+ return make_shared <windowsSocket>(th);
}
} // posix
diff --git a/src/propertySet.cpp b/src/propertySet.cpp
index 284f3eaa..151c3e12 100644
--- a/src/propertySet.cpp
+++ b/src/propertySet.cpp
@@ -43,8 +43,8 @@ propertySet::propertySet(const string& props)
propertySet::propertySet(const propertySet& set)
: object()
{
- for (std::list <ref <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
- m_props.push_back(vmime::create <property>(**it));
+ for (std::list <shared_ptr <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
+ m_props.push_back(make_shared <property>(**it));
}
@@ -58,8 +58,8 @@ propertySet& propertySet::operator=(const propertySet& set)
{
removeAllProperties();
- for (std::list <ref <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
- m_props.push_back(vmime::create <property>(**it));
+ for (std::list <shared_ptr <property> >::const_iterator it = set.m_props.begin() ; it != set.m_props.end() ; ++it)
+ m_props.push_back(make_shared <property>(**it));
return (*this);
}
@@ -79,7 +79,7 @@ void propertySet::removeAllProperties()
void propertySet::removeProperty(const string& name)
{
- std::list <ref <property> >::iterator it = std::find_if
+ std::list <shared_ptr <property> >::iterator it = std::find_if
(m_props.begin(), m_props.end(), propFinder(name));
if (it != m_props.end())
@@ -174,24 +174,24 @@ void propertySet::parse(const string& props)
}
}
- m_props.push_back(vmime::create <property>(option, value));
+ m_props.push_back(make_shared <property>(option, value));
}
}
}
-ref <propertySet::property> propertySet::find(const string& name) const
+shared_ptr <propertySet::property> propertySet::find(const string& name) const
{
- std::list <ref <property> >::const_iterator it = std::find_if
+ std::list <shared_ptr <property> >::const_iterator it = std::find_if
(m_props.begin(), m_props.end(), propFinder(name));
- return (it != m_props.end() ? *it : NULL);
+ return (it != m_props.end() ? *it : null);
}
-ref <propertySet::property> propertySet::findOrCreate(const string& name)
+shared_ptr <propertySet::property> propertySet::findOrCreate(const string& name)
{
- std::list <ref <property> >::const_iterator it = std::find_if
+ std::list <shared_ptr <property> >::const_iterator it = std::find_if
(m_props.begin(), m_props.end(), propFinder(name));
if (it != m_props.end())
@@ -200,7 +200,7 @@ ref <propertySet::property> propertySet::findOrCreate(const string& name)
}
else
{
- ref <property> prop = vmime::create <property>(name, "");
+ shared_ptr <property> prop = make_shared <property>(name, "");
m_props.push_back(prop);
return (prop);
}
@@ -225,9 +225,9 @@ bool propertySet::hasProperty(const string& name) const
}
-const std::vector <ref <const propertySet::property> > propertySet::getPropertyList() const
+const std::vector <shared_ptr <const propertySet::property> > propertySet::getPropertyList() const
{
- std::vector <ref <const property> > res;
+ std::vector <shared_ptr <const property> > res;
for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it)
res.push_back(*it);
@@ -236,9 +236,9 @@ const std::vector <ref <const propertySet::property> > propertySet::getPropertyL
}
-const std::vector <ref <propertySet::property> > propertySet::getPropertyList()
+const std::vector <shared_ptr <propertySet::property> > propertySet::getPropertyList()
{
- std::vector <ref <property> > res;
+ std::vector <shared_ptr <property> > res;
for (list_type::const_iterator it = m_props.begin() ; it != m_props.end() ; ++it)
res.push_back(*it);
diff --git a/src/relay.cpp b/src/relay.cpp
index 90957dbe..327118c5 100644
--- a/src/relay.cpp
+++ b/src/relay.cpp
@@ -254,9 +254,9 @@ relay& relay::operator=(const relay& other)
}
-ref <component> relay::clone() const
+shared_ptr <component> relay::clone() const
{
- return vmime::create <relay>(*this);
+ return make_shared <relay>(*this);
}
@@ -344,10 +344,10 @@ std::vector <string>& relay::getWithList()
}
-const std::vector <ref <component> > relay::getChildComponents()
+const std::vector <shared_ptr <component> > relay::getChildComponents()
{
// TODO: should fields inherit from 'component'? (using typeAdapter)
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/security/cert/certificateChain.cpp b/src/security/cert/certificateChain.cpp
index ab12453e..3cb4e360 100644
--- a/src/security/cert/certificateChain.cpp
+++ b/src/security/cert/certificateChain.cpp
@@ -29,7 +29,7 @@ namespace security {
namespace cert {
-certificateChain::certificateChain(const std::vector <ref <certificate> >& certs)
+certificateChain::certificateChain(const std::vector <shared_ptr <certificate> >& certs)
: m_certs(certs)
{
}
@@ -41,7 +41,7 @@ unsigned int certificateChain::getCount() const
}
-ref <certificate> certificateChain::getAt(const unsigned int index)
+shared_ptr <certificate> certificateChain::getAt(const unsigned int index)
{
return m_certs[index];
}
diff --git a/src/security/cert/defaultCertificateVerifier.cpp b/src/security/cert/defaultCertificateVerifier.cpp
index bb185f36..1a95b353 100644
--- a/src/security/cert/defaultCertificateVerifier.cpp
+++ b/src/security/cert/defaultCertificateVerifier.cpp
@@ -55,7 +55,7 @@ defaultCertificateVerifier::defaultCertificateVerifier(const defaultCertificateV
void defaultCertificateVerifier::verify
- (ref <certificateChain> chain, const string& hostname)
+ (shared_ptr <certificateChain> chain, const string& hostname)
{
if (chain->getCount() == 0)
return;
@@ -70,7 +70,7 @@ void defaultCertificateVerifier::verify
void defaultCertificateVerifier::verifyX509
- (ref <certificateChain> chain, const string& hostname)
+ (shared_ptr <certificateChain> chain, const string& hostname)
{
// For every certificate in the chain, verify that the certificate
// has been issued by the next certificate in the chain
@@ -78,11 +78,11 @@ void defaultCertificateVerifier::verifyX509
{
for (unsigned int i = 0 ; i < chain->getCount() - 1 ; ++i)
{
- ref <X509Certificate> cert =
- chain->getAt(i).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> cert =
+ dynamicCast <X509Certificate>(chain->getAt(i));
- ref <X509Certificate> next =
- chain->getAt(i + 1).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> next =
+ dynamicCast <X509Certificate>(chain->getAt(i + 1));
if (!cert->checkIssuer(next))
{
@@ -98,8 +98,8 @@ void defaultCertificateVerifier::verifyX509
for (unsigned int i = 0 ; i < chain->getCount() ; ++i)
{
- ref <X509Certificate> cert =
- chain->getAt(i).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> cert =
+ dynamicCast <X509Certificate>(chain->getAt(i));
const datetime begin = cert->getActivationDate();
const datetime end = cert->getExpirationDate();
@@ -115,14 +115,14 @@ void defaultCertificateVerifier::verifyX509
// -- First, verify that the the last certificate in the chain was
// -- issued by a third-party that we trust
- ref <X509Certificate> lastCert =
- chain->getAt(chain->getCount() - 1).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> lastCert =
+ dynamicCast <X509Certificate>(chain->getAt(chain->getCount() - 1));
bool trusted = false;
for (unsigned int i = 0 ; !trusted && i < m_x509RootCAs.size() ; ++i)
{
- ref <X509Certificate> rootCa = m_x509RootCAs[i];
+ shared_ptr <X509Certificate> rootCa = m_x509RootCAs[i];
if (lastCert->verify(rootCa))
trusted = true;
@@ -131,12 +131,12 @@ void defaultCertificateVerifier::verifyX509
// -- Next, if the issuer certificate cannot be verified against
// -- root CAs, compare the subject's certificate against the
// -- trusted certificates
- ref <X509Certificate> firstCert =
- chain->getAt(0).dynamicCast <X509Certificate>();
+ shared_ptr <X509Certificate> firstCert =
+ dynamicCast <X509Certificate>(chain->getAt(0));
for (unsigned int i = 0 ; !trusted && i < m_x509TrustedCerts.size() ; ++i)
{
- ref <X509Certificate> cert = m_x509TrustedCerts[i];
+ shared_ptr <X509Certificate> cert = m_x509TrustedCerts[i];
if (firstCert->equals(cert))
trusted = true;
@@ -158,14 +158,14 @@ void defaultCertificateVerifier::verifyX509
void defaultCertificateVerifier::setX509RootCAs
- (const std::vector <ref <X509Certificate> >& caCerts)
+ (const std::vector <shared_ptr <X509Certificate> >& caCerts)
{
m_x509RootCAs = caCerts;
}
void defaultCertificateVerifier::setX509TrustedCerts
- (const std::vector <ref <X509Certificate> >& trustedCerts)
+ (const std::vector <shared_ptr <X509Certificate> >& trustedCerts)
{
m_x509TrustedCerts = trustedCerts;
}
diff --git a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
index 96137844..327ddefa 100644
--- a/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
+++ b/src/security/cert/gnutls/X509Certificate_GnuTLS.cpp
@@ -89,7 +89,7 @@ void* X509Certificate_GnuTLS::getInternalData()
// static
-ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
+shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
@@ -105,7 +105,7 @@ ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
// static
-ref <X509Certificate> X509Certificate::import
+shared_ptr <X509Certificate> X509Certificate::import
(const byte_t* data, const size_t length)
{
gnutls_datum buffer;
@@ -113,18 +113,18 @@ ref <X509Certificate> X509Certificate::import
buffer.size = static_cast <unsigned int>(length);
// Try DER format
- ref <X509Certificate_GnuTLS> derCert = vmime::create <X509Certificate_GnuTLS>();
+ shared_ptr <X509Certificate_GnuTLS> derCert = make_shared <X509Certificate_GnuTLS>();
if (gnutls_x509_crt_import(derCert->m_data->cert, &buffer, GNUTLS_X509_FMT_DER) >= 0)
return derCert;
// Try PEM format
- ref <X509Certificate_GnuTLS> pemCert = vmime::create <X509Certificate_GnuTLS>();
+ shared_ptr <X509Certificate_GnuTLS> pemCert = make_shared <X509Certificate_GnuTLS>();
if (gnutls_x509_crt_import(pemCert->m_data->cert, &buffer, GNUTLS_X509_FMT_PEM) >= 0)
return pemCert;
- return NULL;
+ return null;
}
@@ -161,20 +161,20 @@ const byteArray X509Certificate_GnuTLS::getSerialNumber() const
}
-bool X509Certificate_GnuTLS::checkIssuer(ref <const X509Certificate> issuer_) const
+bool X509Certificate_GnuTLS::checkIssuer(shared_ptr <const X509Certificate> issuer_) const
{
- ref <const X509Certificate_GnuTLS> issuer =
- issuer_.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> issuer =
+ dynamicCast <const X509Certificate_GnuTLS>(issuer_);
return (gnutls_x509_crt_check_issuer
(m_data->cert, issuer->m_data->cert) >= 1);
}
-bool X509Certificate_GnuTLS::verify(ref <const X509Certificate> caCert_) const
+bool X509Certificate_GnuTLS::verify(shared_ptr <const X509Certificate> caCert_) const
{
- ref <const X509Certificate_GnuTLS> caCert =
- caCert_.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> caCert =
+ dynamicCast <const X509Certificate_GnuTLS>(caCert_);
unsigned int verify = 0;
@@ -267,10 +267,10 @@ int X509Certificate_GnuTLS::getVersion() const
}
-bool X509Certificate_GnuTLS::equals(ref <const certificate> other) const
+bool X509Certificate_GnuTLS::equals(shared_ptr <const certificate> other) const
{
- ref <const X509Certificate_GnuTLS> otherX509 =
- other.dynamicCast <const X509Certificate_GnuTLS>();
+ shared_ptr <const X509Certificate_GnuTLS> otherX509 =
+ dynamicCast <const X509Certificate_GnuTLS>(other);
if (!otherX509)
return false;
diff --git a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
index 8c18583b..8c7174a0 100644
--- a/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
+++ b/src/security/cert/openssl/X509Certificate_OpenSSL.cpp
@@ -158,17 +158,17 @@ void* X509Certificate_OpenSSL::getInternalData()
// static
-ref <X509Certificate> X509Certificate_OpenSSL::importInternal(X509* cert)
+shared_ptr <X509Certificate> X509Certificate_OpenSSL::importInternal(X509* cert)
{
if (cert)
- return vmime::create <X509Certificate_OpenSSL>(reinterpret_cast <X509 *>(cert));
+ return make_shared <X509Certificate_OpenSSL>(reinterpret_cast <X509 *>(cert));
- return NULL;
+ return null;
}
// static
-ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
+shared_ptr <X509Certificate> X509Certificate::import(utility::inputStream& is)
{
byteArray bytes;
utility::stream::value_type chunk[4096];
@@ -184,17 +184,17 @@ ref <X509Certificate> X509Certificate::import(utility::inputStream& is)
// static
-ref <X509Certificate> X509Certificate::import
+shared_ptr <X509Certificate> X509Certificate::import
(const byte_t* data, const size_t length)
{
- ref <X509Certificate_OpenSSL> cert = vmime::create <X509Certificate_OpenSSL>();
+ shared_ptr <X509Certificate_OpenSSL> cert = make_shared <X509Certificate_OpenSSL>();
BIO* membio = BIO_new_mem_buf(const_cast <byte_t*>(data), length);
if (!PEM_read_bio_X509(membio, &(cert->m_data->cert), 0, 0))
{
BIO_vfree(membio);
- return NULL;
+ return null;
}
BIO_vfree(membio);
@@ -270,10 +270,10 @@ const byteArray X509Certificate_OpenSSL::getSerialNumber() const
}
-bool X509Certificate_OpenSSL::checkIssuer(ref <const X509Certificate> cert_) const
+bool X509Certificate_OpenSSL::checkIssuer(shared_ptr <const X509Certificate> cert_) const
{
- ref <const X509Certificate_OpenSSL> cert =
- cert_.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> cert =
+ dynamicCast <const X509Certificate_OpenSSL>(cert_);
// Get issuer for this cert
BIO *out;
@@ -297,10 +297,10 @@ bool X509Certificate_OpenSSL::checkIssuer(ref <const X509Certificate> cert_) con
}
-bool X509Certificate_OpenSSL::verify(ref <const X509Certificate> caCert_) const
+bool X509Certificate_OpenSSL::verify(shared_ptr <const X509Certificate> caCert_) const
{
- ref <const X509Certificate_OpenSSL> caCert =
- caCert_.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> caCert =
+ dynamicCast <const X509Certificate_OpenSSL>(caCert_);
bool verified = false;
@@ -550,10 +550,10 @@ int X509Certificate_OpenSSL::getVersion() const
}
-bool X509Certificate_OpenSSL::equals(ref <const certificate> other) const
+bool X509Certificate_OpenSSL::equals(shared_ptr <const certificate> other) const
{
- ref <const X509Certificate_OpenSSL> otherX509 =
- other.dynamicCast <const X509Certificate_OpenSSL>();
+ shared_ptr <const X509Certificate_OpenSSL> otherX509 =
+ dynamicCast <const X509Certificate_OpenSSL>(other);
if (!otherX509)
return false;
diff --git a/src/security/defaultAuthenticator.cpp b/src/security/defaultAuthenticator.cpp
index a2ff37f9..790196d2 100644
--- a/src/security/defaultAuthenticator.cpp
+++ b/src/security/defaultAuthenticator.cpp
@@ -50,7 +50,7 @@ defaultAuthenticator::~defaultAuthenticator()
const string defaultAuthenticator::getUsername() const
{
- ref <const net::service> service = m_service.acquire();
+ shared_ptr <const net::service> service = m_service.lock();
const string prefix = service->getInfos().getPropertyPrefix();
const propertySet& props = service->getSession()->getProperties();
@@ -64,7 +64,7 @@ const string defaultAuthenticator::getUsername() const
const string defaultAuthenticator::getPassword() const
{
- ref <const net::service> service = m_service.acquire();
+ shared_ptr <const net::service> service = m_service.lock();
const string prefix = service->getInfos().getPropertyPrefix();
const propertySet& props = service->getSession()->getProperties();
@@ -95,13 +95,13 @@ const string defaultAuthenticator::getServiceName() const
}
-void defaultAuthenticator::setService(ref <net::service> serv)
+void defaultAuthenticator::setService(shared_ptr <net::service> serv)
{
m_service = serv;
}
-weak_ref <net::service> defaultAuthenticator::getService() const
+weak_ptr <net::service> defaultAuthenticator::getService() const
{
return m_service;
}
diff --git a/src/security/digest/messageDigestFactory.cpp b/src/security/digest/messageDigestFactory.cpp
index 6d424155..2831c5a1 100644
--- a/src/security/digest/messageDigestFactory.cpp
+++ b/src/security/digest/messageDigestFactory.cpp
@@ -52,7 +52,7 @@ messageDigestFactory* messageDigestFactory::getInstance()
}
-ref <messageDigest> messageDigestFactory::create(const string& name)
+shared_ptr <messageDigest> messageDigestFactory::create(const string& name)
{
const MapType::const_iterator it = m_algos.find
(utility::stringUtils::toLower(name));
diff --git a/src/security/sasl/SASLContext.cpp b/src/security/sasl/SASLContext.cpp
index 7b24f1e3..c4d60bd9 100644
--- a/src/security/sasl/SASLContext.cpp
+++ b/src/security/sasl/SASLContext.cpp
@@ -62,27 +62,27 @@ SASLContext::~SASLContext()
}
-ref <SASLSession> SASLContext::createSession
+shared_ptr <SASLSession> SASLContext::createSession
(const string& serviceName,
- ref <authenticator> auth, ref <SASLMechanism> mech)
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
{
- return vmime::create <SASLSession>
- (serviceName, thisRef().dynamicCast <SASLContext>(), auth, mech);
+ return make_shared <SASLSession>
+ (serviceName, dynamicCast <SASLContext>(shared_from_this()), auth, mech);
}
-ref <SASLMechanism> SASLContext::createMechanism(const string& name)
+shared_ptr <SASLMechanism> SASLContext::createMechanism(const string& name)
{
return SASLMechanismFactory::getInstance()->create
- (thisRef().dynamicCast <SASLContext>(), name);
+ (dynamicCast <SASLContext>(shared_from_this()), name);
}
-ref <SASLMechanism> SASLContext::suggestMechanism
- (const std::vector <ref <SASLMechanism> >& mechs)
+shared_ptr <SASLMechanism> SASLContext::suggestMechanism
+ (const std::vector <shared_ptr <SASLMechanism> >& mechs)
{
if (mechs.empty())
- return 0;
+ return null;
std::ostringstream oss;
@@ -102,7 +102,7 @@ ref <SASLMechanism> SASLContext::suggestMechanism
}
}
- return 0;
+ return null;
}
@@ -113,7 +113,7 @@ void SASLContext::decodeB64(const string& input, byte_t** output, long* outputLe
utility::inputStreamStringAdapter is(input);
utility::outputStreamStringAdapter os(res);
- ref <utility::encoder::encoder> dec =
+ shared_ptr <utility::encoder::encoder> dec =
utility::encoder::encoderFactory::getInstance()->create("base64");
dec->decode(is, os);
@@ -134,7 +134,7 @@ const string SASLContext::encodeB64(const byte_t* input, const long inputLen)
utility::inputStreamByteBufferAdapter is(input, inputLen);
utility::outputStreamStringAdapter os(res);
- ref <utility::encoder::encoder> enc =
+ shared_ptr <utility::encoder::encoder> enc =
utility::encoder::encoderFactory::getInstance()->create("base64");
enc->encode(is, os);
diff --git a/src/security/sasl/SASLMechanismFactory.cpp b/src/security/sasl/SASLMechanismFactory.cpp
index 0f2dd3af..255a13f1 100644
--- a/src/security/sasl/SASLMechanismFactory.cpp
+++ b/src/security/sasl/SASLMechanismFactory.cpp
@@ -68,15 +68,15 @@ SASLMechanismFactory* SASLMechanismFactory::getInstance()
}
-ref <SASLMechanism> SASLMechanismFactory::create
- (ref <SASLContext> ctx, const string& name_)
+shared_ptr <SASLMechanism> SASLMechanismFactory::create
+ (shared_ptr <SASLContext> ctx, const string& name_)
{
const string name(utility::stringUtils::toUpper(name_));
// Check for built-in mechanisms
if (isMechanismSupported(name))
{
- return vmime::create <builtinSASLMechanism>(ctx, name);
+ return make_shared <builtinSASLMechanism>(ctx, name);
}
// Check for registered mechanisms
else
@@ -88,7 +88,7 @@ ref <SASLMechanism> SASLMechanismFactory::create
}
throw exceptions::no_such_mechanism(name);
- return 0;
+ return null;
}
diff --git a/src/security/sasl/SASLSession.cpp b/src/security/sasl/SASLSession.cpp
index c34bdd7f..1bdd0889 100644
--- a/src/security/sasl/SASLSession.cpp
+++ b/src/security/sasl/SASLSession.cpp
@@ -43,8 +43,8 @@ namespace security {
namespace sasl {
-SASLSession::SASLSession(const string& serviceName, ref <SASLContext> ctx,
- ref <authenticator> auth, ref <SASLMechanism> mech)
+SASLSession::SASLSession(const string& serviceName, shared_ptr <SASLContext> ctx,
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech)
: m_serviceName(serviceName), m_context(ctx), m_auth(auth),
m_mech(mech), m_gsaslContext(0), m_gsaslSession(0)
{
@@ -61,38 +61,38 @@ SASLSession::SASLSession(const string& serviceName, ref <SASLContext> ctx,
SASLSession::~SASLSession()
{
gsasl_finish(m_gsaslSession);
- m_gsaslSession = 0;
+ m_gsaslSession = NULL;
gsasl_done(m_gsaslContext);
- m_gsaslContext = 0;
+ m_gsaslContext = NULL;
}
void SASLSession::init()
{
- ref <SASLAuthenticator> saslAuth = m_auth.dynamicCast <SASLAuthenticator>();
+ shared_ptr <SASLAuthenticator> saslAuth = dynamicCast <SASLAuthenticator>(m_auth);
if (saslAuth)
{
saslAuth->setSASLMechanism(m_mech);
- saslAuth->setSASLSession(thisRef().dynamicCast <SASLSession>());
+ saslAuth->setSASLSession(dynamicCast <SASLSession>(shared_from_this()));
}
}
-ref <authenticator> SASLSession::getAuthenticator()
+shared_ptr <authenticator> SASLSession::getAuthenticator()
{
return m_auth;
}
-ref <SASLMechanism> SASLSession::getMechanism()
+shared_ptr <SASLMechanism> SASLSession::getMechanism()
{
return m_mech;
}
-ref <SASLContext> SASLSession::getContext()
+shared_ptr <SASLContext> SASLSession::getContext()
{
return m_context;
}
@@ -102,14 +102,14 @@ bool SASLSession::evaluateChallenge
(const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
{
- return m_mech->step(thisRef().dynamicCast <SASLSession>(),
+ return m_mech->step(dynamicCast <SASLSession>(shared_from_this()),
challenge, challengeLen, response, responseLen);
}
-ref <net::socket> SASLSession::getSecuredSocket(ref <net::socket> sok)
+shared_ptr <net::socket> SASLSession::getSecuredSocket(shared_ptr <net::socket> sok)
{
- return vmime::create <SASLSocket>(thisRef().dynamicCast <SASLSession>(), sok);
+ return make_shared <SASLSocket>(dynamicCast <SASLSession>(shared_from_this()), sok);
}
@@ -126,7 +126,7 @@ int SASLSession::gsaslCallback
SASLSession* sess = reinterpret_cast <SASLSession*>(gsasl_callback_hook_get(ctx));
if (!sess) return GSASL_AUTHENTICATION_ERROR;
- ref <authenticator> auth = sess->getAuthenticator();
+ shared_ptr <authenticator> auth = sess->getAuthenticator();
try
{
diff --git a/src/security/sasl/SASLSocket.cpp b/src/security/sasl/SASLSocket.cpp
index b6b1d272..37e297dc 100644
--- a/src/security/sasl/SASLSocket.cpp
+++ b/src/security/sasl/SASLSocket.cpp
@@ -43,7 +43,7 @@ namespace sasl {
-SASLSocket::SASLSocket(ref <SASLSession> sess, ref <net::socket> wrapped)
+SASLSocket::SASLSocket(shared_ptr <SASLSession> sess, shared_ptr <net::socket> wrapped)
: m_session(sess), m_wrapped(wrapped),
m_pendingBuffer(0), m_pendingPos(0), m_pendingLen(0)
{
diff --git a/src/security/sasl/builtinSASLMechanism.cpp b/src/security/sasl/builtinSASLMechanism.cpp
index 86b429bf..e7bd723e 100644
--- a/src/security/sasl/builtinSASLMechanism.cpp
+++ b/src/security/sasl/builtinSASLMechanism.cpp
@@ -45,7 +45,7 @@ namespace security {
namespace sasl {
-builtinSASLMechanism::builtinSASLMechanism(ref <SASLContext> ctx, const string& name)
+builtinSASLMechanism::builtinSASLMechanism(shared_ptr <SASLContext> ctx, const string& name)
: m_context(ctx), m_name(name), m_complete(false)
{
}
@@ -63,7 +63,7 @@ const string builtinSASLMechanism::getName() const
bool builtinSASLMechanism::step
- (ref <SASLSession> sess, const byte_t* challenge, const long challengeLen,
+ (shared_ptr <SASLSession> sess, const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen)
{
char* output = 0;
@@ -121,7 +121,7 @@ bool builtinSASLMechanism::isComplete() const
void builtinSASLMechanism::encode
- (ref <SASLSession> sess, const byte_t* input, const long inputLen,
+ (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
{
char* coutput = 0;
@@ -154,7 +154,7 @@ void builtinSASLMechanism::encode
void builtinSASLMechanism::decode
- (ref <SASLSession> sess, const byte_t* input, const long inputLen,
+ (shared_ptr <SASLSession> sess, const byte_t* input, const long inputLen,
byte_t** output, long* outputLen)
{
char* coutput = 0;
diff --git a/src/security/sasl/defaultSASLAuthenticator.cpp b/src/security/sasl/defaultSASLAuthenticator.cpp
index bb72e56f..7fe9b3eb 100644
--- a/src/security/sasl/defaultSASLAuthenticator.cpp
+++ b/src/security/sasl/defaultSASLAuthenticator.cpp
@@ -51,14 +51,14 @@ defaultSASLAuthenticator::~defaultSASLAuthenticator()
}
-const std::vector <ref <SASLMechanism> >
+const std::vector <shared_ptr <SASLMechanism> >
defaultSASLAuthenticator::getAcceptableMechanisms
- (const std::vector <ref <SASLMechanism> >& available,
- ref <SASLMechanism> suggested) const
+ (const std::vector <shared_ptr <SASLMechanism> >& available,
+ shared_ptr <SASLMechanism> suggested) const
{
if (suggested)
{
- std::vector <ref <SASLMechanism> > res;
+ std::vector <shared_ptr <SASLMechanism> > res;
res.push_back(suggested);
@@ -103,42 +103,42 @@ const string defaultSASLAuthenticator::getAnonymousToken() const
const string defaultSASLAuthenticator::getServiceName() const
{
- return m_saslSession.acquire()->getServiceName();
+ return m_saslSession.lock()->getServiceName();
}
-void defaultSASLAuthenticator::setService(ref <net::service> serv)
+void defaultSASLAuthenticator::setService(shared_ptr <net::service> serv)
{
m_service = serv;
m_default.setService(serv);
}
-weak_ref <net::service> defaultSASLAuthenticator::getService() const
+weak_ptr <net::service> defaultSASLAuthenticator::getService() const
{
return m_service;
}
-void defaultSASLAuthenticator::setSASLSession(ref <SASLSession> sess)
+void defaultSASLAuthenticator::setSASLSession(shared_ptr <SASLSession> sess)
{
m_saslSession = sess;
}
-ref <SASLSession> defaultSASLAuthenticator::getSASLSession() const
+shared_ptr <SASLSession> defaultSASLAuthenticator::getSASLSession() const
{
- return m_saslSession.acquire().constCast <SASLSession>();
+ return constCast <SASLSession>(m_saslSession.lock());
}
-void defaultSASLAuthenticator::setSASLMechanism(ref <SASLMechanism> mech)
+void defaultSASLAuthenticator::setSASLMechanism(shared_ptr <SASLMechanism> mech)
{
m_saslMech = mech;
}
-ref <SASLMechanism> defaultSASLAuthenticator::getSASLMechanism() const
+shared_ptr <SASLMechanism> defaultSASLAuthenticator::getSASLMechanism() const
{
return m_saslMech;
}
diff --git a/src/streamContentHandler.cpp b/src/streamContentHandler.cpp
index d6444833..b84fdae5 100644
--- a/src/streamContentHandler.cpp
+++ b/src/streamContentHandler.cpp
@@ -34,12 +34,12 @@ namespace vmime
streamContentHandler::streamContentHandler()
- : m_encoding(NO_ENCODING), m_stream(null)
+ : m_encoding(NO_ENCODING), m_stream(null), m_length(0)
{
}
-streamContentHandler::streamContentHandler(ref <utility::inputStream> is,
+streamContentHandler::streamContentHandler(shared_ptr <utility::inputStream> is,
const utility::stream::size_type length, const vmime::encoding& enc)
{
setData(is, length, enc);
@@ -58,9 +58,9 @@ streamContentHandler::streamContentHandler(const streamContentHandler& cts)
}
-ref <contentHandler> streamContentHandler::clone() const
+shared_ptr <contentHandler> streamContentHandler::clone() const
{
- return vmime::create <streamContentHandler>(*this);
+ return make_shared <streamContentHandler>(*this);
}
@@ -76,7 +76,7 @@ streamContentHandler& streamContentHandler::operator=(const streamContentHandler
}
-void streamContentHandler::setData(ref <utility::inputStream> is,
+void streamContentHandler::setData(shared_ptr <utility::inputStream> is,
const utility::stream::size_type length, const vmime::encoding& enc)
{
m_encoding = enc;
@@ -100,8 +100,8 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco
// buffer, and then re-encode to output stream...
if (m_encoding != enc)
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -129,7 +129,7 @@ void streamContentHandler::generate(utility::outputStream& os, const vmime::enco
// Need to encode data before
else
{
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -159,7 +159,7 @@ void streamContentHandler::extract(utility::outputStream& os,
// Need to decode data
else
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
m_stream->reset(); // may not work...
@@ -211,7 +211,7 @@ const vmime::encoding& streamContentHandler::getEncoding() const
bool streamContentHandler::isBuffered() const
{
- if (m_stream.dynamicCast <utility::seekableInputStream>() != NULL)
+ if (dynamicCast <utility::seekableInputStream>(m_stream) != NULL)
return true;
// FIXME: some streams can be resetted
diff --git a/src/stringContentHandler.cpp b/src/stringContentHandler.cpp
index e4762dce..0fb032dd 100644
--- a/src/stringContentHandler.cpp
+++ b/src/stringContentHandler.cpp
@@ -68,9 +68,9 @@ stringContentHandler::~stringContentHandler()
}
-ref <contentHandler> stringContentHandler::clone() const
+shared_ptr <contentHandler> stringContentHandler::clone() const
{
- return vmime::create <stringContentHandler>(*this);
+ return make_shared <stringContentHandler>(*this);
}
@@ -125,8 +125,8 @@ void stringContentHandler::generate(utility::outputStream& os,
// buffer, and then re-encode to output stream...
if (m_encoding != enc)
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -152,7 +152,7 @@ void stringContentHandler::generate(utility::outputStream& os,
// Need to encode data before
else
{
- ref <utility::encoder::encoder> theEncoder = enc.getEncoder();
+ shared_ptr <utility::encoder::encoder> theEncoder = enc.getEncoder();
theEncoder->getProperties()["maxlinelength"] = maxLineLength;
theEncoder->getProperties()["text"] = (m_contentType.getType() == mediaTypes::TEXT);
@@ -174,7 +174,7 @@ void stringContentHandler::extract(utility::outputStream& os,
// Need to decode data
else
{
- ref <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
+ shared_ptr <utility::encoder::encoder> theDecoder = m_encoding.getEncoder();
utility::inputStreamStringProxyAdapter in(m_string);
utility::progressListenerSizeAdapter plsa(progress, getLength());
diff --git a/src/text.cpp b/src/text.cpp
index 05353b08..987510c1 100644
--- a/src/text.cpp
+++ b/src/text.cpp
@@ -57,7 +57,7 @@ text::text(const string& t)
text::text(const word& w)
{
- appendWord(vmime::create <word>(w));
+ appendWord(make_shared <word>(w));
}
@@ -75,7 +75,7 @@ void text::parseImpl
string::size_type newPos;
- const std::vector <ref <word> > words = word::parseMultiple(ctx, buffer, position, end, &newPos);
+ const std::vector <shared_ptr <word> > words = word::parseMultiple(ctx, buffer, position, end, &newPos);
copy_vector(words, m_words);
@@ -100,8 +100,8 @@ void text::copyFrom(const component& other)
removeAllWords();
- for (std::vector <ref <word> >::const_iterator i = t.m_words.begin() ; i != t.m_words.end() ; ++i)
- m_words.push_back(vmime::create <word>(**i));
+ for (std::vector <shared_ptr <word> >::const_iterator i = t.m_words.begin() ; i != t.m_words.end() ; ++i)
+ m_words.push_back(make_shared <word>(**i));
}
@@ -125,8 +125,8 @@ bool text::operator==(const text& t) const
{
bool equal = true;
- std::vector <ref <word> >::const_iterator i = m_words.begin();
- std::vector <ref <word> >::const_iterator j = t.m_words.begin();
+ std::vector <shared_ptr <word> >::const_iterator i = m_words.begin();
+ std::vector <shared_ptr <word> >::const_iterator j = t.m_words.begin();
for ( ; equal && i != m_words.end() ; ++i, ++j)
equal = (**i == **j);
@@ -148,26 +148,26 @@ const string text::getConvertedText(const charset& dest, const charsetConverterO
{
string out;
- for (std::vector <ref <word> >::const_iterator i = m_words.begin() ; i != m_words.end() ; ++i)
+ for (std::vector <shared_ptr <word> >::const_iterator i = m_words.begin() ; i != m_words.end() ; ++i)
out += (*i)->getConvertedText(dest, opts);
return (out);
}
-void text::appendWord(ref <word> w)
+void text::appendWord(shared_ptr <word> w)
{
m_words.push_back(w);
}
-void text::insertWordBefore(const size_t pos, ref <word> w)
+void text::insertWordBefore(const size_t pos, shared_ptr <word> w)
{
m_words.insert(m_words.begin() + pos, w);
}
-void text::insertWordAfter(const size_t pos, ref <word> w)
+void text::insertWordAfter(const size_t pos, shared_ptr <word> w)
{
m_words.insert(m_words.begin() + pos + 1, w);
}
@@ -175,7 +175,7 @@ void text::insertWordAfter(const size_t pos, ref <word> w)
void text::removeWord(const size_t pos)
{
- const std::vector <ref <word> >::iterator it = m_words.begin() + pos;
+ const std::vector <shared_ptr <word> >::iterator it = m_words.begin() + pos;
m_words.erase(it);
}
@@ -199,25 +199,25 @@ bool text::isEmpty() const
}
-const ref <word> text::getWordAt(const size_t pos)
+const shared_ptr <word> text::getWordAt(const size_t pos)
{
return (m_words[pos]);
}
-const ref <const word> text::getWordAt(const size_t pos) const
+const shared_ptr <const word> text::getWordAt(const size_t pos) const
{
return (m_words[pos]);
}
-const std::vector <ref <const word> > text::getWordList() const
+const std::vector <shared_ptr <const word> > text::getWordList() const
{
- std::vector <ref <const word> > list;
+ std::vector <shared_ptr <const word> > list;
list.reserve(m_words.size());
- for (std::vector <ref <word> >::const_iterator it = m_words.begin() ;
+ for (std::vector <shared_ptr <word> >::const_iterator it = m_words.begin() ;
it != m_words.end() ; ++it)
{
list.push_back(*it);
@@ -227,21 +227,21 @@ const std::vector <ref <const word> > text::getWordList() const
}
-const std::vector <ref <word> > text::getWordList()
+const std::vector <shared_ptr <word> > text::getWordList()
{
return (m_words);
}
-ref <component> text::clone() const
+shared_ptr <component> text::clone() const
{
- return vmime::create <text>(*this);
+ return make_shared <text>(*this);
}
-ref <text> text::newFromString(const string& in, const charset& ch)
+shared_ptr <text> text::newFromString(const string& in, const charset& ch)
{
- ref <text> t = vmime::create <text>();
+ shared_ptr <text> t = make_shared <text>();
t->createFromString(in, ch);
@@ -272,7 +272,7 @@ void text::createFromString(const string& in, const charset& ch)
// If there are "too much" non-ASCII chars, encode everything
if (alwaysEncode || asciiPercent < 60) // less than 60% ASCII chars
{
- appendWord(vmime::create <word>(in, ch));
+ appendWord(make_shared <word>(in, ch));
}
// Else, only encode words which need it
else
@@ -296,18 +296,18 @@ void text::createFromString(const string& in, const charset& ch)
{
// No need to create a new encoded word, just append
// the current word to the previous one.
- ref <word> w = getWordAt(getWordCount() - 1);
+ shared_ptr <word> w = getWordAt(getWordCount() - 1);
w->getBuffer() += " " + chunk;
}
else
{
if (count)
{
- ref <word> w = getWordAt(getWordCount() - 1);
+ shared_ptr <word> w = getWordAt(getWordCount() - 1);
w->getBuffer() += ' ';
}
- appendWord(vmime::create <word>(chunk, ch));
+ appendWord(make_shared <word>(chunk, ch));
prevIs8bit = true;
++count;
@@ -317,12 +317,12 @@ void text::createFromString(const string& in, const charset& ch)
{
if (count && !prevIs8bit)
{
- ref <word> w = getWordAt(getWordCount() - 1);
+ shared_ptr <word> w = getWordAt(getWordCount() - 1);
w->getBuffer() += " " + chunk;
}
else
{
- appendWord(vmime::create <word>
+ appendWord(make_shared <word>
(chunk, charset(charsets::US_ASCII)));
prevIs8bit = false;
@@ -368,9 +368,9 @@ void text::encodeAndFold
}
-ref <text> text::decodeAndUnfold(const string& in)
+shared_ptr <text> text::decodeAndUnfold(const string& in)
{
- ref <text> t = vmime::create <text>();
+ shared_ptr <text> t = make_shared <text>();
decodeAndUnfold(parsingContext::getDefaultContext(), in, t.get());
@@ -378,9 +378,9 @@ ref <text> text::decodeAndUnfold(const string& in)
}
-ref <text> text::decodeAndUnfold(const parsingContext& ctx, const string& in)
+shared_ptr <text> text::decodeAndUnfold(const parsingContext& ctx, const string& in)
{
- ref <text> t = vmime::create <text>();
+ shared_ptr <text> t = make_shared <text>();
decodeAndUnfold(ctx, in, t.get());
@@ -400,7 +400,7 @@ text* text::decodeAndUnfold(const parsingContext& ctx, const string& in, text* g
out->removeAllWords();
- const std::vector <ref <word> > words = word::parseMultiple(ctx, in, 0, in.length(), NULL);
+ const std::vector <shared_ptr <word> > words = word::parseMultiple(ctx, in, 0, in.length(), NULL);
copy_vector(words, out->m_words);
@@ -408,9 +408,9 @@ text* text::decodeAndUnfold(const parsingContext& ctx, const string& in, text* g
}
-const std::vector <ref <component> > text::getChildComponents()
+const std::vector <shared_ptr <component> > text::getChildComponents()
{
- std::vector <ref <component> > list;
+ std::vector <shared_ptr <component> > list;
copy_vector(m_words, list);
@@ -422,7 +422,7 @@ const string text::getWholeBuffer() const
{
string res;
- for (std::vector <ref <word> >::const_iterator it = m_words.begin() ;
+ for (std::vector <shared_ptr <word> >::const_iterator it = m_words.begin() ;
it != m_words.end() ; ++it)
{
res += (*it)->getBuffer();
diff --git a/src/textPartFactory.cpp b/src/textPartFactory.cpp
index baad6292..85fea6e4 100644
--- a/src/textPartFactory.cpp
+++ b/src/textPartFactory.cpp
@@ -53,7 +53,7 @@ textPartFactory* textPartFactory::getInstance()
}
-ref <textPart> textPartFactory::create(const mediaType& type)
+shared_ptr <textPart> textPartFactory::create(const mediaType& type)
{
for (MapType::const_iterator it = m_map.begin() ;
it != m_map.end() ; ++it)
diff --git a/src/utility/encoder/encoderFactory.cpp b/src/utility/encoder/encoderFactory.cpp
index 02800b4c..098a810a 100644
--- a/src/utility/encoder/encoderFactory.cpp
+++ b/src/utility/encoder/encoderFactory.cpp
@@ -61,24 +61,24 @@ encoderFactory::~encoderFactory()
}
-encoderFactory* encoderFactory::getInstance()
+shared_ptr <encoderFactory> encoderFactory::getInstance()
{
static encoderFactory instance;
- return (&instance);
+ return shared_ptr <encoderFactory>(&instance, noop_shared_ptr_deleter <encoderFactory>());
}
-ref <encoder> encoderFactory::create(const string& name)
+shared_ptr <encoder> encoderFactory::create(const string& name)
{
return (getEncoderByName(name)->create());
}
-const ref <const encoderFactory::registeredEncoder> encoderFactory::getEncoderByName(const string& name) const
+const shared_ptr <const encoderFactory::registeredEncoder> encoderFactory::getEncoderByName(const string& name) const
{
const string lcName(utility::stringUtils::toLower(name));
- for (std::vector <ref <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
+ for (std::vector <shared_ptr <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
it != m_encoders.end() ; ++it)
{
if ((*it)->getName() == lcName)
@@ -95,17 +95,17 @@ size_t encoderFactory::getEncoderCount() const
}
-const ref <const encoderFactory::registeredEncoder> encoderFactory::getEncoderAt(const size_t pos) const
+const shared_ptr <const encoderFactory::registeredEncoder> encoderFactory::getEncoderAt(const size_t pos) const
{
return (m_encoders[pos]);
}
-const std::vector <ref <const encoderFactory::registeredEncoder> > encoderFactory::getEncoderList() const
+const std::vector <shared_ptr <const encoderFactory::registeredEncoder> > encoderFactory::getEncoderList() const
{
- std::vector <ref <const registeredEncoder> > res;
+ std::vector <shared_ptr <const registeredEncoder> > res;
- for (std::vector <ref <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
+ for (std::vector <shared_ptr <registeredEncoder> >::const_iterator it = m_encoders.begin() ;
it != m_encoders.end() ; ++it)
{
res.push_back(*it);
diff --git a/src/utility/parserInputStreamAdapter.cpp b/src/utility/parserInputStreamAdapter.cpp
index 0d6248cf..fd10a586 100644
--- a/src/utility/parserInputStreamAdapter.cpp
+++ b/src/utility/parserInputStreamAdapter.cpp
@@ -28,7 +28,7 @@ namespace vmime {
namespace utility {
-parserInputStreamAdapter::parserInputStreamAdapter(ref <seekableInputStream> stream)
+parserInputStreamAdapter::parserInputStreamAdapter(shared_ptr <seekableInputStream> stream)
: m_stream(stream)
{
}
@@ -53,7 +53,7 @@ stream::size_type parserInputStreamAdapter::read
}
-ref <seekableInputStream> parserInputStreamAdapter::getUnderlyingStream()
+shared_ptr <seekableInputStream> parserInputStreamAdapter::getUnderlyingStream()
{
return m_stream;
}
diff --git a/src/utility/seekableInputStreamRegionAdapter.cpp b/src/utility/seekableInputStreamRegionAdapter.cpp
index ec7c20cf..753d81a5 100644
--- a/src/utility/seekableInputStreamRegionAdapter.cpp
+++ b/src/utility/seekableInputStreamRegionAdapter.cpp
@@ -29,7 +29,7 @@ namespace utility {
seekableInputStreamRegionAdapter::seekableInputStreamRegionAdapter
- (ref <seekableInputStream> stream, const size_type begin, const size_type length)
+ (shared_ptr <seekableInputStream> stream, const size_type begin, const size_type length)
: m_stream(stream), m_begin(begin), m_length(length), m_position(0)
{
}
diff --git a/src/utility/smartPtr.cpp b/src/utility/smartPtr.cpp
deleted file mode 100644
index 78cf9032..00000000
--- a/src/utility/smartPtr.cpp
+++ /dev/null
@@ -1,41 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#include "vmime/object.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
-
-namespace vmime {
-namespace utility {
-
-
-void refManager::deleteObjectImpl(object* obj)
-{
- obj->setRefManager(0);
- delete obj;
-}
-
-
-} // utility
-} // vmime
-
diff --git a/src/utility/smartPtrInt.cpp b/src/utility/smartPtrInt.cpp
deleted file mode 100644
index 2bb9d70d..00000000
--- a/src/utility/smartPtrInt.cpp
+++ /dev/null
@@ -1,295 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#include "vmime/utility/smartPtrInt.hpp"
-#include "vmime/object.hpp"
-
-
-namespace vmime {
-namespace utility {
-
-
-// static
-refManager* refManager::create(object* obj)
-{
- return new refManagerImpl(obj);
-}
-
-
-//
-// refManager
-//
-
-refManagerImpl::refManagerImpl(object* obj)
- : m_object(obj), m_strongCount(1), m_weakCount(1)
-{
-}
-
-
-refManagerImpl::~refManagerImpl()
-{
-}
-
-
-bool refManagerImpl::addStrong()
-{
- if (m_strongCount <= 0)
- return false;
-
- m_strongCount.increment();
- m_weakCount.increment();
-
- return true;
-}
-
-
-void refManagerImpl::releaseStrong()
-{
- if (m_strongCount.decrement() <= 0)
- deleteObject();
-
- releaseWeak();
-}
-
-
-void refManagerImpl::addWeak()
-{
- m_weakCount.increment();
-}
-
-
-void refManagerImpl::releaseWeak()
-{
- if (m_weakCount.decrement() <= 0)
- deleteManager();
-}
-
-
-object* refManagerImpl::getObject()
-{
- return m_object;
-}
-
-
-void refManagerImpl::deleteManager()
-{
- delete this;
-}
-
-
-void refManagerImpl::deleteObject()
-{
- try
- {
- deleteObjectImpl(m_object);
- }
- catch (...)
- {
- // Exception in destructor
- }
-
- m_object = 0;
-}
-
-
-long refManagerImpl::getStrongRefCount() const
-{
- return m_strongCount;
-}
-
-
-long refManagerImpl::getWeakRefCount() const
-{
- return m_weakCount;
-}
-
-
-
-//
-// refCounter
-//
-
-#ifdef _WIN32
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(initialValue)
-{
-}
-
-
-refCounter::~refCounter()
-{
-}
-
-
-long refCounter::increment()
-{
- return InterlockedIncrement(&m_value);
-}
-
-
-long refCounter::decrement()
-{
- return InterlockedDecrement(&m_value);
-}
-
-
-refCounter::operator long() const
-{
- return m_value;
-}
-
-
-#elif defined(__GNUC__) && (defined(__GLIBCPP__) || defined(__GLIBCXX__))
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(static_cast <int>(initialValue))
-{
-}
-
-
-refCounter::~refCounter()
-{
-}
-
-
-long refCounter::increment()
-{
-#if __GNUC_MINOR__ < 4 && __GNUC__ < 4
- return __exchange_and_add(&m_value, 1) + 1;
-#else
- return __gnu_cxx::__exchange_and_add(&m_value, 1) + 1;
-#endif
-}
-
-
-long refCounter::decrement()
-{
-#if __GNUC_MINOR__ < 4 && __GNUC__ < 4
- return __exchange_and_add(&m_value, -1) - 1;
-#else
- return __gnu_cxx::__exchange_and_add(&m_value, -1) - 1;
-#endif
-}
-
-
-refCounter::operator long() const
-{
-#if __GNUC_MINOR__ < 4 && __GNUC__ < 4
- return static_cast <long>(__exchange_and_add(&m_value, 0));
-#else
- return static_cast <long>(__gnu_cxx::__exchange_and_add(&m_value, 0));
-#endif
-}
-
-
-#elif defined(VMIME_HAVE_PTHREAD)
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(initialValue)
-{
- pthread_mutexattr_t attr;
- pthread_mutexattr_init(&attr);
- pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_NORMAL);
- pthread_mutex_init(&m_mutex, &attr);
- pthread_mutexattr_destroy(&attr);
-}
-
-
-refCounter::~refCounter()
-{
- pthread_mutex_destroy(&m_mutex);
-}
-
-
-long refCounter::increment()
-{
- long value;
-
- pthread_mutex_lock(&m_mutex);
- value = ++m_value;
- pthread_mutex_unlock(&m_mutex);
-
- return value;
-}
-
-
-long refCounter::decrement()
-{
- long value;
-
- pthread_mutex_lock(&m_mutex);
- value = --m_value;
- pthread_mutex_unlock(&m_mutex);
-
- return value;
-}
-
-
-refCounter::operator long() const
-{
- return m_value;
-}
-
-
-#else // not thread-safe implementation
-
-
-refCounter::refCounter(const long initialValue)
- : m_value(initialValue)
-{
-}
-
-
-refCounter::~refCounter()
-{
-}
-
-
-long refCounter::increment()
-{
- return ++m_value;
-}
-
-
-long refCounter::decrement()
-{
- return --m_value;
-}
-
-
-refCounter::operator long() const
-{
- return m_value;
-}
-
-
-#endif
-
-
-} // utility
-} // vmime
-
diff --git a/src/word.cpp b/src/word.cpp
index 8e254865..fc791b53 100644
--- a/src/word.cpp
+++ b/src/word.cpp
@@ -25,7 +25,6 @@
#include "vmime/text.hpp"
#include "vmime/utility/stringUtils.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/parserHelpers.hpp"
#include "vmime/utility/outputStreamStringAdapter.hpp"
@@ -66,7 +65,7 @@ word::word(const string& buffer, const charset& charset)
}
-ref <word> word::parseNext
+shared_ptr <word> word::parseNext
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition,
bool prevIsEncoded, bool* isEncoded, bool isFirst)
@@ -128,7 +127,7 @@ ref <word> word::parseNext
if (prevIsEncoded && !isFirst)
unencoded = whiteSpaces + unencoded;
- ref <word> w = vmime::create <word>(unencoded, defaultCharset);
+ shared_ptr <word> w = make_shared <word>(unencoded, defaultCharset);
w->setParsedBounds(position, pos);
if (newPosition)
@@ -185,7 +184,7 @@ ref <word> word::parseNext
pos += 2; // ?=
- ref <word> w = vmime::create <word>();
+ shared_ptr <word> w = make_shared <word>();
w->parse(buffer, wordStart, pos, NULL);
if (newPosition)
@@ -211,7 +210,7 @@ ref <word> word::parseNext
// Treat unencoded text at the end of the buffer
if (!unencoded.empty())
{
- ref <word> w = vmime::create <word>(unencoded, defaultCharset);
+ shared_ptr <word> w = make_shared <word>(unencoded, defaultCharset);
w->setParsedBounds(position, end);
if (newPosition)
@@ -227,12 +226,12 @@ ref <word> word::parseNext
}
-const std::vector <ref <word> > word::parseMultiple
+const std::vector <shared_ptr <word> > word::parseMultiple
(const parsingContext& ctx, const string& buffer, const string::size_type position,
const string::size_type end, string::size_type* newPosition)
{
- std::vector <ref <word> > res;
- ref <word> w;
+ std::vector <shared_ptr <word> > res;
+ shared_ptr <word> w;
string::size_type pos = position;
@@ -743,9 +742,9 @@ const string word::getConvertedText(const charset& dest, const charsetConverterO
}
-ref <component> word::clone() const
+shared_ptr <component> word::clone() const
{
- return vmime::create <word>(m_buffer, m_charset);
+ return make_shared <word>(m_buffer, m_charset);
}
@@ -785,9 +784,9 @@ void word::setBuffer(const string& buffer)
}
-const std::vector <ref <component> > word::getChildComponents()
+const std::vector <shared_ptr <component> > word::getChildComponents()
{
- return std::vector <ref <component> >();
+ return std::vector <shared_ptr <component> >();
}
diff --git a/src/wordEncoder.cpp b/src/wordEncoder.cpp
index 332f9bf2..b3e98fd2 100644
--- a/src/wordEncoder.cpp
+++ b/src/wordEncoder.cpp
@@ -68,11 +68,11 @@ wordEncoder::wordEncoder(const string& buffer, const charset& charset, const Enc
if (m_encoding == ENCODING_B64)
{
- m_encoder = vmime::create <utility::encoder::b64Encoder>();
+ m_encoder = make_shared <utility::encoder::b64Encoder>();
}
else // ENCODING_QP
{
- m_encoder = vmime::create <utility::encoder::qpEncoder>();
+ m_encoder = make_shared <utility::encoder::qpEncoder>();
m_encoder->getProperties()["rfc2047"] = true;
}
}
@@ -168,7 +168,7 @@ const string wordEncoder::getNextChunk(const string::size_type maxLength)
// Fully RFC-compliant encoding
else
{
- ref <charsetConverter> conv = charsetConverter::create(charsets::UTF_8, m_charset);
+ shared_ptr <charsetConverter> conv = charsetConverter::create(charsets::UTF_8, m_charset);
string::size_type inputCount = 0;
string::size_type outputCount = 0;
diff --git a/tests/misc/importanceHelperTest.cpp b/tests/misc/importanceHelperTest.cpp
index f4696efb..9a4b86f7 100644
--- a/tests/misc/importanceHelperTest.cpp
+++ b/tests/misc/importanceHelperTest.cpp
@@ -49,7 +49,7 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
void testResetImportance()
{
- vmime::ref <vmime::header> hdr = vmime::create <vmime::header>();
+ vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
hdr->getField("Importance")->setValue("xxx");
hdr->getField("X-Priority")->setValue("yyy");
@@ -69,7 +69,7 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
void testSetImportanceImpl(const vmime::misc::importanceHelper::Importance i,
const std::string& ImportanceValue, const std::string& XPriorityValue)
{
- vmime::ref <vmime::header> hdr = vmime::create <vmime::header>();
+ vmime::shared_ptr <vmime::header> hdr = vmime::make_shared <vmime::header>();
vmime::misc::importanceHelper::setImportanceHeader(hdr, i);
@@ -117,12 +117,12 @@ VMIME_TEST_SUITE_BEGIN(importanceHelperTest)
const vmime::misc::importanceHelper::Importance i2,
const std::string& ImportanceValue, const std::string& XPriorityValue)
{
- vmime::ref <vmime::header> hdr1 = vmime::create <vmime::header>();
+ vmime::shared_ptr <vmime::header> hdr1 = vmime::make_shared <vmime::header>();
hdr1->getField("Importance")->setValue(ImportanceValue);
VASSERT_EQ("1", i1, vmime::misc::importanceHelper::getImportanceHeader(hdr1));
- vmime::ref <vmime::header> hdr2 = vmime::create <vmime::header>();
+ vmime::shared_ptr <vmime::header> hdr2 = vmime::make_shared <vmime::header>();
hdr2->getField("X-Priority")->setValue(XPriorityValue);
VASSERT_EQ("2", i2, vmime::misc::importanceHelper::getImportanceHeader(hdr2));
diff --git a/tests/net/imap/IMAPParserTest.cpp b/tests/net/imap/IMAPParserTest.cpp
index 93f6e6fd..30e8f574 100644
--- a/tests/net/imap/IMAPParserTest.cpp
+++ b/tests/net/imap/IMAPParserTest.cpp
@@ -37,18 +37,19 @@ VMIME_TEST_SUITE_BEGIN(IMAPParserTest)
// For Apple iCloud IMAP server
void testExtraSpaceInCapaResponse()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <vmime::net::imap::IMAPTag> tag =
- vmime::create <vmime::net::imap::IMAPTag>();
+ vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
+ vmime::make_shared <vmime::net::imap::IMAPTag>();
socket->localSend(
"* CAPABILITY IMAP4rev1 AUTH=ATOKEN AUTH=PLAIN \r\n" // extra space at end
"a001 OK Capability completed.\r\n");
- vmime::ref <vmime::net::imap::IMAPParser> parser =
- vmime::create <vmime::net::imap::IMAPParser>(tag, socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <vmime::net::imap::IMAPParser> parser =
+ vmime::make_shared <vmime::net::imap::IMAPParser>
+ (tag, vmime::dynamicCast <vmime::net::socket>(socket), toh);
parser->setStrict(false);
VASSERT_NO_THROW("non-strict mode", parser->readResponse(/* literalHandler */ NULL));
diff --git a/tests/net/imap/IMAPTagTest.cpp b/tests/net/imap/IMAPTagTest.cpp
index 26ed87c5..db04537a 100644
--- a/tests/net/imap/IMAPTagTest.cpp
+++ b/tests/net/imap/IMAPTagTest.cpp
@@ -38,16 +38,16 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest)
void testConstruct()
{
- vmime::ref <vmime::net::imap::IMAPTag> tag =
- vmime::create <vmime::net::imap::IMAPTag>();
+ vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
+ vmime::make_shared <vmime::net::imap::IMAPTag>();
VASSERT_EQ("init", "a001", static_cast <vmime::string>(*tag));
}
void testIncrement()
{
- vmime::ref <vmime::net::imap::IMAPTag> tag =
- vmime::create <vmime::net::imap::IMAPTag>();
+ vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
+ vmime::make_shared <vmime::net::imap::IMAPTag>();
(*tag)++;
VASSERT_EQ("init", "a002", static_cast <vmime::string>(*tag));
@@ -61,8 +61,8 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest)
void testReset()
{
- vmime::ref <vmime::net::imap::IMAPTag> tag =
- vmime::create <vmime::net::imap::IMAPTag>();
+ vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
+ vmime::make_shared <vmime::net::imap::IMAPTag>();
for (int i = tag->number() ; i < tag->maximumNumber() ; ++i)
(*tag)++;
@@ -76,8 +76,8 @@ VMIME_TEST_SUITE_BEGIN(imapTagTest)
void testNumber()
{
- vmime::ref <vmime::net::imap::IMAPTag> tag =
- vmime::create <vmime::net::imap::IMAPTag>();
+ vmime::shared_ptr <vmime::net::imap::IMAPTag> tag =
+ vmime::make_shared <vmime::net::imap::IMAPTag>();
for (int i = 0 ; i < 41 ; ++i)
(*tag)++;
diff --git a/tests/net/maildir/maildirStoreTest.cpp b/tests/net/maildir/maildirStoreTest.cpp
index 358e095f..34e8249c 100644
--- a/tests/net/maildir/maildirStoreTest.cpp
+++ b/tests/net/maildir/maildirStoreTest.cpp
@@ -187,7 +187,7 @@ public:
{
createMaildir(TEST_MAILDIR_KMAIL, TEST_MAILDIRFILES_KMAIL);
- vmime::ref <vmime::net::maildir::maildirStore> store =
+ vmime::shared_ptr <vmime::net::maildir::maildirStore> store =
vmime::dynamicCast <vmime::net::maildir::maildirStore>(createAndConnectStore());
VASSERT_EQ("*", "kmail", store->getFormat()->getName());
@@ -199,7 +199,7 @@ public:
{
createMaildir(TEST_MAILDIR_COURIER, TEST_MAILDIRFILES_COURIER);
- vmime::ref <vmime::net::maildir::maildirStore> store =
+ vmime::shared_ptr <vmime::net::maildir::maildirStore> store =
vmime::dynamicCast <vmime::net::maildir::maildirStore>(createAndConnectStore());
VASSERT_EQ("*", "courier", store->getFormat()->getName());
@@ -223,11 +223,11 @@ public:
createMaildir(dirs, files);
// Connect to store
- vmime::ref <vmime::net::store> store = createAndConnectStore();
- vmime::ref <vmime::net::folder> rootFolder = store->getRootFolder();
+ vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
+ vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
// Get root folders, not recursive
- const std::vector <vmime::ref <vmime::net::folder> >
+ const std::vector <vmime::shared_ptr <vmime::net::folder> >
rootFolders = rootFolder->getFolders(false);
VASSERT_EQ("1", 2, rootFolders.size());
@@ -253,11 +253,11 @@ public:
createMaildir(dirs, files);
// Connect to store
- vmime::ref <vmime::net::store> store = createAndConnectStore();
- vmime::ref <vmime::net::folder> rootFolder = store->getRootFolder();
+ vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
+ vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
// Get all folders, recursive
- const std::vector <vmime::ref <vmime::net::folder> >
+ const std::vector <vmime::shared_ptr <vmime::net::folder> >
allFolders = rootFolder->getFolders(true);
VASSERT_EQ("1", 5, allFolders.size());
@@ -285,10 +285,10 @@ public:
{
createMaildir(dirs, files);
- vmime::ref <vmime::net::store> store = createAndConnectStore();
- vmime::ref <vmime::net::folder> rootFolder = store->getRootFolder();
+ vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
+ vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
- vmime::ref <vmime::net::folder> folder = store->getFolder
+ vmime::shared_ptr <vmime::net::folder> folder = store->getFolder
(fpath() / "Folder" / "SubFolder" / "SubSubFolder2");
int count, unseen;
@@ -298,7 +298,7 @@ public:
folder->open(vmime::net::folder::MODE_READ_ONLY);
- vmime::ref <vmime::net::message> msg = folder->getMessage(1);
+ vmime::shared_ptr <vmime::net::message> msg = folder->getMessage(1);
folder->fetchMessage(msg, vmime::net::fetchAttributes::SIZE);
@@ -346,17 +346,17 @@ public:
{
createMaildir(dirs, files);
- vmime::ref <vmime::net::store> store = createAndConnectStore();
- vmime::ref <vmime::net::folder> rootFolder = store->getRootFolder();
+ vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
+ vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
// Rename "Folder/SubFolder" to "Folder/foo"
- vmime::ref <vmime::net::folder> folder = store->getFolder
+ vmime::shared_ptr <vmime::net::folder> folder = store->getFolder
(fpath() / "Folder" / "SubFolder");
folder->rename(fpath() / "Folder" / "foo");
// Ensure folder and its subfolders have been renamed
- const std::vector <vmime::ref <vmime::net::folder> >
+ const std::vector <vmime::shared_ptr <vmime::net::folder> >
allFolders = rootFolder->getFolders(true);
VASSERT_EQ("1", 5, allFolders.size());
@@ -387,17 +387,17 @@ public:
{
createMaildir(dirs, files);
- vmime::ref <vmime::net::store> store = createAndConnectStore();
- vmime::ref <vmime::net::folder> rootFolder = store->getRootFolder();
+ vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
+ vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
// Destroy "Folder/SubFolder" (total: 3 folders)
- vmime::ref <vmime::net::folder> folder = store->getFolder
+ vmime::shared_ptr <vmime::net::folder> folder = store->getFolder
(fpath() / "Folder" / "SubFolder");
folder->destroy();
// Ensure folder and its subfolders have been deleted and other folders still exist
- const std::vector <vmime::ref <vmime::net::folder> >
+ const std::vector <vmime::shared_ptr <vmime::net::folder> >
allFolders = rootFolder->getFolders(true);
VASSERT_EQ("1", 2, allFolders.size());
@@ -425,8 +425,8 @@ public:
{
createMaildir(dirs, files);
- vmime::ref <vmime::net::store> store = createAndConnectStore();
- vmime::ref <vmime::net::folder> rootFolder = store->getRootFolder();
+ vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
+ vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
VASSERT("1", store->getFolder(fpath() / "Folder" / "SubFolder")->exists());
VASSERT("2", !store->getFolder(fpath() / "Folder" / "SubSubFolder1")->exists());
@@ -451,8 +451,8 @@ public:
{
createMaildir(dirs, files);
- vmime::ref <vmime::net::store> store = createAndConnectStore();
- vmime::ref <vmime::net::folder> rootFolder = store->getRootFolder();
+ vmime::shared_ptr <vmime::net::store> store = createAndConnectStore();
+ vmime::shared_ptr <vmime::net::folder> rootFolder = store->getRootFolder();
VASSERT("Before", !store->getFolder(fpath() / "Folder" / "NewFolder")->exists());
@@ -469,12 +469,12 @@ private:
vmime::utility::file::path m_tempPath;
- vmime::ref <vmime::net::store> createAndConnectStore()
+ vmime::shared_ptr <vmime::net::store> createAndConnectStore()
{
- vmime::ref <vmime::net::session> session =
- vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> session =
+ vmime::make_shared <vmime::net::session>();
- vmime::ref <vmime::net::store> store =
+ vmime::shared_ptr <vmime::net::store> store =
session->getStore(getStoreURL());
store->connect();
@@ -482,8 +482,8 @@ private:
return store;
}
- const vmime::ref <vmime::net::folder> findFolder
- (const std::vector <vmime::ref <vmime::net::folder> >& folders,
+ const vmime::shared_ptr <vmime::net::folder> findFolder
+ (const std::vector <vmime::shared_ptr <vmime::net::folder> >& folders,
const vmime::net::folder::path& path)
{
for (unsigned int i = 0, n = folders.size() ; i < n ; ++i)
@@ -492,12 +492,12 @@ private:
return folders[i];
}
- return NULL;
+ return vmime::null;
}
const vmime::utility::url getStoreURL()
{
- vmime::ref <vmime::utility::fileSystemFactory> fsf =
+ vmime::shared_ptr <vmime::utility::fileSystemFactory> fsf =
vmime::platform::getHandler()->getFileSystemFactory();
vmime::utility::url url(std::string("maildir://localhost")
@@ -508,15 +508,15 @@ private:
void createMaildir(const vmime::string* const dirs, const vmime::string* const files)
{
- vmime::ref <vmime::utility::fileSystemFactory> fsf =
+ vmime::shared_ptr <vmime::utility::fileSystemFactory> fsf =
vmime::platform::getHandler()->getFileSystemFactory();
- vmime::ref <vmime::utility::file> rootDir = fsf->create(m_tempPath);
+ vmime::shared_ptr <vmime::utility::file> rootDir = fsf->create(m_tempPath);
rootDir->createDirectory(false);
for (vmime::string const* dir = dirs ; *dir != "*" ; ++dir)
{
- vmime::ref <vmime::utility::file> fdir = fsf->create(m_tempPath / fsf->stringToPath(*dir));
+ vmime::shared_ptr <vmime::utility::file> fdir = fsf->create(m_tempPath / fsf->stringToPath(*dir));
fdir->createDirectory(false);
}
@@ -524,39 +524,39 @@ private:
{
const vmime::string& contents = *(file + 1);
- vmime::ref <vmime::utility::file> ffile = fsf->create(m_tempPath / fsf->stringToPath(*file));
+ vmime::shared_ptr <vmime::utility::file> ffile = fsf->create(m_tempPath / fsf->stringToPath(*file));
ffile->createFile();
- vmime::ref <vmime::utility::fileWriter> fileWriter = ffile->getFileWriter();
- vmime::ref <vmime::utility::outputStream> os = fileWriter->getOutputStream();
+ vmime::shared_ptr <vmime::utility::fileWriter> fileWriter = ffile->getFileWriter();
+ vmime::shared_ptr <vmime::utility::outputStream> os = fileWriter->getOutputStream();
os->write(contents.data(), contents.length());
os->flush();
- fileWriter = NULL;
+ fileWriter = vmime::null;
}
}
void destroyMaildir()
{
- vmime::ref <vmime::utility::fileSystemFactory> fsf =
+ vmime::shared_ptr <vmime::utility::fileSystemFactory> fsf =
vmime::platform::getHandler()->getFileSystemFactory();
recursiveDelete(fsf->create(m_tempPath));
}
- void recursiveDelete(vmime::ref <vmime::utility::file> dir)
+ void recursiveDelete(vmime::shared_ptr <vmime::utility::file> dir)
{
if (!dir->exists() || !dir->isDirectory())
return;
- vmime::ref <vmime::utility::fileIterator> files = dir->getFiles();
+ vmime::shared_ptr <vmime::utility::fileIterator> files = dir->getFiles();
// First, delete files and subdirectories in this directory
while (files->hasMoreElements())
{
- vmime::ref <vmime::utility::file> file = files->nextElement();
+ vmime::shared_ptr <vmime::utility::file> file = files->nextElement();
if (file->isDirectory())
{
diff --git a/tests/net/pop3/POP3CommandTest.cpp b/tests/net/pop3/POP3CommandTest.cpp
index 14c92be4..4733c96b 100644
--- a/tests/net/pop3/POP3CommandTest.cpp
+++ b/tests/net/pop3/POP3CommandTest.cpp
@@ -59,7 +59,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testCreateCommand()
{
- vmime::ref <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND");
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND", cmd->getText());
@@ -67,7 +67,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testCreateCommandParams()
{
- vmime::ref <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText());
@@ -75,7 +75,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testCAPA()
{
- vmime::ref <POP3Command> cmd = POP3Command::CAPA();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::CAPA();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "CAPA", cmd->getText());
@@ -83,7 +83,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testNOOP()
{
- vmime::ref <POP3Command> cmd = POP3Command::NOOP();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::NOOP();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "NOOP", cmd->getText());
@@ -91,7 +91,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testAUTH()
{
- vmime::ref <POP3Command> cmd = POP3Command::AUTH("saslmechanism");
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::AUTH("saslmechanism");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText());
@@ -99,7 +99,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testSTLS()
{
- vmime::ref <POP3Command> cmd = POP3Command::STLS();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::STLS();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "STLS", cmd->getText());
@@ -107,7 +107,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testAPOP()
{
- vmime::ref <POP3Command> cmd = POP3Command::APOP("user", "digest");
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::APOP("user", "digest");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "APOP user digest", cmd->getText());
@@ -115,7 +115,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testUSER()
{
- vmime::ref <POP3Command> cmd = POP3Command::USER("user");
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::USER("user");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "USER user", cmd->getText());
@@ -123,7 +123,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testPASS()
{
- vmime::ref <POP3Command> cmd = POP3Command::PASS("pass");
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::PASS("pass");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "PASS pass", cmd->getText());
@@ -131,7 +131,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testSTAT()
{
- vmime::ref <POP3Command> cmd = POP3Command::STAT();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::STAT();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "STAT", cmd->getText());
@@ -139,7 +139,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testLIST()
{
- vmime::ref <POP3Command> cmd = POP3Command::LIST();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "LIST", cmd->getText());
@@ -147,7 +147,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testLISTMessage()
{
- vmime::ref <POP3Command> cmd = POP3Command::LIST(42);
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::LIST(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "LIST 42", cmd->getText());
@@ -155,7 +155,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testUIDL()
{
- vmime::ref <POP3Command> cmd = POP3Command::UIDL();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "UIDL", cmd->getText());
@@ -163,7 +163,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testUIDLMessage()
{
- vmime::ref <POP3Command> cmd = POP3Command::UIDL(42);
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::UIDL(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "UIDL 42", cmd->getText());
@@ -171,7 +171,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testDELE()
{
- vmime::ref <POP3Command> cmd = POP3Command::DELE(42);
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::DELE(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "DELE 42", cmd->getText());
@@ -179,7 +179,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testRETR()
{
- vmime::ref <POP3Command> cmd = POP3Command::RETR(42);
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::RETR(42);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RETR 42", cmd->getText());
@@ -187,7 +187,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testTOP()
{
- vmime::ref <POP3Command> cmd = POP3Command::TOP(42, 567);
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::TOP(42, 567);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "TOP 42 567", cmd->getText());
@@ -195,7 +195,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testRSET()
{
- vmime::ref <POP3Command> cmd = POP3Command::RSET();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::RSET();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RSET", cmd->getText());
@@ -203,7 +203,7 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testQUIT()
{
- vmime::ref <POP3Command> cmd = POP3Command::QUIT();
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::QUIT();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "QUIT", cmd->getText());
@@ -211,11 +211,12 @@ VMIME_TEST_SUITE_BEGIN(POP3CommandTest)
void testWriteToSocket()
{
- vmime::ref <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
+ vmime::shared_ptr <POP3Command> cmd = POP3Command::createCommand("MY_COMMAND param1 param2");
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (sok.dynamicCast <vmime::net::socket>(), vmime::null);
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(sok),
+ vmime::shared_ptr <vmime::net::timeoutHandler>());
cmd->send(conn);
diff --git a/tests/net/pop3/POP3ResponseTest.cpp b/tests/net/pop3/POP3ResponseTest.cpp
index f1fbcd54..2d3b3d32 100644
--- a/tests/net/pop3/POP3ResponseTest.cpp
+++ b/tests/net/pop3/POP3ResponseTest.cpp
@@ -47,15 +47,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
void testSingleLineResponseOK()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("+OK Response Text\r\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readResponse(conn);
VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode());
@@ -67,15 +67,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
void testSingleLineResponseERR()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("-ERR Response Text\r\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readResponse(conn);
VASSERT_EQ("Code", POP3Response::CODE_ERR, resp->getCode());
@@ -87,15 +87,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
void testSingleLineResponseReady()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("+ challenge_string\r\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readResponse(conn);
VASSERT_EQ("Code", POP3Response::CODE_READY, resp->getCode());
@@ -107,15 +107,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
void testSingleLineResponseInvalid()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("Invalid Response Text\r\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readResponse(conn);
VASSERT_EQ("Code", POP3Response::CODE_ERR, resp->getCode());
@@ -127,15 +127,15 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
void testSingleLineResponseLF()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("+OK Response terminated by LF\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readResponse(conn);
VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode());
@@ -147,18 +147,18 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
void testMultiLineResponse()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("+OK Response Text\r\n");
socket->localSend("Line 1\r\n");
socket->localSend("Line 2\r\n");
socket->localSend(".\r\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readMultilineResponse(conn);
VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode());
@@ -172,18 +172,18 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
void testMultiLineResponseLF()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("+OK Response Text\n");
socket->localSend("Line 1\n");
socket->localSend("Line 2\n");
socket->localSend(".\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readMultilineResponse(conn);
VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode());
@@ -202,11 +202,11 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
for (unsigned int i = 0 ; i < 5000 ; ++i)
data << "VMIME.VMIME\nVMIME\r\nVMIME_VMIME";
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("+OK Large Response Follows\n");
socket->localSend(data.str());
@@ -215,7 +215,7 @@ VMIME_TEST_SUITE_BEGIN(POP3ResponseTest)
vmime::string receivedData;
vmime::utility::outputStreamStringAdapter receivedDataStream(receivedData);
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readLargeResponse(conn, receivedDataStream, NULL, 0);
VASSERT_EQ("Code", POP3Response::CODE_OK, resp->getCode());
diff --git a/tests/net/pop3/POP3StoreTest.cpp b/tests/net/pop3/POP3StoreTest.cpp
index d938f472..5517f770 100644
--- a/tests/net/pop3/POP3StoreTest.cpp
+++ b/tests/net/pop3/POP3StoreTest.cpp
@@ -39,29 +39,29 @@ VMIME_TEST_SUITE_BEGIN(POP3StoreTest)
void testCreateFromURL()
{
- vmime::ref <vmime::net::session> sess
- = vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> sess
+ = vmime::make_shared <vmime::net::session>();
// POP3
vmime::utility::url url("pop3://pop3.vmime.org");
- vmime::ref <vmime::net::store> store = sess->getStore(url);
+ vmime::shared_ptr <vmime::net::store> store = sess->getStore(url);
VASSERT_TRUE("pop3", typeid(*store) == typeid(vmime::net::pop3::POP3Store));
// POP3S
vmime::utility::url url2("pop3s://pop3s.vmime.org");
- vmime::ref <vmime::net::store> store2 = sess->getStore(url2);
+ vmime::shared_ptr <vmime::net::store> store2 = sess->getStore(url2);
VASSERT_TRUE("pop3s", typeid(*store2) == typeid(vmime::net::pop3::POP3SStore));
}
void testConnectToInvalidServer()
{
- vmime::ref <vmime::net::session> sess
- = vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> sess
+ = vmime::make_shared <vmime::net::session>();
vmime::utility::url url("pop3://invalid-pop3-server");
- vmime::ref <vmime::net::store> store = sess->getStore(url);
+ vmime::shared_ptr <vmime::net::store> store = sess->getStore(url);
VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error);
}
diff --git a/tests/net/pop3/POP3TestUtils.hpp b/tests/net/pop3/POP3TestUtils.hpp
index 26b6601a..1c6e8935 100644
--- a/tests/net/pop3/POP3TestUtils.hpp
+++ b/tests/net/pop3/POP3TestUtils.hpp
@@ -29,25 +29,26 @@ class POP3ConnectionTest : public vmime::net::pop3::POP3Connection
{
public:
- POP3ConnectionTest(vmime::ref <vmime::net::socket> socket,
- vmime::ref <vmime::net::timeoutHandler> timeoutHandler)
- : POP3Connection(NULL, NULL),
+ POP3ConnectionTest(vmime::shared_ptr <vmime::net::socket> socket,
+ vmime::shared_ptr <vmime::net::timeoutHandler> timeoutHandler)
+ : POP3Connection(vmime::shared_ptr <vmime::net::pop3::POP3Store>(),
+ vmime::shared_ptr <vmime::security::authenticator>()),
m_socket(socket), m_timeoutHandler(timeoutHandler)
{
}
- vmime::ref <vmime::net::socket> getSocket()
+ vmime::shared_ptr <vmime::net::socket> getSocket()
{
return m_socket;
}
- vmime::ref <vmime::net::timeoutHandler> getTimeoutHandler()
+ vmime::shared_ptr <vmime::net::timeoutHandler> getTimeoutHandler()
{
return m_timeoutHandler;
}
private:
- vmime::ref <vmime::net::socket> m_socket;
- vmime::ref <vmime::net::timeoutHandler> m_timeoutHandler;
+ vmime::shared_ptr <vmime::net::socket> m_socket;
+ vmime::shared_ptr <vmime::net::timeoutHandler> m_timeoutHandler;
};
diff --git a/tests/net/pop3/POP3UtilsTest.cpp b/tests/net/pop3/POP3UtilsTest.cpp
index 9d443ddb..55a99806 100644
--- a/tests/net/pop3/POP3UtilsTest.cpp
+++ b/tests/net/pop3/POP3UtilsTest.cpp
@@ -41,11 +41,11 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest)
void testParseMultiListOrUidlResponse()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh = vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh = vmime::make_shared <testTimeoutHandler>();
- vmime::ref <POP3ConnectionTest> conn = vmime::create <POP3ConnectionTest>
- (socket.dynamicCast <vmime::net::socket>(), toh);
+ vmime::shared_ptr <POP3ConnectionTest> conn = vmime::make_shared <POP3ConnectionTest>
+ (vmime::dynamicCast <vmime::net::socket>(socket), toh);
socket->localSend("+OK Response Text\r\n");
socket->localSend("1 abcdef\r\n");
@@ -55,7 +55,7 @@ VMIME_TEST_SUITE_BEGIN(POP3UtilsTest)
socket->localSend("8 yz \r\n");
socket->localSend(".\r\n");
- vmime::ref <POP3Response> resp =
+ vmime::shared_ptr <POP3Response> resp =
POP3Response::readMultilineResponse(conn);
std::map <int, vmime::string> result;
diff --git a/tests/net/smtp/SMTPCommandSetTest.cpp b/tests/net/smtp/SMTPCommandSetTest.cpp
index 0cf4b03b..af250078 100644
--- a/tests/net/smtp/SMTPCommandSetTest.cpp
+++ b/tests/net/smtp/SMTPCommandSetTest.cpp
@@ -46,7 +46,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testCreate()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
VASSERT_NOT_NULL("Not null", cset);
VASSERT_FALSE("Finished", cset->isFinished());
@@ -54,7 +54,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testCreatePipeline()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
VASSERT_NOT_NULL("Not null", cset);
VASSERT_FALSE("Finished", cset->isFinished());
@@ -62,14 +62,14 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testAddCommand()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")));
VASSERT_EQ("Text", "MY_COMMAND1\r\n", cset->getText());
VASSERT_NO_THROW("No throw 2", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")));
VASSERT_EQ("Text", "MY_COMMAND1\r\nMY_COMMAND2\r\n", cset->getText());
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
cset->writeToSocket(sok);
VASSERT_FALSE("Finished", cset->isFinished());
@@ -83,14 +83,14 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testAddCommandPipeline()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
VASSERT_NO_THROW("No throw 1", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1")));
VASSERT_EQ("Text", "MY_COMMAND1\r\n", cset->getText());
VASSERT_NO_THROW("No throw 2", cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2")));
VASSERT_EQ("Text", "MY_COMMAND1\r\nMY_COMMAND2\r\n", cset->getText());
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
vmime::string response;
cset->writeToSocket(sok);
@@ -105,12 +105,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testWriteToSocket()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"));
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
vmime::string response;
cset->writeToSocket(sok);
@@ -126,12 +126,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testWriteToSocketPipeline()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"));
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
vmime::string response;
cset->writeToSocket(sok);
@@ -142,12 +142,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testGetLastCommandSent()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ false);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"));
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
cset->writeToSocket(sok);
VASSERT_EQ("Cmd 1", "MY_COMMAND1", cset->getLastCommandSent()->getText());
@@ -158,12 +158,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandSetTest)
void testGetLastCommandSentPipeline()
{
- vmime::ref <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
+ vmime::shared_ptr <SMTPCommandSet> cset = SMTPCommandSet::create(/* pipelining */ true);
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND1"));
cset->addCommand(SMTPCommand::createCommand("MY_COMMAND2"));
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
cset->writeToSocket(sok);
VASSERT_EQ("Cmd 1", "MY_COMMAND1", cset->getLastCommandSent()->getText());
diff --git a/tests/net/smtp/SMTPCommandTest.cpp b/tests/net/smtp/SMTPCommandTest.cpp
index 9a2c90fc..6d466865 100644
--- a/tests/net/smtp/SMTPCommandTest.cpp
+++ b/tests/net/smtp/SMTPCommandTest.cpp
@@ -57,7 +57,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testCreateCommand()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND");
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND", cmd->getText());
@@ -65,7 +65,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testCreateCommandParams()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2");
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MY_COMMAND param1 param2", cmd->getText());
@@ -73,7 +73,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testHELO()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::HELO("hostname");
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::HELO("hostname");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "HELO hostname", cmd->getText());
@@ -81,7 +81,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testEHLO()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::EHLO("hostname");
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::EHLO("hostname");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "EHLO hostname", cmd->getText());
@@ -89,7 +89,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testAUTH()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::AUTH("saslmechanism");
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::AUTH("saslmechanism");
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "AUTH saslmechanism", cmd->getText());
@@ -97,7 +97,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testSTARTTLS()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::STARTTLS();
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::STARTTLS();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "STARTTLS", cmd->getText());
@@ -105,7 +105,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testMAIL()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL(vmime::mailbox("[email protected]"), false);
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL(vmime::mailbox("[email protected]"), false);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "MAIL FROM:<[email protected]>", cmd->getText());
@@ -113,7 +113,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testMAIL_Encoded()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
(vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false);
VASSERT_NOT_NULL("Not null", cmd);
@@ -122,7 +122,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testMAIL_UTF8()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
(vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true);
VASSERT_NOT_NULL("Not null", cmd);
@@ -131,7 +131,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testMAIL_SIZE()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
(vmime::mailbox("[email protected]"), false, 123456789);
VASSERT_NOT_NULL("Not null", cmd);
@@ -140,7 +140,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testMAIL_SIZE_UTF8()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::MAIL
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::MAIL
(vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true, 123456789);
VASSERT_NOT_NULL("Not null", cmd);
@@ -149,7 +149,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testRCPT()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::RCPT(vmime::mailbox("[email protected]"), false);
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT(vmime::mailbox("[email protected]"), false);
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RCPT TO:<[email protected]>", cmd->getText());
@@ -157,7 +157,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testRCPT_Encoded()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::RCPT
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT
(vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), false);
VASSERT_NOT_NULL("Not null", cmd);
@@ -166,7 +166,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testRCPT_UTF8()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::RCPT
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RCPT
(vmime::mailbox(vmime::emailAddress("mailtest", "例え.テスト")), true);
VASSERT_NOT_NULL("Not null", cmd);
@@ -175,7 +175,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testRSET()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::RSET();
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::RSET();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "RSET", cmd->getText());
@@ -183,7 +183,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testDATA()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::DATA();
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::DATA();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "DATA", cmd->getText());
@@ -191,12 +191,12 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testBDAT()
{
- vmime::ref <SMTPCommand> cmd1 = SMTPCommand::BDAT(12345, false);
+ vmime::shared_ptr <SMTPCommand> cmd1 = SMTPCommand::BDAT(12345, false);
VASSERT_NOT_NULL("Not null", cmd1);
VASSERT_EQ("Text", "BDAT 12345", cmd1->getText());
- vmime::ref <SMTPCommand> cmd2 = SMTPCommand::BDAT(67890, true);
+ vmime::shared_ptr <SMTPCommand> cmd2 = SMTPCommand::BDAT(67890, true);
VASSERT_NOT_NULL("Not null", cmd2);
VASSERT_EQ("Text", "BDAT 67890 LAST", cmd2->getText());
@@ -204,7 +204,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testNOOP()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::NOOP();
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::NOOP();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "NOOP", cmd->getText());
@@ -212,7 +212,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testQUIT()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::QUIT();
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::QUIT();
VASSERT_NOT_NULL("Not null", cmd);
VASSERT_EQ("Text", "QUIT", cmd->getText());
@@ -220,9 +220,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPCommandTest)
void testWriteToSocket()
{
- vmime::ref <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2");
+ vmime::shared_ptr <SMTPCommand> cmd = SMTPCommand::createCommand("MY_COMMAND param1 param2");
- vmime::ref <testSocket> sok = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> sok = vmime::make_shared <testSocket>();
cmd->writeToSocket(sok);
vmime::string response;
diff --git a/tests/net/smtp/SMTPResponseTest.cpp b/tests/net/smtp/SMTPResponseTest.cpp
index 5e75b6a7..352f46c2 100644
--- a/tests/net/smtp/SMTPResponseTest.cpp
+++ b/tests/net/smtp/SMTPResponseTest.cpp
@@ -43,15 +43,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testSingleLineResponse()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>();
socket->localSend("123 Response Text\r\n");
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 123, resp->getCode());
@@ -61,15 +61,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testSingleLineResponseLF()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>();
socket->localSend("123 Response Text\n");
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 123, resp->getCode());
@@ -79,9 +79,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testMultiLineResponse()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>();
socket->localSend
(
@@ -91,7 +91,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 123, resp->getCode());
@@ -107,9 +107,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testMultiLineResponseDifferentCode()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>();
socket->localSend
(
@@ -119,7 +119,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 0, resp->getCode());
@@ -135,9 +135,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testIncompleteMultiLineResponse()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>(1);
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>(1);
socket->localSend
(
@@ -155,9 +155,9 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testNoResponseText()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>(1);
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>(1);
socket->localSend
(
@@ -166,7 +166,7 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 250, resp->getCode());
@@ -176,15 +176,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testEnhancedStatusCode()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>();
socket->localSend("250 2.1.5 OK fu13sm4720601wic.7 - gsmtp\r\n");
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 250, resp->getCode());
@@ -197,15 +197,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testNoEnhancedStatusCode()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>();
socket->localSend("354 Go ahead fu13sm4720601wic.7 - gsmtp\r\n");
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 354, resp->getCode());
@@ -218,15 +218,15 @@ VMIME_TEST_SUITE_BEGIN(SMTPResponseTest)
void testInvalidEnhancedStatusCode()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
- vmime::ref <vmime::net::timeoutHandler> toh =
- vmime::create <testTimeoutHandler>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
+ vmime::shared_ptr <vmime::net::timeoutHandler> toh =
+ vmime::make_shared <testTimeoutHandler>();
socket->localSend("250 4.2 xxx\r\n");
vmime::net::smtp::SMTPResponse::state responseState;
- vmime::ref <vmime::net::smtp::SMTPResponse> resp =
+ vmime::shared_ptr <vmime::net::smtp::SMTPResponse> resp =
vmime::net::smtp::SMTPResponse::readResponse(socket, toh, responseState);
VASSERT_EQ("Code", 250, resp->getCode());
diff --git a/tests/net/smtp/SMTPTransportTest.cpp b/tests/net/smtp/SMTPTransportTest.cpp
index 13c18309..5997588e 100644
--- a/tests/net/smtp/SMTPTransportTest.cpp
+++ b/tests/net/smtp/SMTPTransportTest.cpp
@@ -44,25 +44,25 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testConnectToInvalidServer()
{
- vmime::ref <vmime::net::session> sess
- = vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> sess
+ = vmime::make_shared <vmime::net::session>();
vmime::utility::url url("smtp://invalid-smtp-server");
- vmime::ref <vmime::net::transport> store = sess->getTransport(url);
+ vmime::shared_ptr <vmime::net::transport> store = sess->getTransport(url);
VASSERT_THROW("connect", store->connect(), vmime::exceptions::connection_error);
}
void testGreetingError()
{
- vmime::ref <vmime::net::session> session =
- vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> session =
+ vmime::make_shared <vmime::net::session>();
- vmime::ref <vmime::net::transport> tr = session->getTransport
+ vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
- tr->setSocketFactory(vmime::create <testSocketFactory <greetingErrorSMTPTestSocket> >());
- tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>());
+ tr->setSocketFactory(vmime::make_shared <testSocketFactory <greetingErrorSMTPTestSocket> >());
+ tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
VASSERT_THROW("Connection", tr->connect(),
vmime::exceptions::connection_greeting_error);
@@ -70,23 +70,23 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testMAILandRCPT()
{
- vmime::ref <vmime::net::session> session =
- vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> session =
+ vmime::make_shared <vmime::net::session>();
- vmime::ref <vmime::net::transport> tr = session->getTransport
+ vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
- tr->setSocketFactory(vmime::create <testSocketFactory <MAILandRCPTSMTPTestSocket> >());
- tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>());
+ tr->setSocketFactory(vmime::make_shared <testSocketFactory <MAILandRCPTSMTPTestSocket> >());
+ tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
VASSERT_NO_THROW("Connection", tr->connect());
vmime::mailbox exp("[email protected]");
vmime::mailboxList recips;
- recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]"));
- recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]"));
- recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]"));
+ recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]"));
+ recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]"));
+ recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]"));
vmime::string data("Message data");
vmime::utility::inputStreamStringAdapter is(data);
@@ -96,52 +96,52 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testChunking()
{
- vmime::ref <vmime::net::session> session =
- vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> session =
+ vmime::make_shared <vmime::net::session>();
- vmime::ref <vmime::net::transport> tr = session->getTransport
+ vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
- tr->setSocketFactory(vmime::create <testSocketFactory <chunkingSMTPTestSocket> >());
- tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>());
+ tr->setSocketFactory(vmime::make_shared <testSocketFactory <chunkingSMTPTestSocket> >());
+ tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
tr->connect();
VASSERT("Test server should report it supports the CHUNKING extension!",
- tr.dynamicCast <vmime::net::smtp::SMTPTransport>()->getConnection()->hasExtension("CHUNKING"));
+ vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("CHUNKING"));
vmime::mailbox exp("[email protected]");
vmime::mailboxList recips;
- recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]"));
+ recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]"));
- vmime::ref <vmime::message> msg = vmime::create <SMTPTestMessage>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPTestMessage>();
tr->send(msg, exp, recips);
}
void testSize_Chunking()
{
- vmime::ref <vmime::net::session> session =
- vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> session =
+ vmime::make_shared <vmime::net::session>();
- vmime::ref <vmime::net::transport> tr = session->getTransport
+ vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
- tr->setSocketFactory(vmime::create <testSocketFactory <bigMessageSMTPTestSocket <true> > >());
- tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>());
+ tr->setSocketFactory(vmime::make_shared <testSocketFactory <bigMessageSMTPTestSocket <true> > >());
+ tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
tr->connect();
VASSERT("Test server should report it supports the SIZE extension!",
- tr.dynamicCast <vmime::net::smtp::SMTPTransport>()->getConnection()->hasExtension("SIZE"));
+ vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE"));
vmime::mailbox exp("[email protected]");
vmime::mailboxList recips;
- recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]"));
+ recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]"));
- vmime::ref <vmime::message> msg = vmime::create <SMTPBigTestMessage4MB>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPBigTestMessage4MB>();
VASSERT_THROW("Connection", tr->send(msg, exp, recips),
vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException);
@@ -149,26 +149,26 @@ VMIME_TEST_SUITE_BEGIN(SMTPTransportTest)
void testSize_NoChunking()
{
- vmime::ref <vmime::net::session> session =
- vmime::create <vmime::net::session>();
+ vmime::shared_ptr <vmime::net::session> session =
+ vmime::make_shared <vmime::net::session>();
- vmime::ref <vmime::net::transport> tr = session->getTransport
+ vmime::shared_ptr <vmime::net::transport> tr = session->getTransport
(vmime::utility::url("smtp://localhost"));
- tr->setSocketFactory(vmime::create <testSocketFactory <bigMessageSMTPTestSocket <false> > >());
- tr->setTimeoutHandlerFactory(vmime::create <testTimeoutHandlerFactory>());
+ tr->setSocketFactory(vmime::make_shared <testSocketFactory <bigMessageSMTPTestSocket <false> > >());
+ tr->setTimeoutHandlerFactory(vmime::make_shared <testTimeoutHandlerFactory>());
tr->connect();
VASSERT("Test server should report it supports the SIZE extension!",
- tr.dynamicCast <vmime::net::smtp::SMTPTransport>()->getConnection()->hasExtension("SIZE"));
+ vmime::dynamicCast <vmime::net::smtp::SMTPTransport>(tr)->getConnection()->hasExtension("SIZE"));
vmime::mailbox exp("[email protected]");
vmime::mailboxList recips;
- recips.appendMailbox(vmime::create <vmime::mailbox>("[email protected]"));
+ recips.appendMailbox(vmime::make_shared <vmime::mailbox>("[email protected]"));
- vmime::ref <vmime::message> msg = vmime::create <SMTPBigTestMessage4MB>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <SMTPBigTestMessage4MB>();
VASSERT_THROW("Connection", tr->send(msg, exp, recips),
vmime::net::smtp::SMTPMessageSizeExceedsMaxLimitsException);
diff --git a/tests/net/smtp/SMTPTransportTestUtils.hpp b/tests/net/smtp/SMTPTransportTestUtils.hpp
index b74f9783..dd7afeb5 100644
--- a/tests/net/smtp/SMTPTransportTestUtils.hpp
+++ b/tests/net/smtp/SMTPTransportTestUtils.hpp
@@ -410,7 +410,7 @@ public:
vmime::utility::stream::size_type getChunkBufferSize() const
{
- static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(NULL);
+ static vmime::net::smtp::SMTPChunkingOutputStreamAdapter chunkStream(vmime::null);
return chunkStream.getBlockSize();
}
@@ -456,13 +456,11 @@ public:
bigMessageSMTPTestSocket()
{
m_state = STATE_NOT_CONNECTED;
- m_bdatChunkCount = 0;
m_ehloSent = m_mailSent = m_rcptSent = m_quitSent = false;
}
~bigMessageSMTPTestSocket()
{
- VASSERT_EQ("BDAT chunk count", 3, m_bdatChunkCount);
VASSERT("Client must send the QUIT command", m_quitSent);
}
@@ -476,22 +474,6 @@ public:
void onDataReceived()
{
- if (m_state == STATE_DATA)
- {
- if (m_bdatChunkReceived != m_bdatChunkSize)
- {
- const size_type remaining = m_bdatChunkSize - m_bdatChunkReceived;
- const size_type received = localReceiveRaw(NULL, remaining);
-
- m_bdatChunkReceived += received;
- }
-
- if (m_bdatChunkReceived == m_bdatChunkSize)
- {
- m_state = STATE_COMMAND;
- }
- }
-
processCommand();
}
@@ -584,8 +566,6 @@ private:
};
int m_state;
- int m_bdatChunkCount;
- int m_bdatChunkSize, m_bdatChunkReceived;
bool m_ehloSent, m_mailSent, m_rcptSent, m_quitSent;
};
diff --git a/tests/parser/attachmentHelperTest.cpp b/tests/parser/attachmentHelperTest.cpp
index 0ddf2448..4d4a2623 100644
--- a/tests/parser/attachmentHelperTest.cpp
+++ b/tests/parser/attachmentHelperTest.cpp
@@ -39,9 +39,9 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VMIME_TEST_LIST_END
- static const vmime::string getStructure(vmime::ref <vmime::bodyPart> part)
+ static const vmime::string getStructure(vmime::shared_ptr <vmime::bodyPart> part)
{
- vmime::ref <vmime::body> bdy = part->getBody();
+ vmime::shared_ptr <vmime::body> bdy = part->getBody();
vmime::string res = part->getBody()->getContentType().generate();
@@ -52,7 +52,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
for (size_t i = 0 ; i < bdy->getPartCount() ; ++i)
{
- vmime::ref <vmime::bodyPart> subPart = bdy->getPartAt(i);
+ vmime::shared_ptr <vmime::bodyPart> subPart = bdy->getPartAt(i);
if (i != 0)
res += ",";
@@ -63,9 +63,9 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
return res + "]";
}
- static const vmime::string extractBodyContents(vmime::ref <const vmime::bodyPart> part)
+ static const vmime::string extractBodyContents(vmime::shared_ptr <const vmime::bodyPart> part)
{
- vmime::ref <const vmime::contentHandler> cth = part->getBody()->getContents();
+ vmime::shared_ptr <const vmime::contentHandler> cth = part->getBody()->getContents();
vmime::string data;
vmime::utility::outputStreamStringAdapter os(data);
@@ -83,11 +83,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"The text\r\n"
"";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
- vmime::ref <vmime::attachment> att = vmime::create <vmime::defaultAttachment>
- (vmime::create <vmime::stringContentHandler>("test"),
+ vmime::shared_ptr <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
+ (vmime::make_shared <vmime::stringContentHandler>("test"),
vmime::mediaType("image/jpeg"));
vmime::attachmentHelper::addAttachment(msg, att);
@@ -112,11 +112,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"--foo--\r\n"
"";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
- vmime::ref <vmime::attachment> att = vmime::create <vmime::defaultAttachment>
- (vmime::create <vmime::stringContentHandler>("test"),
+ vmime::shared_ptr <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
+ (vmime::make_shared <vmime::stringContentHandler>("test"),
vmime::mediaType("image/jpeg"));
vmime::attachmentHelper::addAttachment(msg, att);
@@ -136,11 +136,11 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"\r\n"
"TWVzc2FnZSBib2R5";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
- vmime::ref <vmime::attachment> att = vmime::create <vmime::defaultAttachment>
- (vmime::create <vmime::stringContentHandler>("test"),
+ vmime::shared_ptr <vmime::attachment> att = vmime::make_shared <vmime::defaultAttachment>
+ (vmime::make_shared <vmime::stringContentHandler>("test"),
vmime::mediaType("image/jpeg"));
vmime::attachmentHelper::addAttachment(msg, att);
@@ -155,7 +155,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
{
vmime::string data = "Content-Disposition: attachment\r\n\r\nFoo\r\n";
- vmime::ref <vmime::bodyPart> p = vmime::create <vmime::bodyPart>();
+ vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
p->parse(data);
VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p));
@@ -167,7 +167,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
{
vmime::string data = "Content-Type: multipart/*\r\n\r\nFoo\r\n";
- vmime::ref <vmime::bodyPart> p = vmime::create <vmime::bodyPart>();
+ vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
p->parse(data);
VASSERT_EQ("1", false, vmime::attachmentHelper::isBodyPartAnAttachment(p));
@@ -184,7 +184,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
{
vmime::string data = "Content-Type: application/octet-stream\r\n\r\nFoo\r\n";
- vmime::ref <vmime::bodyPart> p = vmime::create <vmime::bodyPart>();
+ vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
p->parse(data);
VASSERT_EQ("1", true, vmime::attachmentHelper::isBodyPartAnAttachment(p));
@@ -199,7 +199,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"Content-Id: bar\r\n"
"\r\nFoo\r\n";
- vmime::ref <vmime::bodyPart> p = vmime::create <vmime::bodyPart>();
+ vmime::shared_ptr <vmime::bodyPart> p = vmime::make_shared <vmime::bodyPart>();
p->parse(data);
VASSERT_EQ("1", false, vmime::attachmentHelper::isBodyPartAnAttachment(p));
@@ -215,10 +215,10 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"\r\n"
"Foo bar baz";
- vmime::ref <vmime::bodyPart> part = vmime::create <vmime::bodyPart>();
+ vmime::shared_ptr <vmime::bodyPart> part = vmime::make_shared <vmime::bodyPart>();
part->parse(data);
- vmime::ref <const vmime::attachment> att =
+ vmime::shared_ptr <const vmime::attachment> att =
vmime::attachmentHelper::getBodyPartAttachment(part);
VASSERT_EQ("1", "image/jpeg", att->getType().generate());
@@ -233,7 +233,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VASSERT_EQ("5", "Foo bar baz", attData);
//VASSERT_EQ("6", part, att->getPart());
- VASSERT_EQ("6", part->generate(), att->getPart().dynamicCast <const vmime::component>()->generate());
+ VASSERT_EQ("6", part->generate(), vmime::dynamicCast <const vmime::component>(att->getPart())->generate());
//VASSERT_EQ("7", part->getHeader(), att->getHeader());
VASSERT_EQ("7", part->getHeader()->generate(), att->getHeader()->generate());
}
@@ -246,7 +246,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"\r\n"
"Message body";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
const vmime::string attData =
@@ -256,7 +256,7 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"\r\n"
"QXR0YWNoZWQgbWVzc2FnZSBib2R5";
- vmime::ref <vmime::message> amsg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> amsg = vmime::make_shared <vmime::message>();
amsg->parse(attData);
vmime::attachmentHelper::addAttachment(msg, amsg);
@@ -265,20 +265,20 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
VASSERT_EQ("2", "Message body", extractBodyContents(msg->getBody()->getPartAt(0)));
// Ensure message has been encoded properly
- vmime::ref <const vmime::bodyPart> attPart = msg->getBody()->getPartAt(1);
- vmime::ref <const vmime::contentHandler> attCth = attPart->getBody()->getContents();
+ vmime::shared_ptr <const vmime::bodyPart> attPart = msg->getBody()->getPartAt(1);
+ vmime::shared_ptr <const vmime::contentHandler> attCth = attPart->getBody()->getContents();
vmime::string attDataOut;
vmime::utility::outputStreamStringAdapter attDataOutOs(attDataOut);
attCth->extract(attDataOutOs);
- vmime::ref <vmime::message> amsgOut = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> amsgOut = vmime::make_shared <vmime::message>();
amsgOut->parse(attDataOut);
- vmime::ref <vmime::header> hdr = amsgOut->getHeader();
+ vmime::shared_ptr <vmime::header> hdr = amsgOut->getHeader();
- VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast <vmime::text>()->generate());
+ VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue <vmime::text>()->generate());
VASSERT_EQ("4", "Attached message body", extractBodyContents(amsgOut));
}
@@ -300,25 +300,25 @@ VMIME_TEST_SUITE_BEGIN(attachmentHelperTest)
"FooBar\r\n"
"--foo--\r\n";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(data);
VASSERT_EQ("0", 2, msg->getBody()->getPartCount());
- vmime::ref <const vmime::attachment> att = vmime::attachmentHelper::
+ vmime::shared_ptr <const vmime::attachment> att = vmime::attachmentHelper::
getBodyPartAttachment(msg->getBody()->getPartAt(0));
VASSERT("1", att != NULL);
- vmime::ref <const vmime::messageAttachment> msgAtt =
- att.dynamicCast <const vmime::messageAttachment>();
+ vmime::shared_ptr <const vmime::messageAttachment> msgAtt =
+ vmime::dynamicCast <const vmime::messageAttachment>(att);
VASSERT("2", msgAtt != NULL);
- vmime::ref <vmime::message> amsg = msgAtt->getMessage();
- vmime::ref <vmime::header> hdr = amsg->getHeader();
+ vmime::shared_ptr <vmime::message> amsg = msgAtt->getMessage();
+ vmime::shared_ptr <vmime::header> hdr = amsg->getHeader();
- VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue().dynamicCast <vmime::text>()->generate());
+ VASSERT_EQ("3", "Attached message", hdr->Subject()->getValue <vmime::text>()->generate());
VASSERT_EQ("4", "Attached message body", extractBodyContents(amsg));
}
diff --git a/tests/parser/bodyPartTest.cpp b/tests/parser/bodyPartTest.cpp
index 453982e0..f6f82f75 100644
--- a/tests/parser/bodyPartTest.cpp
+++ b/tests/parser/bodyPartTest.cpp
@@ -49,7 +49,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
buffer.begin() + c.getParsedOffset() + c.getParsedLength());
}
- static const vmime::string extractContents(const vmime::ref <const vmime::contentHandler> cts)
+ static const vmime::string extractContents(const vmime::shared_ptr <const vmime::contentHandler> cts)
{
std::ostringstream oss;
vmime::utility::outputStreamAdapter os(oss);
@@ -105,7 +105,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
{
vmime::bodyPart p1;
p1.getHeader()->getField("Foo")->setValue(vmime::string("bar"));
- p1.getBody()->setContents(vmime::create <vmime::stringContentHandler>("Baz"));
+ p1.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>("Baz"));
VASSERT_EQ("1", "Foo: bar\r\n\r\nBaz", p1.generate());
}
@@ -162,7 +162,7 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
"--=_+ZWjySayKqSf2CyrfnNpaAcO6-G1HpoXdHZ4YyswAWqEY39Q--\r\n"
"Epilog text";
- vmime::ref<vmime::message> msg = vmime::create<vmime::message>();
+ vmime::shared_ptr<vmime::message> msg = vmime::make_shared<vmime::message>();
std::string istr(testmail);
@@ -223,26 +223,26 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
/** Ensure '7bit' encoding is used when body is 7-bit only. */
void testGenerate7bit()
{
- vmime::ref <vmime::plainTextPart> p1 = vmime::create <vmime::plainTextPart>();
- p1->setText(vmime::create <vmime::stringContentHandler>("Part1 is US-ASCII only."));
+ vmime::shared_ptr <vmime::plainTextPart> p1 = vmime::make_shared <vmime::plainTextPart>();
+ p1->setText(vmime::make_shared <vmime::stringContentHandler>("Part1 is US-ASCII only."));
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
p1->generateIn(msg, msg);
- vmime::ref <vmime::header> header1 = msg->getBody()->getPartAt(0)->getHeader();
+ vmime::shared_ptr <vmime::header> header1 = msg->getBody()->getPartAt(0)->getHeader();
VASSERT_EQ("1", "7bit", header1->ContentTransferEncoding()->getValue()->generate());
}
void testTextUsageForQPEncoding()
{
- vmime::ref <vmime::plainTextPart> part = vmime::create <vmime::plainTextPart>();
- part->setText(vmime::create <vmime::stringContentHandler>("Part1-line1\r\nPart1-line2\r\n\x89"));
+ vmime::shared_ptr <vmime::plainTextPart> part = vmime::make_shared <vmime::plainTextPart>();
+ part->setText(vmime::make_shared <vmime::stringContentHandler>("Part1-line1\r\nPart1-line2\r\n\x89"));
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
part->generateIn(msg, msg);
- vmime::ref <vmime::body> body = msg->getBody()->getPartAt(0)->getBody();
- vmime::ref <vmime::header> header = msg->getBody()->getPartAt(0)->getHeader();
+ vmime::shared_ptr <vmime::body> body = msg->getBody()->getPartAt(0)->getBody();
+ vmime::shared_ptr <vmime::header> header = msg->getBody()->getPartAt(0)->getHeader();
std::ostringstream oss;
vmime::utility::outputStreamAdapter os(oss);
@@ -339,30 +339,30 @@ VMIME_TEST_SUITE_BEGIN(bodyPartTest)
oss << "\r\n"
<< "--MY-BOUNDARY--\r\n";
- vmime::ref <vmime::utility::inputStreamStringAdapter> is =
- vmime::create <vmime::utility::inputStreamStringAdapter>(oss.str());
+ vmime::shared_ptr <vmime::utility::inputStreamStringAdapter> is =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(oss.str());
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(is, oss.str().length());
- vmime::ref <vmime::body> body1 = msg->getBody()->getPartAt(0)->getBody();
- vmime::ref <const vmime::contentHandler> body1Cts = body1->getContents();
+ vmime::shared_ptr <vmime::body> body1 = msg->getBody()->getPartAt(0)->getBody();
+ vmime::shared_ptr <const vmime::contentHandler> body1Cts = body1->getContents();
- vmime::ref <vmime::body> body2 = msg->getBody()->getPartAt(1)->getBody();
- vmime::ref <const vmime::contentHandler> body2Cts = body2->getContents();
+ vmime::shared_ptr <vmime::body> body2 = msg->getBody()->getPartAt(1)->getBody();
+ vmime::shared_ptr <const vmime::contentHandler> body2Cts = body2->getContents();
vmime::string body1CtsExtracted;
vmime::utility::outputStreamStringAdapter body1CtsExtractStream(body1CtsExtracted);
body1Cts->extract(body1CtsExtractStream);
VASSERT_EQ("1.1", BODY1_LENGTH, body1Cts->getLength());
- VASSERT("1.2", body1Cts.dynamicCast <const vmime::streamContentHandler>() != NULL);
+ VASSERT("1.2", vmime::dynamicCast <const vmime::streamContentHandler>(body1Cts) != NULL);
VASSERT_EQ("1.3", BODY1_LENGTH, body1CtsExtracted.length());
VASSERT_EQ("1.4", BODY1_BEGIN, body1CtsExtracted.substr(0, BODY1_BEGIN.length()));
VASSERT_EQ("1.5", BODY1_END, body1CtsExtracted.substr(BODY1_LENGTH - BODY1_END.length(), BODY1_END.length()));
VASSERT_EQ("2.1", BODY2_LINE.length() * BODY2_REPEAT, body2Cts->getLength());
- VASSERT("2.2", body2Cts.dynamicCast <const vmime::streamContentHandler>() != NULL);
+ VASSERT("2.2", vmime::dynamicCast <const vmime::streamContentHandler>(body2Cts) != NULL);
}
VMIME_TEST_SUITE_END
diff --git a/tests/parser/bodyTest.cpp b/tests/parser/bodyTest.cpp
index bb4d966b..92a4575e 100644
--- a/tests/parser/bodyTest.cpp
+++ b/tests/parser/bodyTest.cpp
@@ -40,7 +40,7 @@ VMIME_TEST_SUITE_BEGIN(bodyTest)
// Quoted-Printable encoding
vmime::bodyPart p;
- p.getBody()->setContents(vmime::create <vmime::stringContentHandler>
+ p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>
("Foo éé\r\né bar\r\nbaz"), vmime::mediaType("text", "plain"),
vmime::charset("utf-8"), vmime::encoding("quoted-printable"));
@@ -54,7 +54,7 @@ VMIME_TEST_SUITE_BEGIN(bodyTest)
void testGenerate_NonText()
{
vmime::bodyPart p;
- p.getBody()->setContents(vmime::create <vmime::stringContentHandler>
+ p.getBody()->setContents(vmime::make_shared <vmime::stringContentHandler>
("Binary\xfa\xfb\r\ndata\r\n\r\n\xfc"), vmime::mediaType("application", "octet-stream"),
vmime::charset("utf-8"), vmime::encoding("quoted-printable"));
diff --git a/tests/parser/charsetFilteredOutputStreamTest.cpp b/tests/parser/charsetFilteredOutputStreamTest.cpp
index 32c4c5f3..4c91a71c 100644
--- a/tests/parser/charsetFilteredOutputStreamTest.cpp
+++ b/tests/parser/charsetFilteredOutputStreamTest.cpp
@@ -42,12 +42,12 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
void testInputBufferUnderflow()
{
- vmime::ref <vmime::charsetConverter> cc =
+ vmime::shared_ptr <vmime::charsetConverter> cc =
vmime::charsetConverter::create("utf-8", "iso-8859-1");
vmime::string output;
vmime::utility::outputStreamStringAdapter os(output);
- vmime::ref <vmime::utility::filteredOutputStream> cfos = cc->getFilteredOutputStream(os);
+ vmime::shared_ptr <vmime::utility::filteredOutputStream> cfos = cc->getFilteredOutputStream(os);
VASSERT_NOT_NULL("filteredOutputStream availability", cfos);
@@ -73,12 +73,12 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::string actualOut;
vmime::utility::outputStreamStringAdapter osa(actualOut);
- vmime::ref <vmime::charsetConverter> conv =
+ vmime::shared_ptr <vmime::charsetConverter> conv =
vmime::charsetConverter::create
(vmime::charset("utf-8"),
vmime::charset("iso-8859-1"));
- vmime::ref <vmime::utility::charsetFilteredOutputStream> os =
+ vmime::shared_ptr <vmime::utility::charsetFilteredOutputStream> os =
conv->getFilteredOutputStream(osa);
VASSERT_NOT_NULL("filteredOutputStream availability", os);
@@ -114,10 +114,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::string actualOut;
vmime::utility::outputStreamStringAdapter osa(actualOut);
- vmime::ref <vmime::charsetConverter> conv =
+ vmime::shared_ptr <vmime::charsetConverter> conv =
vmime::charsetConverter::create(entry.fromCharset, entry.toCharset);
- vmime::ref <vmime::utility::charsetFilteredOutputStream> os =
+ vmime::shared_ptr <vmime::utility::charsetFilteredOutputStream> os =
conv->getFilteredOutputStream(osa);
VASSERT_NOT_NULL("filteredOutputStream availability", os);
@@ -151,10 +151,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::string actualOut;
vmime::utility::outputStreamStringAdapter osa(actualOut);
- vmime::ref <vmime::charsetConverter> conv =
+ vmime::shared_ptr <vmime::charsetConverter> conv =
vmime::charsetConverter::create(entry.fromCharset, entry.toCharset);
- vmime::ref <vmime::utility::charsetFilteredOutputStream> os =
+ vmime::shared_ptr <vmime::utility::charsetFilteredOutputStream> os =
conv->getFilteredOutputStream(osa);
VASSERT_NOT_NULL("filteredOutputStream availability", os);
@@ -191,10 +191,10 @@ VMIME_TEST_SUITE_BEGIN(charsetFilteredOutputStreamTest)
vmime::string actualOut;
vmime::utility::outputStreamStringAdapter osa(actualOut);
- vmime::ref <vmime::charsetConverter> conv =
+ vmime::shared_ptr <vmime::charsetConverter> conv =
vmime::charsetConverter::create(entry.fromCharset, entry.toCharset);
- vmime::ref <vmime::utility::charsetFilteredOutputStream> os =
+ vmime::shared_ptr <vmime::utility::charsetFilteredOutputStream> os =
conv->getFilteredOutputStream(osa);
VASSERT_NOT_NULL("filteredOutputStream availability", os);
diff --git a/tests/parser/fileContentHandlerTest.cpp b/tests/parser/fileContentHandlerTest.cpp
index b7373959..9d1459db 100644
--- a/tests/parser/fileContentHandlerTest.cpp
+++ b/tests/parser/fileContentHandlerTest.cpp
@@ -38,7 +38,7 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
VMIME_TEST_LIST_END
- vmime::ref <vmime::utility::file> testFile;
+ vmime::shared_ptr <vmime::utility::file> testFile;
vmime::string testDataEncoded, testDataDecoded;
@@ -50,7 +50,7 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
std::ostringstream testFilePath;
testFilePath << "/tmp/vmime_test_" << (rand() % 999999999);
- vmime::ref <vmime::utility::fileSystemFactory> fsf =
+ vmime::shared_ptr <vmime::utility::fileSystemFactory> fsf =
vmime::platform::getHandler()->getFileSystemFactory();
testFile = fsf->create(fsf->stringToPath(testFilePath.str()));
@@ -61,7 +61,7 @@ VMIME_TEST_SUITE_BEGIN(fileContentHandlerTest)
void tearDown()
{
testFile->remove();
- testFile = NULL;
+ testFile = vmime::null;
}
diff --git a/tests/parser/headerFieldTest.cpp b/tests/parser/headerFieldTest.cpp
index b551c781..5281a3a2 100644
--- a/tests/parser/headerFieldTest.cpp
+++ b/tests/parser/headerFieldTest.cpp
@@ -35,16 +35,17 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
void testBadValueType()
{
- vmime::headerFieldFactory *hfactory = vmime::headerFieldFactory::getInstance();
+ vmime::shared_ptr <vmime::headerFieldFactory> hfactory =
+ vmime::headerFieldFactory::getInstance();
// "To" header field accepts values of type "addressList"
- vmime::ref <vmime::headerField> to = hfactory->create(vmime::fields::TO);
+ vmime::shared_ptr <vmime::headerField> to = hfactory->create(vmime::fields::TO);
VASSERT_THROW("to",
to->setValue(vmime::mailbox("[email protected]")),
vmime::exceptions::bad_field_value_type);
// Unregistered header field accepts any value type
- vmime::ref <vmime::headerField> custom = hfactory->create("X-MyCustomHeader");
+ vmime::shared_ptr <vmime::headerField> custom = hfactory->create("X-MyCustomHeader");
VASSERT_NO_THROW("custom/1",
custom->setValue(vmime::mailbox("[email protected]")));
VASSERT_NO_THROW("custom/2",
@@ -57,11 +58,11 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
const vmime::string buffer = "Field: \r\n\tfield data";
- vmime::ref <vmime::headerField> hfield =
+ vmime::shared_ptr <vmime::headerField> hfield =
vmime::headerField::parseNext(ctx, buffer, 0, buffer.size());
- vmime::ref <vmime::text> hvalue =
- hfield->getValue().dynamicCast <vmime::text>();
+ vmime::shared_ptr <vmime::text> hvalue =
+ hfield->getValue <vmime::text>();
VASSERT_EQ("Field name", "Field", hfield->getName());
VASSERT_EQ("Field value", "field data", hvalue->getWholeBuffer());
@@ -73,11 +74,11 @@ VMIME_TEST_SUITE_BEGIN(headerFieldTest)
const vmime::string buffer = "Field: \r\n\tfield data ";
- vmime::ref <vmime::headerField> hfield =
+ vmime::shared_ptr <vmime::headerField> hfield =
vmime::headerField::parseNext(ctx, buffer, 0, buffer.size());
- vmime::ref <vmime::text> hvalue =
- hfield->getValue().dynamicCast <vmime::text>();
+ vmime::shared_ptr <vmime::text> hvalue =
+ hfield->getValue <vmime::text>();
VASSERT_EQ("Field name", "Field", hfield->getName());
VASSERT_EQ("Field value", toHex("field data"), toHex(hvalue->getWholeBuffer()));
diff --git a/tests/parser/headerTest.cpp b/tests/parser/headerTest.cpp
index 91eb03df..959fc631 100644
--- a/tests/parser/headerTest.cpp
+++ b/tests/parser/headerTest.cpp
@@ -100,10 +100,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("");
- vmime::ref <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("A", "a");
+ vmime::shared_ptr <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("A", "a");
hdr.appendField(hf);
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(1), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -114,10 +114,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\n");
- vmime::ref <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
+ vmime::shared_ptr <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
hdr.appendField(hf);
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(2), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -130,10 +130,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
- vmime::ref <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
+ vmime::shared_ptr <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
hdr.insertFieldBefore(hdr.getField("C"), hf);
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(3), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -146,10 +146,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
- vmime::ref <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
+ vmime::shared_ptr <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
hdr.insertFieldBefore(1, hf);
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(3), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -163,10 +163,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
- vmime::ref <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
+ vmime::shared_ptr <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
hdr.insertFieldAfter(hdr.getField("A"), hf);
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(3), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -179,10 +179,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\nC: c\r\n");
- vmime::ref <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
+ vmime::shared_ptr <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("B", "b");
hdr.insertFieldAfter(0, hf);
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(3), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -196,10 +196,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\nB: b\r\nC: c\r\n");
- vmime::ref <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("Z", "z");
+ vmime::shared_ptr <vmime::headerField> hf = vmime::headerFieldFactory::getInstance()->create("Z", "z");
hdr.replaceField(hdr.getField("B"), hf);
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(3), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -217,13 +217,13 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
hdr1.removeField(hdr1.getField("B"));
hdr2.removeField(1);
- std::vector <vmime::ref <vmime::headerField> > res1 = hdr1.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res1 = hdr1.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(2), res1.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res1[0]));
VASSERT_EQ("Second value", "C: c", headerTest::getFieldValue(*res1[1]));
- std::vector <vmime::ref <vmime::headerField> > res2 = hdr2.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res2 = hdr2.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(2), res2.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res2[0]));
@@ -239,10 +239,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
hdr1.removeField(hdr1.getField("A"));
hdr2.removeField(0);
- std::vector <vmime::ref <vmime::headerField> > res1 = hdr1.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res1 = hdr1.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(0), res1.size());
- std::vector <vmime::ref <vmime::headerField> > res2 = hdr2.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res2 = hdr2.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(0), res2.size());
}
@@ -256,10 +256,10 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
hdr1.removeAllFields();
hdr2.removeAllFields();
- std::vector <vmime::ref <vmime::headerField> > res1 = hdr1.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res1 = hdr1.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(0), res1.size());
- std::vector <vmime::ref <vmime::headerField> > res2 = hdr2.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res2 = hdr2.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(0), res2.size());
}
@@ -295,7 +295,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("B: b\r\nA: a\r\nC: c\r\n");
- vmime::ref <vmime::headerField> res = hdr.getFieldAt(2);
+ vmime::shared_ptr <vmime::headerField> res = hdr.getFieldAt(2);
VASSERT_EQ("Value", "C: c", getFieldValue(*res));
}
@@ -306,7 +306,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\nB: b1\r\nC: c\r\nB: b2\r\n");
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(4), res.size());
VASSERT_EQ("First value", "A: a", headerTest::getFieldValue(*res[0]));
@@ -320,7 +320,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("\r\n");
- std::vector <vmime::ref <vmime::headerField> > res = hdr.getFieldList();
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.getFieldList();
VASSERT_EQ("Count", static_cast <unsigned int>(0), res.size());
}
@@ -331,7 +331,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a\r\nB: b\r\nC: c\r\nB: d\r\n");
- vmime::ref <vmime::headerField> res = hdr.findField("B");
+ vmime::shared_ptr <vmime::headerField> res = hdr.findField("B");
VASSERT_EQ("Value", "B: b", getFieldValue(*res));
}
@@ -342,7 +342,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a1\nC: c1\n");
- std::vector <vmime::ref <vmime::headerField> > res = hdr.findAllFields("B");
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.findAllFields("B");
VASSERT_EQ("Count", static_cast <unsigned int>(0), res.size());
}
@@ -352,7 +352,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\n");
- std::vector <vmime::ref <vmime::headerField> > res = hdr.findAllFields("B");
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.findAllFields("B");
VASSERT_EQ("Count", static_cast <unsigned int>(2), res.size());
VASSERT_EQ("First value", "B: b1", headerTest::getFieldValue(*res[0]));
@@ -364,7 +364,7 @@ VMIME_TEST_SUITE_BEGIN(headerTest)
vmime::header hdr;
hdr.parse("A: a1\nB: b1\nB: b2\nC: c1\nC: c3\nC: c2\n");
- std::vector <vmime::ref <vmime::headerField> > res = hdr.findAllFields("C");
+ std::vector <vmime::shared_ptr <vmime::headerField> > res = hdr.findAllFields("C");
VASSERT_EQ("Count", static_cast <unsigned int>(3), res.size());
VASSERT_EQ("First value", "C: c1", headerTest::getFieldValue(*res[0]));
diff --git a/tests/parser/htmlTextPartTest.cpp b/tests/parser/htmlTextPartTest.cpp
index 0eb7bbaf..278a87c1 100644
--- a/tests/parser/htmlTextPartTest.cpp
+++ b/tests/parser/htmlTextPartTest.cpp
@@ -35,7 +35,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
static const vmime::string extractContent
- (vmime::ref <const vmime::contentHandler> cth)
+ (vmime::shared_ptr <const vmime::contentHandler> cth)
{
std::ostringstream oss;
vmime::utility::outputStreamAdapter osa(oss);
@@ -74,7 +74,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
"--LEVEL1--\r\n"
"";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(msgString);
// Sanity checks
@@ -129,7 +129,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
"--LEVEL1--\r\n"
"";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(msgString);
// Sanity checks
@@ -153,7 +153,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
VASSERT_EQ("has-obj2-pre", true, htmlPart.hasObject("cid:image2@test"));
// Check data in objects
- vmime::ref <const vmime::htmlTextPart::embeddedObject> obj;
+ vmime::shared_ptr <const vmime::htmlTextPart::embeddedObject> obj;
obj = htmlPart.findObject("image1@test");
@@ -201,7 +201,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
"--LEVEL1--\r\n"
"";
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->parse(msgString);
// Sanity checks
@@ -221,7 +221,7 @@ VMIME_TEST_SUITE_BEGIN(htmlTextPartTest)
VASSERT_EQ("has-obj-cid", false, htmlPart.hasObject("image1@test"));
// Check data
- vmime::ref <const vmime::htmlTextPart::embeddedObject> obj;
+ vmime::shared_ptr <const vmime::htmlTextPart::embeddedObject> obj;
obj = htmlPart.findObject("http://www.vmime.org/test/image1.png");
diff --git a/tests/parser/mailboxGroupTest.cpp b/tests/parser/mailboxGroupTest.cpp
index 49d22658..6c1319da 100644
--- a/tests/parser/mailboxGroupTest.cpp
+++ b/tests/parser/mailboxGroupTest.cpp
@@ -57,8 +57,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxGroupTest)
VASSERT_EQ("count", 1, addrs.getAddressCount());
VASSERT_TRUE("is group", addrs.getAddressAt(0)->isGroup());
- vmime::ref <vmime::mailboxGroup> mgrp =
- addrs.getAddressAt(0).dynamicCast <vmime::mailboxGroup>();
+ vmime::shared_ptr <vmime::mailboxGroup> mgrp =
+ vmime::dynamicCast <vmime::mailboxGroup>(addrs.getAddressAt(0));
VASSERT_EQ("name", "group", mgrp->getName().getWholeBuffer());
VASSERT_EQ("count", 2, mgrp->getMailboxCount());
diff --git a/tests/parser/mailboxTest.cpp b/tests/parser/mailboxTest.cpp
index e6e4a608..6bf6670c 100644
--- a/tests/parser/mailboxTest.cpp
+++ b/tests/parser/mailboxTest.cpp
@@ -119,7 +119,8 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
VASSERT_EQ("count", 1, addrList.getAddressCount());
VASSERT_EQ("!group", false, addrList.getAddressAt(0)->isGroup());
- vmime::ref <vmime::mailbox> mbox = addrList.getAddressAt(0).dynamicCast <vmime::mailbox>();
+ vmime::shared_ptr <vmime::mailbox> mbox =
+ vmime::dynamicCast <vmime::mailbox>(addrList.getAddressAt(0));
VASSERT_EQ("name", "Full Name", mbox->getName());
VASSERT_EQ("email", "", mbox->getEmail());
@@ -132,8 +133,10 @@ VMIME_TEST_SUITE_BEGIN(mailboxTest)
VASSERT_EQ("count", 2, addrList.getAddressCount());
- vmime::ref <vmime::mailbox> mbox1 = addrList.getAddressAt(0).dynamicCast <vmime::mailbox>();
- vmime::ref <vmime::mailbox> mbox2 = addrList.getAddressAt(1).dynamicCast <vmime::mailbox>();
+ vmime::shared_ptr <vmime::mailbox> mbox1 =
+ vmime::dynamicCast <vmime::mailbox>(addrList.getAddressAt(0));
+ vmime::shared_ptr <vmime::mailbox> mbox2 =
+ vmime::dynamicCast <vmime::mailbox>(addrList.getAddressAt(1));
VASSERT_EQ("name1", vmime::text(), mbox1->getName());
VASSERT_EQ("email1", "[email protected]", mbox1->getEmail());
diff --git a/tests/parser/messageIdSequenceTest.cpp b/tests/parser/messageIdSequenceTest.cpp
index ed6d0be3..bc5c7617 100644
--- a/tests/parser/messageIdSequenceTest.cpp
+++ b/tests/parser/messageIdSequenceTest.cpp
@@ -64,13 +64,13 @@ VMIME_TEST_SUITE_BEGIN(messageIdSequenceTest)
void testGenerate()
{
vmime::messageIdSequence s1;
- s1.appendMessageId(vmime::create <vmime::messageId>("a", "b"));
+ s1.appendMessageId(vmime::make_shared <vmime::messageId>("a", "b"));
VASSERT_EQ("1", "<a@b>", s1.generate());
vmime::messageIdSequence s2;
- s2.appendMessageId(vmime::create <vmime::messageId>("a", "b"));
- s2.appendMessageId(vmime::create <vmime::messageId>("c", "d"));
+ s2.appendMessageId(vmime::make_shared <vmime::messageId>("a", "b"));
+ s2.appendMessageId(vmime::make_shared <vmime::messageId>("c", "d"));
VASSERT_EQ("2", "<a@b> <c@d>", s2.generate());
}
diff --git a/tests/parser/messageTest.cpp b/tests/parser/messageTest.cpp
index 56605e39..a7a16813 100644
--- a/tests/parser/messageTest.cpp
+++ b/tests/parser/messageTest.cpp
@@ -35,12 +35,12 @@ VMIME_TEST_SUITE_BEGIN(messageTest)
{
vmime::generationContext ctx;
- vmime::ref <vmime::message> msg = vmime::create <vmime::message>();
+ vmime::shared_ptr <vmime::message> msg = vmime::make_shared <vmime::message>();
msg->getHeader()->getField("Foo")->setValue(vmime::string("bar"));
vmime::htmlTextPart textPart;
- textPart.setPlainText(vmime::create <vmime::stringContentHandler>("Foo bar bazé foo foo foo"));
- textPart.setText(vmime::create <vmime::stringContentHandler>("Foo bar <strong>bazé</strong> foo foo foo"));
+ textPart.setPlainText(vmime::make_shared <vmime::stringContentHandler>("Foo bar bazé foo foo foo"));
+ textPart.setText(vmime::make_shared <vmime::stringContentHandler>("Foo bar <strong>bazé</strong> foo foo foo"));
textPart.generateIn(msg, msg);
// Estimated/computed generated size must be greater than the actual generated size
diff --git a/tests/parser/parameterTest.cpp b/tests/parser/parameterTest.cpp
index 3ebd6e35..3b0edebf 100644
--- a/tests/parser/parameterTest.cpp
+++ b/tests/parser/parameterTest.cpp
@@ -197,19 +197,19 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
{
// Simple parameter/value
parameterizedHeaderField p1;
- p1.appendParameter(vmime::create <vmime::parameter>("param1", "value1"));
+ p1.appendParameter(vmime::make_shared <vmime::parameter>("param1", "value1"));
VASSERT_EQ("1", "F: X; param1=value1", p1.generate());
// Value that needs quoting (1/2)
parameterizedHeaderField p2a;
- p2a.appendParameter(vmime::create <vmime::parameter>("param1", "value1a;value1b"));
+ p2a.appendParameter(vmime::make_shared <vmime::parameter>("param1", "value1a;value1b"));
VASSERT_EQ("2a", "F: X; param1=\"value1a;value1b\"", p2a.generate());
// Value that needs quoting (2/2)
parameterizedHeaderField p2b;
- p2b.appendParameter(vmime::create <vmime::parameter>("param1", "va\\lue\"1"));
+ p2b.appendParameter(vmime::make_shared <vmime::parameter>("param1", "va\\lue\"1"));
VASSERT_EQ("2b", "F: X; param1=\"va\\\\lue\\\"1\"", p2b.generate());
}
@@ -218,7 +218,7 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
{
// Extended parameter with charset specifier
parameterizedHeaderField p1;
- p1.appendParameter(vmime::create <vmime::parameter>("param1",
+ p1.appendParameter(vmime::make_shared <vmime::parameter>("param1",
vmime::word("value 1\xe9", vmime::charset("charset"))));
#if VMIME_ALWAYS_GENERATE_7BIT_PARAMETER
@@ -229,7 +229,7 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// Value that spans on multiple lines
parameterizedHeaderField p2;
- p2.appendParameter(vmime::create <vmime::parameter>("param1",
+ p2.appendParameter(vmime::make_shared <vmime::parameter>("param1",
vmime::word("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",
vmime::charset("charset"))));
@@ -256,7 +256,7 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// Non-ASCII parameter value
parameterizedHeaderField p3;
- p3.appendParameter(vmime::create <vmime::parameter>("param1",
+ p3.appendParameter(vmime::make_shared <vmime::parameter>("param1",
vmime::word("δσσσσσσσσσσσσσσσσσσσσδσδα δσαδσδσαδσαδασδασ δσαδασδσα δσαδασδσα δασδασδασ δασαχφδδσα 2008.doc",
vmime::charset("utf-8"))));
@@ -325,28 +325,28 @@ VMIME_TEST_SUITE_BEGIN(parameterTest)
// Encode "tspecials"
void testEncodeTSpecials()
{
- VASSERT_EQ(" 1", "p=\"val(ue\"", vmime::create <vmime::parameter>("p", "val(ue")->generate());
- VASSERT_EQ(" 2", "p=\"val)ue\"", vmime::create <vmime::parameter>("p", "val)ue")->generate());
- VASSERT_EQ(" 3", "p=\"val<ue\"", vmime::create <vmime::parameter>("p", "val<ue")->generate());
- VASSERT_EQ(" 4", "p=\"val>ue\"", vmime::create <vmime::parameter>("p", "val>ue")->generate());
- VASSERT_EQ(" 5", "p=\"val@ue\"", vmime::create <vmime::parameter>("p", "val@ue")->generate());
- VASSERT_EQ(" 6", "p=\"val,ue\"", vmime::create <vmime::parameter>("p", "val,ue")->generate());
- VASSERT_EQ(" 7", "p=\"val;ue\"", vmime::create <vmime::parameter>("p", "val;ue")->generate());
- VASSERT_EQ(" 8", "p=\"val:ue\"", vmime::create <vmime::parameter>("p", "val:ue")->generate());
- VASSERT_EQ(" 9", "p=\"val/ue\"", vmime::create <vmime::parameter>("p", "val/ue")->generate());
- VASSERT_EQ("10", "p=\"val[ue\"", vmime::create <vmime::parameter>("p", "val[ue")->generate());
- VASSERT_EQ("11", "p=\"val]ue\"", vmime::create <vmime::parameter>("p", "val]ue")->generate());
- VASSERT_EQ("12", "p=\"val?ue\"", vmime::create <vmime::parameter>("p", "val?ue")->generate());
- VASSERT_EQ("13", "p=\"val=ue\"", vmime::create <vmime::parameter>("p", "val=ue")->generate());
- VASSERT_EQ("14", "p=\"val ue\"", vmime::create <vmime::parameter>("p", "val ue")->generate());
- VASSERT_EQ("15", "p=\"val\tue\"", vmime::create <vmime::parameter>("p", "val\tue")->generate());
+ VASSERT_EQ(" 1", "p=\"val(ue\"", vmime::make_shared <vmime::parameter>("p", "val(ue")->generate());
+ VASSERT_EQ(" 2", "p=\"val)ue\"", vmime::make_shared <vmime::parameter>("p", "val)ue")->generate());
+ VASSERT_EQ(" 3", "p=\"val<ue\"", vmime::make_shared <vmime::parameter>("p", "val<ue")->generate());
+ VASSERT_EQ(" 4", "p=\"val>ue\"", vmime::make_shared <vmime::parameter>("p", "val>ue")->generate());
+ VASSERT_EQ(" 5", "p=\"val@ue\"", vmime::make_shared <vmime::parameter>("p", "val@ue")->generate());
+ VASSERT_EQ(" 6", "p=\"val,ue\"", vmime::make_shared <vmime::parameter>("p", "val,ue")->generate());
+ VASSERT_EQ(" 7", "p=\"val;ue\"", vmime::make_shared <vmime::parameter>("p", "val;ue")->generate());
+ VASSERT_EQ(" 8", "p=\"val:ue\"", vmime::make_shared <vmime::parameter>("p", "val:ue")->generate());
+ VASSERT_EQ(" 9", "p=\"val/ue\"", vmime::make_shared <vmime::parameter>("p", "val/ue")->generate());
+ VASSERT_EQ("10", "p=\"val[ue\"", vmime::make_shared <vmime::parameter>("p", "val[ue")->generate());
+ VASSERT_EQ("11", "p=\"val]ue\"", vmime::make_shared <vmime::parameter>("p", "val]ue")->generate());
+ VASSERT_EQ("12", "p=\"val?ue\"", vmime::make_shared <vmime::parameter>("p", "val?ue")->generate());
+ VASSERT_EQ("13", "p=\"val=ue\"", vmime::make_shared <vmime::parameter>("p", "val=ue")->generate());
+ VASSERT_EQ("14", "p=\"val ue\"", vmime::make_shared <vmime::parameter>("p", "val ue")->generate());
+ VASSERT_EQ("15", "p=\"val\tue\"", vmime::make_shared <vmime::parameter>("p", "val\tue")->generate());
}
// http://sourceforge.net/projects/vmime/forums/forum/237356/topic/3812278
void testEncodeTSpecialsInRFC2231()
{
VASSERT_EQ("1", "filename*=UTF-8''my_file_name_%C3%B6%C3%A4%C3%BC_%281%29.txt",
- vmime::create <vmime::parameter>("filename", "my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt")->generate());
+ vmime::make_shared <vmime::parameter>("filename", "my_file_name_\xc3\xb6\xc3\xa4\xc3\xbc_(1).txt")->generate());
}
void testWhitespaceBreaksTheValue()
diff --git a/tests/parser/streamContentHandlerTest.cpp b/tests/parser/streamContentHandlerTest.cpp
index 75b3d4d4..55680c93 100644
--- a/tests/parser/streamContentHandlerTest.cpp
+++ b/tests/parser/streamContentHandlerTest.cpp
@@ -51,8 +51,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
void testGetLength()
{
vmime::string data("Test Data");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length());
@@ -63,8 +63,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
void testIsEncoded()
{
vmime::string data("Test Data");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length());
@@ -73,8 +73,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
vmime::string data2("Zm9vEjRWYmFy=");
- vmime::ref <vmime::utility::inputStream> stream2 =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data2);
+ vmime::shared_ptr <vmime::utility::inputStream> stream2 =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data2);
vmime::streamContentHandler cth2(stream2, data2.length(), vmime::encoding("base64"));
@@ -85,8 +85,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
void testGetLength_Encoded()
{
vmime::string data("foo=12=34=56bar");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("quoted-printable"));
@@ -97,8 +97,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
void testExtract()
{
vmime::string data("Test Data");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length());
@@ -114,8 +114,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
{
vmime::string data
("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("base64"));
@@ -133,8 +133,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
{
vmime::string data
("QUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODk=");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("base64"));
@@ -151,8 +151,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
void testGenerate()
{
vmime::string data("foo\x12\x34\x56 bar");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length());
@@ -168,8 +168,8 @@ VMIME_TEST_SUITE_BEGIN(streamContentHandlerTest)
void testGenerate_Encoded()
{
vmime::string data("foo=12=34=56bar");
- vmime::ref <vmime::utility::inputStream> stream =
- vmime::create <vmime::utility::inputStreamStringAdapter>(data);
+ vmime::shared_ptr <vmime::utility::inputStream> stream =
+ vmime::make_shared <vmime::utility::inputStreamStringAdapter>(data);
vmime::streamContentHandler cth(stream, data.length(), vmime::encoding("quoted-printable"));
diff --git a/tests/parser/textTest.cpp b/tests/parser/textTest.cpp
index f4f30b1b..274687a5 100644
--- a/tests/parser/textTest.cpp
+++ b/tests/parser/textTest.cpp
@@ -104,7 +104,7 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("4.3", w1.getCharset(), t4.getWordAt(0)->getCharset());
vmime::word w2("Other", vmime::charset(vmime::charsets::US_ASCII));
- t4.appendWord(vmime::create <vmime::word>(w2));
+ t4.appendWord(vmime::make_shared <vmime::word>(w2));
vmime::text t5(t4);
@@ -296,8 +296,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
// White-space between two encoded words
vmime::text txt;
- txt.appendWord(vmime::create <vmime::word>("\xc3\x89t\xc3\xa9", "utf-8"));
- txt.appendWord(vmime::create <vmime::word>("Fran\xc3\xa7ois", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>("\xc3\x89t\xc3\xa9", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>("Fran\xc3\xa7ois", "utf-8"));
const vmime::string decoded = "\xc3\x89t\xc3\xa9""Fran\xc3\xa7ois";
const vmime::string encoded = "=?utf-8?B?w4l0w6k=?= =?utf-8?Q?Fran=C3=A7ois?=";
@@ -319,11 +319,11 @@ VMIME_TEST_SUITE_BEGIN(textTest)
{
// White-space between two encoded words (#2)
vmime::text txt;
- txt.appendWord(vmime::create <vmime::word>("Facture ", "utf-8"));
- txt.appendWord(vmime::create <vmime::word>("\xc3\xa0", "utf-8"));
- txt.appendWord(vmime::create <vmime::word>(" envoyer ", "utf-8"));
- txt.appendWord(vmime::create <vmime::word>("\xc3\xa0", "utf-8"));
- txt.appendWord(vmime::create <vmime::word>(" Martine", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>("Facture ", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>("\xc3\xa0", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>(" envoyer ", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>("\xc3\xa0", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>(" Martine", "utf-8"));
const vmime::string decoded = "Facture ""\xc3\xa0"" envoyer ""\xc3\xa0"" Martine";
const vmime::string encoded = "Facture =?utf-8?B?w6A=?= envoyer =?utf-8?B?w6A=?= Martine";
@@ -422,8 +422,8 @@ VMIME_TEST_SUITE_BEGIN(textTest)
VASSERT_EQ("generate1", "=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?= <[email protected]>", mbox.generate());
vmime::text txt;
- txt.appendWord(vmime::create <vmime::word>("Achim ", "us-ascii"));
- txt.appendWord(vmime::create <vmime::word>("Br\xc3\xa4ndt", "utf-8"));
+ txt.appendWord(vmime::make_shared <vmime::word>("Achim ", "us-ascii"));
+ txt.appendWord(vmime::make_shared <vmime::word>("Br\xc3\xa4ndt", "utf-8"));
mbox = vmime::mailbox(txt, "[email protected]");
VASSERT_EQ("generate2", "=?us-ascii?Q?Achim_?= =?utf-8?Q?Br=C3=A4ndt?= <[email protected]>", mbox.generate());
diff --git a/tests/security/digest/md5Test.cpp b/tests/security/digest/md5Test.cpp
index ec4e62b2..c7f0b521 100644
--- a/tests/security/digest/md5Test.cpp
+++ b/tests/security/digest/md5Test.cpp
@@ -27,7 +27,7 @@
#define INIT_DIGEST(var, algo) \
- vmime::ref <vmime::security::digest::messageDigest> var = \
+ vmime::shared_ptr <vmime::security::digest::messageDigest> var = \
vmime::security::digest::messageDigestFactory::getInstance()->create(algo)
diff --git a/tests/security/digest/sha1Test.cpp b/tests/security/digest/sha1Test.cpp
index 2accf8c7..c6ce1e65 100644
--- a/tests/security/digest/sha1Test.cpp
+++ b/tests/security/digest/sha1Test.cpp
@@ -27,7 +27,7 @@
#define INIT_DIGEST(var, algo) \
- vmime::ref <vmime::security::digest::messageDigest> var = \
+ vmime::shared_ptr <vmime::security::digest::messageDigest> var = \
vmime::security::digest::messageDigestFactory::getInstance()->create(algo)
diff --git a/tests/testUtils.cpp b/tests/testUtils.cpp
index 93cb9e38..c22649e6 100644
--- a/tests/testUtils.cpp
+++ b/tests/testUtils.cpp
@@ -243,9 +243,9 @@ bool testTimeoutHandler::handleTimeOut()
// testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory
-vmime::ref <vmime::net::timeoutHandler> testTimeoutHandlerFactory::create()
+vmime::shared_ptr <vmime::net::timeoutHandler> testTimeoutHandlerFactory::create()
{
- return vmime::create <testTimeoutHandler>();
+ return vmime::make_shared <testTimeoutHandler>();
}
diff --git a/tests/testUtils.hpp b/tests/testUtils.hpp
index 01910cbc..fdcca575 100644
--- a/tests/testUtils.hpp
+++ b/tests/testUtils.hpp
@@ -315,14 +315,14 @@ class testSocketFactory : public vmime::net::socketFactory
{
public:
- vmime::ref <vmime::net::socket> create()
+ vmime::shared_ptr <vmime::net::socket> create()
{
- return vmime::create <T>();
+ return vmime::make_shared <T>();
}
- vmime::ref <vmime::net::socket> create(vmime::ref <vmime::net::timeoutHandler> /* th */)
+ vmime::shared_ptr <vmime::net::socket> create(vmime::shared_ptr <vmime::net::timeoutHandler> /* th */)
{
- return vmime::create <T>();
+ return vmime::make_shared <T>();
}
};
@@ -366,7 +366,7 @@ class testTimeoutHandlerFactory : public vmime::net::timeoutHandlerFactory
{
public:
- vmime::ref <vmime::net::timeoutHandler> create();
+ vmime::shared_ptr <vmime::net::timeoutHandler> create();
};
diff --git a/tests/utility/encoder/encoderTestUtils.hpp b/tests/utility/encoder/encoderTestUtils.hpp
index 0eb93871..d74c4709 100644
--- a/tests/utility/encoder/encoderTestUtils.hpp
+++ b/tests/utility/encoder/encoderTestUtils.hpp
@@ -23,10 +23,10 @@
// Helper function to obtain an encoder given its name
-static vmime::ref <vmime::utility::encoder::encoder> getEncoder(const vmime::string& name,
+static vmime::shared_ptr <vmime::utility::encoder::encoder> getEncoder(const vmime::string& name,
int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet())
{
- vmime::ref <vmime::utility::encoder::encoder> enc =
+ vmime::shared_ptr <vmime::utility::encoder::encoder> enc =
vmime::utility::encoder::encoderFactory::getInstance()->create(name);
enc->getProperties() = props;
@@ -42,7 +42,7 @@ static vmime::ref <vmime::utility::encoder::encoder> getEncoder(const vmime::str
static const vmime::string encode(const vmime::string& name, const vmime::string& in,
int maxLineLength = 0, const vmime::propertySet props = vmime::propertySet())
{
- vmime::ref <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength, props);
+ vmime::shared_ptr <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength, props);
vmime::utility::inputStreamStringAdapter vin(in);
@@ -58,7 +58,7 @@ static const vmime::string encode(const vmime::string& name, const vmime::string
// Decoding helper function
static const vmime::string decode(const vmime::string& name, const vmime::string& in, int maxLineLength = 0)
{
- vmime::ref <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength);
+ vmime::shared_ptr <vmime::utility::encoder::encoder> enc = getEncoder(name, maxLineLength);
vmime::utility::inputStreamStringAdapter vin(in);
diff --git a/tests/utility/outputStreamSocketAdapterTest.cpp b/tests/utility/outputStreamSocketAdapterTest.cpp
index 920c7f47..417eff8b 100644
--- a/tests/utility/outputStreamSocketAdapterTest.cpp
+++ b/tests/utility/outputStreamSocketAdapterTest.cpp
@@ -37,7 +37,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
void testWrite()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::utility::outputStreamSocketAdapter stream(*socket);
stream << "some data";
@@ -55,7 +55,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
"\xc5\x9a\xc3\xb8\xc9\xb1\xc9\x9b\x20\xc9\x93\xc9\xa8\xc9\xb2\xc9"
"\x91\xc5\x95\xc9\xa3\x20\xc9\x96\xc9\x90\xca\x88\xc9\x92";
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::utility::outputStreamSocketAdapter stream(*socket);
stream.write(binaryData, sizeof(binaryData));
@@ -69,7 +69,7 @@ VMIME_TEST_SUITE_BEGIN(outputStreamSocketAdapterTest)
void testWriteCRLF()
{
- vmime::ref <testSocket> socket = vmime::create <testSocket>();
+ vmime::shared_ptr <testSocket> socket = vmime::make_shared <testSocket>();
vmime::utility::outputStreamSocketAdapter stream(*socket);
stream << "some data";
diff --git a/tests/utility/seekableInputStreamRegionAdapterTest.cpp b/tests/utility/seekableInputStreamRegionAdapterTest.cpp
index 3ed024e8..1c33c056 100644
--- a/tests/utility/seekableInputStreamRegionAdapterTest.cpp
+++ b/tests/utility/seekableInputStreamRegionAdapterTest.cpp
@@ -42,16 +42,16 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VMIME_TEST_LIST_END
- vmime::ref <seekableInputStreamRegionAdapter> createStream
- (vmime::ref <seekableInputStream>* underlyingStream = NULL)
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> createStream
+ (vmime::shared_ptr <seekableInputStream>* underlyingStream = NULL)
{
vmime::string buffer("THIS IS A TEST BUFFER");
- vmime::ref <seekableInputStream> strStream =
- vmime::create <inputStreamStringAdapter>(buffer);
+ vmime::shared_ptr <seekableInputStream> strStream =
+ vmime::make_shared <inputStreamStringAdapter>(buffer);
- vmime::ref <seekableInputStreamRegionAdapter> rgnStream =
- vmime::create <seekableInputStreamRegionAdapter>(strStream, 10, 11);
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> rgnStream =
+ vmime::make_shared <seekableInputStreamRegionAdapter>(strStream, 10, 11);
if (underlyingStream)
*underlyingStream = strStream;
@@ -61,7 +61,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
void testInitialPosition()
{
- vmime::ref <seekableInputStreamRegionAdapter> stream = createStream();
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
VASSERT_EQ("Pos", 0, stream->getPosition());
VASSERT_FALSE("EOF", stream->eof());
@@ -69,7 +69,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
void testSeekAndGetPosition()
{
- vmime::ref <seekableInputStreamRegionAdapter> stream = createStream();
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->seek(5);
@@ -84,11 +84,12 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
void testRead()
{
- vmime::ref <seekableInputStreamRegionAdapter> stream = createStream();
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->seek(5);
stream::value_type buffer[100];
+ std::fill(vmime::begin(buffer), vmime::end(buffer), 0);
stream::size_type read = stream->read(buffer, 6);
VASSERT_EQ("Pos", 11, stream->getPosition());
@@ -99,7 +100,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
void testSkip()
{
- vmime::ref <seekableInputStreamRegionAdapter> stream = createStream();
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->skip(5);
@@ -107,6 +108,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
VASSERT_FALSE("EOF 1", stream->eof());
stream::value_type buffer[100];
+ std::fill(vmime::begin(buffer), vmime::end(buffer), 0);
stream::size_type read = stream->read(buffer, 3);
VASSERT_EQ("Pos 2", 8, stream->getPosition());
@@ -122,7 +124,7 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
void testReset()
{
- vmime::ref <seekableInputStreamRegionAdapter> stream = createStream();
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream();
stream->skip(100);
stream->reset();
@@ -136,15 +138,17 @@ VMIME_TEST_SUITE_BEGIN(seekableInputStreamRegionAdapterTest)
// seekableInputStreamRegionAdapter should keep track of its own position
// in the underlying stream, and not be affected by possible seek/read
// operations on it...
- vmime::ref <seekableInputStream> ustream;
- vmime::ref <seekableInputStreamRegionAdapter> stream = createStream(&ustream);
+ vmime::shared_ptr <seekableInputStream> ustream;
+ vmime::shared_ptr <seekableInputStreamRegionAdapter> stream = createStream(&ustream);
stream->seek(5);
stream::value_type buffer1[100];
+ std::fill(vmime::begin(buffer1), vmime::end(buffer1), 0);
stream::size_type read = ustream->read(buffer1, 7);
stream::value_type buffer2[100];
+ std::fill(vmime::begin(buffer2), vmime::end(buffer2), 0);
stream::size_type read2 = stream->read(buffer2, 6);
VASSERT_EQ("Buffer 1", "THIS IS", vmime::string(buffer1, 0, 7));
diff --git a/tests/utility/smartPtrTest.cpp b/tests/utility/smartPtrTest.cpp
deleted file mode 100644
index 584adf3b..00000000
--- a/tests/utility/smartPtrTest.cpp
+++ /dev/null
@@ -1,241 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#include "tests/testUtils.hpp"
-
-#include "vmime/utility/smartPtr.hpp"
-
-
-VMIME_TEST_SUITE_BEGIN(smartPtrTest)
-
- VMIME_TEST_LIST_BEGIN
- VMIME_TEST(testNull)
- VMIME_TEST(testRefCounting)
- VMIME_TEST(testWeakRef)
- VMIME_TEST(testCast)
- VMIME_TEST(testContainer)
- VMIME_TEST(testCompare)
- VMIME_TEST_LIST_END
-
-
- struct A : public vmime::object
- {
- int strongCount() const { return getRefManager()->getStrongRefCount(); }
- int weakCount() const { return getRefManager()->getWeakRefCount(); }
- };
-
- struct B : public virtual A { };
- struct C : public virtual A { };
- struct D : public B, public C { };
-
- class R : public A
- {
- public:
-
- R(bool* aliveFlag) : m_aliveFlag(aliveFlag) { *m_aliveFlag = true; }
- ~R() { *m_aliveFlag = false; }
-
- private:
-
- bool* m_aliveFlag;
- };
-
-
- void testNull()
- {
- vmime::ref <A> r1;
-
- VASSERT("1", r1 == NULL);
- VASSERT("2", r1 == 0);
- VASSERT("3", NULL == r1);
- VASSERT("4", 0 == r1);
- VASSERT("5", !r1);
- VASSERT("6", r1 == vmime::null);
- VASSERT("7", vmime::null == r1);
- VASSERT_EQ("8", static_cast <A*>(0), r1.get());
- }
-
- void testRefCounting()
- {
- bool o1_alive;
- vmime::ref <R> r1 = vmime::create <R>(&o1_alive);
-
- VASSERT("1", r1.get() != 0);
- VASSERT("2", o1_alive);
- VASSERT_EQ("3", 1, r1->strongCount());
- VASSERT_EQ("4", 1, r1->weakCount());
-
- vmime::ref <R> r2 = r1;
-
- VASSERT("5", o1_alive);
- VASSERT_EQ("6", 2, r1->strongCount());
- VASSERT_EQ("7", 2, r1->weakCount());
-
- bool o2_alive;
- vmime::ref <R> r3 = vmime::create <R>(&o2_alive);
-
- r2 = r3;
-
- VASSERT("8", o1_alive);
- VASSERT("9", o2_alive);
- VASSERT_EQ("10", 1, r1->strongCount());
- VASSERT_EQ("11", 2, r2->strongCount());
- VASSERT_EQ("12", 2, r3->strongCount());
-
- {
- vmime::ref <R> r4;
-
- r4 = r1;
-
- VASSERT("13", o1_alive);
- VASSERT("14", o2_alive);
- VASSERT_EQ("15", 2, r4->strongCount());
- VASSERT_EQ("16", 2, r1->strongCount());
-
- r1 = NULL;
-
- VASSERT("17", o1_alive);
- VASSERT("18", o2_alive);
- VASSERT_EQ("19", 1, r4->strongCount());
-
- // Here, object1 will be deleted
- }
-
- VASSERT("20", !o1_alive);
- VASSERT("21", o2_alive);
-
- {
- vmime::weak_ref <R> w1 = r3;
-
- VASSERT_EQ("22", 3, r3->weakCount());
- }
-
- VASSERT("23", o2_alive);
- VASSERT_EQ("24", 2, r3->strongCount());
- VASSERT_EQ("25", 2, r3->weakCount());
- }
-
- void testWeakRef()
- {
- vmime::ref <A> r1 = vmime::create <A>();
- vmime::weak_ref <A> w1 = r1;
-
- VASSERT("1", r1.get() != 0);
- VASSERT("2", r1.get() == w1.acquire().get());
-
- {
- vmime::ref <A> r2 = r1;
-
- VASSERT("3", r1.get() == r2.get());
- VASSERT("4", r1.get() == w1.acquire().get());
- }
-
- VASSERT("5", r1.get() != 0);
- VASSERT("6", r1.get() == w1.acquire().get());
-
- r1 = 0;
-
- VASSERT("7", w1.acquire().get() == 0);
- }
-
- void testCast()
- {
- // Explicit upcast
- vmime::ref <A> r1 = vmime::create <C>();
- vmime::ref <C> r2 = r1.dynamicCast <C>();
-
- VASSERT("1", r2.get() == dynamic_cast <C*>(r1.get()));
- VASSERT("2", 0 == r1.dynamicCast <B>().get());
-
- // Implicit downcast
- vmime::ref <D> r3 = vmime::create <D>();
- vmime::ref <A> r4 = r3;
-
- VASSERT("3", r4.get() == dynamic_cast <A*>(r3.get()));
- }
-
- void testContainer()
- {
- bool o1_alive;
- vmime::ref <R> r1 = vmime::create <R>(&o1_alive);
-
- bool o2_alive;
- vmime::ref <R> r2 = vmime::create <R>(&o2_alive);
-
- std::vector <vmime::ref <R> > v1;
- v1.push_back(r1);
- v1.push_back(r2);
-
- VASSERT("1", o1_alive);
- VASSERT_EQ("2", 2, r1->strongCount());
- VASSERT("3", o2_alive);
- VASSERT_EQ("4", 2, r2->strongCount());
-
- {
- std::vector <vmime::ref <R> > v2 = v1;
-
- VASSERT("5", o1_alive);
- VASSERT_EQ("6", 3, r1->strongCount());
- VASSERT("7", o2_alive);
- VASSERT_EQ("8", 3, r2->strongCount());
-
- v2[1] = NULL;
-
- VASSERT("9", o1_alive);
- VASSERT_EQ("10", 3, r1->strongCount());
- VASSERT("11", o2_alive);
- VASSERT_EQ("12", 2, r2->strongCount());
- }
-
- VASSERT("13", o1_alive);
- VASSERT_EQ("14", 2, r1->strongCount());
- VASSERT("15", o2_alive);
- VASSERT_EQ("16", 2, r2->strongCount());
- }
-
- void testCompare()
- {
- vmime::ref <A> r1 = vmime::create <A>();
- vmime::ref <A> r2 = vmime::create <B>();
- vmime::ref <A> r3 = vmime::create <C>();
- vmime::ref <A> r4 = r1;
-
- VASSERT("1", r1 != r2);
- VASSERT("2", r1.get() == r1);
- VASSERT("3", r1 == r1.get());
- VASSERT("4", r2 != r1.get());
- VASSERT("5", r1.get() != r2);
- VASSERT("6", r1 == r4);
- VASSERT("7", r1.get() == r4);
-
- std::vector <vmime::ref <A> > v;
- v.push_back(r1);
- v.push_back(r2);
-
- VASSERT("8", std::find(v.begin(), v.end(), r1) == v.begin());
- VASSERT("9", std::find(v.begin(), v.end(), r2) == v.begin() + 1);
- VASSERT("10", std::find(v.begin(), v.end(), r3) == v.end());
- }
-
-VMIME_TEST_SUITE_END
-
diff --git a/vmime/address.hpp b/vmime/address.hpp
index 3c0c0b2a..110e1e6b 100644
--- a/vmime/address.hpp
+++ b/vmime/address.hpp
@@ -61,7 +61,7 @@ public:
*/
virtual bool isGroup() const = 0;
- virtual ref <component> clone() const = 0;
+ virtual shared_ptr <component> clone() const = 0;
/** Parse an address from an input buffer.
*
@@ -74,7 +74,7 @@ public:
* of a group (end delimiter was found), or false otherwise (may be set to NULL)
* @return a new address object, or null if no more address is available in the input buffer
*/
- static ref <address> parseNext
+ static shared_ptr <address> parseNext
(const parsingContext& ctx, const string& buffer,
const string::size_type position, const string::size_type end,
string::size_type* newPosition, bool *isLastAddressOfGroup);
diff --git a/vmime/addressList.hpp b/vmime/addressList.hpp
index 9fd5ab08..2958000b 100644
--- a/vmime/addressList.hpp
+++ b/vmime/addressList.hpp
@@ -51,19 +51,19 @@ public:
~addressList();
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
addressList& operator=(const addressList& other);
addressList& operator=(const mailboxList& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Add a address at the end of the list.
*
* @param addr address to append
*/
- void appendAddress(ref <address> addr);
+ void appendAddress(shared_ptr <address> addr);
/** Insert a new address before the specified address.
*
@@ -71,7 +71,7 @@ public:
* @param addr address to insert
* @throw exceptions::no_such_address if the address is not in the list
*/
- void insertAddressBefore(ref <address> beforeAddress, ref <address> addr);
+ void insertAddressBefore(shared_ptr <address> beforeAddress, shared_ptr <address> addr);
/** Insert a new address before the specified position.
*
@@ -79,7 +79,7 @@ public:
* the beginning of the list)
* @param addr address to insert
*/
- void insertAddressBefore(const size_t pos, ref <address> addr);
+ void insertAddressBefore(const size_t pos, shared_ptr <address> addr);
/** Insert a new address after the specified address.
*
@@ -87,21 +87,21 @@ public:
* @param addr address to insert
* @throw exceptions::no_such_address if the address is not in the list
*/
- void insertAddressAfter(ref <address> afterAddress, ref <address> addr);
+ void insertAddressAfter(shared_ptr <address> afterAddress, shared_ptr <address> addr);
/** Insert a new address after the specified position.
*
* @param pos position of the address before the new address
* @param addr address to insert
*/
- void insertAddressAfter(const size_t pos, ref <address> addr);
+ void insertAddressAfter(const size_t pos, shared_ptr <address> addr);
/** Remove the specified address from the list.
*
* @param addr address to remove
* @throw exceptions::no_such_address if the address is not in the list
*/
- void removeAddress(ref <address> addr);
+ void removeAddress(shared_ptr <address> addr);
/** Remove the address at the specified position.
*
@@ -130,26 +130,26 @@ public:
* @param pos position
* @return address at position 'pos'
*/
- ref <address> getAddressAt(const size_t pos);
+ shared_ptr <address> getAddressAt(const size_t pos);
/** Return the address at the specified position.
*
* @param pos position
* @return address at position 'pos'
*/
- const ref <const address> getAddressAt(const size_t pos) const;
+ const shared_ptr <const address> getAddressAt(const size_t pos) const;
/** Return the address list.
*
* @return list of addresses
*/
- const std::vector <ref <const address> > getAddressList() const;
+ const std::vector <shared_ptr <const address> > getAddressList() const;
/** Return the address list.
*
* @return list of addresses
*/
- const std::vector <ref <address> > getAddressList();
+ const std::vector <shared_ptr <address> > getAddressList();
/** Return a list of mailboxes.
* If some addresses are actually groups, mailboxes are recursively
@@ -157,11 +157,11 @@ public:
*
* @return list of mailboxes
*/
- ref <mailboxList> toMailboxList() const;
+ shared_ptr <mailboxList> toMailboxList() const;
private:
- std::vector <ref <address> > m_list;
+ std::vector <shared_ptr <address> > m_list;
protected:
diff --git a/vmime/attachment.hpp b/vmime/attachment.hpp
index e131fcd0..9730bc6c 100644
--- a/vmime/attachment.hpp
+++ b/vmime/attachment.hpp
@@ -79,7 +79,7 @@ public:
*
* @return attachment data
*/
- virtual const ref <const contentHandler> getData() const = 0;
+ virtual const shared_ptr <const contentHandler> getData() const = 0;
/** Return the encoding used for this attachment.
*
@@ -93,14 +93,14 @@ public:
* @return attachment part or NULL if the attachment is not
* attached to a part
*/
- virtual ref <const object> getPart() const = 0;
+ virtual shared_ptr <const object> getPart() const = 0;
/** Return the header of the attachment part.
*
* @return attachment part header or NULL if the attachment
* is not attached to a part
*/
- virtual ref <const header> getHeader() const = 0;
+ virtual shared_ptr <const header> getHeader() const = 0;
protected:
@@ -108,7 +108,7 @@ protected:
*
* @param parent body part in which to generate the attachment
*/
- virtual void generateIn(ref <bodyPart> parent) const = 0;
+ virtual void generateIn(shared_ptr <bodyPart> parent) const = 0;
};
diff --git a/vmime/attachmentHelper.hpp b/vmime/attachmentHelper.hpp
index 0dd052cb..e03a4f7d 100644
--- a/vmime/attachmentHelper.hpp
+++ b/vmime/attachmentHelper.hpp
@@ -59,7 +59,7 @@ public:
* @param options search options (see FindOptions)
* @return true if the part is an attachment, false otherwise
*/
- static bool isBodyPartAnAttachment(ref <const bodyPart> part, const unsigned int options = 0);
+ static bool isBodyPartAnAttachment(shared_ptr <const bodyPart> part, const unsigned int options = 0);
/** Return attachment information in the specified body part.
* If the specified body part does not contain attachment
@@ -69,8 +69,8 @@ public:
* @param options search options (see FindOptions)
* @return attachment found in the part, or NULL
*/
- static ref <const attachment>
- getBodyPartAttachment(ref <const bodyPart> part, const unsigned int options = 0);
+ static shared_ptr <const attachment>
+ getBodyPartAttachment(shared_ptr <const bodyPart> part, const unsigned int options = 0);
/** Find all attachments contained in the specified part
* and all its children parts.
@@ -80,8 +80,8 @@ public:
* @param options search options (see FindOptions)
* @return a list of attachments found
*/
- static const std::vector <ref <const attachment> >
- findAttachmentsInBodyPart(ref <const bodyPart> part, const unsigned int options = 0);
+ static const std::vector <shared_ptr <const attachment> >
+ findAttachmentsInBodyPart(shared_ptr <const bodyPart> part, const unsigned int options = 0);
/** Find all attachments contained in the specified message.
* This is simply a recursive call to getBodyPartAttachment().
@@ -90,27 +90,27 @@ public:
* @param options search options (see FindOptions)
* @return a list of attachments found
*/
- static const std::vector <ref <const attachment> >
- findAttachmentsInMessage(ref <const message> msg, const unsigned int options = 0);
+ static const std::vector <shared_ptr <const attachment> >
+ findAttachmentsInMessage(shared_ptr <const message> msg, const unsigned int options = 0);
/** Add an attachment to the specified message.
*
* @param msg message into which to add the attachment
* @param att attachment to add
*/
- static void addAttachment(ref <message> msg, ref <attachment> att);
+ static void addAttachment(shared_ptr <message> msg, shared_ptr <attachment> att);
/** Add a message attachment to the specified message.
*
* @param msg message into which to add the attachment
* @param amsg message to attach
*/
- static void addAttachment(ref <message> msg, ref <message> amsg);
+ static void addAttachment(shared_ptr <message> msg, shared_ptr <message> amsg);
protected:
- static ref <bodyPart> findBodyPart
- (ref <bodyPart> part, const mediaType& type);
+ static shared_ptr <bodyPart> findBodyPart
+ (shared_ptr <bodyPart> part, const mediaType& type);
};
diff --git a/vmime/base.hpp b/vmime/base.hpp
index 2437514b..36938cb7 100644
--- a/vmime/base.hpp
+++ b/vmime/base.hpp
@@ -35,7 +35,6 @@
#include "vmime/config.hpp"
#include "vmime/types.hpp"
#include "vmime/constants.hpp"
-#include "vmime/utility/smartPtr.hpp"
namespace vmime
@@ -51,6 +50,19 @@ namespace vmime
extern VMIME_EXPORT const text NULL_TEXT;
extern VMIME_EXPORT const word NULL_WORD;
+#ifndef VMIME_BUILDING_DOC
+
+ // Null pointer
+ struct nullPtrType
+ {
+ template<typename T>
+ operator shared_ptr <T>() { return shared_ptr <T>(); }
+ };
+
+ extern nullPtrType VMIME_EXPORT null;
+
+#endif // VMIME_BUILDING_DOC
+
//
// Library name and version
@@ -66,13 +78,25 @@ namespace vmime
//
template <typename T, size_t N>
- inline T const* begin(T const (&array)[N])
+ inline T const* cbegin(T const (&array)[N])
{
return (array);
}
template <typename T, size_t N>
- inline T const* end(T const (&array)[N])
+ inline T const* cend(T const (&array)[N])
+ {
+ return (array + N);
+ }
+
+ template <typename T, size_t N>
+ inline T* begin(T (&array)[N])
+ {
+ return (array);
+ }
+
+ template <typename T, size_t N>
+ inline T* end(T (&array)[N])
{
return (array + N);
}
@@ -158,100 +182,49 @@ namespace vmime
namespace utility { }
-#ifndef VMIME_BUILDING_DOC
- /** Work-around for friend template functions.
- *
- * Make this class a friend if you want to be able to use
- * vmime::create() with private/protected constructors.
- */
- class VMIME_EXPORT creator
- {
- public:
-
- template <class T>
- static ref <T> create() { return ref <T>::fromPtr(new T); }
-
- template <class T, class P0>
- static ref <T> create(const P0& p0) { return ref <T>::fromPtr(new T(p0)); }
-
- template <class T, class P0, class P1>
- static ref <T> create(const P0& p0, const P1& p1) { return ref <T>::fromPtr(new T(p0, p1)); }
-
- template <class T, class P0, class P1, class P2>
- static ref <T> create(const P0& p0, const P1& p1, const P2& p2) { return ref <T>::fromPtr(new T(p0, p1, p2)); }
-
- template <class T, class P0, class P1, class P2, class P3>
- static ref <T> create(const P0& p0, const P1& p1, const P2& p2, const P3& p3) { return ref <T>::fromPtr(new T(p0, p1, p2, p3)); }
-
- template <class T, class P0, class P1, class P2, class P3, class P4>
- static ref <T> create(const P0& p0, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { return ref <T>::fromPtr(new T(p0, p1, p2, p3, p4)); }
- };
-#endif // VMIME_BUILDING_DOC
-
- /** Create a new object and return a reference to it.
- * @return reference to the new object
+ /** Clone helper (using a shared_ptr).
+ * This is an alias for dynamic_pointer_cast <T>(obj->clone()).
*/
template <class T>
- static ref <T> create() { return creator::create <T>(); }
-
- /** Create a new object and return a reference to it.
- * @return reference to the new object
- */
- template <class T, class P0>
- static ref <T> create(const P0& p0) { return creator::create <T, P0>(p0); }
-
- /** Create a new object and return a reference to it.
- * @return reference to the new object
- */
- template <class T, class P0, class P1>
- static ref <T> create(const P0& p0, const P1& p1) { return creator::create <T, P0, P1>(p0, p1); }
-
- /** Create a new object and return a reference to it.
- * @return reference to the new object
- */
- template <class T, class P0, class P1, class P2>
- static ref <T> create(const P0& p0, const P1& p1, const P2& p2) { return creator::create <T, P0, P1, P2>(p0, p1, p2); }
-
- /** Create a new object and return a reference to it.
- * @return reference to the new object
- */
- template <class T, class P0, class P1, class P2, class P3>
- static ref <T> create(const P0& p0, const P1& p1, const P2& p2, const P3& p3) { return creator::create <T, P0, P1, P2, P3>(p0, p1, p2, p3); }
-
- /** Create a new object and return a reference to it.
- * @return reference to the new object
- */
- template <class T, class P0, class P1, class P2, class P3, class P4>
- static ref <T> create(const P0& p0, const P1& p1, const P2& p2, const P3& p3, const P4& p4) { return creator::create <T, P0, P1, P2, P3, P4>(p0, p1, p2, p3, p4); }
-
+ shared_ptr <T> clone(shared_ptr <T> obj)
+ {
+ return dynamic_pointer_cast <T>(obj->clone());
+ }
- /** Clone helper.
- * Use "vmime::clone(obj)" instead of "obj->clone().cast <objtype>()".
+ /** Clone helper (using a const shared_ptr).
+ * This is an alias for dynamic_pointer_cast <T>(obj->clone()).
*/
template <class T>
- ref <T> clone(ref <const T> x)
+ shared_ptr <T> clone(shared_ptr <const T> obj)
{
- return x->clone().template dynamicCast <T>();
+ return dynamic_pointer_cast <T>(obj->clone());
}
- /** Clone helper.
- * Use "vmime::clone(obj)" instead of "obj.clone().cast <objtype>()".
+ /** Clone helper (using a const reference).
+ * This is an alias for dynamic_pointer_cast <T>(obj.clone()).
*/
template <class T>
- ref <T> clone(const T& x)
+ shared_ptr <T> clone(const T& obj)
{
- return x.clone().template dynamicCast <T>();
+ return dynamic_pointer_cast <T>(obj.clone());
}
-
/** Downcast helper.
* Usage: vmime::dynamicCast <DerivedType>(obj), where 'obj' is of
* type Type, and DerivedType is derived from Type.
*/
template <class X, class Y>
- ref <X> dynamicCast(ref <Y> y)
+ shared_ptr <X> dynamicCast(shared_ptr <Y> obj)
+ {
+ return dynamic_pointer_cast <X, Y>(obj);
+ }
+
+ /** Const cast helper.
+ */
+ template <class X, class Y>
+ shared_ptr <X> constCast(const shared_ptr <Y>& obj)
{
- return y.template dynamicCast <X>();
+ return const_pointer_cast <X, Y>(obj);
}
/** Inherit from this class to indicate the subclass is not copyable,
diff --git a/vmime/body.hpp b/vmime/body.hpp
index 3f2ea483..465a7a81 100644
--- a/vmime/body.hpp
+++ b/vmime/body.hpp
@@ -60,7 +60,7 @@ public:
*
* @param part part to append
*/
- void appendPart(ref <bodyPart> part);
+ void appendPart(shared_ptr <bodyPart> part);
/** Insert a new part before the specified part.
*
@@ -68,7 +68,7 @@ public:
* @param part part to insert
* @throw exceptions::no_such_part if the part is not in the list
*/
- void insertPartBefore(ref <bodyPart> beforePart, ref <bodyPart> part);
+ void insertPartBefore(shared_ptr <bodyPart> beforePart, shared_ptr <bodyPart> part);
/** Insert a new part before the specified position.
*
@@ -76,7 +76,7 @@ public:
* the beginning of the list)
* @param part part to insert
*/
- void insertPartBefore(const size_t pos, ref <bodyPart> part);
+ void insertPartBefore(const size_t pos, shared_ptr <bodyPart> part);
/** Insert a new part after the specified part.
*
@@ -84,21 +84,21 @@ public:
* @param part part to insert
* @throw exceptions::no_such_part if the part is not in the list
*/
- void insertPartAfter(ref <bodyPart> afterPart, ref <bodyPart> part);
+ void insertPartAfter(shared_ptr <bodyPart> afterPart, shared_ptr <bodyPart> part);
/** Insert a new part after the specified position.
*
* @param pos position of the part before the new part
* @param part part to insert
*/
- void insertPartAfter(const size_t pos, ref <bodyPart> part);
+ void insertPartAfter(const size_t pos, shared_ptr <bodyPart> part);
/** Remove the specified part from the list.
*
* @param part part to remove
* @throw exceptions::no_such_part if the part is not in the list
*/
- void removePart(ref <bodyPart> part);
+ void removePart(shared_ptr <bodyPart> part);
/** Remove the part at the specified position.
*
@@ -127,26 +127,26 @@ public:
* @param pos position
* @return part at position 'pos'
*/
- ref <bodyPart> getPartAt(const size_t pos);
+ shared_ptr <bodyPart> getPartAt(const size_t pos);
/** Return the part at the specified position.
*
* @param pos position
* @return part at position 'pos'
*/
- const ref <const bodyPart> getPartAt(const size_t pos) const;
+ const shared_ptr <const bodyPart> getPartAt(const size_t pos) const;
/** Return the part list.
*
* @return list of parts
*/
- const std::vector <ref <const bodyPart> > getPartList() const;
+ const std::vector <shared_ptr <const bodyPart> > getPartList() const;
/** Return the part list.
*
* @return list of parts
*/
- const std::vector <ref <bodyPart> > getPartList();
+ const std::vector <shared_ptr <bodyPart> > getPartList();
/** Return the prolog text.
*
@@ -176,20 +176,20 @@ public:
*
* @return read-only body contents
*/
- const ref <const contentHandler> getContents() const;
+ const shared_ptr <const contentHandler> getContents() const;
/** Set the body contents.
*
* @param contents new body contents
*/
- void setContents(ref <const contentHandler> contents);
+ void setContents(shared_ptr <const contentHandler> contents);
/** Set the body contents and type.
*
* @param contents new body contents
* @param type type of contents
*/
- void setContents(ref <const contentHandler> contents, const mediaType& type);
+ void setContents(shared_ptr <const contentHandler> contents, const mediaType& type);
/** Set the body contents, type and charset.
*
@@ -197,7 +197,7 @@ public:
* @param type type of contents
* @param chset charset of contents
*/
- void setContents(ref <const contentHandler> contents, const mediaType& type, const charset& chset);
+ void setContents(shared_ptr <const contentHandler> contents, const mediaType& type, const charset& chset);
/** Set the body contents, type, charset and encoding.
*
@@ -206,7 +206,7 @@ public:
* @param chset charset of contents
* @param enc contents encoding
*/
- void setContents(ref <const contentHandler> contents, const mediaType& type,
+ void setContents(shared_ptr <const contentHandler> contents, const mediaType& type,
const charset& chset, const encoding& enc);
/** Set the MIME type and charset of contents.
@@ -274,11 +274,11 @@ public:
*/
static bool isValidBoundary(const string& boundary);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
body& operator=(const body& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
utility::stream::size_type getGeneratedSize(const generationContext& ctx);
@@ -287,22 +287,21 @@ private:
text getActualPrologText(const generationContext& ctx) const;
text getActualEpilogText(const generationContext& ctx) const;
- void setParentPart(ref <bodyPart> parent);
+ void setParentPart(bodyPart* parent);
string m_prologText;
string m_epilogText;
- ref <const contentHandler> m_contents;
+ shared_ptr <const contentHandler> m_contents;
- weak_ref <bodyPart> m_part;
- weak_ref <header> m_header;
+ bodyPart* m_part;
- std::vector <ref <bodyPart> > m_parts;
+ std::vector <shared_ptr <bodyPart> > m_parts;
bool isRootPart() const;
- void initNewPart(ref <bodyPart> part);
+ void initNewPart(shared_ptr <bodyPart> part);
protected:
@@ -319,14 +318,14 @@ protected:
* @return the position of the boundary string, or stream::npos if not found
*/
utility::stream::size_type findNextBoundaryPosition
- (ref <utility::parserInputStreamAdapter> parser, const string& boundary,
+ (shared_ptr <utility::parserInputStreamAdapter> parser, const string& boundary,
const utility::stream::size_type position, const utility::stream::size_type end,
utility::stream::size_type* boundaryStart, utility::stream::size_type* boundaryEnd);
// Component parsing & assembling
void parseImpl
(const parsingContext& ctx,
- ref <utility::parserInputStreamAdapter> parser,
+ shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition = NULL);
diff --git a/vmime/bodyPart.hpp b/vmime/bodyPart.hpp
index 62365b8b..fd0deb73 100644
--- a/vmime/bodyPart.hpp
+++ b/vmime/bodyPart.hpp
@@ -46,78 +46,97 @@ class VMIME_EXPORT bodyPart : public component
public:
bodyPart();
- bodyPart(weak_ref <vmime::bodyPart> parentPart);
/** Return the header section of this part.
*
* @return header section
*/
- const ref <const header> getHeader() const;
+ const shared_ptr <const header> getHeader() const;
/** Return the header section of this part.
*
* @return header section
*/
- ref <header> getHeader();
+ shared_ptr <header> getHeader();
/** Replaces the header section of this part.
*
* @param header the new header of this part
*/
- void setHeader(ref <header> header);
+ void setHeader(shared_ptr <header> header);
/** Return the body section of this part.
*
* @return body section
*/
- const ref <const body> getBody() const;
+ const shared_ptr <const body> getBody() const;
/** Return the body section of this part.
*
* @return body section
*/
- ref <body> getBody();
+ shared_ptr <body> getBody();
/** Replaces the body section of this part.
*
* @param body new body section
*/
- void setBody(ref <body> body);
+ void setBody(shared_ptr <body> body);
/** Return the parent part of this part.
*
* @return parent part or NULL if not known
*/
- ref <bodyPart> getParentPart();
+ bodyPart* getParentPart();
/** Return the parent part of this part (const version).
*
* @return parent part or NULL if not known
*/
- ref <const bodyPart> getParentPart() const;
+ const bodyPart* getParentPart() const;
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
bodyPart& operator=(const bodyPart& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
utility::stream::size_type getGeneratedSize(const generationContext& ctx);
private:
- ref <header> m_header;
- ref <body> m_body;
+ shared_ptr <header> m_header;
+ mutable shared_ptr <body> m_body;
- weak_ref <bodyPart> m_parent;
+ // We can't use a weak_ptr<> here as the parent part may
+ // have been allocated on the stack
+ bodyPart* m_parent;
protected:
+ /** Creates and returns a new part and set this part as its
+ * parent. The newly created sub-part should then be added
+ * to this part by calling getBody()->appendPart(). Called
+ * by the body class.
+ *
+ * @return child part
+ */
+ shared_ptr <bodyPart> createChildPart();
+
+ /** Detach the specified part from its current parent part (if
+ * any) and attach it to this part by setting this part as its
+ * new parent. The sub-part should then be added to this part
+ * by calling getBody()->appendPart(). Called by body class.
+ *
+ * @param part child part to attach
+ */
+ void importChildPart(shared_ptr <bodyPart> part);
+
// Component parsing & assembling
void parseImpl
(const parsingContext& ctx,
- ref <utility::parserInputStreamAdapter> parser,
+ shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition = NULL);
diff --git a/vmime/bodyPartAttachment.hpp b/vmime/bodyPartAttachment.hpp
index b885d020..e1a4a89a 100644
--- a/vmime/bodyPartAttachment.hpp
+++ b/vmime/bodyPartAttachment.hpp
@@ -42,33 +42,29 @@ namespace vmime
*/
class VMIME_EXPORT bodyPartAttachment : public attachment
{
- friend class creator;
-
-protected:
-
- bodyPartAttachment(ref <const bodyPart> part);
-
public:
+ bodyPartAttachment(shared_ptr <const bodyPart> part);
+
const mediaType getType() const;
const word getName() const;
const text getDescription() const;
const encoding getEncoding() const;
- const ref <const contentHandler> getData() const;
+ const shared_ptr <const contentHandler> getData() const;
- ref <const object> getPart() const;
- ref <const header> getHeader() const;
+ shared_ptr <const object> getPart() const;
+ shared_ptr <const header> getHeader() const;
private:
- void generateIn(ref <bodyPart> parent) const;
+ void generateIn(shared_ptr <bodyPart> parent) const;
- ref <const contentDispositionField> getContentDisposition() const;
- ref <const contentTypeField> getContentType() const;
+ shared_ptr <const contentDispositionField> getContentDisposition() const;
+ shared_ptr <const contentTypeField> getContentType() const;
- ref <const bodyPart> m_part;
+ shared_ptr <const bodyPart> m_part;
};
diff --git a/vmime/charset.hpp b/vmime/charset.hpp
index c77a2e01..9c1325c6 100644
--- a/vmime/charset.hpp
+++ b/vmime/charset.hpp
@@ -63,7 +63,7 @@ public:
bool operator==(const charset& value) const;
bool operator!=(const charset& value) const;
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Gets the recommended encoding for this charset.
* Note: there may be no recommended encoding.
@@ -117,7 +117,7 @@ public:
const charset& source, const charset& dest,
const charsetConverterOptions& opts = charsetConverterOptions());
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
private:
diff --git a/vmime/charsetConverter.hpp b/vmime/charsetConverter.hpp
index 9a4f8b37..07f38d8f 100644
--- a/vmime/charsetConverter.hpp
+++ b/vmime/charsetConverter.hpp
@@ -69,7 +69,7 @@ public:
* @param dest output charset
* @param opts conversion options
*/
- static ref <charsetConverter> create
+ static shared_ptr <charsetConverter> create
(const charset& source, const charset& dest,
const charsetConverterOptions& opts = charsetConverterOptions());
@@ -103,11 +103,11 @@ public:
* @param os stream into which filtered data will be written
* @return a filtered output stream, or NULL if not supported
*/
- virtual ref <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os) = 0;
+ virtual shared_ptr <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os) = 0;
private:
- static ref <charsetConverter> createGenericConverter
+ static shared_ptr <charsetConverter> createGenericConverter
(const charset& source, const charset& dest,
const charsetConverterOptions& opts);
};
diff --git a/vmime/charsetConverter_iconv.hpp b/vmime/charsetConverter_iconv.hpp
index a590b320..0309d848 100644
--- a/vmime/charsetConverter_iconv.hpp
+++ b/vmime/charsetConverter_iconv.hpp
@@ -59,7 +59,7 @@ public:
void convert(const string& in, string& out);
void convert(utility::inputStream& in, utility::outputStream& out);
- ref <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os);
+ shared_ptr <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os);
private:
diff --git a/vmime/charsetConverter_icu.hpp b/vmime/charsetConverter_icu.hpp
index c693775e..91cf0b86 100644
--- a/vmime/charsetConverter_icu.hpp
+++ b/vmime/charsetConverter_icu.hpp
@@ -62,7 +62,7 @@ public:
void convert(const string& in, string& out);
void convert(utility::inputStream& in, utility::outputStream& out);
- ref <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os);
+ shared_ptr <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os);
private:
diff --git a/vmime/charsetConverter_idna.hpp b/vmime/charsetConverter_idna.hpp
index d3b8b25f..874d6bf1 100644
--- a/vmime/charsetConverter_idna.hpp
+++ b/vmime/charsetConverter_idna.hpp
@@ -53,7 +53,7 @@ public:
void convert(const string& in, string& out);
void convert(utility::inputStream& in, utility::outputStream& out);
- ref <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os);
+ shared_ptr <utility::charsetFilteredOutputStream> getFilteredOutputStream(utility::outputStream& os);
private:
diff --git a/vmime/component.hpp b/vmime/component.hpp
index f96572b7..0c3716cb 100644
--- a/vmime/component.hpp
+++ b/vmime/component.hpp
@@ -70,7 +70,7 @@ public:
* @param inputStream stream from which to read data
* @param length data length, in bytes (0 = unknown/not specified)
*/
- void parse(ref <utility::inputStream> inputStream, const utility::stream::size_type length);
+ void parse(shared_ptr <utility::inputStream> inputStream, const utility::stream::size_type length);
/** Parse RFC-822/MIME data for this component, using the default
* parsing context.
@@ -112,7 +112,7 @@ public:
* @param newPosition will receive the new position in the input stream
*/
void parse
- (ref <utility::inputStream> inputStream,
+ (shared_ptr <utility::inputStream> inputStream,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition = NULL);
@@ -129,7 +129,7 @@ public:
*/
void parse
(const parsingContext& ctx,
- ref <utility::inputStream> inputStream,
+ shared_ptr <utility::inputStream> inputStream,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition = NULL);
@@ -174,7 +174,7 @@ public:
*
* @return a copy of this component
*/
- virtual ref <component> clone() const = 0;
+ virtual shared_ptr <component> clone() const = 0;
/** Replace data in this component by data in other component.
* Both components must be of the same type.
@@ -205,7 +205,7 @@ public:
*
* @return list of child components
*/
- virtual const std::vector <ref <component> > getChildComponents() = 0;
+ virtual const std::vector <shared_ptr <component> > getChildComponents() = 0;
/** Get the number of bytes that will be used by this component when
* it is generated. This may be a heuristically-derived estimate,
@@ -224,7 +224,7 @@ protected:
// AT LEAST ONE of these parseImpl() functions MUST be implemented in derived class
virtual void parseImpl
(const parsingContext& ctx,
- ref <utility::parserInputStreamAdapter> parser,
+ shared_ptr <utility::parserInputStreamAdapter> parser,
const utility::stream::size_type position,
const utility::stream::size_type end,
utility::stream::size_type* newPosition = NULL);
diff --git a/vmime/contentDisposition.hpp b/vmime/contentDisposition.hpp
index 9407885d..0f417111 100644
--- a/vmime/contentDisposition.hpp
+++ b/vmime/contentDisposition.hpp
@@ -59,11 +59,11 @@ public:
*/
void setName(const string& name);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
contentDisposition& operator=(const contentDisposition& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
contentDisposition& operator=(const string& name);
diff --git a/vmime/contentDispositionField.hpp b/vmime/contentDispositionField.hpp
index 58b40dff..0eb32bc4 100644
--- a/vmime/contentDispositionField.hpp
+++ b/vmime/contentDispositionField.hpp
@@ -38,7 +38,7 @@ namespace vmime
class VMIME_EXPORT contentDispositionField : public parameterizedHeaderField
{
- friend class vmime::creator; // create ref
+ friend class headerFieldFactory;
protected:
diff --git a/vmime/contentHandler.hpp b/vmime/contentHandler.hpp
index ae20e892..5ae9e02b 100644
--- a/vmime/contentHandler.hpp
+++ b/vmime/contentHandler.hpp
@@ -29,7 +29,6 @@
#include "vmime/base.hpp"
#include "vmime/utility/stringProxy.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/utility/progressListener.hpp"
#include "vmime/encoding.hpp"
#include "vmime/mediaType.hpp"
@@ -53,7 +52,7 @@ public:
*
* @return copy of this object
*/
- virtual ref <contentHandler> clone() const = 0;
+ virtual shared_ptr <contentHandler> clone() const = 0;
/** Output the contents into the specified stream. Data will be
* encoded before being written into the stream. This is used internally
diff --git a/vmime/contentTypeField.hpp b/vmime/contentTypeField.hpp
index b522927a..b81d9a68 100644
--- a/vmime/contentTypeField.hpp
+++ b/vmime/contentTypeField.hpp
@@ -37,7 +37,7 @@ namespace vmime
class VMIME_EXPORT contentTypeField : public parameterizedHeaderField
{
- friend class vmime::creator; // create ref
+ friend class headerFieldFactory;
protected:
diff --git a/vmime/dateTime.hpp b/vmime/dateTime.hpp
index 1d25124a..8a596f02 100644
--- a/vmime/dateTime.hpp
+++ b/vmime/dateTime.hpp
@@ -224,7 +224,7 @@ public:
void copyFrom(const component& other);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
// Comparison
bool operator==(const datetime& other) const;
@@ -237,7 +237,7 @@ public:
// Current date and time
static const datetime now();
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
protected:
diff --git a/vmime/defaultAttachment.hpp b/vmime/defaultAttachment.hpp
index 171b7a84..6eb0c5b6 100644
--- a/vmime/defaultAttachment.hpp
+++ b/vmime/defaultAttachment.hpp
@@ -45,8 +45,8 @@ protected:
public:
- defaultAttachment(ref <const contentHandler> data, const encoding& enc, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD);
- defaultAttachment(ref <const contentHandler> data, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD);
+ defaultAttachment(shared_ptr <const contentHandler> data, const encoding& enc, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD);
+ defaultAttachment(shared_ptr <const contentHandler> data, const mediaType& type, const text& desc = NULL_TEXT, const word& name = NULL_WORD);
defaultAttachment(const defaultAttachment& attach);
~defaultAttachment();
@@ -56,29 +56,29 @@ public:
const mediaType getType() const;
const text getDescription() const;
const word getName() const;
- const ref <const contentHandler> getData() const;
+ const shared_ptr <const contentHandler> getData() const;
const encoding getEncoding() const;
- ref <const object> getPart() const;
+ shared_ptr <const object> getPart() const;
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
protected:
mediaType m_type; /**< Media type (eg. "application/octet-stream") */
text m_desc; /**< Description (eg. "The image you requested") */
- ref <const contentHandler> m_data; /**< Attachment data (eg. the file contents) */
+ shared_ptr <const contentHandler> m_data; /**< Attachment data (eg. the file contents) */
encoding m_encoding; /**< Encoding */
word m_name; /**< Name/filename (eg. "sunset.jpg") */
private:
// No need to override "generateIn", use "generatePart" instead (see below).
- void generateIn(ref <bodyPart> parent) const;
+ void generateIn(shared_ptr <bodyPart> parent) const;
protected:
- virtual void generatePart(ref <bodyPart> part) const;
+ virtual void generatePart(shared_ptr <bodyPart> part) const;
};
diff --git a/vmime/disposition.hpp b/vmime/disposition.hpp
index b75327a1..01de1653 100644
--- a/vmime/disposition.hpp
+++ b/vmime/disposition.hpp
@@ -46,11 +46,11 @@ public:
disposition(const string& actionMode, const string& sendingMode, const string& type, const string& modifier);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
disposition& operator=(const disposition& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Set the disposition action mode.
diff --git a/vmime/emailAddress.hpp b/vmime/emailAddress.hpp
index a16366c7..e46afdf6 100644
--- a/vmime/emailAddress.hpp
+++ b/vmime/emailAddress.hpp
@@ -98,10 +98,10 @@ public:
// Assignment
void copyFrom(const component& other);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
emailAddress& operator=(const emailAddress& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
protected:
diff --git a/vmime/emptyContentHandler.hpp b/vmime/emptyContentHandler.hpp
index 829e8898..1307f7eb 100644
--- a/vmime/emptyContentHandler.hpp
+++ b/vmime/emptyContentHandler.hpp
@@ -38,7 +38,7 @@ public:
emptyContentHandler();
- ref <contentHandler> clone() const;
+ shared_ptr <contentHandler> clone() const;
void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const;
diff --git a/vmime/encoding.hpp b/vmime/encoding.hpp
index cdee1d43..ba07a25f 100644
--- a/vmime/encoding.hpp
+++ b/vmime/encoding.hpp
@@ -93,7 +93,7 @@ public:
bool operator==(const encoding& value) const;
bool operator!=(const encoding& value) const;
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Decide which encoding to use based on the specified data.
*
@@ -101,7 +101,7 @@ public:
* @param usage context of use of data
* @return suitable encoding for specified data
*/
- static const encoding decide(ref <const contentHandler> data, const EncodingUsage usage = USAGE_BINARY_DATA);
+ static const encoding decide(shared_ptr <const contentHandler> data, const EncodingUsage usage = USAGE_BINARY_DATA);
/** Decide which encoding to use based on the specified data and charset.
*
@@ -110,10 +110,10 @@ public:
* @param usage context of use of data
* @return suitable encoding for specified data and charset
*/
- static const encoding decide(ref <const contentHandler> data, const charset& chset, const EncodingUsage usage = USAGE_BINARY_DATA);
+ static const encoding decide(shared_ptr <const contentHandler> data, const charset& chset, const EncodingUsage usage = USAGE_BINARY_DATA);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
/** Use encoderFactory to obtain an encoder/decoder object
@@ -123,7 +123,7 @@ public:
* is registered for the encoding
* @return a new encoder object for the encoding type
*/
- ref <utility::encoder::encoder> getEncoder() const;
+ shared_ptr <utility::encoder::encoder> getEncoder() const;
private:
diff --git a/vmime/fileAttachment.hpp b/vmime/fileAttachment.hpp
index d18b8a14..2d9ff575 100644
--- a/vmime/fileAttachment.hpp
+++ b/vmime/fileAttachment.hpp
@@ -52,9 +52,9 @@ public:
fileAttachment(const string& filepath, const mediaType& type, const text& desc);
fileAttachment(const string& filepath, const mediaType& type, const text& desc, const encoding& enc);
- fileAttachment(ref <contentHandler> cts, const word& filename, const mediaType& type);
- fileAttachment(ref <contentHandler> cts, const word& filename, const mediaType& type, const text& desc);
- fileAttachment(ref <contentHandler> cts, const word& filename, const mediaType& type, const text& desc, const encoding& enc);
+ fileAttachment(shared_ptr <contentHandler> cts, const word& filename, const mediaType& type);
+ fileAttachment(shared_ptr <contentHandler> cts, const word& filename, const mediaType& type, const text& desc);
+ fileAttachment(shared_ptr <contentHandler> cts, const word& filename, const mediaType& type, const text& desc, const encoding& enc);
/** Stores information about a file attachment.
*/
@@ -181,11 +181,11 @@ public:
private:
void setData(const string& filepath);
- void setData(ref <contentHandler> cts);
+ void setData(shared_ptr <contentHandler> cts);
fileInfo m_fileInfo;
- void generatePart(ref <bodyPart> part) const;
+ void generatePart(shared_ptr <bodyPart> part) const;
};
diff --git a/vmime/fileContentHandler.hpp b/vmime/fileContentHandler.hpp
index 36a6a459..68b4d396 100644
--- a/vmime/fileContentHandler.hpp
+++ b/vmime/fileContentHandler.hpp
@@ -56,7 +56,7 @@ public:
* @return a reference to a new content handler
*/
fileContentHandler
- (ref <utility::file> file,
+ (shared_ptr <utility::file> file,
const vmime::encoding& enc = NO_ENCODING);
~fileContentHandler();
@@ -64,7 +64,7 @@ public:
fileContentHandler(const fileContentHandler& cts);
fileContentHandler& operator=(const fileContentHandler& cts);
- ref <contentHandler> clone() const;
+ shared_ptr <contentHandler> clone() const;
/** Sets the data managed by this content handler.
*
@@ -73,7 +73,7 @@ public:
* in the file is already encoded with the specified encoding
*/
void setData
- (ref <utility::file> file,
+ (shared_ptr <utility::file> file,
const vmime::encoding& enc = NO_ENCODING);
private:
@@ -83,7 +83,7 @@ private:
vmime::encoding m_encoding;
// Actual data
- ref <utility::file> m_file;
+ shared_ptr <utility::file> m_file;
};
diff --git a/vmime/generatedMessageAttachment.hpp b/vmime/generatedMessageAttachment.hpp
index 4c9c0aba..7137b22b 100644
--- a/vmime/generatedMessageAttachment.hpp
+++ b/vmime/generatedMessageAttachment.hpp
@@ -42,30 +42,30 @@ class VMIME_EXPORT generatedMessageAttachment : public messageAttachment
{
public:
- generatedMessageAttachment(ref <const bodyPart> part);
+ generatedMessageAttachment(shared_ptr <const bodyPart> part);
const mediaType getType() const;
const text getDescription() const;
const word getName() const;
- const ref <const contentHandler> getData() const;
+ const shared_ptr <const contentHandler> getData() const;
const encoding getEncoding() const;
- ref <const object> getPart() const;
+ shared_ptr <const object> getPart() const;
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
- ref <message> getMessage() const;
+ shared_ptr <message> getMessage() const;
protected:
- void generateIn(ref <bodyPart> parent) const;
+ void generateIn(shared_ptr <bodyPart> parent) const;
private:
- ref <bodyPartAttachment> m_bpa;
- mutable ref <message> m_msg;
+ shared_ptr <bodyPartAttachment> m_bpa;
+ mutable shared_ptr <message> m_msg;
};
diff --git a/vmime/header.hpp b/vmime/header.hpp
index 0758e775..b073e8cb 100644
--- a/vmime/header.hpp
+++ b/vmime/header.hpp
@@ -55,8 +55,8 @@ public:
~header();
#define FIELD_ACCESS(methodName, fieldName) \
- ref <headerField> methodName() { return getField(fields::fieldName); } \
- ref <const headerField> methodName() const { return findField(fields::fieldName); }
+ shared_ptr <headerField> methodName() { return getField(fields::fieldName); } \
+ shared_ptr <const headerField> methodName() const { return findField(fields::fieldName); }
FIELD_ACCESS(From, FROM)
FIELD_ACCESS(Sender, SENDER)
@@ -102,14 +102,26 @@ public:
* @throw exceptions::no_such_field if no field with this name exists
* @return first field with the specified name
*/
- ref <headerField> findField(const string& fieldName) const;
+ shared_ptr <headerField> findField(const string& fieldName) const;
+
+ /** Find the first field that matches the specified name,
+ * casted to the specified type.
+ * If no field is found, an exception is thrown.
+ *
+ * @return value object
+ */
+ template <typename T>
+ shared_ptr <T> findField(const string& fieldName) const
+ {
+ return dynamicCast <T>(findField(fieldName));
+ }
/** Find all fields that match the specified name.
* If no field is found, an empty vector is returned.
*
* @return list of fields with the specified name
*/
- std::vector <ref <headerField> > findAllFields(const string& fieldName);
+ std::vector <shared_ptr <headerField> > findAllFields(const string& fieldName);
/** Find the first field that matches the specified name.
* If no field is found, one will be created and inserted into
@@ -118,13 +130,27 @@ public:
* @return first field with the specified name or a new field
* if no field is found
*/
- ref <headerField> getField(const string& fieldName);
+ shared_ptr <headerField> getField(const string& fieldName);
+
+ /** Find the first field that matches the specified name,
+ * casted to the specified type.
+ * If no field is found, one will be created and inserted into
+ * the header.
+ *
+ * @return first field with the specified name or a new field
+ * if no field is found
+ */
+ template <typename T>
+ shared_ptr <T> getField(const string& fieldName)
+ {
+ return dynamicCast <T>(getField(fieldName));
+ }
/** Add a field at the end of the list.
*
* @param field field to append
*/
- void appendField(ref <headerField> field);
+ void appendField(shared_ptr <headerField> field);
/** Insert a new field before the specified field.
*
@@ -132,7 +158,7 @@ public:
* @param field field to insert
* @throw exceptions::no_such_field if the field is not in the list
*/
- void insertFieldBefore(ref <headerField> beforeField, ref <headerField> field);
+ void insertFieldBefore(shared_ptr <headerField> beforeField, shared_ptr <headerField> field);
/** Insert a new field before the specified position.
*
@@ -140,7 +166,7 @@ public:
* the beginning of the list)
* @param field field to insert
*/
- void insertFieldBefore(const size_t pos, ref <headerField> field);
+ void insertFieldBefore(const size_t pos, shared_ptr <headerField> field);
/** Insert a new field after the specified field.
*
@@ -148,21 +174,21 @@ public:
* @param field field to insert
* @throw exceptions::no_such_field if the field is not in the list
*/
- void insertFieldAfter(ref <headerField> afterField, ref <headerField> field);
+ void insertFieldAfter(shared_ptr <headerField> afterField, shared_ptr <headerField> field);
/** Insert a new field after the specified position.
*
* @param pos position of the field before the new field
* @param field field to insert
*/
- void insertFieldAfter(const size_t pos, ref <headerField> field);
+ void insertFieldAfter(const size_t pos, shared_ptr <headerField> field);
/** Remove the specified field from the list.
*
* @param field field to remove
* @throw exceptions::no_such_field if the field is not in the list
*/
- void removeField(ref <headerField> field);
+ void removeField(shared_ptr <headerField> field);
/** Remove the field at the specified position.
*
@@ -176,7 +202,7 @@ public:
* @param newField field to replace with
* @throw exceptions::no_such_field if the field is not in the list
*/
- void replaceField(ref <headerField> field, ref <headerField> newField);
+ void replaceField(shared_ptr <headerField> field, shared_ptr <headerField> newField);
/** Remove all fields from the list.
*/
@@ -203,38 +229,38 @@ public:
* @param pos position
* @return field at position 'pos'
*/
- const ref <headerField> getFieldAt(const size_t pos);
+ const shared_ptr <headerField> getFieldAt(const size_t pos);
/** Return the field at the specified position.
*
* @param pos position
* @return field at position 'pos'
*/
- const ref <const headerField> getFieldAt(const size_t pos) const;
+ const shared_ptr <const headerField> getFieldAt(const size_t pos) const;
/** Return the field list.
*
* @return list of fields
*/
- const std::vector <ref <const headerField> > getFieldList() const;
+ const std::vector <shared_ptr <const headerField> > getFieldList() const;
/** Return the field list.
*
* @return list of fields
*/
- const std::vector <ref <headerField> > getFieldList();
+ const std::vector <shared_ptr <headerField> > getFieldList();
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
header& operator=(const header& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
utility::stream::size_type getGeneratedSize(const generationContext& ctx);
private:
- std::vector <ref <headerField> > m_fields;
+ std::vector <shared_ptr <headerField> > m_fields;
class fieldHasName
@@ -242,7 +268,7 @@ private:
public:
fieldHasName(const string& name);
- bool operator() (const ref <const headerField>& field);
+ bool operator() (const shared_ptr <const headerField>& field);
private:
@@ -254,7 +280,7 @@ private:
public:
fieldHasNotName(const string& name);
- bool operator() (const ref <const headerField>& field);
+ bool operator() (const shared_ptr <const headerField>& field);
private:
diff --git a/vmime/headerField.hpp b/vmime/headerField.hpp
index 5276c84a..c9972317 100644
--- a/vmime/headerField.hpp
+++ b/vmime/headerField.hpp
@@ -42,8 +42,6 @@ class VMIME_EXPORT headerField : public component
friend class headerFieldFactory;
friend class header;
- friend class vmime::creator; // create ref
-
protected:
// Protected constructor to prevent the user from creating
@@ -55,11 +53,11 @@ public:
~headerField();
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
headerField& operator=(const headerField& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Sets the name of this field.
*
@@ -84,13 +82,35 @@ public:
*
* @return read-only value object
*/
- virtual ref <const headerFieldValue> getValue() const;
+ virtual shared_ptr <const headerFieldValue> getValue() const;
+
+ /** Return the read-only value object attached to this field,
+ * casted to the specified type.
+ *
+ * @return value object
+ */
+ template <typename T>
+ shared_ptr <const T> getValue() const
+ {
+ return dynamicCast <const T>(m_value);
+ }
/** Return the value object attached to this field.
*
* @return value object
*/
- virtual ref <headerFieldValue> getValue();
+ virtual shared_ptr <headerFieldValue> getValue();
+
+ /** Return the value object attached to this field,
+ * casted to the specified type.
+ *
+ * @return value object
+ */
+ template <typename T>
+ shared_ptr <T> getValue()
+ {
+ return dynamicCast <T>(m_value);
+ }
/** Set the value of this field.
*
@@ -98,7 +118,7 @@ public:
* valid for this header field
* @param value new value
*/
- virtual void setValue(ref <headerFieldValue> value);
+ virtual void setValue(shared_ptr <headerFieldValue> value);
/** Set the value of this field by cloning the specified value.
*
@@ -106,7 +126,7 @@ public:
* valid for this header field
* @param value new value
*/
- virtual void setValueConst(ref <const headerFieldValue> value);
+ virtual void setValueConst(shared_ptr <const headerFieldValue> value);
/** Set the value of this field (reference version).
* The value will be cloned.
@@ -134,7 +154,7 @@ public:
* @return parsed header field, or NULL if no more header field can be parsed
* in the input buffer
*/
- static ref <headerField> parseNext
+ static shared_ptr <headerField> parseNext
(const parsingContext& ctx,
const string& buffer,
const string::size_type position,
@@ -160,7 +180,7 @@ protected:
string m_name;
- ref <headerFieldValue> m_value;
+ shared_ptr <headerFieldValue> m_value;
};
diff --git a/vmime/headerFieldFactory.hpp b/vmime/headerFieldFactory.hpp
index e8a1a84c..960f27b7 100644
--- a/vmime/headerFieldFactory.hpp
+++ b/vmime/headerFieldFactory.hpp
@@ -43,7 +43,7 @@ protected:
headerFieldFactory();
~headerFieldFactory();
- typedef ref <headerField> (*AllocFunc)(void);
+ typedef shared_ptr <headerField> (*AllocFunc)(void);
typedef std::map <string, AllocFunc> NameMap;
NameMap m_nameMap;
@@ -51,7 +51,7 @@ protected:
struct ValueInfo
{
- typedef ref <headerFieldValue> (*ValueAllocFunc)(void);
+ typedef shared_ptr <headerFieldValue> (*ValueAllocFunc)(void);
typedef bool (*ValueTypeCheckFunc)(const object&);
ValueAllocFunc allocFunc;
@@ -64,7 +64,7 @@ protected:
public:
- static headerFieldFactory* getInstance();
+ static shared_ptr <headerFieldFactory> getInstance();
#ifndef VMIME_BUILDING_DOC
// TYPE must inherit from BASE_TYPE
@@ -79,10 +79,10 @@ public:
return typedObj != NULL;
}
- static ref <BASE_TYPE> creator()
+ static shared_ptr <BASE_TYPE> creator()
{
// Allocate a new object
- return vmime::create <TYPE>();
+ return shared_ptr <BASE_TYPE>(new TYPE());
}
};
#endif // VMIME_BUILDING_DOC
@@ -126,14 +126,14 @@ public:
* the value of the field
* @return a new field object
*/
- ref <headerField> create(const string& name, const string& body = NULL_STRING);
+ shared_ptr <headerField> create(const string& name, const string& body = NULL_STRING);
/** Create a new field value for the specified field.
*
* @param fieldName name of the field for which to create value
* @return a new value object for the field
*/
- ref <headerFieldValue> createValue(const string& fieldName);
+ shared_ptr <headerFieldValue> createValue(const string& fieldName);
/** Returns whether the specified value type is valid for the specified field.
*
diff --git a/vmime/htmlTextPart.hpp b/vmime/htmlTextPart.hpp
index 59ed1add..9596f3f4 100644
--- a/vmime/htmlTextPart.hpp
+++ b/vmime/htmlTextPart.hpp
@@ -51,11 +51,11 @@ public:
const charset& getCharset() const;
void setCharset(const charset& ch);
- ref <const contentHandler> getPlainText() const;
- void setPlainText(ref <contentHandler> plainText);
+ shared_ptr <const contentHandler> getPlainText() const;
+ void setPlainText(shared_ptr <contentHandler> plainText);
- const ref <const contentHandler> getText() const;
- void setText(ref <contentHandler> text);
+ const shared_ptr <const contentHandler> getText() const;
+ void setText(shared_ptr <contentHandler> text);
/** Embedded object (eg: image for &lt;IMG> tag).
*/
@@ -79,7 +79,7 @@ public:
* @param refType reference type
* @return a reference to a new embedded object
*/
- embeddedObject(ref <contentHandler> data, const encoding& enc,
+ embeddedObject(shared_ptr <contentHandler> data, const encoding& enc,
const string& id, const mediaType& type,
const ReferenceType refType);
@@ -87,7 +87,7 @@ public:
*
* @return stored data
*/
- ref <const contentHandler> getData() const;
+ shared_ptr <const contentHandler> getData() const;
/** Return the encoding used for data in this
* embedded object.
@@ -136,7 +136,7 @@ public:
static const string cleanId(const string& id);
- ref <contentHandler> m_data;
+ shared_ptr <contentHandler> m_data;
encoding m_encoding;
string m_id;
mediaType m_type;
@@ -158,7 +158,7 @@ public:
* @param id object identifier
* @return embedded object with the specified identifier
*/
- ref <const embeddedObject> findObject(const string& id) const;
+ shared_ptr <const embeddedObject> findObject(const string& id) const;
/** Return the number of embedded objects.
*
@@ -171,7 +171,7 @@ public:
* @param pos position of the embedded object
* @return embedded object at position 'pos'
*/
- ref <const embeddedObject> getObjectAt(const size_t pos) const;
+ shared_ptr <const embeddedObject> getObjectAt(const size_t pos) const;
/** Embed an object and returns a string which identifies it.
* The returned identifier is suitable for use in the 'src' attribute
@@ -185,7 +185,7 @@ public:
* @return an unique object identifier used to identify the new
* object among all other embedded objects
*/
- ref <const embeddedObject> addObject(const string& data, const mediaType& type);
+ shared_ptr <const embeddedObject> addObject(const string& data, const mediaType& type);
/** Embed an object and returns a string which identifies it.
* The returned identifier is suitable for use in the 'src' attribute
@@ -196,7 +196,7 @@ public:
* @return an unique object identifier used to identify the new
* object among all other embedded objects
*/
- ref <const embeddedObject> addObject(ref <contentHandler> data, const mediaType& type);
+ shared_ptr <const embeddedObject> addObject(shared_ptr <contentHandler> data, const mediaType& type);
/** Embed an object and returns a string which identifies it.
* The returned identifier is suitable for use in the 'src' attribute
@@ -208,23 +208,23 @@ public:
* @return an unique object identifier used to identify the new
* object among all other embedded objects
*/
- ref <const embeddedObject> addObject(ref <contentHandler> data, const encoding& enc, const mediaType& type);
+ shared_ptr <const embeddedObject> addObject(shared_ptr <contentHandler> data, const encoding& enc, const mediaType& type);
size_t getPartCount() const;
- void generateIn(ref <bodyPart> message, ref <bodyPart> parent) const;
- void parse(ref <const bodyPart> message, ref <const bodyPart> parent, ref <const bodyPart> textPart);
+ void generateIn(shared_ptr <bodyPart> message, shared_ptr <bodyPart> parent) const;
+ void parse(shared_ptr <const bodyPart> message, shared_ptr <const bodyPart> parent, shared_ptr <const bodyPart> textPart);
private:
- ref <contentHandler> m_plainText;
- ref <contentHandler> m_text;
+ shared_ptr <contentHandler> m_plainText;
+ shared_ptr <contentHandler> m_text;
charset m_charset;
- std::vector <ref <embeddedObject> > m_objects;
+ std::vector <shared_ptr <embeddedObject> > m_objects;
- void findEmbeddedParts(const bodyPart& part, std::vector <ref <const bodyPart> >& cidParts, std::vector <ref <const bodyPart> >& locParts);
+ void findEmbeddedParts(const bodyPart& part, std::vector <shared_ptr <const bodyPart> >& cidParts, std::vector <shared_ptr <const bodyPart> >& locParts);
void addEmbeddedObject(const bodyPart& part, const string& id, const embeddedObject::ReferenceType refType);
bool findPlainTextPart(const bodyPart& part, const bodyPart& parent, const bodyPart& textPart);
diff --git a/vmime/mailbox.hpp b/vmime/mailbox.hpp
index b6dc9fbe..586f88ee 100644
--- a/vmime/mailbox.hpp
+++ b/vmime/mailbox.hpp
@@ -79,14 +79,14 @@ public:
// Assignment
void copyFrom(const component& other);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
mailbox& operator=(const mailbox& other);
bool isEmpty() const;
void clear();
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
bool isGroup() const;
diff --git a/vmime/mailboxField.hpp b/vmime/mailboxField.hpp
index 798e84d7..75cae592 100644
--- a/vmime/mailboxField.hpp
+++ b/vmime/mailboxField.hpp
@@ -43,7 +43,7 @@ namespace vmime
class VMIME_EXPORT mailboxField : public headerField
{
- friend class vmime::creator; // create ref
+ friend class headerFieldFactory;
protected:
diff --git a/vmime/mailboxGroup.hpp b/vmime/mailboxGroup.hpp
index 1c0511e1..ac6b9741 100644
--- a/vmime/mailboxGroup.hpp
+++ b/vmime/mailboxGroup.hpp
@@ -49,10 +49,10 @@ public:
void copyFrom(const component& other);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
mailboxGroup& operator=(const component& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Return the name of the group.
*
@@ -70,7 +70,7 @@ public:
*
* @param mbox mailbox to append
*/
- void appendMailbox(ref <mailbox> mbox);
+ void appendMailbox(shared_ptr <mailbox> mbox);
/** Insert a new mailbox before the specified mailbox.
*
@@ -78,7 +78,7 @@ public:
* @param mbox mailbox to insert
* @throw exceptions::no_such_mailbox if the mailbox is not in the list
*/
- void insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox);
+ void insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox);
/** Insert a new mailbox before the specified position.
*
@@ -86,7 +86,7 @@ public:
* the beginning of the list)
* @param mbox mailbox to insert
*/
- void insertMailboxBefore(const size_t pos, ref <mailbox> mbox);
+ void insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox);
/** Insert a new mailbox after the specified mailbox.
*
@@ -94,21 +94,21 @@ public:
* @param mbox mailbox to insert
* @throw exceptions::no_such_mailbox if the mailbox is not in the list
*/
- void insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox);
+ void insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox);
/** Insert a new mailbox after the specified position.
*
* @param pos position of the mailbox before the new mailbox
* @param mbox mailbox to insert
*/
- void insertMailboxAfter(const size_t pos, ref <mailbox> mbox);
+ void insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox);
/** Remove the specified mailbox from the list.
*
* @param mbox mailbox to remove
* @throw exceptions::no_such_mailbox if the mailbox is not in the list
*/
- void removeMailbox(ref <mailbox> mbox);
+ void removeMailbox(shared_ptr <mailbox> mbox);
/** Remove the mailbox at the specified position.
*
@@ -137,33 +137,33 @@ public:
* @param pos position
* @return mailbox at position 'pos'
*/
- ref <mailbox> getMailboxAt(const size_t pos);
+ shared_ptr <mailbox> getMailboxAt(const size_t pos);
/** Return the mailbox at the specified position.
*
* @param pos position
* @return mailbox at position 'pos'
*/
- const ref <const mailbox> getMailboxAt(const size_t pos) const;
+ const shared_ptr <const mailbox> getMailboxAt(const size_t pos) const;
/** Return the mailbox list.
*
* @return list of mailboxes
*/
- const std::vector <ref <const mailbox> > getMailboxList() const;
+ const std::vector <shared_ptr <const mailbox> > getMailboxList() const;
/** Return the mailbox list.
*
* @return list of mailboxes
*/
- const std::vector <ref <mailbox> > getMailboxList();
+ const std::vector <shared_ptr <mailbox> > getMailboxList();
bool isGroup() const;
private:
text m_name;
- std::vector <ref <mailbox> > m_list;
+ std::vector <shared_ptr <mailbox> > m_list;
protected:
diff --git a/vmime/mailboxList.hpp b/vmime/mailboxList.hpp
index 1b4cbb50..25daefec 100644
--- a/vmime/mailboxList.hpp
+++ b/vmime/mailboxList.hpp
@@ -47,17 +47,17 @@ public:
mailboxList(const mailboxList& mboxList);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
mailboxList& operator=(const mailboxList& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Add a mailbox at the end of the list.
*
* @param mbox mailbox to append
*/
- void appendMailbox(ref <mailbox> mbox);
+ void appendMailbox(shared_ptr <mailbox> mbox);
/** Insert a new mailbox before the specified mailbox.
*
@@ -65,7 +65,7 @@ public:
* @param mbox mailbox to insert
* @throw exceptions::no_such_mailbox if the mailbox is not in the list
*/
- void insertMailboxBefore(ref <mailbox> beforeMailbox, ref <mailbox> mbox);
+ void insertMailboxBefore(shared_ptr <mailbox> beforeMailbox, shared_ptr <mailbox> mbox);
/** Insert a new mailbox before the specified position.
*
@@ -73,7 +73,7 @@ public:
* the beginning of the list)
* @param mbox mailbox to insert
*/
- void insertMailboxBefore(const size_t pos, ref <mailbox> mbox);
+ void insertMailboxBefore(const size_t pos, shared_ptr <mailbox> mbox);
/** Insert a new mailbox after the specified mailbox.
*
@@ -81,21 +81,21 @@ public:
* @param mbox mailbox to insert
* @throw exceptions::no_such_mailbox if the mailbox is not in the list
*/
- void insertMailboxAfter(ref <mailbox> afterMailbox, ref <mailbox> mbox);
+ void insertMailboxAfter(shared_ptr <mailbox> afterMailbox, shared_ptr <mailbox> mbox);
/** Insert a new mailbox after the specified position.
*
* @param pos position of the mailbox before the new mailbox
* @param mbox mailbox to insert
*/
- void insertMailboxAfter(const size_t pos, ref <mailbox> mbox);
+ void insertMailboxAfter(const size_t pos, shared_ptr <mailbox> mbox);
/** Remove the specified mailbox from the list.
*
* @param mbox mailbox to remove
* @throw exceptions::no_such_mailbox if the mailbox is not in the list
*/
- void removeMailbox(ref <mailbox> mbox);
+ void removeMailbox(shared_ptr <mailbox> mbox);
/** Remove the mailbox at the specified position.
*
@@ -124,32 +124,32 @@ public:
* @param pos position
* @return mailbox at position 'pos'
*/
- ref <mailbox> getMailboxAt(const size_t pos);
+ shared_ptr <mailbox> getMailboxAt(const size_t pos);
/** Return the mailbox at the specified position.
*
* @param pos position
* @return mailbox at position 'pos'
*/
- const ref <const mailbox> getMailboxAt(const size_t pos) const;
+ const shared_ptr <const mailbox> getMailboxAt(const size_t pos) const;
/** Return the mailbox list.
*
* @return list of mailboxes
*/
- const std::vector <ref <const mailbox> > getMailboxList() const;
+ const std::vector <shared_ptr <const mailbox> > getMailboxList() const;
/** Return the mailbox list.
*
* @return list of mailboxes
*/
- const std::vector <ref <mailbox> > getMailboxList();
+ const std::vector <shared_ptr <mailbox> > getMailboxList();
/** Return a list of addresses.
*
* @return list of addresses
*/
- ref <addressList> toAddressList() const;
+ shared_ptr <addressList> toAddressList() const;
private:
diff --git a/vmime/mdn/MDNHelper.hpp b/vmime/mdn/MDNHelper.hpp
index 0e853989..2584978f 100644
--- a/vmime/mdn/MDNHelper.hpp
+++ b/vmime/mdn/MDNHelper.hpp
@@ -48,14 +48,14 @@ public:
* @param msg message in which to add a MDN request
* @param mailboxes list of mailboxes to which the MDN will be sent
*/
- static void attachMDNRequest(ref <message> msg, const mailboxList& mailboxes);
+ static void attachMDNRequest(shared_ptr <message> msg, const mailboxList& mailboxes);
/** Attach a MDN request to the specified message.
*
* @param msg message in which to add a MDN request
* @param mbox mailbox to which the MDN will be sent
*/
- static void attachMDNRequest(ref <message> msg, const mailbox& mbox);
+ static void attachMDNRequest(shared_ptr <message> msg, const mailbox& mbox);
/** Return a list of possible MDNs that can be generated
* for the specified message.
@@ -63,14 +63,14 @@ public:
* @param msg message for which to send a MDN
* @return list of possible MDNs
*/
- static const std::vector <sendableMDNInfos> getPossibleMDNs(const ref <const message> msg);
+ static const std::vector <sendableMDNInfos> getPossibleMDNs(const shared_ptr <const message> msg);
/** Test whether the specified message is a MDN.
*
* @param msg message
* @return true if the message is a MDN, false otherwise
*/
- static bool isMDN(const ref <const message> msg);
+ static bool isMDN(const shared_ptr <const message> msg);
/** If the specified message is a MDN, return information
* about it.
@@ -79,7 +79,7 @@ public:
* @throw exceptions::invalid_argument if the message is not a MDN
* @return information about the MDN
*/
- static receivedMDNInfos getReceivedMDN(const ref <const message> msg);
+ static receivedMDNInfos getReceivedMDN(const shared_ptr <const message> msg);
/** Check whether we need user confirmation for sending a MDN even
* if he/she explicitely allowed automatic send of MDNs. This can
@@ -88,7 +88,7 @@ public:
* @param msg message for which to send a MDN
* @return true if user confirmation should be asked, false otherwise
*/
- static bool needConfirmation(const ref <const message> msg);
+ static bool needConfirmation(const shared_ptr <const message> msg);
/** Build a new MDN for the message. The resulting MDN can then be
* sent over SMTP transport service.
@@ -105,7 +105,7 @@ public:
* @param fields additional MDN fields, like "Error", "Warning" or "Failure" (optional)
* @return a new message object containing the MDN
*/
- static ref <message> buildMDN(const sendableMDNInfos& mdnInfos,
+ static shared_ptr <message> buildMDN(const sendableMDNInfos& mdnInfos,
const string& text,
const charset& ch,
const mailbox& expeditor,
@@ -118,17 +118,17 @@ public:
private:
- static ref <bodyPart> createFirstMDNPart(const sendableMDNInfos& mdnInfos,
+ static shared_ptr <bodyPart> createFirstMDNPart(const sendableMDNInfos& mdnInfos,
const string& text, const charset& ch);
- static ref <bodyPart> createSecondMDNPart(const sendableMDNInfos& mdnInfos,
+ static shared_ptr <bodyPart> createSecondMDNPart(const sendableMDNInfos& mdnInfos,
const disposition& dispo,
const string& reportingUA,
const std::vector <string>& reportingUAProducts,
const std::map <string, string>& fields);
- static ref <bodyPart> createThirdMDNPart(const sendableMDNInfos& mdnInfos);
+ static shared_ptr <bodyPart> createThirdMDNPart(const sendableMDNInfos& mdnInfos);
};
diff --git a/vmime/mdn/MDNInfos.hpp b/vmime/mdn/MDNInfos.hpp
index d77a0306..030aa23e 100644
--- a/vmime/mdn/MDNInfos.hpp
+++ b/vmime/mdn/MDNInfos.hpp
@@ -47,7 +47,7 @@ public:
*
* @return related message
*/
- virtual const ref <const message> getMessage() const = 0;
+ virtual const shared_ptr <const message> getMessage() const = 0;
};
diff --git a/vmime/mdn/receivedMDNInfos.hpp b/vmime/mdn/receivedMDNInfos.hpp
index c836f23c..c6953a24 100644
--- a/vmime/mdn/receivedMDNInfos.hpp
+++ b/vmime/mdn/receivedMDNInfos.hpp
@@ -44,13 +44,13 @@ class VMIME_EXPORT receivedMDNInfos : public MDNInfos
{
public:
- receivedMDNInfos(const ref <const message> msg);
+ receivedMDNInfos(const shared_ptr <const message> msg);
receivedMDNInfos(const receivedMDNInfos& other);
receivedMDNInfos& operator=(const receivedMDNInfos& other);
- const ref <const message> getMessage() const;
+ const shared_ptr <const message> getMessage() const;
/** Return the identifier of the message for which this MDN
* has been generated.
@@ -79,7 +79,7 @@ private:
void extract();
- ref <const message> m_msg;
+ shared_ptr <const message> m_msg;
disposition m_disp;
messageId m_omid;
diff --git a/vmime/mdn/sendableMDNInfos.hpp b/vmime/mdn/sendableMDNInfos.hpp
index f886b5fa..e4f6d20d 100644
--- a/vmime/mdn/sendableMDNInfos.hpp
+++ b/vmime/mdn/sendableMDNInfos.hpp
@@ -42,12 +42,12 @@ class VMIME_EXPORT sendableMDNInfos : public MDNInfos
{
public:
- sendableMDNInfos(const ref <const message> msg, const mailbox& mbox);
+ sendableMDNInfos(const shared_ptr <const message> msg, const mailbox& mbox);
sendableMDNInfos(const sendableMDNInfos& other);
sendableMDNInfos& operator=(const sendableMDNInfos& other);
- const ref <const message> getMessage() const;
+ const shared_ptr <const message> getMessage() const;
/** Return the recipient of the MDN (the mailbox that will receive
* the notification message).
@@ -61,7 +61,7 @@ private:
void copyFrom(const sendableMDNInfos& other);
- ref <const message> m_msg;
+ shared_ptr <const message> m_msg;
mailbox m_mailbox;
};
diff --git a/vmime/mediaType.hpp b/vmime/mediaType.hpp
index b396c8bf..c2b214bd 100644
--- a/vmime/mediaType.hpp
+++ b/vmime/mediaType.hpp
@@ -51,11 +51,11 @@ public:
mediaType& operator=(const string& type);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
mediaType& operator=(const mediaType& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Return the media type.
* See the constants in vmime::mediaTypes.
diff --git a/vmime/messageAttachment.hpp b/vmime/messageAttachment.hpp
index b6b360f4..641fd3e1 100644
--- a/vmime/messageAttachment.hpp
+++ b/vmime/messageAttachment.hpp
@@ -44,7 +44,7 @@ public:
*
* @return encapsulated message
*/
- virtual ref <message> getMessage() const = 0;
+ virtual shared_ptr <message> getMessage() const = 0;
};
diff --git a/vmime/messageBuilder.hpp b/vmime/messageBuilder.hpp
index f3f9fa0d..af86e826 100644
--- a/vmime/messageBuilder.hpp
+++ b/vmime/messageBuilder.hpp
@@ -136,13 +136,13 @@ public:
*
* @param attach new attachment
*/
- void attach(ref <attachment> attach);
+ void attach(shared_ptr <attachment> attach);
/** Attach a new object to the message.
*
* @param attach new attachment
*/
- void appendAttachment(ref <attachment> attach);
+ void appendAttachment(shared_ptr <attachment> attach);
/** Remove the attachment at the specified position.
*
@@ -155,14 +155,14 @@ public:
* @param pos position of the attachment
* @return attachment at the specified position
*/
- const ref <const attachment> getAttachmentAt(const size_t pos) const;
+ const shared_ptr <const attachment> getAttachmentAt(const size_t pos) const;
/** Return the attachment at the specified position.
*
* @param pos position of the attachment
* @return attachment at the specified position
*/
- ref <attachment> getAttachmentAt(const size_t pos);
+ shared_ptr <attachment> getAttachmentAt(const size_t pos);
/** Return the number of attachments in the message.
*
@@ -174,13 +174,13 @@ public:
*
* @return list of attachments
*/
- const std::vector <ref <const attachment> > getAttachmentList() const;
+ const std::vector <shared_ptr <const attachment> > getAttachmentList() const;
/** Return the list of attachments.
*
* @return list of attachments
*/
- const std::vector <ref <attachment> > getAttachmentList();
+ const std::vector <shared_ptr <attachment> > getAttachmentList();
/** Change the type of the text part and construct a new part.
*
@@ -192,14 +192,14 @@ public:
*
* @return text part of the message
*/
- ref <textPart> getTextPart();
+ shared_ptr <textPart> getTextPart();
/** Construct a new message based on the information specified
* in this object.
*
* @return a new message
*/
- ref <message> construct() const;
+ shared_ptr <message> construct() const;
private:
@@ -211,9 +211,9 @@ private:
text m_subject;
- ref <textPart> m_textPart;
+ shared_ptr <textPart> m_textPart;
- std::vector <ref <attachment> > m_attach;
+ std::vector <shared_ptr <attachment> > m_attach;
};
diff --git a/vmime/messageId.hpp b/vmime/messageId.hpp
index 7d6348e3..8c2f85d1 100644
--- a/vmime/messageId.hpp
+++ b/vmime/messageId.hpp
@@ -93,11 +93,11 @@ public:
*/
const string getId() const;
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
messageId& operator=(const messageId& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
private:
@@ -128,7 +128,7 @@ protected:
* @param newPosition will receive the new position in the input buffer
* @return a new message-id object, or null if no more message-id can be parsed from the input buffer
*/
- static ref <messageId> parseNext
+ static shared_ptr <messageId> parseNext
(const parsingContext& ctx,
const string& buffer,
const string::size_type position,
diff --git a/vmime/messageIdSequence.hpp b/vmime/messageIdSequence.hpp
index ec54dbd3..39c415c7 100644
--- a/vmime/messageIdSequence.hpp
+++ b/vmime/messageIdSequence.hpp
@@ -45,18 +45,18 @@ public:
~messageIdSequence();
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
messageIdSequence& operator=(const messageIdSequence& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Add a message-id at the end of the list.
*
* @param mid message-id to append
*/
- void appendMessageId(ref <messageId> mid);
+ void appendMessageId(shared_ptr <messageId> mid);
/** Insert a new message-id before the specified message-id.
*
@@ -64,7 +64,7 @@ public:
* @param mid message-id to insert
* @throw exceptions::no_such_messageid if the message-id is not in the list
*/
- void insertMessageIdBefore(ref <messageId> beforeMid, ref <messageId> mid);
+ void insertMessageIdBefore(shared_ptr <messageId> beforeMid, shared_ptr <messageId> mid);
/** Insert a new message-id before the specified position.
*
@@ -72,7 +72,7 @@ public:
* the beginning of the list)
* @param mid message-id to insert
*/
- void insertMessageIdBefore(const size_t pos, ref <messageId> mid);
+ void insertMessageIdBefore(const size_t pos, shared_ptr <messageId> mid);
/** Insert a new message-id after the specified message-id.
*
@@ -80,21 +80,21 @@ public:
* @param mid message-id to insert
* @throw exceptions::no_such_message_id if the message-id is not in the list
*/
- void insertMessageIdAfter(ref <messageId> afterMid, ref <messageId> mid);
+ void insertMessageIdAfter(shared_ptr <messageId> afterMid, shared_ptr <messageId> mid);
/** Insert a new message-id after the specified position.
*
* @param pos position of the message-id before the new message-id
* @param mid message-id to insert
*/
- void insertMessageIdAfter(const size_t pos, ref <messageId> mid);
+ void insertMessageIdAfter(const size_t pos, shared_ptr <messageId> mid);
/** Remove the specified message-id from the list.
*
* @param mid message-id to remove
* @throw exceptions::no_such_message_id if the message-id is not in the list
*/
- void removeMessageId(ref <messageId> mid);
+ void removeMessageId(shared_ptr <messageId> mid);
/** Remove the message-id at the specified position.
*
@@ -123,30 +123,30 @@ public:
* @param pos position
* @return message-id at position 'pos'
*/
- const ref <messageId> getMessageIdAt(const size_t pos);
+ const shared_ptr <messageId> getMessageIdAt(const size_t pos);
/** Return the message-id at the specified position.
*
* @param pos position
* @return message-id at position 'pos'
*/
- const ref <const messageId> getMessageIdAt(const size_t pos) const;
+ const shared_ptr <const messageId> getMessageIdAt(const size_t pos) const;
/** Return the message-id list.
*
* @return list of message-ids
*/
- const std::vector <ref <const messageId> > getMessageIdList() const;
+ const std::vector <shared_ptr <const messageId> > getMessageIdList() const;
/** Return the message-id list.
*
* @return list of message-ids
*/
- const std::vector <ref <messageId> > getMessageIdList();
+ const std::vector <shared_ptr <messageId> > getMessageIdList();
private:
- std::vector <ref <messageId> > m_list;
+ std::vector <shared_ptr <messageId> > m_list;
protected:
diff --git a/vmime/messageParser.hpp b/vmime/messageParser.hpp
index d89170ad..c3a48f11 100644
--- a/vmime/messageParser.hpp
+++ b/vmime/messageParser.hpp
@@ -49,7 +49,7 @@ class VMIME_EXPORT messageParser
public:
messageParser(const string& buffer);
- messageParser(ref <const message> msg);
+ messageParser(shared_ptr <const message> msg);
~messageParser();
public:
@@ -101,19 +101,19 @@ public:
* @param pos position of the attachment
* @return attachment at position 'pos'
*/
- const ref <const attachment> getAttachmentAt(const size_t pos) const;
+ const shared_ptr <const attachment> getAttachmentAt(const size_t pos) const;
/** Return the attachments of the message.
*
* @return list of attachments in the message
*/
- const std::vector <ref <const attachment> > getAttachmentList() const;
+ const std::vector <shared_ptr <const attachment> > getAttachmentList() const;
/** Return the text parts of the message.
*
* @return list of text parts in the message
*/
- const std::vector <ref <const textPart> > getTextPartList() const;
+ const std::vector <shared_ptr <const textPart> > getTextPartList() const;
/** Return the number of text parts in the message.
*
@@ -126,7 +126,7 @@ public:
* @param pos position of the text part
* @return text part at position 'pos'
*/
- const ref <const textPart> getTextPartAt(const size_t pos) const;
+ const shared_ptr <const textPart> getTextPartAt(const size_t pos) const;
private:
@@ -140,16 +140,16 @@ private:
datetime m_date;
- std::vector <ref <const attachment> > m_attach;
+ std::vector <shared_ptr <const attachment> > m_attach;
- std::vector <ref <textPart> > m_textParts;
+ std::vector <shared_ptr <textPart> > m_textParts;
- void parse(ref <const message> msg);
+ void parse(shared_ptr <const message> msg);
- void findAttachments(ref <const message> msg);
+ void findAttachments(shared_ptr <const message> msg);
- void findTextParts(ref <const bodyPart> msg, ref <const bodyPart> part);
- bool findSubTextParts(ref <const bodyPart> msg, ref <const bodyPart> part);
+ void findTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> part);
+ bool findSubTextParts(shared_ptr <const bodyPart> msg, shared_ptr <const bodyPart> part);
};
diff --git a/vmime/misc/importanceHelper.hpp b/vmime/misc/importanceHelper.hpp
index c5c48f50..ae8297fc 100644
--- a/vmime/misc/importanceHelper.hpp
+++ b/vmime/misc/importanceHelper.hpp
@@ -58,13 +58,13 @@ public:
*
* @param msg message on which to reset importance
*/
- static void resetImportance(ref <message> msg);
+ static void resetImportance(shared_ptr <message> msg);
/** Reset the importance of a message to the default importance.
*
* @param hdr message header on which to reset importance
*/
- static void resetImportanceHeader(ref <header> hdr);
+ static void resetImportanceHeader(shared_ptr <header> hdr);
/** Return the importance of the specified message.
*
@@ -72,7 +72,7 @@ public:
* @return importance of the message, or default importance is no
* information about importance is given in the message
*/
- static Importance getImportance(ref <const message> msg);
+ static Importance getImportance(shared_ptr <const message> msg);
/** Return the importance of a message, given its header.
*
@@ -80,21 +80,21 @@ public:
* @return importance of the message, or default importance is no
* information about importance is given in the message
*/
- static Importance getImportanceHeader(ref <const header> hdr);
+ static Importance getImportanceHeader(shared_ptr <const header> hdr);
/** Set the importance of the specified message.
*
* @param msg message on which to set importance
* @param i new message importance
*/
- static void setImportance(ref <message> msg, const Importance i);
+ static void setImportance(shared_ptr <message> msg, const Importance i);
/** Set the importance of a message, given its header.
*
* @param hdr message header on which to set importance
* @param i new message importance
*/
- static void setImportanceHeader(ref <header> hdr, const Importance i);
+ static void setImportanceHeader(shared_ptr <header> hdr, const Importance i);
};
diff --git a/vmime/net/events.hpp b/vmime/net/events.hpp
index 1e5fd7f3..a3e952d4 100644
--- a/vmime/net/events.hpp
+++ b/vmime/net/events.hpp
@@ -75,13 +75,13 @@ public:
};
- messageCountEvent(ref <folder> folder, const Types type, const std::vector <int>& nums);
+ messageCountEvent(shared_ptr <folder> folder, const Types type, const std::vector <int>& nums);
/** Return the folder in which messages have been added/removed.
*
* @return folder in which message count changed
*/
- ref <folder> getFolder() const;
+ shared_ptr <folder> getFolder() const;
/** Return the event type.
*
@@ -106,7 +106,7 @@ public:
private:
- ref <folder> m_folder;
+ shared_ptr <folder> m_folder;
const Types m_type;
std::vector <int> m_nums;
};
@@ -123,8 +123,8 @@ protected:
public:
- virtual void messagesAdded(ref <messageCountEvent> event) = 0;
- virtual void messagesRemoved(ref <messageCountEvent> event) = 0;
+ virtual void messagesAdded(shared_ptr <messageCountEvent> event) = 0;
+ virtual void messagesRemoved(shared_ptr <messageCountEvent> event) = 0;
};
@@ -144,13 +144,13 @@ public:
};
- messageChangedEvent(ref <folder> folder, const Types type, const std::vector <int>& nums);
+ messageChangedEvent(shared_ptr <folder> folder, const Types type, const std::vector <int>& nums);
/** Return the folder in which messages have changed.
*
* @return folder in which message count changed
*/
- ref <folder> getFolder() const;
+ shared_ptr <folder> getFolder() const;
/** Return the event type.
*
@@ -175,7 +175,7 @@ public:
private:
- ref <folder> m_folder;
+ shared_ptr <folder> m_folder;
const Types m_type;
std::vector <int> m_nums;
};
@@ -192,7 +192,7 @@ protected:
public:
- virtual void messageChanged(ref <messageChangedEvent> event) = 0;
+ virtual void messageChanged(shared_ptr <messageChangedEvent> event) = 0;
};
@@ -214,13 +214,13 @@ public:
};
- folderEvent(ref <folder> folder, const Types type, const utility::path& oldPath, const utility::path& newPath);
+ folderEvent(shared_ptr <folder> folder, const Types type, const utility::path& oldPath, const utility::path& newPath);
/** Return the folder on which the event occured.
*
* @return folder on which the event occured
*/
- ref <folder> getFolder() const;
+ shared_ptr <folder> getFolder() const;
/** Return the event type.
*
@@ -239,7 +239,7 @@ public:
private:
- ref <folder> m_folder;
+ shared_ptr <folder> m_folder;
const Types m_type;
const utility::path m_oldPath;
const utility::path m_newPath;
@@ -257,9 +257,9 @@ protected:
public:
- virtual void folderCreated(ref <folderEvent> event) = 0;
- virtual void folderRenamed(ref <folderEvent> event) = 0;
- virtual void folderDeleted(ref <folderEvent> event) = 0;
+ virtual void folderCreated(shared_ptr <folderEvent> event) = 0;
+ virtual void folderRenamed(shared_ptr <folderEvent> event) = 0;
+ virtual void folderDeleted(shared_ptr <folderEvent> event) = 0;
};
diff --git a/vmime/net/folder.hpp b/vmime/net/folder.hpp
index 643a323b..deefaf49 100644
--- a/vmime/net/folder.hpp
+++ b/vmime/net/folder.hpp
@@ -186,7 +186,7 @@ public:
* @return a new object referencing the specified message
* @throw exceptions::net_exception if an error occurs
*/
- virtual ref <message> getMessage(const int num) = 0;
+ virtual shared_ptr <message> getMessage(const int num) = 0;
/** Get new references to messages in this folder, given either their
* sequence numbers or UIDs.
@@ -215,7 +215,7 @@ public:
* @return new objects referencing the specified messages
* @throw exceptions::net_exception if an error occurs
*/
- virtual std::vector <ref <message> > getMessages(const messageSet& msgs) = 0;
+ virtual std::vector <shared_ptr <message> > getMessages(const messageSet& msgs) = 0;
/** Return the number of messages in this folder.
*
@@ -229,7 +229,7 @@ public:
* @return a new object referencing the specified folder
* @throw exceptions::net_exception if an error occurs
*/
- virtual ref <folder> getFolder(const folder::path::component& name) = 0;
+ virtual shared_ptr <folder> getFolder(const folder::path::component& name) = 0;
/** Get the list of all sub-folders in this folder.
*
@@ -238,7 +238,7 @@ public:
* @return list of sub-folders
* @throw exceptions::net_exception if an error occurs
*/
- virtual std::vector <ref <folder> > getFolders(const bool recursive = false) = 0;
+ virtual std::vector <shared_ptr <folder> > getFolders(const bool recursive = false) = 0;
/** Rename (move) this folder to another location.
*
@@ -271,7 +271,7 @@ public:
* @param progress progress listener, or NULL if not used
* @throw exceptions::net_exception if an error occurs
*/
- virtual void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0;
+ virtual void addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL) = 0;
/** Add a message to this folder.
*
@@ -307,7 +307,7 @@ public:
* @return current folder status
* @throw exceptions::net_exception if an error occurs
*/
- virtual ref <folderStatus> getStatus() = 0;
+ virtual shared_ptr <folderStatus> getStatus() = 0;
/** Expunge deleted messages.
*
@@ -319,19 +319,19 @@ public:
*
* @return parent folder object
*/
- virtual ref <folder> getParent() = 0;
+ virtual shared_ptr <folder> getParent() = 0;
/** Return a reference to the store to which this folder belongs.
*
* @return the store object to which this folder is attached
*/
- virtual ref <const store> getStore() const = 0;
+ virtual shared_ptr <const store> getStore() const = 0;
/** Return a reference to the store to which this folder belongs.
*
* @return the store object to which this folder is attached
*/
- virtual ref <store> getStore() = 0;
+ virtual shared_ptr <store> getStore() = 0;
/** Fetch objects for the specified messages.
*
@@ -340,7 +340,7 @@ public:
* @param progress progress listener, or NULL if not used
* @throw exceptions::net_exception if an error occurs
*/
- virtual void fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& attribs, utility::progressListener* progress = NULL) = 0;
+ virtual void fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& attribs, utility::progressListener* progress = NULL) = 0;
/** Fetch objects for the specified message.
*
@@ -348,7 +348,7 @@ public:
* @param attribs set of attributes to fetch
* @throw exceptions::net_exception if an error occurs
*/
- virtual void fetchMessage(ref <message> msg, const fetchAttributes& attribs) = 0;
+ virtual void fetchMessage(shared_ptr <message> msg, const fetchAttributes& attribs) = 0;
/** Return the list of fetchable objects supported by
* the underlying protocol (see folder::fetchAttributes).
@@ -377,10 +377,10 @@ public:
protected:
- void notifyMessageChanged(ref <events::messageChangedEvent> event);
- void notifyMessageCount(ref <events::messageCountEvent> event);
- void notifyFolder(ref <events::folderEvent> event);
- void notifyEvent(ref <events::event> event);
+ void notifyMessageChanged(shared_ptr <events::messageChangedEvent> event);
+ void notifyMessageCount(shared_ptr <events::messageCountEvent> event);
+ void notifyFolder(shared_ptr <events::folderEvent> event);
+ void notifyEvent(shared_ptr <events::event> event);
private:
diff --git a/vmime/net/folderStatus.hpp b/vmime/net/folderStatus.hpp
index f4cc62fc..b94db052 100644
--- a/vmime/net/folderStatus.hpp
+++ b/vmime/net/folderStatus.hpp
@@ -61,7 +61,7 @@ public:
*
* @return a copy of this object
*/
- virtual ref <folderStatus> clone() const = 0;
+ virtual shared_ptr <folderStatus> clone() const = 0;
};
diff --git a/vmime/net/imap/IMAPConnection.hpp b/vmime/net/imap/IMAPConnection.hpp
index ff95c611..bc5590ba 100644
--- a/vmime/net/imap/IMAPConnection.hpp
+++ b/vmime/net/imap/IMAPConnection.hpp
@@ -54,7 +54,7 @@ class VMIME_EXPORT IMAPConnection : public object
{
public:
- IMAPConnection(ref <IMAPStore> store, ref <security::authenticator> auth);
+ IMAPConnection(shared_ptr <IMAPStore> store, shared_ptr <security::authenticator> auth);
~IMAPConnection();
@@ -85,22 +85,22 @@ public:
IMAPParser::response* readResponse(IMAPParser::literalHandler* lh = NULL);
- ref <const IMAPStore> getStore() const;
- ref <IMAPStore> getStore();
+ shared_ptr <const IMAPStore> getStore() const;
+ shared_ptr <IMAPStore> getStore();
- ref <session> getSession();
+ shared_ptr <session> getSession();
void fetchCapabilities();
void invalidateCapabilities();
const std::vector <string> getCapabilities();
bool hasCapability(const string& capa);
- ref <security::authenticator> getAuthenticator();
+ shared_ptr <security::authenticator> getAuthenticator();
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
+ shared_ptr <connectionInfos> getConnectionInfos() const;
- ref <const socket> getSocket() const;
+ shared_ptr <const socket> getSocket() const;
bool isMODSEQDisabled() const;
void disableMODSEQ();
@@ -120,24 +120,24 @@ private:
void processCapabilityResponseData(const IMAPParser::capability_data* capaData);
- weak_ref <IMAPStore> m_store;
+ weak_ptr <IMAPStore> m_store;
- ref <security::authenticator> m_auth;
+ shared_ptr <security::authenticator> m_auth;
- ref <socket> m_socket;
+ shared_ptr <socket> m_socket;
- ref <IMAPParser> m_parser;
+ shared_ptr <IMAPParser> m_parser;
- ref <IMAPTag> m_tag;
+ shared_ptr <IMAPTag> m_tag;
char m_hierarchySeparator;
ProtocolStates m_state;
- ref <timeoutHandler> m_timeoutHandler;
+ shared_ptr <timeoutHandler> m_timeoutHandler;
bool m_secured;
- ref <connectionInfos> m_cntInfos;
+ shared_ptr <connectionInfos> m_cntInfos;
bool m_firstTag;
diff --git a/vmime/net/imap/IMAPFolder.hpp b/vmime/net/imap/IMAPFolder.hpp
index 7bb9c0af..5edbfb16 100644
--- a/vmime/net/imap/IMAPFolder.hpp
+++ b/vmime/net/imap/IMAPFolder.hpp
@@ -61,16 +61,15 @@ private:
friend class IMAPStore;
friend class IMAPMessage;
- friend class vmime::creator; // vmime::create <IMAPFolder>
-
- IMAPFolder(const folder::path& path, ref <IMAPStore> store, const int type = TYPE_UNDEFINED, const int flags = FLAG_UNDEFINED);
IMAPFolder(const IMAPFolder&);
- ~IMAPFolder();
-
public:
+ IMAPFolder(const folder::path& path, shared_ptr <IMAPStore> store, const int type = TYPE_UNDEFINED, const int flags = FLAG_UNDEFINED);
+
+ ~IMAPFolder();
+
int getMode() const;
int getType();
@@ -90,15 +89,15 @@ public:
bool isOpen() const;
- ref <message> getMessage(const int num);
- std::vector <ref <message> > getMessages(const messageSet& msgs);
+ shared_ptr <message> getMessage(const int num);
+ std::vector <shared_ptr <message> > getMessages(const messageSet& msgs);
std::vector <int> getMessageNumbersStartingOnUID(const message::uid& uid);
int getMessageCount();
- ref <folder> getFolder(const folder::path::component& name);
- std::vector <ref <folder> > getFolders(const bool recursive = false);
+ shared_ptr <folder> getFolder(const folder::path::component& name);
+ std::vector <shared_ptr <folder> > getFolders(const bool recursive = false);
void rename(const folder::path& newPath);
@@ -106,26 +105,26 @@ public:
void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
- void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
+ void addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void copyMessages(const folder::path& dest, const messageSet& msgs);
void status(int& count, int& unseen);
- ref <folderStatus> getStatus();
+ shared_ptr <folderStatus> getStatus();
void noop();
void expunge();
- ref <folder> getParent();
+ shared_ptr <folder> getParent();
- ref <const store> getStore() const;
- ref <store> getStore();
+ shared_ptr <const store> getStore() const;
+ shared_ptr <store> getStore();
- void fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL);
- void fetchMessage(ref <message> msg, const fetchAttributes& options);
+ void fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL);
+ void fetchMessage(shared_ptr <message> msg, const fetchAttributes& options);
int getFetchCapabilities() const;
@@ -177,8 +176,8 @@ private:
void processStatusUpdate(const IMAPParser::response* resp);
- weak_ref <IMAPStore> m_store;
- ref <IMAPConnection> m_connection;
+ weak_ptr <IMAPStore> m_store;
+ shared_ptr <IMAPConnection> m_connection;
folder::path m_path;
folder::path::component m_name;
@@ -189,7 +188,7 @@ private:
int m_type;
int m_flags;
- ref <IMAPFolderStatus> m_status;
+ shared_ptr <IMAPFolderStatus> m_status;
std::vector <IMAPMessage*> m_messages;
};
diff --git a/vmime/net/imap/IMAPFolderStatus.hpp b/vmime/net/imap/IMAPFolderStatus.hpp
index bcd6415e..03ca5937 100644
--- a/vmime/net/imap/IMAPFolderStatus.hpp
+++ b/vmime/net/imap/IMAPFolderStatus.hpp
@@ -55,7 +55,7 @@ public:
unsigned int getMessageCount() const;
unsigned int getUnseenCount() const;
- ref <folderStatus> clone() const;
+ shared_ptr <folderStatus> clone() const;
/** Returns the the number of messages with the Recent flag set.
*
diff --git a/vmime/net/imap/IMAPMessage.hpp b/vmime/net/imap/IMAPMessage.hpp
index b57ae332..272fe17b 100644
--- a/vmime/net/imap/IMAPMessage.hpp
+++ b/vmime/net/imap/IMAPMessage.hpp
@@ -54,16 +54,16 @@ private:
friend class IMAPFolder;
friend class IMAPMessagePartContentHandler;
- friend class vmime::creator; // vmime::create <IMAPMessage>
- IMAPMessage(ref <IMAPFolder> folder, const int num);
- IMAPMessage(ref <IMAPFolder> folder, const int num, const uid& uid);
IMAPMessage(const IMAPMessage&) : message() { }
- ~IMAPMessage();
-
public:
+ IMAPMessage(shared_ptr <IMAPFolder> folder, const int num);
+ IMAPMessage(shared_ptr <IMAPFolder> folder, const int num, const uid& uid);
+
+ ~IMAPMessage();
+
int getNumber() const;
const uid getUID() const;
@@ -84,20 +84,20 @@ public:
bool isExpunged() const;
- ref <const messageStructure> getStructure() const;
- ref <messageStructure> getStructure();
+ shared_ptr <const messageStructure> getStructure() const;
+ shared_ptr <messageStructure> getStructure();
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
int getFlags() const;
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
- void extractPart(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
+ void extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
- void fetchPartHeader(ref <messagePart> p);
+ void fetchPartHeader(shared_ptr <messagePart> p);
- ref <vmime::message> getParsedMessage();
+ shared_ptr <vmime::message> getParsedMessage();
private:
@@ -125,7 +125,7 @@ private:
*
* @param str structure for which to fetch parts headers
*/
- void fetchPartHeaderForStructure(ref <messageStructure> str);
+ void fetchPartHeaderForStructure(shared_ptr <messageStructure> str);
/** Recursively contruct parsed message from structure.
* Called by getParsedMessage().
@@ -134,7 +134,7 @@ private:
* @param str structure for which to construct part
* @param level current nesting level (0 is root)
*/
- void constructParsedMessage(ref <bodyPart> parentPart, ref <messageStructure> str, int level = 0);
+ void constructParsedMessage(shared_ptr <bodyPart> parentPart, shared_ptr <messageStructure> str, int level = 0);
enum ExtractFlags
@@ -144,16 +144,16 @@ private:
EXTRACT_PEEK = 0x10
};
- void extractImpl(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
+ void extractImpl(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress,
const int start, const int length, const int extractFlags) const;
- ref <header> getOrCreateHeader();
+ shared_ptr <header> getOrCreateHeader();
void onFolderClosed();
- weak_ref <IMAPFolder> m_folder;
+ weak_ptr <IMAPFolder> m_folder;
int m_num;
int m_size;
@@ -162,8 +162,8 @@ private:
uid m_uid;
vmime_uint64 m_modseq;
- ref <header> m_header;
- ref <messageStructure> m_structure;
+ shared_ptr <header> m_header;
+ shared_ptr <messageStructure> m_structure;
};
diff --git a/vmime/net/imap/IMAPMessagePart.hpp b/vmime/net/imap/IMAPMessagePart.hpp
index 5c38501d..f71d7d43 100644
--- a/vmime/net/imap/IMAPMessagePart.hpp
+++ b/vmime/net/imap/IMAPMessagePart.hpp
@@ -46,38 +46,34 @@ class IMAPMessageStructure;
class VMIME_EXPORT IMAPMessagePart : public messagePart
{
-private:
-
- friend class vmime::creator;
-
- IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart);
- IMAPMessagePart(ref <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part);
-
public:
- ref <const messageStructure> getStructure() const;
- ref <messageStructure> getStructure();
+ IMAPMessagePart(shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_mpart* mpart);
+ IMAPMessagePart(shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body_type_1part* part);
+
+ shared_ptr <const messageStructure> getStructure() const;
+ shared_ptr <messageStructure> getStructure();
- ref <const IMAPMessagePart> getParent() const;
+ shared_ptr <const IMAPMessagePart> getParent() const;
const mediaType& getType() const;
int getSize() const;
int getNumber() const;
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
- static ref <IMAPMessagePart> create
- (ref <IMAPMessagePart> parent, const int number, const IMAPParser::body* body);
+ static shared_ptr <IMAPMessagePart> create
+ (shared_ptr <IMAPMessagePart> parent, const int number, const IMAPParser::body* body);
header& getOrCreateHeader();
private:
- ref <IMAPMessageStructure> m_structure;
- weak_ref <IMAPMessagePart> m_parent;
- ref <header> m_header;
+ shared_ptr <IMAPMessageStructure> m_structure;
+ weak_ptr <IMAPMessagePart> m_parent;
+ shared_ptr <header> m_header;
int m_number;
int m_size;
diff --git a/vmime/net/imap/IMAPMessagePartContentHandler.hpp b/vmime/net/imap/IMAPMessagePartContentHandler.hpp
index ac273151..80e1f0e5 100644
--- a/vmime/net/imap/IMAPMessagePartContentHandler.hpp
+++ b/vmime/net/imap/IMAPMessagePartContentHandler.hpp
@@ -44,9 +44,9 @@ class VMIME_EXPORT IMAPMessagePartContentHandler : public contentHandler
{
public:
- IMAPMessagePartContentHandler(ref <IMAPMessage> msg, ref <messagePart> part, const vmime::encoding& encoding);
+ IMAPMessagePartContentHandler(shared_ptr <IMAPMessage> msg, shared_ptr <messagePart> part, const vmime::encoding& encoding);
- ref <contentHandler> clone() const;
+ shared_ptr <contentHandler> clone() const;
void generate(utility::outputStream& os, const vmime::encoding& enc, const string::size_type maxLineLength = lineLengthLimits::infinite) const;
@@ -68,8 +68,8 @@ public:
private:
- weak_ref <IMAPMessage> m_message;
- weak_ref <messagePart> m_part;
+ weak_ptr <IMAPMessage> m_message;
+ weak_ptr <messagePart> m_part;
vmime::encoding m_encoding;
vmime::mediaType m_contentType;
diff --git a/vmime/net/imap/IMAPMessageStructure.hpp b/vmime/net/imap/IMAPMessageStructure.hpp
index e2a9f169..44b6d6f0 100644
--- a/vmime/net/imap/IMAPMessageStructure.hpp
+++ b/vmime/net/imap/IMAPMessageStructure.hpp
@@ -50,17 +50,17 @@ public:
IMAPMessageStructure();
IMAPMessageStructure(const IMAPParser::body* body);
- IMAPMessageStructure(ref <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list);
+ IMAPMessageStructure(shared_ptr <IMAPMessagePart> parent, const std::vector <IMAPParser::body*>& list);
- ref <const messagePart> getPartAt(const size_t x) const;
- ref <messagePart> getPartAt(const size_t x);
+ shared_ptr <const messagePart> getPartAt(const size_t x) const;
+ shared_ptr <messagePart> getPartAt(const size_t x);
size_t getPartCount() const;
- static ref <IMAPMessageStructure> emptyStructure();
+ static shared_ptr <IMAPMessageStructure> emptyStructure();
private:
- std::vector <ref <IMAPMessagePart> > m_parts;
+ std::vector <shared_ptr <IMAPMessagePart> > m_parts;
};
diff --git a/vmime/net/imap/IMAPParser.hpp b/vmime/net/imap/IMAPParser.hpp
index 63858b89..519cadd8 100644
--- a/vmime/net/imap/IMAPParser.hpp
+++ b/vmime/net/imap/IMAPParser.hpp
@@ -36,7 +36,6 @@
#include "vmime/charset.hpp"
#include "vmime/exception.hpp"
-#include "vmime/utility/smartPtr.hpp"
#include "vmime/utility/stringUtils.hpp"
#include "vmime/utility/progressListener.hpp"
@@ -55,6 +54,7 @@
#include <vector>
#include <stdexcept>
+#include <memory>
//#define DEBUG_RESPONSE 1
@@ -142,19 +142,19 @@ class VMIME_EXPORT IMAPParser : public object
{
public:
- IMAPParser(weak_ref <IMAPTag> tag, weak_ref <socket> sok, weak_ref <timeoutHandler> _timeoutHandler)
+ IMAPParser(weak_ptr <IMAPTag> tag, weak_ptr <socket> sok, weak_ptr <timeoutHandler> _timeoutHandler)
: m_tag(tag), m_socket(sok), m_progress(NULL), m_strict(false),
m_literalHandler(NULL), m_timeoutHandler(_timeoutHandler)
{
}
- ref <const IMAPTag> getTag() const
+ shared_ptr <const IMAPTag> getTag() const
{
- return m_tag.acquire();
+ return m_tag.lock();
}
- void setSocket(ref <socket> sok)
+ void setSocket(shared_ptr <socket> sok)
{
m_socket = sok;
}
@@ -871,7 +871,7 @@ public:
// quoted ::= <"> *QUOTED_CHAR <">
if (parser.check <one_char <'"'> >(line, &pos, true))
{
- utility::auto_ptr <quoted_text> text(parser.get <quoted_text>(line, &pos));
+ std::auto_ptr <quoted_text> text(parser.get <quoted_text>(line, &pos));
parser.check <one_char <'"'> >(line, &pos);
if (parser.m_literalHandler != NULL)
@@ -2189,28 +2189,28 @@ public:
parser.check <one_char <'"'> >(line, &pos);
parser.check <SPACE>(line, &pos, true);
- utility::auto_ptr <number> nd(parser.get <number>(line, &pos));
+ std::auto_ptr <number> nd(parser.get <number>(line, &pos));
parser.check <one_char <'-'> >(line, &pos);
- utility::auto_ptr <atom> amo(parser.get <atom>(line, &pos));
+ std::auto_ptr <atom> amo(parser.get <atom>(line, &pos));
parser.check <one_char <'-'> >(line, &pos);
- utility::auto_ptr <number> ny(parser.get <number>(line, &pos));
+ std::auto_ptr <number> ny(parser.get <number>(line, &pos));
parser.check <SPACE>(line, &pos, true);
// 2digit ":" 2digit ":" 2digit
- utility::auto_ptr <number> nh(parser.get <number>(line, &pos));
+ std::auto_ptr <number> nh(parser.get <number>(line, &pos));
parser.check <one_char <':'> >(line, &pos);
- utility::auto_ptr <number> nmi(parser.get <number>(line, &pos));
+ std::auto_ptr <number> nmi(parser.get <number>(line, &pos));
parser.check <one_char <':'> >(line, &pos);
- utility::auto_ptr <number> ns(parser.get <number>(line, &pos));
+ std::auto_ptr <number> ns(parser.get <number>(line, &pos));
parser.check <SPACE>(line, &pos, true);
@@ -2220,7 +2220,7 @@ public:
if (!(parser.check <one_char <'+'> >(line, &pos, true)))
parser.check <one_char <'-'> >(line, &pos);
- utility::auto_ptr <number> nz(parser.get <number>(line, &pos));
+ std::auto_ptr <number> nz(parser.get <number>(line, &pos));
parser.check <one_char <'"'> >(line, &pos);
@@ -5406,8 +5406,8 @@ public:
private:
- weak_ref <IMAPTag> m_tag;
- weak_ref <socket> m_socket;
+ weak_ptr <IMAPTag> m_tag;
+ weak_ptr <socket> m_socket;
utility::progressListener* m_progress;
@@ -5415,7 +5415,7 @@ private:
literalHandler* m_literalHandler;
- weak_ref <timeoutHandler> m_timeoutHandler;
+ weak_ptr <timeoutHandler> m_timeoutHandler;
string m_buffer;
@@ -5461,8 +5461,8 @@ public:
{
string receiveBuffer;
- ref <timeoutHandler> toh = m_timeoutHandler.acquire();
- ref <socket> sok = m_socket.acquire();
+ shared_ptr <timeoutHandler> toh = m_timeoutHandler.lock();
+ shared_ptr <socket> sok = m_socket.lock();
if (toh)
toh->resetTimeOut();
@@ -5499,8 +5499,8 @@ public:
string::size_type len = 0;
string receiveBuffer;
- ref <timeoutHandler> toh = m_timeoutHandler.acquire();
- ref <socket> sok = m_socket.acquire();
+ shared_ptr <timeoutHandler> toh = m_timeoutHandler.lock();
+ shared_ptr <socket> sok = m_socket.lock();
if (m_progress)
m_progress->start(count);
diff --git a/vmime/net/imap/IMAPSStore.hpp b/vmime/net/imap/IMAPSStore.hpp
index e7f05d3f..9d27bdd0 100644
--- a/vmime/net/imap/IMAPSStore.hpp
+++ b/vmime/net/imap/IMAPSStore.hpp
@@ -46,7 +46,7 @@ class VMIME_EXPORT IMAPSStore : public IMAPStore
{
public:
- IMAPSStore(ref <session> sess, ref <security::authenticator> auth);
+ IMAPSStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth);
~IMAPSStore();
const string getProtocolName() const;
diff --git a/vmime/net/imap/IMAPStore.hpp b/vmime/net/imap/IMAPStore.hpp
index e6b27d8d..f854fadf 100644
--- a/vmime/net/imap/IMAPStore.hpp
+++ b/vmime/net/imap/IMAPStore.hpp
@@ -60,14 +60,14 @@ class VMIME_EXPORT IMAPStore : public store
public:
- IMAPStore(ref <session> sess, ref <security::authenticator> auth, const bool secured = false);
+ IMAPStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured = false);
~IMAPStore();
const string getProtocolName() const;
- ref <folder> getDefaultFolder();
- ref <folder> getRootFolder();
- ref <folder> getFolder(const folder::path& path);
+ shared_ptr <folder> getDefaultFolder();
+ shared_ptr <folder> getRootFolder();
+ shared_ptr <folder> getFolder(const folder::path& path);
bool isValidFolderName(const folder::path::component& name) const;
@@ -85,17 +85,17 @@ public:
bool isIMAPS() const;
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
- ref <IMAPConnection> getConnection();
+ shared_ptr <connectionInfos> getConnectionInfos() const;
+ shared_ptr <IMAPConnection> getConnection();
protected:
// Connection
- ref <IMAPConnection> m_connection;
+ shared_ptr <IMAPConnection> m_connection;
- ref <IMAPConnection> connection();
+ shared_ptr <IMAPConnection> connection();
void registerFolder(IMAPFolder* folder);
diff --git a/vmime/net/imap/IMAPUtils.hpp b/vmime/net/imap/IMAPUtils.hpp
index 76c44494..988b6a2c 100644
--- a/vmime/net/imap/IMAPUtils.hpp
+++ b/vmime/net/imap/IMAPUtils.hpp
@@ -89,7 +89,7 @@ public:
* @return fetch request
*/
static const string buildFetchRequest
- (ref <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options);
+ (shared_ptr <IMAPConnection> cnt, const messageSet& msgs, const fetchAttributes& options);
/** Convert a parser-style address list to a mailbox list.
*
@@ -115,7 +115,7 @@ public:
private:
static const string buildFetchRequestImpl
- (ref <IMAPConnection> cnt, const string& mode, const string& set, const int options);
+ (shared_ptr <IMAPConnection> cnt, const string& mode, const string& set, const int options);
};
diff --git a/vmime/net/maildir/format/courierMaildirFormat.hpp b/vmime/net/maildir/format/courierMaildirFormat.hpp
index 6f47b7f8..b8443426 100644
--- a/vmime/net/maildir/format/courierMaildirFormat.hpp
+++ b/vmime/net/maildir/format/courierMaildirFormat.hpp
@@ -47,7 +47,7 @@ class VMIME_EXPORT courierMaildirFormat : public maildirFormat
{
public:
- courierMaildirFormat(ref <context> ctx);
+ courierMaildirFormat(shared_ptr <context> ctx);
/* Folder types:
diff --git a/vmime/net/maildir/format/kmailMaildirFormat.hpp b/vmime/net/maildir/format/kmailMaildirFormat.hpp
index ca73eba7..98ca212e 100644
--- a/vmime/net/maildir/format/kmailMaildirFormat.hpp
+++ b/vmime/net/maildir/format/kmailMaildirFormat.hpp
@@ -47,7 +47,7 @@ class VMIME_EXPORT kmailMaildirFormat : public maildirFormat
{
public:
- kmailMaildirFormat(ref <context> ctx);
+ kmailMaildirFormat(shared_ptr <context> ctx);
/* Folder types:
diff --git a/vmime/net/maildir/maildirFolder.hpp b/vmime/net/maildir/maildirFolder.hpp
index 92de4d0d..338c6f96 100644
--- a/vmime/net/maildir/maildirFolder.hpp
+++ b/vmime/net/maildir/maildirFolder.hpp
@@ -59,15 +59,15 @@ private:
friend class maildirStore;
friend class maildirMessage;
- friend class vmime::creator; // vmime::create <maildirFolder>
-
- maildirFolder(const folder::path& path, ref <maildirStore> store);
maildirFolder(const maildirFolder&) : folder() { }
+public:
+
+ maildirFolder(const folder::path& path, shared_ptr <maildirStore> store);
+
~maildirFolder();
-public:
int getMode() const;
@@ -88,13 +88,13 @@ public:
bool isOpen() const;
- ref <message> getMessage(const int num);
- std::vector <ref <message> > getMessages(const messageSet& msgs);
+ shared_ptr <message> getMessage(const int num);
+ std::vector <shared_ptr <message> > getMessages(const messageSet& msgs);
int getMessageCount();
- ref <folder> getFolder(const folder::path::component& name);
- std::vector <ref <folder> > getFolders(const bool recursive = false);
+ shared_ptr <folder> getFolder(const folder::path::component& name);
+ std::vector <shared_ptr <folder> > getFolders(const bool recursive = false);
void rename(const folder::path& newPath);
@@ -102,24 +102,24 @@ public:
void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
- void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
+ void addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void copyMessages(const folder::path& dest, const messageSet& msgs);
void status(int& count, int& unseen);
- ref <folderStatus> getStatus();
+ shared_ptr <folderStatus> getStatus();
void expunge();
- ref <folder> getParent();
+ shared_ptr <folder> getParent();
- ref <const store> getStore() const;
- ref <store> getStore();
+ shared_ptr <const store> getStore() const;
+ shared_ptr <store> getStore();
- void fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL);
- void fetchMessage(ref <message> msg, const fetchAttributes& options);
+ void fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL);
+ void fetchMessage(shared_ptr <message> msg, const fetchAttributes& options);
int getFetchCapabilities() const;
@@ -129,7 +129,7 @@ private:
void scanFolder();
- void listFolders(std::vector <ref <folder> >& list, const bool recursive);
+ void listFolders(std::vector <shared_ptr <folder> >& list, const bool recursive);
void registerMessage(maildirMessage* msg);
void unregisterMessage(maildirMessage* msg);
@@ -149,7 +149,7 @@ private:
void notifyMessagesCopied(const folder::path& dest);
- weak_ref <maildirStore> m_store;
+ weak_ptr <maildirStore> m_store;
folder::path m_path;
folder::path::component m_name;
diff --git a/vmime/net/maildir/maildirFolderStatus.hpp b/vmime/net/maildir/maildirFolderStatus.hpp
index 28e01f11..155fb20f 100644
--- a/vmime/net/maildir/maildirFolderStatus.hpp
+++ b/vmime/net/maildir/maildirFolderStatus.hpp
@@ -53,7 +53,7 @@ public:
unsigned int getMessageCount() const;
unsigned int getUnseenCount() const;
- ref <folderStatus> clone() const;
+ shared_ptr <folderStatus> clone() const;
void setMessageCount(const unsigned int count);
diff --git a/vmime/net/maildir/maildirFormat.hpp b/vmime/net/maildir/maildirFormat.hpp
index e2afea6d..c0daf288 100644
--- a/vmime/net/maildir/maildirFormat.hpp
+++ b/vmime/net/maildir/maildirFormat.hpp
@@ -55,13 +55,13 @@ public:
{
public:
- context(ref <maildirStore> store);
+ context(shared_ptr <maildirStore> store);
- ref <maildirStore> getStore() const;
+ shared_ptr <maildirStore> getStore() const;
private:
- weak_ref <maildirStore> m_store;
+ weak_ptr <maildirStore> m_store;
};
@@ -146,7 +146,7 @@ public:
* @param store of which to detect format
* @return a Maildir format implementation for the specified store
*/
- static ref <maildirFormat> detect(ref <maildirStore> store);
+ static shared_ptr <maildirFormat> detect(shared_ptr <maildirStore> store);
protected:
@@ -155,20 +155,20 @@ protected:
static const utility::file::path::component NEW_DIR; /**< Unread messages. */
- maildirFormat(ref <context> ctx);
+ maildirFormat(shared_ptr <context> ctx);
/** Returns the current context.
*
* @return current context
*/
- ref <context> getContext();
+ shared_ptr <context> getContext();
/** Returns the current context (const version).
*
* @return current context
*/
- ref <const context> getContext() const;
+ shared_ptr <const context> getContext() const;
/** Quick checks whether this implementation can read the Maildir
* format in the specified directory.
@@ -180,7 +180,7 @@ protected:
private:
- ref <context> m_context;
+ shared_ptr <context> m_context;
};
diff --git a/vmime/net/maildir/maildirMessage.hpp b/vmime/net/maildir/maildirMessage.hpp
index 527461ff..6218c812 100644
--- a/vmime/net/maildir/maildirMessage.hpp
+++ b/vmime/net/maildir/maildirMessage.hpp
@@ -49,16 +49,15 @@ class maildirFolder;
class VMIME_EXPORT maildirMessage : public message
{
friend class maildirFolder;
- friend class vmime::creator; // vmime::create <maildirMessage>
-private:
-
- maildirMessage(ref <maildirFolder> folder, const int num);
maildirMessage(const maildirMessage&) : message() { }
+public:
+
+ maildirMessage(shared_ptr <maildirFolder> folder, const int num);
+
~maildirMessage();
-public:
int getNumber() const;
@@ -68,33 +67,33 @@ public:
bool isExpunged() const;
- ref <const messageStructure> getStructure() const;
- ref <messageStructure> getStructure();
+ shared_ptr <const messageStructure> getStructure() const;
+ shared_ptr <messageStructure> getStructure();
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
int getFlags() const;
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
- void extractPart(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
+ void extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
- void fetchPartHeader(ref <messagePart> p);
+ void fetchPartHeader(shared_ptr <messagePart> p);
- ref <vmime::message> getParsedMessage();
+ shared_ptr <vmime::message> getParsedMessage();
private:
- void fetch(ref <maildirFolder> folder, const fetchAttributes& options);
+ void fetch(shared_ptr <maildirFolder> folder, const fetchAttributes& options);
void onFolderClosed();
- ref <header> getOrCreateHeader();
+ shared_ptr <header> getOrCreateHeader();
void extractImpl(utility::outputStream& os, utility::progressListener* progress, const int start, const int length, const int partialStart, const int partialLength, const bool peek) const;
- weak_ref <maildirFolder> m_folder;
+ weak_ptr <maildirFolder> m_folder;
int m_num;
int m_size;
@@ -102,8 +101,8 @@ private:
bool m_expunged;
uid m_uid;
- ref <header> m_header;
- ref <messageStructure> m_structure;
+ shared_ptr <header> m_header;
+ shared_ptr <messageStructure> m_structure;
};
diff --git a/vmime/net/maildir/maildirMessagePart.hpp b/vmime/net/maildir/maildirMessagePart.hpp
index f79804ca..00c931ec 100644
--- a/vmime/net/maildir/maildirMessagePart.hpp
+++ b/vmime/net/maildir/maildirMessagePart.hpp
@@ -46,20 +46,20 @@ class maildirMessagePart : public messagePart
{
public:
- maildirMessagePart(ref <maildirMessagePart> parent, const int number, const bodyPart& part);
+ maildirMessagePart(shared_ptr <maildirMessagePart> parent, const int number, const bodyPart& part);
~maildirMessagePart();
- ref <const messageStructure> getStructure() const;
- ref <messageStructure> getStructure();
+ shared_ptr <const messageStructure> getStructure() const;
+ shared_ptr <messageStructure> getStructure();
- weak_ref <const maildirMessagePart> getParent() const { return (m_parent); }
+ weak_ptr <const maildirMessagePart> getParent() const { return (m_parent); }
const mediaType& getType() const;
int getSize() const;
int getNumber() const;
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
header& getOrCreateHeader();
@@ -73,9 +73,9 @@ public:
private:
- ref <maildirMessageStructure> m_structure;
- weak_ref <maildirMessagePart> m_parent;
- ref <header> m_header;
+ shared_ptr <maildirMessageStructure> m_structure;
+ weak_ptr <maildirMessagePart> m_parent;
+ shared_ptr <header> m_header;
int m_number;
int m_size;
diff --git a/vmime/net/maildir/maildirMessageStructure.hpp b/vmime/net/maildir/maildirMessageStructure.hpp
index 6d62be2b..a43fc15c 100644
--- a/vmime/net/maildir/maildirMessageStructure.hpp
+++ b/vmime/net/maildir/maildirMessageStructure.hpp
@@ -47,22 +47,22 @@ class maildirMessageStructure : public messageStructure
public:
maildirMessageStructure();
- maildirMessageStructure(ref <maildirMessagePart> parent, const bodyPart& part);
- maildirMessageStructure(ref <maildirMessagePart> parent, const std::vector <ref <const vmime::bodyPart> >& list);
+ maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const bodyPart& part);
+ maildirMessageStructure(shared_ptr <maildirMessagePart> parent, const std::vector <shared_ptr <const vmime::bodyPart> >& list);
- ref <const messagePart> getPartAt(const size_t x) const;
- ref <messagePart> getPartAt(const size_t x);
+ shared_ptr <const messagePart> getPartAt(const size_t x) const;
+ shared_ptr <messagePart> getPartAt(const size_t x);
size_t getPartCount() const;
- static ref <maildirMessageStructure> emptyStructure();
+ static shared_ptr <maildirMessageStructure> emptyStructure();
private:
- static ref <maildirMessageStructure> m_emptyStructure;
+ static shared_ptr <maildirMessageStructure> m_emptyStructure;
- std::vector <ref <maildirMessagePart> > m_parts;
+ std::vector <shared_ptr <maildirMessagePart> > m_parts;
};
diff --git a/vmime/net/maildir/maildirStore.hpp b/vmime/net/maildir/maildirStore.hpp
index b6ccd111..efadfdfe 100644
--- a/vmime/net/maildir/maildirStore.hpp
+++ b/vmime/net/maildir/maildirStore.hpp
@@ -60,14 +60,14 @@ class VMIME_EXPORT maildirStore : public store
public:
- maildirStore(ref <session> sess, ref <security::authenticator> auth);
+ maildirStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth);
~maildirStore();
const string getProtocolName() const;
- ref <folder> getDefaultFolder();
- ref <folder> getRootFolder();
- ref <folder> getFolder(const folder::path& path);
+ shared_ptr <folder> getDefaultFolder();
+ shared_ptr <folder> getRootFolder();
+ shared_ptr <folder> getFolder(const folder::path& path);
bool isValidFolderName(const folder::path::component& name) const;
@@ -85,10 +85,10 @@ public:
int getCapabilities() const;
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
+ shared_ptr <connectionInfos> getConnectionInfos() const;
- ref <maildirFormat> getFormat();
- ref <const maildirFormat> getFormat() const;
+ shared_ptr <maildirFormat> getFormat();
+ shared_ptr <const maildirFormat> getFormat() const;
private:
@@ -98,7 +98,7 @@ private:
std::list <maildirFolder*> m_folders;
- ref <maildirFormat> m_format;
+ shared_ptr <maildirFormat> m_format;
bool m_connected;
diff --git a/vmime/net/maildir/maildirUtils.hpp b/vmime/net/maildir/maildirUtils.hpp
index 072a2648..82deefbb 100644
--- a/vmime/net/maildir/maildirUtils.hpp
+++ b/vmime/net/maildir/maildirUtils.hpp
@@ -130,7 +130,7 @@ public:
*
* @param dir directory to delete
*/
- static void recursiveFSDelete(ref <utility::file> dir);
+ static void recursiveFSDelete(shared_ptr <utility::file> dir);
/** Returns a list of message numbers given a message set.
*
diff --git a/vmime/net/message.hpp b/vmime/net/message.hpp
index 6bf4b492..4e291089 100644
--- a/vmime/net/message.hpp
+++ b/vmime/net/message.hpp
@@ -65,20 +65,20 @@ public:
*
* @return structure of the part
*/
- virtual ref <const messageStructure> getStructure() const = 0;
+ virtual shared_ptr <const messageStructure> getStructure() const = 0;
/** Return the structure of this part.
*
* @return structure of the part
*/
- virtual ref <messageStructure> getStructure() = 0;
+ virtual shared_ptr <messageStructure> getStructure() = 0;
/** Return the header section for this part (you must fetch header
* before using this function: see message::fetchPartHeader).
*
* @return header section
*/
- virtual ref <const header> getHeader() const = 0;
+ virtual shared_ptr <const header> getHeader() const = 0;
/** Return the media-type of the content in this part.
*
@@ -105,7 +105,7 @@ public:
* @param pos index of the sub-part
* @return sub-part at position 'pos'
*/
- ref <const messagePart> getPartAt(const size_t pos) const;
+ shared_ptr <const messagePart> getPartAt(const size_t pos) const;
/** Return the sub-part at the specified position (zero is the
* first part).
@@ -113,7 +113,7 @@ public:
* @param pos index of the sub-part
* @return sub-part at position 'pos'
*/
- ref <messagePart> getPartAt(const size_t pos);
+ shared_ptr <messagePart> getPartAt(const size_t pos);
/** Return the number of sub-parts in this part.
*
@@ -143,7 +143,7 @@ public:
* @param pos position
* @return part at position 'pos'
*/
- virtual ref <const messagePart> getPartAt(const size_t pos) const = 0;
+ virtual shared_ptr <const messagePart> getPartAt(const size_t pos) const = 0;
/** Return the part at the specified position (first
* part is at position 0).
@@ -151,7 +151,7 @@ public:
* @param pos position
* @return part at position 'pos'
*/
- virtual ref <messagePart> getPartAt(const size_t pos) = 0;
+ virtual shared_ptr <messagePart> getPartAt(const size_t pos) = 0;
/** Return the number of parts in this part.
*
@@ -206,19 +206,19 @@ public:
*
* @return MIME structure of the message
*/
- virtual ref <const messageStructure> getStructure() const = 0;
+ virtual shared_ptr <const messageStructure> getStructure() const = 0;
/** Return the MIME structure of the message (must fetch before).
*
* @return MIME structure of the message
*/
- virtual ref <messageStructure> getStructure() = 0;
+ virtual shared_ptr <messageStructure> getStructure() = 0;
/** Return a reference to the header fields of the message (must fetch before).
*
* @return header section of the message
*/
- virtual ref <const header> getHeader() const = 0;
+ virtual shared_ptr <const header> getHeader() const = 0;
/** Return the sequence number of this message. This number is
* used to reference the message in the folder.
@@ -313,7 +313,7 @@ public:
* an exception if not supported.
*/
virtual void extractPart
- (ref <const messagePart> p,
+ (shared_ptr <const messagePart> p,
utility::outputStream& os,
utility::progressListener* progress = NULL,
const int start = 0,
@@ -324,7 +324,7 @@ public:
*
* @param p the part for which to fetch the header
*/
- virtual void fetchPartHeader(ref <messagePart> p) = 0;
+ virtual void fetchPartHeader(shared_ptr <messagePart> p) = 0;
/** Get the RFC-822 message for this abstract message.
* Warning: This may require getting some data (ie: structure and headers) from
@@ -334,7 +334,7 @@ public:
*
* @return a RFC-822-parsed message
*/
- virtual ref <vmime::message> getParsedMessage() = 0;
+ virtual shared_ptr <vmime::message> getParsedMessage() = 0;
};
diff --git a/vmime/net/pop3/POP3Command.hpp b/vmime/net/pop3/POP3Command.hpp
index ef2b3ac4..cc3c4fd5 100644
--- a/vmime/net/pop3/POP3Command.hpp
+++ b/vmime/net/pop3/POP3Command.hpp
@@ -52,40 +52,38 @@ class POP3Connection;
*/
class VMIME_EXPORT POP3Command : public object
{
- friend class vmime::creator;
-
public:
- static ref <POP3Command> CAPA();
- static ref <POP3Command> NOOP();
- static ref <POP3Command> AUTH(const string& mechName);
- static ref <POP3Command> STLS();
- static ref <POP3Command> APOP(const string& username, const string& digest);
- static ref <POP3Command> USER(const string& username);
- static ref <POP3Command> PASS(const string& password);
- static ref <POP3Command> STAT();
- static ref <POP3Command> LIST();
- static ref <POP3Command> LIST(const unsigned long msg);
- static ref <POP3Command> UIDL();
- static ref <POP3Command> UIDL(const unsigned long msg);
- static ref <POP3Command> DELE(const unsigned long msg);
- static ref <POP3Command> RETR(const unsigned long msg);
- static ref <POP3Command> TOP(const unsigned long msg, const unsigned long lines);
- static ref <POP3Command> RSET();
- static ref <POP3Command> QUIT();
+ static shared_ptr <POP3Command> CAPA();
+ static shared_ptr <POP3Command> NOOP();
+ static shared_ptr <POP3Command> AUTH(const string& mechName);
+ static shared_ptr <POP3Command> STLS();
+ static shared_ptr <POP3Command> APOP(const string& username, const string& digest);
+ static shared_ptr <POP3Command> USER(const string& username);
+ static shared_ptr <POP3Command> PASS(const string& password);
+ static shared_ptr <POP3Command> STAT();
+ static shared_ptr <POP3Command> LIST();
+ static shared_ptr <POP3Command> LIST(const unsigned long msg);
+ static shared_ptr <POP3Command> UIDL();
+ static shared_ptr <POP3Command> UIDL(const unsigned long msg);
+ static shared_ptr <POP3Command> DELE(const unsigned long msg);
+ static shared_ptr <POP3Command> RETR(const unsigned long msg);
+ static shared_ptr <POP3Command> TOP(const unsigned long msg, const unsigned long lines);
+ static shared_ptr <POP3Command> RSET();
+ static shared_ptr <POP3Command> QUIT();
/** Creates a new POP3 command with the specified text.
*
* @param text command text
* @return a new POP3Command object
*/
- static ref <POP3Command> createCommand(const string& text);
+ static shared_ptr <POP3Command> createCommand(const string& text);
/** Sends this command over the specified connection.
*
* @param conn connection onto which the command will be sent
*/
- virtual void send(ref <POP3Connection> conn);
+ virtual void send(shared_ptr <POP3Connection> conn);
/** Returns the full text of the command, including command name
* and parameters (if any).
diff --git a/vmime/net/pop3/POP3Connection.hpp b/vmime/net/pop3/POP3Connection.hpp
index 96916bab..3622f745 100644
--- a/vmime/net/pop3/POP3Connection.hpp
+++ b/vmime/net/pop3/POP3Connection.hpp
@@ -62,11 +62,9 @@ class POP3Store;
*/
class VMIME_EXPORT POP3Connection : public object
{
- friend class vmime::creator;
-
public:
- POP3Connection(ref <POP3Store> store, ref <security::authenticator> auth);
+ POP3Connection(shared_ptr <POP3Store> store, shared_ptr <security::authenticator> auth);
virtual ~POP3Connection();
@@ -75,13 +73,13 @@ public:
virtual void disconnect();
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
+ shared_ptr <connectionInfos> getConnectionInfos() const;
- virtual ref <POP3Store> getStore();
- virtual ref <socket> getSocket();
- virtual ref <timeoutHandler> getTimeoutHandler();
- virtual ref <security::authenticator> getAuthenticator();
- virtual ref <session> getSession();
+ virtual shared_ptr <POP3Store> getStore();
+ virtual shared_ptr <socket> getSocket();
+ virtual shared_ptr <timeoutHandler> getTimeoutHandler();
+ virtual shared_ptr <security::authenticator> getAuthenticator();
+ virtual shared_ptr <session> getSession();
private:
@@ -101,16 +99,16 @@ private:
void internalDisconnect();
- weak_ref <POP3Store> m_store;
+ weak_ptr <POP3Store> m_store;
- ref <security::authenticator> m_auth;
- ref <socket> m_socket;
- ref <timeoutHandler> m_timeoutHandler;
+ shared_ptr <security::authenticator> m_auth;
+ shared_ptr <socket> m_socket;
+ shared_ptr <timeoutHandler> m_timeoutHandler;
bool m_authenticated;
bool m_secured;
- ref <connectionInfos> m_cntInfos;
+ shared_ptr <connectionInfos> m_cntInfos;
std::vector <string> m_capabilities;
bool m_capabilitiesFetched;
diff --git a/vmime/net/pop3/POP3Folder.hpp b/vmime/net/pop3/POP3Folder.hpp
index 5dbb8d1d..93a2bf35 100644
--- a/vmime/net/pop3/POP3Folder.hpp
+++ b/vmime/net/pop3/POP3Folder.hpp
@@ -57,15 +57,15 @@ private:
friend class POP3Store;
friend class POP3Message;
- friend class vmime::creator; // vmime::create <POP3Folder>
- POP3Folder(const folder::path& path, ref <POP3Store> store);
- POP3Folder(const POP3Folder&) : folder() { }
-
- ~POP3Folder();
+ POP3Folder(const POP3Folder&);
public:
+ POP3Folder(const folder::path& path, shared_ptr <POP3Store> store);
+
+ ~POP3Folder();
+
int getMode() const;
int getType();
@@ -85,13 +85,13 @@ public:
bool isOpen() const;
- ref <message> getMessage(const int num);
- std::vector <ref <message> > getMessages(const messageSet& msgs);
+ shared_ptr <message> getMessage(const int num);
+ std::vector <shared_ptr <message> > getMessages(const messageSet& msgs);
int getMessageCount();
- ref <folder> getFolder(const folder::path::component& name);
- std::vector <ref <folder> > getFolders(const bool recursive = false);
+ shared_ptr <folder> getFolder(const folder::path::component& name);
+ std::vector <shared_ptr <folder> > getFolders(const bool recursive = false);
void rename(const folder::path& newPath);
@@ -99,24 +99,24 @@ public:
void setMessageFlags(const messageSet& msgs, const int flags, const int mode = message::FLAG_MODE_SET);
- void addMessage(ref <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
+ void addMessage(shared_ptr <vmime::message> msg, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void addMessage(utility::inputStream& is, const int size, const int flags = message::FLAG_UNDEFINED, vmime::datetime* date = NULL, utility::progressListener* progress = NULL);
void copyMessages(const folder::path& dest, const messageSet& msgs);
void status(int& count, int& unseen);
- ref <folderStatus> getStatus();
+ shared_ptr <folderStatus> getStatus();
void expunge();
- ref <folder> getParent();
+ shared_ptr <folder> getParent();
- ref <const store> getStore() const;
- ref <store> getStore();
+ shared_ptr <const store> getStore() const;
+ shared_ptr <store> getStore();
- void fetchMessages(std::vector <ref <message> >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL);
- void fetchMessage(ref <message> msg, const fetchAttributes& options);
+ void fetchMessages(std::vector <shared_ptr <message> >& msg, const fetchAttributes& options, utility::progressListener* progress = NULL);
+ void fetchMessage(shared_ptr <message> msg, const fetchAttributes& options);
int getFetchCapabilities() const;
@@ -132,7 +132,7 @@ private:
void onClose();
- weak_ref <POP3Store> m_store;
+ weak_ptr <POP3Store> m_store;
folder::path m_path;
folder::path::component m_name;
diff --git a/vmime/net/pop3/POP3FolderStatus.hpp b/vmime/net/pop3/POP3FolderStatus.hpp
index d074ff47..70ba48b6 100644
--- a/vmime/net/pop3/POP3FolderStatus.hpp
+++ b/vmime/net/pop3/POP3FolderStatus.hpp
@@ -53,7 +53,7 @@ public:
unsigned int getMessageCount() const;
unsigned int getUnseenCount() const;
- ref <folderStatus> clone() const;
+ shared_ptr <folderStatus> clone() const;
void setMessageCount(const unsigned int count);
diff --git a/vmime/net/pop3/POP3Message.hpp b/vmime/net/pop3/POP3Message.hpp
index 573fe808..6cb3c719 100644
--- a/vmime/net/pop3/POP3Message.hpp
+++ b/vmime/net/pop3/POP3Message.hpp
@@ -51,14 +51,15 @@ class VMIME_EXPORT POP3Message : public message
private:
friend class POP3Folder;
- friend class vmime::creator; // vmime::create <POP3Message>
- POP3Message(ref <POP3Folder> folder, const int num);
- POP3Message(const POP3Message&) : message() { }
+ POP3Message(const POP3Message&);
+
+public:
+
+ POP3Message(shared_ptr <POP3Folder> folder, const int num);
~POP3Message();
-public:
int getNumber() const;
@@ -68,35 +69,35 @@ public:
bool isExpunged() const;
- ref <const messageStructure> getStructure() const;
- ref <messageStructure> getStructure();
+ shared_ptr <const messageStructure> getStructure() const;
+ shared_ptr <messageStructure> getStructure();
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
int getFlags() const;
void setFlags(const int flags, const int mode = FLAG_MODE_SET);
void extract(utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
- void extractPart(ref <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
+ void extractPart(shared_ptr <const messagePart> p, utility::outputStream& os, utility::progressListener* progress = NULL, const int start = 0, const int length = -1, const bool peek = false) const;
- void fetchPartHeader(ref <messagePart> p);
+ void fetchPartHeader(shared_ptr <messagePart> p);
- ref <vmime::message> getParsedMessage();
+ shared_ptr <vmime::message> getParsedMessage();
private:
- void fetch(ref <POP3Folder> folder, const fetchAttributes& options);
+ void fetch(shared_ptr <POP3Folder> folder, const fetchAttributes& options);
void onFolderClosed();
- weak_ref <POP3Folder> m_folder;
+ weak_ptr <POP3Folder> m_folder;
int m_num;
uid m_uid;
int m_size;
bool m_deleted;
- ref <header> m_header;
+ shared_ptr <header> m_header;
};
diff --git a/vmime/net/pop3/POP3Response.hpp b/vmime/net/pop3/POP3Response.hpp
index efe72d05..4b69290f 100644
--- a/vmime/net/pop3/POP3Response.hpp
+++ b/vmime/net/pop3/POP3Response.hpp
@@ -57,8 +57,6 @@ class POP3Connection;
*/
class VMIME_EXPORT POP3Response : public object
{
- friend class vmime::creator;
-
public:
/** Possible response codes. */
@@ -78,7 +76,7 @@ public:
* @throws exceptions::operation_timed_out if no data
* has been received within the granted time
*/
- static ref <POP3Response> readResponse(ref <POP3Connection> conn);
+ static shared_ptr <POP3Response> readResponse(shared_ptr <POP3Connection> conn);
/** Receive and parse a multiline POP3 response from
* the specified connection.
@@ -88,7 +86,7 @@ public:
* @throws exceptions::operation_timed_out if no data
* has been received within the granted time
*/
- static ref <POP3Response> readMultilineResponse(ref <POP3Connection> conn);
+ static shared_ptr <POP3Response> readMultilineResponse(shared_ptr <POP3Connection> conn);
/** Receive and parse a large POP3 response (eg. message data)
* from the specified connection.
@@ -101,8 +99,8 @@ public:
* @throws exceptions::operation_timed_out if no data
* has been received within the granted time
*/
- static ref <POP3Response> readLargeResponse
- (ref <POP3Connection> conn, utility::outputStream& os,
+ static shared_ptr <POP3Response> readLargeResponse
+ (shared_ptr <POP3Connection> conn, utility::outputStream& os,
utility::progressListener* progress, const long predictedSize);
@@ -145,7 +143,7 @@ public:
private:
- POP3Response(ref <socket> sok, ref <timeoutHandler> toh);
+ POP3Response(shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh);
void readResponseImpl(string& buffer, const bool multiLine);
void readResponseImpl
@@ -163,8 +161,8 @@ private:
static bool checkOneTerminator(string& buffer, const string& term);
- ref <socket> m_socket;
- ref <timeoutHandler> m_timeoutHandler;
+ shared_ptr <socket> m_socket;
+ shared_ptr <timeoutHandler> m_timeoutHandler;
string m_firstLine;
ResponseCode m_code;
diff --git a/vmime/net/pop3/POP3SStore.hpp b/vmime/net/pop3/POP3SStore.hpp
index 3804d97c..e60b4ef8 100644
--- a/vmime/net/pop3/POP3SStore.hpp
+++ b/vmime/net/pop3/POP3SStore.hpp
@@ -46,7 +46,7 @@ class VMIME_EXPORT POP3SStore : public POP3Store
{
public:
- POP3SStore(ref <session> sess, ref <security::authenticator> auth);
+ POP3SStore(shared_ptr <session> sess, shared_ptr <security::authenticator> auth);
~POP3SStore();
const string getProtocolName() const;
diff --git a/vmime/net/pop3/POP3Store.hpp b/vmime/net/pop3/POP3Store.hpp
index 17dfdbb0..b35659a0 100644
--- a/vmime/net/pop3/POP3Store.hpp
+++ b/vmime/net/pop3/POP3Store.hpp
@@ -59,14 +59,14 @@ class VMIME_EXPORT POP3Store : public store
public:
- POP3Store(ref <session> sess, ref <security::authenticator> auth, const bool secured = false);
+ POP3Store(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured = false);
~POP3Store();
const string getProtocolName() const;
- ref <folder> getDefaultFolder();
- ref <folder> getRootFolder();
- ref <folder> getFolder(const folder::path& path);
+ shared_ptr <folder> getDefaultFolder();
+ shared_ptr <folder> getRootFolder();
+ shared_ptr <folder> getFolder(const folder::path& path);
bool isValidFolderName(const folder::path::component& name) const;
@@ -82,14 +82,14 @@ public:
int getCapabilities() const;
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
- ref <POP3Connection> getConnection();
+ shared_ptr <connectionInfos> getConnectionInfos() const;
+ shared_ptr <POP3Connection> getConnection();
bool isPOP3S() const;
private:
- ref <POP3Connection> m_connection;
+ shared_ptr <POP3Connection> m_connection;
void registerFolder(POP3Folder* folder);
diff --git a/vmime/net/pop3/POP3Utils.hpp b/vmime/net/pop3/POP3Utils.hpp
index 9d20431c..c7459efe 100644
--- a/vmime/net/pop3/POP3Utils.hpp
+++ b/vmime/net/pop3/POP3Utils.hpp
@@ -64,7 +64,7 @@ public:
* number to its corresponding data (either UID or size)
*/
static void parseMultiListOrUidlResponse
- (ref <POP3Response> response, std::map <int, string>& result);
+ (shared_ptr <POP3Response> response, std::map <int, string>& result);
/** Returns a list of message numbers given a message set.
*
diff --git a/vmime/net/sendmail/sendmailTransport.hpp b/vmime/net/sendmail/sendmailTransport.hpp
index 3ac4fec2..7967ab87 100644
--- a/vmime/net/sendmail/sendmailTransport.hpp
+++ b/vmime/net/sendmail/sendmailTransport.hpp
@@ -50,7 +50,7 @@ class VMIME_EXPORT sendmailTransport : public transport
{
public:
- sendmailTransport(ref <session> sess, ref <security::authenticator> auth);
+ sendmailTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth);
~sendmailTransport();
const string getProtocolName() const;
@@ -73,7 +73,7 @@ public:
const mailbox& sender = mailbox());
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
+ shared_ptr <connectionInfos> getConnectionInfos() const;
private:
diff --git a/vmime/net/service.hpp b/vmime/net/service.hpp
index 57b2c3a0..6969ac20 100644
--- a/vmime/net/service.hpp
+++ b/vmime/net/service.hpp
@@ -59,7 +59,7 @@ class VMIME_EXPORT service : public object
{
protected:
- service(ref <session> sess, const serviceInfos& infos, ref <security::authenticator> auth);
+ service(shared_ptr <session> sess, const serviceInfos& infos, shared_ptr <security::authenticator> auth);
public:
@@ -88,13 +88,13 @@ public:
*
* @return session object
*/
- ref <const session> getSession() const;
+ shared_ptr <const session> getSession() const;
/** Return the session object associated with this service instance.
*
* @return session object
*/
- ref <session> getSession();
+ shared_ptr <session> getSession();
/** Return information about this service.
*
@@ -126,31 +126,31 @@ public:
*
* @return authenticator object
*/
- ref <const security::authenticator> getAuthenticator() const;
+ shared_ptr <const security::authenticator> getAuthenticator() const;
/** Return the authenticator object used with this service instance.
*
* @return authenticator object
*/
- ref <security::authenticator> getAuthenticator();
+ shared_ptr <security::authenticator> getAuthenticator();
/** Set the authenticator object used with this service instance.
*
* @param auth authenticator object
*/
- void setAuthenticator(ref <security::authenticator> auth);
+ void setAuthenticator(shared_ptr <security::authenticator> auth);
#if VMIME_HAVE_TLS_SUPPORT
/** Set the object responsible for verifying certificates when
* using secured connections (TLS/SSL).
*/
- void setCertificateVerifier(ref <security::cert::certificateVerifier> cv);
+ void setCertificateVerifier(shared_ptr <security::cert::certificateVerifier> cv);
/** Get the object responsible for verifying certificates when
* using secured connections (TLS/SSL).
*/
- ref <security::cert::certificateVerifier> getCertificateVerifier();
+ shared_ptr <security::cert::certificateVerifier> getCertificateVerifier();
#endif // VMIME_HAVE_TLS_SUPPORT
@@ -159,14 +159,14 @@ public:
*
* @param sf socket factory
*/
- void setSocketFactory(ref <socketFactory> sf);
+ void setSocketFactory(shared_ptr <socketFactory> sf);
/** Return the factory used to create socket objects for this
* service.
*
* @return socket factory
*/
- ref <socketFactory> getSocketFactory();
+ shared_ptr <socketFactory> getSocketFactory();
/** Set the factory used to create timeoutHandler objects for
* this service. By default, no timeout handler is used. Not all
@@ -174,14 +174,14 @@ public:
*
* @param thf timeoutHandler factory
*/
- void setTimeoutHandlerFactory(ref <timeoutHandlerFactory> thf);
+ void setTimeoutHandlerFactory(shared_ptr <timeoutHandlerFactory> thf);
/** Return the factory used to create timeoutHandler objects for
* this service.
*
* @return timeoutHandler factory
*/
- ref <timeoutHandlerFactory> getTimeoutHandlerFactory();
+ shared_ptr <timeoutHandlerFactory> getTimeoutHandlerFactory();
/** Set a property for this service (service prefix is added automatically).
*
@@ -207,20 +207,20 @@ public:
*
* @return information about the connection
*/
- virtual ref <connectionInfos> getConnectionInfos() const = 0;
+ virtual shared_ptr <connectionInfos> getConnectionInfos() const = 0;
private:
- ref <session> m_session;
- ref <security::authenticator> m_auth;
+ shared_ptr <session> m_session;
+ shared_ptr <security::authenticator> m_auth;
#if VMIME_HAVE_TLS_SUPPORT
- ref <security::cert::certificateVerifier> m_certVerifier;
+ shared_ptr <security::cert::certificateVerifier> m_certVerifier;
#endif // VMIME_HAVE_TLS_SUPPORT
- ref <socketFactory> m_socketFactory;
+ shared_ptr <socketFactory> m_socketFactory;
- ref <timeoutHandlerFactory> m_toHandlerFactory;
+ shared_ptr <timeoutHandlerFactory> m_toHandlerFactory;
};
diff --git a/vmime/net/serviceFactory.hpp b/vmime/net/serviceFactory.hpp
index c2df141b..baf692a8 100644
--- a/vmime/net/serviceFactory.hpp
+++ b/vmime/net/serviceFactory.hpp
@@ -67,7 +67,7 @@ private:
public:
- static serviceFactory* getInstance();
+ static shared_ptr <serviceFactory> getInstance();
/** Information about a registered service. */
class registeredService : public object
@@ -80,9 +80,9 @@ public:
public:
- virtual ref <service> create
- (ref <session> sess,
- ref <security::authenticator> auth) const = 0;
+ virtual shared_ptr <service> create
+ (shared_ptr <session> sess,
+ shared_ptr <security::authenticator> auth) const = 0;
virtual int getType() const = 0;
virtual const string& getName() const = 0;
@@ -94,7 +94,7 @@ public:
*
* @param reg service registration infos
*/
- void registerService(ref <registeredService> reg);
+ void registerService(shared_ptr <registeredService> reg);
/** Create a new service instance from a protocol name.
*
@@ -105,10 +105,10 @@ public:
* @throw exceptions::no_service_available if no service is registered
* for this protocol
*/
- ref <service> create
- (ref <session> sess,
+ shared_ptr <service> create
+ (shared_ptr <session> sess,
const string& protocol,
- ref <security::authenticator> auth = NULL);
+ shared_ptr <security::authenticator> auth = null);
/** Create a new service instance from a URL.
*
@@ -120,10 +120,10 @@ public:
* @throw exceptions::no_service_available if no service is registered
* for this protocol
*/
- ref <service> create
- (ref <session> sess,
+ shared_ptr <service> create
+ (shared_ptr <session> sess,
const utility::url& u,
- ref <security::authenticator> auth = NULL);
+ shared_ptr <security::authenticator> auth = null);
/** Return information about a registered protocol.
*
@@ -132,7 +132,7 @@ public:
* @throw exceptions::no_service_available if no service is registered
* for this protocol
*/
- ref <const registeredService> getServiceByProtocol(const string& protocol) const;
+ shared_ptr <const registeredService> getServiceByProtocol(const string& protocol) const;
/** Return the number of registered services.
*
@@ -145,17 +145,17 @@ public:
* @param pos position of the registered service to return
* @return registered service at the specified position
*/
- ref <const registeredService> getServiceAt(const size_t pos) const;
+ shared_ptr <const registeredService> getServiceAt(const size_t pos) const;
/** Return a list of all registered services.
*
* @return list of registered services
*/
- const std::vector <ref <const registeredService> > getServiceList() const;
+ const std::vector <shared_ptr <const registeredService> > getServiceList() const;
private:
- std::vector <ref <registeredService> > m_services;
+ std::vector <shared_ptr <registeredService> > m_services;
};
diff --git a/vmime/net/serviceInfos.hpp b/vmime/net/serviceInfos.hpp
index efdc8456..6e3209ca 100644
--- a/vmime/net/serviceInfos.hpp
+++ b/vmime/net/serviceInfos.hpp
@@ -217,7 +217,7 @@ public:
* @return value of the property
*/
template <typename TYPE>
- const TYPE getPropertyValue(ref <session> s, const property& p) const
+ const TYPE getPropertyValue(shared_ptr <session> s, const property& p) const
{
if (p.getFlags() & property::FLAG_REQUIRED)
return s->getProperties()[getPropertyPrefix() + p.getName()].template getValue <TYPE>();
@@ -233,7 +233,7 @@ public:
* @param p property to test
* @return true if the property is set, false otherwise
*/
- bool hasProperty(ref <session> s, const property& p) const;
+ bool hasProperty(shared_ptr <session> s, const property& p) const;
};
diff --git a/vmime/net/session.hpp b/vmime/net/session.hpp
index b92c2ac7..59337879 100644
--- a/vmime/net/session.hpp
+++ b/vmime/net/session.hpp
@@ -72,8 +72,8 @@ public:
* credentials by reading the session properties "auth.username" and "auth.password".
* @return a new transport service
*/
- ref <transport> getTransport
- (ref <security::authenticator> auth = NULL);
+ shared_ptr <transport> getTransport
+ (shared_ptr <security::authenticator> auth = null);
/** Return a transport service instance for the specified protocol.
*
@@ -83,9 +83,9 @@ public:
* credentials by reading the session properties "auth.username" and "auth.password".
* @return a new transport service
*/
- ref <transport> getTransport
+ shared_ptr <transport> getTransport
(const string& protocol,
- ref <security::authenticator> auth = NULL);
+ shared_ptr <security::authenticator> auth = null);
/** Return a transport service instance for the specified URL.
*
@@ -95,9 +95,9 @@ public:
* credentials by reading the session properties "auth.username" and "auth.password".
* @return a new transport service
*/
- ref <transport> getTransport
+ shared_ptr <transport> getTransport
(const utility::url& url,
- ref <security::authenticator> auth = NULL);
+ shared_ptr <security::authenticator> auth = null);
/** Return a transport service instance for the protocol specified
* in the session properties.
@@ -109,7 +109,7 @@ public:
* credentials by reading the session properties "auth.username" and "auth.password".
* @return a new store service
*/
- ref <store> getStore(ref <security::authenticator> auth = NULL);
+ shared_ptr <store> getStore(shared_ptr <security::authenticator> auth = null);
/** Return a store service instance for the specified protocol.
*
@@ -119,9 +119,9 @@ public:
* credentials by reading the session properties "auth.username" and "auth.password".
* @return a new store service
*/
- ref <store> getStore
+ shared_ptr <store> getStore
(const string& protocol,
- ref <security::authenticator> auth = NULL);
+ shared_ptr <security::authenticator> auth = null);
/** Return a store service instance for the specified URL.
*
@@ -131,9 +131,9 @@ public:
* credentials by reading the session properties "auth.username" and "auth.password".
* @return a new store service
*/
- ref <store> getStore
+ shared_ptr <store> getStore
(const utility::url& url,
- ref <security::authenticator> auth = NULL);
+ shared_ptr <security::authenticator> auth = null);
/** Properties for the session and for the services.
*/
@@ -147,19 +147,19 @@ public:
*
* @param tlsProps SSL/TLS properties
*/
- void setTLSProperties(ref <tls::TLSProperties> tlsProps);
+ void setTLSProperties(shared_ptr <tls::TLSProperties> tlsProps);
/** Get properties for SSL/TLS secured connections in this session.
*
* @return SSL/TLS properties
*/
- ref <tls::TLSProperties> getTLSProperties() const;
+ shared_ptr <tls::TLSProperties> getTLSProperties() const;
private:
propertySet m_props;
- ref <tls::TLSProperties> m_tlsProps;
+ shared_ptr <tls::TLSProperties> m_tlsProps;
};
diff --git a/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp b/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp
index a29fbfb4..6ca6c527 100644
--- a/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp
+++ b/vmime/net/smtp/SMTPChunkingOutputStreamAdapter.hpp
@@ -46,11 +46,9 @@ class SMTPConnection;
*/
class VMIME_EXPORT SMTPChunkingOutputStreamAdapter : public utility::outputStream
{
- friend class vmime::creator;
-
public:
- SMTPChunkingOutputStreamAdapter(ref <SMTPConnection> conn);
+ SMTPChunkingOutputStreamAdapter(shared_ptr <SMTPConnection> conn);
void write(const value_type* const data, const size_type count);
void flush();
@@ -65,7 +63,7 @@ private:
void sendChunk(const value_type* const data, const size_type count, const bool last);
- ref <SMTPConnection> m_connection;
+ shared_ptr <SMTPConnection> m_connection;
value_type m_buffer[262144]; // 256 KB
size_type m_bufferSize;
diff --git a/vmime/net/smtp/SMTPCommand.hpp b/vmime/net/smtp/SMTPCommand.hpp
index c4001f85..4005dcdf 100644
--- a/vmime/net/smtp/SMTPCommand.hpp
+++ b/vmime/net/smtp/SMTPCommand.hpp
@@ -55,35 +55,33 @@ namespace smtp {
*/
class VMIME_EXPORT SMTPCommand : public object
{
- friend class vmime::creator;
-
public:
- static ref <SMTPCommand> HELO(const string& hostname);
- static ref <SMTPCommand> EHLO(const string& hostname);
- static ref <SMTPCommand> AUTH(const string& mechName);
- static ref <SMTPCommand> STARTTLS();
- static ref <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8);
- static ref <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8, const unsigned long size);
- static ref <SMTPCommand> RCPT(const mailbox& mbox, const bool utf8);
- static ref <SMTPCommand> RSET();
- static ref <SMTPCommand> DATA();
- static ref <SMTPCommand> BDAT(const unsigned long chunkSize, const bool last);
- static ref <SMTPCommand> NOOP();
- static ref <SMTPCommand> QUIT();
+ static shared_ptr <SMTPCommand> HELO(const string& hostname);
+ static shared_ptr <SMTPCommand> EHLO(const string& hostname);
+ static shared_ptr <SMTPCommand> AUTH(const string& mechName);
+ static shared_ptr <SMTPCommand> STARTTLS();
+ static shared_ptr <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8);
+ static shared_ptr <SMTPCommand> MAIL(const mailbox& mbox, const bool utf8, const unsigned long size);
+ static shared_ptr <SMTPCommand> RCPT(const mailbox& mbox, const bool utf8);
+ static shared_ptr <SMTPCommand> RSET();
+ static shared_ptr <SMTPCommand> DATA();
+ static shared_ptr <SMTPCommand> BDAT(const unsigned long chunkSize, const bool last);
+ static shared_ptr <SMTPCommand> NOOP();
+ static shared_ptr <SMTPCommand> QUIT();
/** Creates a new SMTP command with the specified text.
*
* @param text command text
* @return a new SMTPCommand object
*/
- static ref <SMTPCommand> createCommand(const string& text);
+ static shared_ptr <SMTPCommand> createCommand(const string& text);
/** Sends this command to the specified socket.
*
* @param sok socket to which the command will be written
*/
- virtual void writeToSocket(ref <socket> sok);
+ virtual void writeToSocket(shared_ptr <socket> sok);
/** Returns the full text of the command, including command name
* and parameters (if any).
diff --git a/vmime/net/smtp/SMTPCommandSet.hpp b/vmime/net/smtp/SMTPCommandSet.hpp
index e6c5be94..8e744c2b 100644
--- a/vmime/net/smtp/SMTPCommandSet.hpp
+++ b/vmime/net/smtp/SMTPCommandSet.hpp
@@ -46,8 +46,6 @@ namespace smtp {
*/
class VMIME_EXPORT SMTPCommandSet : public SMTPCommand
{
- friend class vmime::creator;
-
public:
/** Creates a new set of SMTP commands.
@@ -55,7 +53,7 @@ public:
* @param pipeline set to true if the server supports pipelining
* @return a new SMTPCommandSet object
*/
- static ref <SMTPCommandSet> create(const bool pipeline);
+ static shared_ptr <SMTPCommandSet> create(const bool pipeline);
/** Adds a new command to this set.
* If one or more comments have already been sent to the server,
@@ -63,7 +61,7 @@ public:
*
* @param cmd command to add
*/
- void addCommand(ref <SMTPCommand> cmd);
+ void addCommand(shared_ptr <SMTPCommand> cmd);
/** Tests whether all commands have been sent.
*
@@ -77,10 +75,10 @@ public:
* @return a pointer to a SMTPCommand, of NULL if no command
* has been sent yet
*/
- ref <SMTPCommand> getLastCommandSent() const;
+ shared_ptr <SMTPCommand> getLastCommandSent() const;
- void writeToSocket(ref <socket> sok);
+ void writeToSocket(shared_ptr <socket> sok);
const string getText() const;
@@ -92,8 +90,8 @@ private:
bool m_pipeline;
bool m_started;
- std::list <ref <SMTPCommand> > m_commands;
- ref <SMTPCommand> m_lastCommandSent;
+ std::list <shared_ptr <SMTPCommand> > m_commands;
+ shared_ptr <SMTPCommand> m_lastCommandSent;
};
diff --git a/vmime/net/smtp/SMTPConnection.hpp b/vmime/net/smtp/SMTPConnection.hpp
index 96469ab1..cc59ef34 100644
--- a/vmime/net/smtp/SMTPConnection.hpp
+++ b/vmime/net/smtp/SMTPConnection.hpp
@@ -62,11 +62,9 @@ class SMTPTransport;
*/
class VMIME_EXPORT SMTPConnection : public object
{
- friend class vmime::creator;
-
public:
- SMTPConnection(ref <SMTPTransport> transport, ref <security::authenticator> auth);
+ SMTPConnection(shared_ptr <SMTPTransport> transport, shared_ptr <security::authenticator> auth);
virtual ~SMTPConnection();
@@ -75,16 +73,16 @@ public:
virtual void disconnect();
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
+ shared_ptr <connectionInfos> getConnectionInfos() const;
- virtual ref <SMTPTransport> getTransport();
- virtual ref <socket> getSocket();
- virtual ref <timeoutHandler> getTimeoutHandler();
- virtual ref <security::authenticator> getAuthenticator();
- virtual ref <session> getSession();
+ virtual shared_ptr <SMTPTransport> getTransport();
+ virtual shared_ptr <socket> getSocket();
+ virtual shared_ptr <timeoutHandler> getTimeoutHandler();
+ virtual shared_ptr <security::authenticator> getAuthenticator();
+ virtual shared_ptr <session> getSession();
- void sendRequest(ref <SMTPCommand> cmd);
- ref <SMTPResponse> readResponse();
+ void sendRequest(shared_ptr <SMTPCommand> cmd);
+ shared_ptr <SMTPResponse> readResponse();
bool hasExtension(const std::string& extName, std::vector <string>* params = NULL) const;
@@ -103,18 +101,18 @@ private:
#endif // VMIME_HAVE_TLS_SUPPORT
- weak_ref <SMTPTransport> m_transport;
+ weak_ptr <SMTPTransport> m_transport;
- ref <security::authenticator> m_auth;
- ref <socket> m_socket;
- ref <timeoutHandler> m_timeoutHandler;
+ shared_ptr <security::authenticator> m_auth;
+ shared_ptr <socket> m_socket;
+ shared_ptr <timeoutHandler> m_timeoutHandler;
SMTPResponse::state m_responseState;
bool m_authenticated;
bool m_secured;
- ref <connectionInfos> m_cntInfos;
+ shared_ptr <connectionInfos> m_cntInfos;
bool m_extendedSMTP;
std::map <string, std::vector <string> > m_extensions;
diff --git a/vmime/net/smtp/SMTPResponse.hpp b/vmime/net/smtp/SMTPResponse.hpp
index e0a5e1cd..000448ac 100644
--- a/vmime/net/smtp/SMTPResponse.hpp
+++ b/vmime/net/smtp/SMTPResponse.hpp
@@ -50,8 +50,6 @@ namespace smtp {
*/
class VMIME_EXPORT SMTPResponse : public object
{
- friend class vmime::creator;
-
public:
/** Current state of response parser. */
@@ -104,7 +102,7 @@ public:
* @throws exceptions::operation_timed_out if no data
* has been received within the granted time
*/
- static ref <SMTPResponse> readResponse(ref <socket> sok, ref <timeoutHandler> toh, const state& st);
+ static shared_ptr <SMTPResponse> readResponse(shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh, const state& st);
/** Return the SMTP response code.
*
@@ -152,7 +150,7 @@ public:
private:
- SMTPResponse(ref <socket> sok, ref <timeoutHandler> toh, const state& st);
+ SMTPResponse(shared_ptr <socket> sok, shared_ptr <timeoutHandler> toh, const state& st);
SMTPResponse(const SMTPResponse&);
void readResponse();
@@ -166,8 +164,8 @@ private:
std::vector <responseLine> m_lines;
- ref <socket> m_socket;
- ref <timeoutHandler> m_timeoutHandler;
+ shared_ptr <socket> m_socket;
+ shared_ptr <timeoutHandler> m_timeoutHandler;
string m_responseBuffer;
bool m_responseContinues;
diff --git a/vmime/net/smtp/SMTPSTransport.hpp b/vmime/net/smtp/SMTPSTransport.hpp
index cbc6a168..7782f711 100644
--- a/vmime/net/smtp/SMTPSTransport.hpp
+++ b/vmime/net/smtp/SMTPSTransport.hpp
@@ -46,7 +46,7 @@ class VMIME_EXPORT SMTPSTransport : public SMTPTransport
{
public:
- SMTPSTransport(ref <session> sess, ref <security::authenticator> auth);
+ SMTPSTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth);
~SMTPSTransport();
const string getProtocolName() const;
diff --git a/vmime/net/smtp/SMTPTransport.hpp b/vmime/net/smtp/SMTPTransport.hpp
index 962f4406..90ad447c 100644
--- a/vmime/net/smtp/SMTPTransport.hpp
+++ b/vmime/net/smtp/SMTPTransport.hpp
@@ -54,7 +54,7 @@ class VMIME_EXPORT SMTPTransport : public transport
{
public:
- SMTPTransport(ref <session> sess, ref <security::authenticator> auth, const bool secured = false);
+ SMTPTransport(shared_ptr <session> sess, shared_ptr <security::authenticator> auth, const bool secured = false);
~SMTPTransport();
const string getProtocolName() const;
@@ -77,15 +77,15 @@ public:
const mailbox& sender = mailbox());
void send
- (ref <vmime::message> msg,
+ (shared_ptr <vmime::message> msg,
const mailbox& expeditor,
const mailboxList& recipients,
utility::progressListener* progress = NULL,
const mailbox& sender = mailbox());
bool isSecuredConnection() const;
- ref <connectionInfos> getConnectionInfos() const;
- ref <SMTPConnection> getConnection();
+ shared_ptr <connectionInfos> getConnectionInfos() const;
+ shared_ptr <SMTPConnection> getConnection();
bool isSMTPS() const;
@@ -109,7 +109,7 @@ private:
const utility::stream::size_type size);
- ref <SMTPConnection> m_connection;
+ shared_ptr <SMTPConnection> m_connection;
const bool m_isSMTPS;
diff --git a/vmime/net/socket.hpp b/vmime/net/socket.hpp
index 5662da23..3dadc72b 100644
--- a/vmime/net/socket.hpp
+++ b/vmime/net/socket.hpp
@@ -162,14 +162,14 @@ public:
*
* @return a new socket
*/
- virtual ref <socket> create() = 0;
+ virtual shared_ptr <socket> create() = 0;
/** Creates a socket with the specified timeout handler.
*
* @param th timeout handler
* @return a new socket
*/
- virtual ref <socket> create(ref <timeoutHandler> th) = 0;
+ virtual shared_ptr <socket> create(shared_ptr <timeoutHandler> th) = 0;
};
diff --git a/vmime/net/store.hpp b/vmime/net/store.hpp
index 92a43feb..37dcadbc 100644
--- a/vmime/net/store.hpp
+++ b/vmime/net/store.hpp
@@ -47,7 +47,7 @@ class VMIME_EXPORT store : public service
{
protected:
- store(ref <session> sess, const serviceInfos& infos, ref <security::authenticator> auth)
+ store(shared_ptr <session> sess, const serviceInfos& infos, shared_ptr <security::authenticator> auth)
: service(sess, infos, auth) { }
public:
@@ -57,21 +57,21 @@ public:
*
* @return default folder
*/
- virtual ref <folder> getDefaultFolder() = 0;
+ virtual shared_ptr <folder> getDefaultFolder() = 0;
/** Return the root folder. This is protocol dependent
* and usually is the user's mail drop root folder.
*
* @return root folder
*/
- virtual ref <folder> getRootFolder() = 0;
+ virtual shared_ptr <folder> getRootFolder() = 0;
/** Return the folder specified by the path.
*
* @param path absolute folder path
* @return folder at the specified path
*/
- virtual ref <folder> getFolder(const folder::path& path) = 0;
+ virtual shared_ptr <folder> getFolder(const folder::path& path) = 0;
/** Test whether the specified folder name is a syntactically
* a valid name.
diff --git a/vmime/net/timeoutHandler.hpp b/vmime/net/timeoutHandler.hpp
index f49ece0c..24129701 100644
--- a/vmime/net/timeoutHandler.hpp
+++ b/vmime/net/timeoutHandler.hpp
@@ -76,7 +76,7 @@ public:
virtual ~timeoutHandlerFactory() { }
- virtual ref <timeoutHandler> create() = 0;
+ virtual shared_ptr <timeoutHandler> create() = 0;
};
diff --git a/vmime/net/tls/TLSProperties.hpp b/vmime/net/tls/TLSProperties.hpp
index 23540eeb..0dbc8f05 100644
--- a/vmime/net/tls/TLSProperties.hpp
+++ b/vmime/net/tls/TLSProperties.hpp
@@ -91,7 +91,7 @@ public:
private:
- ref <object> m_data;
+ shared_ptr <object> m_data;
};
diff --git a/vmime/net/tls/TLSSecuredConnectionInfos.hpp b/vmime/net/tls/TLSSecuredConnectionInfos.hpp
index be0fb41a..e552d6f9 100644
--- a/vmime/net/tls/TLSSecuredConnectionInfos.hpp
+++ b/vmime/net/tls/TLSSecuredConnectionInfos.hpp
@@ -52,7 +52,7 @@ class VMIME_EXPORT TLSSecuredConnectionInfos : public securedConnectionInfos
public:
TLSSecuredConnectionInfos(const string& host, const port_t port,
- ref <TLSSession> tlsSession, ref <TLSSocket> tlsSocket);
+ shared_ptr <TLSSession> tlsSession, shared_ptr <TLSSocket> tlsSocket);
const string getHost() const;
port_t getPort() const;
@@ -61,15 +61,15 @@ public:
*
* @return server certificate chain
*/
- ref <const security::cert::certificateChain> getPeerCertificates() const;
+ shared_ptr <const security::cert::certificateChain> getPeerCertificates() const;
private:
string m_host;
port_t m_port;
- ref <TLSSession> m_tlsSession;
- ref <TLSSocket> m_tlsSocket;
+ shared_ptr <TLSSession> m_tlsSession;
+ shared_ptr <TLSSocket> m_tlsSocket;
};
diff --git a/vmime/net/tls/TLSSession.hpp b/vmime/net/tls/TLSSession.hpp
index faca9d11..9e061f89 100644
--- a/vmime/net/tls/TLSSession.hpp
+++ b/vmime/net/tls/TLSSession.hpp
@@ -57,7 +57,7 @@ public:
* @param props TLS properties for this session
* @return a new TLS session
*/
- static ref <TLSSession> create(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props);
+ static shared_ptr <TLSSession> create(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props);
/** Create a new socket that adds a TLS security layer around
* an existing socket. You should create only one socket
@@ -66,12 +66,12 @@ public:
* @param sok socket to wrap
* @return TLS socket wrapper
*/
- virtual ref <TLSSocket> getSocket(ref <socket> sok) = 0;
+ virtual shared_ptr <TLSSocket> getSocket(shared_ptr <socket> sok) = 0;
/** Get the object responsible for verifying certificates when
* using secured connections (TLS/SSL).
*/
- virtual ref <security::cert::certificateVerifier> getCertificateVerifier() = 0;
+ virtual shared_ptr <security::cert::certificateVerifier> getCertificateVerifier() = 0;
protected:
diff --git a/vmime/net/tls/TLSSocket.hpp b/vmime/net/tls/TLSSocket.hpp
index 68ed1963..e2668ad4 100644
--- a/vmime/net/tls/TLSSocket.hpp
+++ b/vmime/net/tls/TLSSocket.hpp
@@ -59,7 +59,7 @@ public:
* @param session TLS session
* @param sok socket to wrap
*/
- static ref <TLSSocket> wrap(ref <TLSSession> session, ref <socket> sok);
+ static shared_ptr <TLSSocket> wrap(shared_ptr <TLSSession> session, shared_ptr <socket> sok);
/** Starts a TLS handshake on this connection.
*
@@ -67,14 +67,14 @@ public:
* during the negociation process, exceptions::operation_timed_out
* if a time-out occurs
*/
- virtual void handshake(ref <timeoutHandler> toHandler = NULL) = 0;
+ virtual void handshake(shared_ptr <timeoutHandler> toHandler = null) = 0;
/** Return the peer's certificate (chain) as sent by the peer.
*
* @return server certificate chain, or NULL if the handshake
* has not been performed yet
*/
- virtual ref <security::cert::certificateChain> getPeerCertificates() const = 0;
+ virtual shared_ptr <security::cert::certificateChain> getPeerCertificates() const = 0;
};
diff --git a/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp b/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp
index 45fee070..7f762b58 100644
--- a/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp
+++ b/vmime/net/tls/gnutls/TLSSession_GnuTLS.hpp
@@ -52,13 +52,13 @@ class TLSSession_GnuTLS : public TLSSession
public:
- TLSSession_GnuTLS(ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props);
+ TLSSession_GnuTLS(shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props);
~TLSSession_GnuTLS();
- ref <TLSSocket> getSocket(ref <socket> sok);
+ shared_ptr <TLSSocket> getSocket(shared_ptr <socket> sok);
- ref <security::cert::certificateVerifier> getCertificateVerifier();
+ shared_ptr <security::cert::certificateVerifier> getCertificateVerifier();
private:
@@ -73,8 +73,8 @@ private:
void* m_gnutlsSession;
#endif // LIBGNUTLS_VERSION
- ref <security::cert::certificateVerifier> m_certVerifier;
- ref <TLSProperties> m_props;
+ shared_ptr <security::cert::certificateVerifier> m_certVerifier;
+ shared_ptr <TLSProperties> m_props;
};
diff --git a/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp b/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp
index 4cce9832..43848ec9 100644
--- a/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp
+++ b/vmime/net/tls/gnutls/TLSSocket_GnuTLS.hpp
@@ -48,17 +48,15 @@ class TLSSession_GnuTLS;
class TLSSocket_GnuTLS : public TLSSocket
{
- friend class vmime::creator;
-
public:
- TLSSocket_GnuTLS(ref <TLSSession_GnuTLS> session, ref <socket> sok);
+ TLSSocket_GnuTLS(shared_ptr <TLSSession_GnuTLS> session, shared_ptr <socket> sok);
~TLSSocket_GnuTLS();
- void handshake(ref <timeoutHandler> toHandler = NULL);
+ void handshake(shared_ptr <timeoutHandler> toHandler = null);
- ref <security::cert::certificateChain> getPeerCertificates() const;
+ shared_ptr <security::cert::certificateChain> getPeerCertificates() const;
// Implementation of 'socket'
void connect(const string& address, const port_t port);
@@ -92,15 +90,15 @@ private:
#endif // LIBGNUTLS_VERSION
- ref <TLSSession_GnuTLS> m_session;
- ref <socket> m_wrapped;
+ shared_ptr <TLSSession_GnuTLS> m_session;
+ shared_ptr <socket> m_wrapped;
bool m_connected;
char m_buffer[65536];
bool m_handshaking;
- ref <timeoutHandler> m_toHandler;
+ shared_ptr <timeoutHandler> m_toHandler;
exception* m_ex;
diff --git a/vmime/net/tls/openssl/OpenSSLInitializer.hpp b/vmime/net/tls/openssl/OpenSSLInitializer.hpp
index 5277d4ff..d7595aa8 100644
--- a/vmime/net/tls/openssl/OpenSSLInitializer.hpp
+++ b/vmime/net/tls/openssl/OpenSSLInitializer.hpp
@@ -80,7 +80,7 @@ protected:
static void uninitialize();
- static ref <vmime::utility::sync::criticalSection> getMutex();
+ static shared_ptr <vmime::utility::sync::criticalSection> getMutex();
enum
{
@@ -94,7 +94,7 @@ protected:
private:
- static ref <vmime::utility::sync::criticalSection >* sm_mutexes;
+ static shared_ptr <vmime::utility::sync::criticalSection >* sm_mutexes;
};
diff --git a/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp b/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp
index 85f018f1..5a2b60a8 100644
--- a/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp
+++ b/vmime/net/tls/openssl/TLSSession_OpenSSL.hpp
@@ -55,13 +55,13 @@ class TLSSession_OpenSSL : public TLSSession
public:
- TLSSession_OpenSSL(const ref <security::cert::certificateVerifier> cv, ref <TLSProperties> props);
+ TLSSession_OpenSSL(const shared_ptr <security::cert::certificateVerifier> cv, shared_ptr <TLSProperties> props);
~TLSSession_OpenSSL();
- ref <TLSSocket> getSocket(ref <socket> sok);
+ shared_ptr <TLSSocket> getSocket(shared_ptr <socket> sok);
- ref <security::cert::certificateVerifier> getCertificateVerifier();
+ shared_ptr <security::cert::certificateVerifier> getCertificateVerifier();
/** Set the private key to use if server requires a client certificate.
@@ -90,8 +90,8 @@ private:
SSL_CTX* m_sslctx;
- ref <security::cert::certificateVerifier> m_certVerifier;
- ref <TLSProperties> m_props;
+ shared_ptr <security::cert::certificateVerifier> m_certVerifier;
+ shared_ptr <TLSProperties> m_props;
};
diff --git a/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp b/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp
index 5bf27804..b4ff5872 100644
--- a/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp
+++ b/vmime/net/tls/openssl/TLSSocket_OpenSSL.hpp
@@ -52,17 +52,15 @@ class TLSSession_OpenSSL;
class TLSSocket_OpenSSL : public TLSSocket
{
- friend class vmime::creator;
-
public:
- TLSSocket_OpenSSL(ref <TLSSession_OpenSSL> session, ref <socket> sok);
+ TLSSocket_OpenSSL(shared_ptr <TLSSession_OpenSSL> session, shared_ptr <socket> sok);
~TLSSocket_OpenSSL();
- void handshake(ref <timeoutHandler> toHandler = NULL);
+ void handshake(shared_ptr <timeoutHandler> toHandler = null);
- ref <security::cert::certificateChain> getPeerCertificates() const;
+ shared_ptr <security::cert::certificateChain> getPeerCertificates() const;
// Implementation of 'socket'
void connect(const string& address, const port_t port);
@@ -101,15 +99,15 @@ private:
void handleError(int rc);
- ref <TLSSession_OpenSSL> m_session;
+ shared_ptr <TLSSession_OpenSSL> m_session;
- ref <socket> m_wrapped;
+ shared_ptr <socket> m_wrapped;
bool m_connected;
char m_buffer[65536];
- ref <timeoutHandler> m_toHandler;
+ shared_ptr <timeoutHandler> m_toHandler;
SSL* m_ssl;
diff --git a/vmime/net/transport.hpp b/vmime/net/transport.hpp
index 3acb2266..96e37669 100644
--- a/vmime/net/transport.hpp
+++ b/vmime/net/transport.hpp
@@ -56,7 +56,7 @@ class VMIME_EXPORT transport : public service
{
protected:
- transport(ref <session> sess, const serviceInfos& infos, ref <security::authenticator> auth);
+ transport(shared_ptr <session> sess, const serviceInfos& infos, shared_ptr <security::authenticator> auth);
public:
@@ -67,7 +67,7 @@ public:
* @param msg message to send
* @param progress progress listener, or NULL if not used
*/
- virtual void send(ref <vmime::message> msg, utility::progressListener* progress = NULL);
+ virtual void send(shared_ptr <vmime::message> msg, utility::progressListener* progress = NULL);
/** Send a message over this transport service.
*
@@ -97,7 +97,7 @@ public:
* @param sender envelope sender (if empty, expeditor will be used)
*/
virtual void send
- (ref <vmime::message> msg,
+ (shared_ptr <vmime::message> msg,
const mailbox& expeditor,
const mailboxList& recipients,
utility::progressListener* progress = NULL,
@@ -115,7 +115,7 @@ protected:
* if the field is to be replaced, or a reference to the same headerField
* that was passed if the field should be left as is
*/
- ref <headerField> processHeaderField(ref <headerField> field);
+ shared_ptr <headerField> processHeaderField(shared_ptr <headerField> field);
/** Prepares the header before transmitting the message.
* Removes headers that should not be present (eg. "Bcc", "Return-Path"),
@@ -124,7 +124,7 @@ protected:
*
* @param header headers to process
*/
- void processHeader(ref <header> header);
+ void processHeader(shared_ptr <header> header);
};
diff --git a/vmime/object.hpp b/vmime/object.hpp
index 192ab050..0b12df3c 100644
--- a/vmime/object.hpp
+++ b/vmime/object.hpp
@@ -28,24 +28,15 @@
#include "vmime/types.hpp"
-#include <vector>
-
-
namespace vmime
{
-/** Base object for all objects in the library. This implements
- * reference counting and auto-deletion.
+/** Base object for all objects in the library.
*/
-class VMIME_EXPORT object
+class VMIME_EXPORT object : public enable_shared_from_this <object>
{
- template <class T> friend class utility::ref;
- template <class T> friend class utility::weak_ref;
-
- friend class utility::refManager;
-
protected:
object();
@@ -54,42 +45,6 @@ protected:
object& operator=(const object&);
virtual ~object();
-
-#ifndef VMIME_BUILDING_DOC
-
- /** Return a reference to this object.
- *
- * @return reference to self
- */
- ref <object> thisRef();
-
- /** Return a reference to this object (const version).
- *
- * @return reference to self
- */
- ref <const object> thisRef() const;
-
- /** Return a weak reference to this object.
- *
- * @return weak reference to self
- */
- weak_ref <object> thisWeakRef();
-
- /** Return a weak reference to this object (const version).
- *
- * @return weak reference to self
- */
- weak_ref <const object> thisWeakRef() const;
-
-
- void setRefManager(utility::refManager* mgr);
- utility::refManager* getRefManager() const;
-
-#endif // VMIME_BUILDING_DOC
-
-private:
-
- mutable utility::refManager* m_refMgr;
};
diff --git a/vmime/parameter.hpp b/vmime/parameter.hpp
index a3d0f0f8..d872b312 100644
--- a/vmime/parameter.hpp
+++ b/vmime/parameter.hpp
@@ -63,11 +63,11 @@ public:
#endif // VMIME_BUILDING_DOC
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
parameter& operator=(const parameter& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Return the name of this parameter.
*
@@ -91,7 +91,7 @@ public:
* is equivalent to:
*
* <pre>
- * ref <vmime::word> rawValue = getParameter("creation-date");
+ * shared_ptr <vmime::word> rawValue = getParameter("creation-date");
*
* vmime::dateTime theDate;
* theDate.parse(rawValue->getBuffer());
@@ -143,7 +143,7 @@ private:
string m_name;
- ref <word> m_value;
+ shared_ptr <word> m_value;
};
diff --git a/vmime/parameterizedHeaderField.hpp b/vmime/parameterizedHeaderField.hpp
index 1a80073e..efe9c81e 100644
--- a/vmime/parameterizedHeaderField.hpp
+++ b/vmime/parameterizedHeaderField.hpp
@@ -41,7 +41,7 @@ namespace vmime
class VMIME_EXPORT parameterizedHeaderField : virtual public headerField
{
- friend class vmime::creator; // create ref
+ friend class headerFieldFactory;
protected:
@@ -69,7 +69,7 @@ public:
* @throw exceptions::no_such_parameter if no parameter with this name exists
* @return first parameter with the specified name
*/
- ref <parameter> findParameter(const string& paramName) const;
+ shared_ptr <parameter> findParameter(const string& paramName) const;
/** Find the first parameter that matches the specified name.
* If no parameter is found, one will be created and inserted into
@@ -78,13 +78,13 @@ public:
* @return first parameter with the specified name or a new field
* if no parameter is found
*/
- ref <parameter> getParameter(const string& paramName);
+ shared_ptr <parameter> getParameter(const string& paramName);
/** Add a parameter at the end of the list.
*
* @param param parameter to append
*/
- void appendParameter(ref <parameter> param);
+ void appendParameter(shared_ptr <parameter> param);
/** Insert a new parameter before the specified parameter.
*
@@ -92,7 +92,7 @@ public:
* @param param parameter to insert
* @throw exceptions::no_such_parameter if the parameter is not in the list
*/
- void insertParameterBefore(ref <parameter> beforeParam, ref <parameter> param);
+ void insertParameterBefore(shared_ptr <parameter> beforeParam, shared_ptr <parameter> param);
/** Insert a new parameter before the specified position.
*
@@ -100,7 +100,7 @@ public:
* the beginning of the list)
* @param param parameter to insert
*/
- void insertParameterBefore(const size_t pos, ref <parameter> param);
+ void insertParameterBefore(const size_t pos, shared_ptr <parameter> param);
/** Insert a new parameter after the specified parameter.
*
@@ -108,21 +108,21 @@ public:
* @param param parameter to insert
* @throw exceptions::no_such_parameter if the parameter is not in the list
*/
- void insertParameterAfter(ref <parameter> afterParam, ref <parameter> param);
+ void insertParameterAfter(shared_ptr <parameter> afterParam, shared_ptr <parameter> param);
/** Insert a new parameter after the specified position.
*
* @param pos position of the parameter before the new parameter
* @param param parameter to insert
*/
- void insertParameterAfter(const size_t pos, ref <parameter> param);
+ void insertParameterAfter(const size_t pos, shared_ptr <parameter> param);
/** Remove the specified parameter from the list.
*
* @param param parameter to remove
* @throw exceptions::no_such_parameter if the parameter is not in the list
*/
- void removeParameter(ref <parameter> param);
+ void removeParameter(shared_ptr <parameter> param);
/** Remove the parameter at the specified position.
*
@@ -151,32 +151,32 @@ public:
* @param pos position
* @return parameter at position 'pos'
*/
- const ref <parameter> getParameterAt(const size_t pos);
+ const shared_ptr <parameter> getParameterAt(const size_t pos);
/** Return the parameter at the specified position.
*
* @param pos position
* @return parameter at position 'pos'
*/
- const ref <const parameter> getParameterAt(const size_t pos) const;
+ const shared_ptr <const parameter> getParameterAt(const size_t pos) const;
/** Return the parameter list.
*
* @return list of parameters
*/
- const std::vector <ref <const parameter> > getParameterList() const;
+ const std::vector <shared_ptr <const parameter> > getParameterList() const;
/** Return the parameter list.
*
* @return list of parameters
*/
- const std::vector <ref <parameter> > getParameterList();
+ const std::vector <shared_ptr <parameter> > getParameterList();
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
private:
- std::vector <ref <parameter> > m_params;
+ std::vector <shared_ptr <parameter> > m_params;
protected:
diff --git a/vmime/parsedMessageAttachment.hpp b/vmime/parsedMessageAttachment.hpp
index d37c84a6..6c96f80a 100644
--- a/vmime/parsedMessageAttachment.hpp
+++ b/vmime/parsedMessageAttachment.hpp
@@ -41,30 +41,30 @@ class VMIME_EXPORT parsedMessageAttachment : public messageAttachment
{
public:
- parsedMessageAttachment(ref <message> msg);
+ parsedMessageAttachment(shared_ptr <message> msg);
const mediaType getType() const;
const text getDescription() const;
const word getName() const;
- const ref <const contentHandler> getData() const;
+ const shared_ptr <const contentHandler> getData() const;
const encoding getEncoding() const;
- ref <const object> getPart() const;
+ shared_ptr <const object> getPart() const;
- ref <const header> getHeader() const;
+ shared_ptr <const header> getHeader() const;
- ref <message> getMessage() const;
+ shared_ptr <message> getMessage() const;
protected:
- void generateIn(ref <bodyPart> parent) const;
+ void generateIn(shared_ptr <bodyPart> parent) const;
private:
- ref <message> m_msg;
- mutable ref <contentHandler> m_data;
+ shared_ptr <message> m_msg;
+ mutable shared_ptr <contentHandler> m_data;
};
diff --git a/vmime/path.hpp b/vmime/path.hpp
index cb6e4ed4..87409413 100644
--- a/vmime/path.hpp
+++ b/vmime/path.hpp
@@ -73,10 +73,10 @@ public:
// Assignment
void copyFrom(const component& other);
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
path& operator=(const path& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
protected:
diff --git a/vmime/plainTextPart.hpp b/vmime/plainTextPart.hpp
index a68b5306..72a8a71c 100644
--- a/vmime/plainTextPart.hpp
+++ b/vmime/plainTextPart.hpp
@@ -47,17 +47,17 @@ public:
const charset& getCharset() const;
void setCharset(const charset& ch);
- const ref <const contentHandler> getText() const;
- void setText(ref <contentHandler> text);
+ const shared_ptr <const contentHandler> getText() const;
+ void setText(shared_ptr <contentHandler> text);
size_t getPartCount() const;
- void generateIn(ref <bodyPart> message, ref <bodyPart> parent) const;
- void parse(ref <const bodyPart> message, ref <const bodyPart> parent, ref <const bodyPart> textPart);
+ void generateIn(shared_ptr <bodyPart> message, shared_ptr <bodyPart> parent) const;
+ void parse(shared_ptr <const bodyPart> message, shared_ptr <const bodyPart> parent, shared_ptr <const bodyPart> textPart);
private:
- ref <contentHandler> m_text;
+ shared_ptr <contentHandler> m_text;
charset m_charset;
};
diff --git a/vmime/platform.hpp b/vmime/platform.hpp
index f10e5c9c..c72f160e 100644
--- a/vmime/platform.hpp
+++ b/vmime/platform.hpp
@@ -117,7 +117,7 @@ public:
*
* @return socket factory
*/
- virtual ref <net::socketFactory> getSocketFactory() = 0;
+ virtual shared_ptr <net::socketFactory> getSocketFactory() = 0;
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
@@ -125,14 +125,14 @@ public:
*
* @return file-system factory
*/
- virtual ref <utility::fileSystemFactory> getFileSystemFactory() = 0;
+ virtual shared_ptr <utility::fileSystemFactory> getFileSystemFactory() = 0;
/** Return a pointer to a factory that creates child process objects,
* which are used to spawn processes (run executable files).
*
* @return child process factory
*/
- virtual ref <utility::childProcessFactory> getChildProcessFactory() = 0;
+ virtual shared_ptr <utility::childProcessFactory> getChildProcessFactory() = 0;
#endif
/** Fills a buffer with cryptographically random bytes.
@@ -144,22 +144,22 @@ public:
/** Creates and initializes a critical section.
*/
- virtual ref <utility::sync::criticalSection> createCriticalSection() = 0;
+ virtual shared_ptr <utility::sync::criticalSection> createCriticalSection() = 0;
};
template <class TYPE>
static void setHandler()
{
- sm_handler = vmime::create <TYPE>();
+ sm_handler = vmime::make_shared <TYPE>();
}
- static ref <handler> getDefaultHandler();
- static ref <handler> getHandler();
+ static shared_ptr <handler> getDefaultHandler();
+ static shared_ptr <handler> getHandler();
private:
- static ref <handler> sm_handler;
+ static shared_ptr <handler> sm_handler;
};
diff --git a/vmime/platforms/posix/posixChildProcess.hpp b/vmime/platforms/posix/posixChildProcess.hpp
index 9e60ef19..5b9fa021 100644
--- a/vmime/platforms/posix/posixChildProcess.hpp
+++ b/vmime/platforms/posix/posixChildProcess.hpp
@@ -51,8 +51,8 @@ public:
void start(const std::vector <string> args, const int flags = 0);
- ref <utility::outputStream> getStdIn();
- ref <utility::inputStream> getStdOut();
+ shared_ptr <utility::outputStream> getStdIn();
+ shared_ptr <utility::inputStream> getStdOut();
void waitForFinish();
@@ -61,8 +61,8 @@ private:
utility::file::path m_processPath;
bool m_started;
- ref <utility::outputStream> m_stdIn;
- ref <utility::inputStream> m_stdOut;
+ shared_ptr <utility::outputStream> m_stdIn;
+ shared_ptr <utility::inputStream> m_stdOut;
sigset_t m_oldProcMask;
pid_t m_pid;
@@ -77,7 +77,7 @@ class posixChildProcessFactory : public utility::childProcessFactory
{
public:
- ref <utility::childProcess> create(const utility::file::path& path) const;
+ shared_ptr <utility::childProcess> create(const utility::file::path& path) const;
};
diff --git a/vmime/platforms/posix/posixFile.hpp b/vmime/platforms/posix/posixFile.hpp
index c19f1674..a1353841 100644
--- a/vmime/platforms/posix/posixFile.hpp
+++ b/vmime/platforms/posix/posixFile.hpp
@@ -95,7 +95,7 @@ public:
posixFileWriter(const vmime::utility::file::path& path, const vmime::string& nativePath);
- ref <vmime::utility::outputStream> getOutputStream();
+ shared_ptr <vmime::utility::outputStream> getOutputStream();
private:
@@ -111,7 +111,7 @@ public:
posixFileReader(const vmime::utility::file::path& path, const vmime::string& nativePath);
- ref <vmime::utility::inputStream> getInputStream();
+ shared_ptr <vmime::utility::inputStream> getInputStream();
private:
@@ -129,7 +129,7 @@ public:
~posixFileIterator();
bool hasMoreElements() const;
- ref <vmime::utility::file> nextElement();
+ shared_ptr <vmime::utility::file> nextElement();
private:
@@ -165,16 +165,16 @@ public:
bool exists() const;
- ref <vmime::utility::file> getParent() const;
+ shared_ptr <vmime::utility::file> getParent() const;
void rename(const path& newName);
void remove();
- ref <vmime::utility::fileWriter> getFileWriter();
- ref <vmime::utility::fileReader> getFileReader();
+ shared_ptr <vmime::utility::fileWriter> getFileWriter();
+ shared_ptr <vmime::utility::fileReader> getFileReader();
- ref <vmime::utility::fileIterator> getFiles() const;
+ shared_ptr <vmime::utility::fileIterator> getFiles() const;
private:
@@ -192,7 +192,7 @@ class posixFileSystemFactory : public vmime::utility::fileSystemFactory
{
public:
- ref <vmime::utility::file> create(const vmime::utility::file::path& path) const;
+ shared_ptr <vmime::utility::file> create(const vmime::utility::file::path& path) const;
const vmime::utility::file::path stringToPath(const vmime::string& str) const;
const vmime::string pathToString(const vmime::utility::file::path& path) const;
diff --git a/vmime/platforms/posix/posixHandler.hpp b/vmime/platforms/posix/posixHandler.hpp
index 34453916..0bba372b 100644
--- a/vmime/platforms/posix/posixHandler.hpp
+++ b/vmime/platforms/posix/posixHandler.hpp
@@ -67,30 +67,30 @@ public:
unsigned int getThreadId() const;
#if VMIME_HAVE_MESSAGING_FEATURES
- ref <vmime::net::socketFactory> getSocketFactory();
+ shared_ptr <vmime::net::socketFactory> getSocketFactory();
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- ref <vmime::utility::fileSystemFactory> getFileSystemFactory();
+ shared_ptr <vmime::utility::fileSystemFactory> getFileSystemFactory();
- ref <vmime::utility::childProcessFactory> getChildProcessFactory();
+ shared_ptr <vmime::utility::childProcessFactory> getChildProcessFactory();
#endif
void wait() const;
void generateRandomBytes(unsigned char* buffer, const unsigned int count);
- ref <utility::sync::criticalSection> createCriticalSection();
+ shared_ptr <utility::sync::criticalSection> createCriticalSection();
private:
#if VMIME_HAVE_MESSAGING_FEATURES
- ref <posixSocketFactory> m_socketFactory;
+ shared_ptr <posixSocketFactory> m_socketFactory;
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- ref <posixFileSystemFactory> m_fileSysFactory;
- ref <posixChildProcessFactory> m_childProcFactory;
+ shared_ptr <posixFileSystemFactory> m_fileSysFactory;
+ shared_ptr <posixChildProcessFactory> m_childProcFactory;
#endif
};
diff --git a/vmime/platforms/posix/posixSocket.hpp b/vmime/platforms/posix/posixSocket.hpp
index ebbf551e..10df657e 100644
--- a/vmime/platforms/posix/posixSocket.hpp
+++ b/vmime/platforms/posix/posixSocket.hpp
@@ -43,7 +43,7 @@ class posixSocket : public vmime::net::socket
{
public:
- posixSocket(ref <vmime::net::timeoutHandler> th);
+ posixSocket(shared_ptr <vmime::net::timeoutHandler> th);
~posixSocket();
void connect(const vmime::string& address, const vmime::port_t port);
@@ -70,7 +70,7 @@ protected:
private:
- ref <vmime::net::timeoutHandler> m_timeoutHandler;
+ shared_ptr <vmime::net::timeoutHandler> m_timeoutHandler;
char m_buffer[65536];
int m_desc;
@@ -86,8 +86,8 @@ class posixSocketFactory : public vmime::net::socketFactory
{
public:
- ref <vmime::net::socket> create();
- ref <vmime::net::socket> create(ref <vmime::net::timeoutHandler> th);
+ shared_ptr <vmime::net::socket> create();
+ shared_ptr <vmime::net::socket> create(shared_ptr <vmime::net::timeoutHandler> th);
};
diff --git a/vmime/platforms/windows/windowsFile.hpp b/vmime/platforms/windows/windowsFile.hpp
index 1dae064c..65049b8f 100644
--- a/vmime/platforms/windows/windowsFile.hpp
+++ b/vmime/platforms/windows/windowsFile.hpp
@@ -46,7 +46,7 @@ class windowsFileSystemFactory : public vmime::utility::fileSystemFactory
{
public:
- ref <vmime::utility::file> create(const vmime::utility::file::path& path) const;
+ shared_ptr <vmime::utility::file> create(const vmime::utility::file::path& path) const;
const vmime::utility::file::path stringToPath(const vmime::string& str) const;
const vmime::string pathToString(const vmime::utility::file::path& path) const;
@@ -84,16 +84,16 @@ public:
bool exists() const;
- ref <file> getParent() const;
+ shared_ptr <file> getParent() const;
void rename(const path& newName);
void remove();
- ref <vmime::utility::fileWriter> getFileWriter();
+ shared_ptr <vmime::utility::fileWriter> getFileWriter();
- ref <vmime::utility::fileReader> getFileReader();
+ shared_ptr <vmime::utility::fileReader> getFileReader();
- ref <vmime::utility::fileIterator> getFiles() const;
+ shared_ptr <vmime::utility::fileIterator> getFiles() const;
private:
@@ -114,7 +114,7 @@ public:
~windowsFileIterator();
bool hasMoreElements() const;
- vmime::ref <vmime::utility::file> nextElement();
+ shared_ptr <vmime::utility::file> nextElement();
private:
@@ -140,7 +140,7 @@ public:
public:
- ref <vmime::utility::inputStream> getInputStream();
+ shared_ptr <vmime::utility::inputStream> getInputStream();
private:
@@ -180,7 +180,7 @@ public:
public:
- ref <vmime::utility::outputStream> getOutputStream();
+ shared_ptr <vmime::utility::outputStream> getOutputStream();
private:
diff --git a/vmime/platforms/windows/windowsHandler.hpp b/vmime/platforms/windows/windowsHandler.hpp
index d3ac434c..4a3678eb 100644
--- a/vmime/platforms/windows/windowsHandler.hpp
+++ b/vmime/platforms/windows/windowsHandler.hpp
@@ -66,29 +66,29 @@ public:
unsigned int getThreadId() const;
#if VMIME_HAVE_MESSAGING_FEATURES
- ref <vmime::net::socketFactory> getSocketFactory();
+ shared_ptr <vmime::net::socketFactory> getSocketFactory();
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- ref <vmime::utility::fileSystemFactory> getFileSystemFactory();
+ shared_ptr <vmime::utility::fileSystemFactory> getFileSystemFactory();
- ref <vmime::utility::childProcessFactory> getChildProcessFactory();
+ shared_ptr <vmime::utility::childProcessFactory> getChildProcessFactory();
#endif
void wait() const;
void generateRandomBytes(unsigned char* buffer, const unsigned int count);
- ref <utility::sync::criticalSection> createCriticalSection();
+ shared_ptr <utility::sync::criticalSection> createCriticalSection();
private:
#if VMIME_HAVE_MESSAGING_FEATURES
- ref <windowsSocketFactory> m_socketFactory;
+ shared_ptr <windowsSocketFactory> m_socketFactory;
#endif
#if VMIME_HAVE_FILESYSTEM_FEATURES
- ref <windowsFileSystemFactory> m_fileSysFactory;
+ shared_ptr <windowsFileSystemFactory> m_fileSysFactory;
#endif
};
diff --git a/vmime/platforms/windows/windowsSocket.hpp b/vmime/platforms/windows/windowsSocket.hpp
index db3e6323..4c4344d8 100644
--- a/vmime/platforms/windows/windowsSocket.hpp
+++ b/vmime/platforms/windows/windowsSocket.hpp
@@ -45,7 +45,7 @@ class windowsSocket : public vmime::net::socket
public:
windowsSocket();
- windowsSocket(ref <vmime::net::timeoutHandler> th);
+ windowsSocket(shared_ptr <vmime::net::timeoutHandler> th);
~windowsSocket();
public:
@@ -83,7 +83,7 @@ protected:
private:
- ref <vmime::net::timeoutHandler> m_timeoutHandler;
+ shared_ptr <vmime::net::timeoutHandler> m_timeoutHandler;
char m_buffer[65536];
SOCKET m_desc;
@@ -99,8 +99,8 @@ class windowsSocketFactory : public vmime::net::socketFactory
{
public:
- ref <vmime::net::socket> create();
- ref <vmime::net::socket> create(ref <vmime::net::timeoutHandler> th);
+ shared_ptr <vmime::net::socket> create();
+ shared_ptr <vmime::net::socket> create(shared_ptr <vmime::net::timeoutHandler> th);
};
diff --git a/vmime/propertySet.hpp b/vmime/propertySet.hpp
index eefdbcc3..bf1c39bf 100644
--- a/vmime/propertySet.hpp
+++ b/vmime/propertySet.hpp
@@ -276,7 +276,7 @@ public:
template <class TYPE>
const TYPE getProperty(const string& name) const
{
- const ref <property> prop = find(name);
+ const shared_ptr <property> prop = find(name);
if (!prop) throw exceptions::no_such_property(name);
//return (prop->getValue <TYPE>()); // BUG: with g++ < 3.4
@@ -295,7 +295,7 @@ public:
template <class TYPE>
const TYPE getProperty(const string& name, const TYPE defaultValue) const
{
- const ref <property> prop = find(name);
+ const shared_ptr <property> prop = find(name);
//return (prop ? prop->getValue <TYPE>() : defaultValue); // BUG: with g++ < 3.4
return (prop ? prop->template getValue <TYPE>() : defaultValue);
}
@@ -335,13 +335,13 @@ private:
void parse(const string& props);
- class propFinder : public std::unary_function <ref <property>, bool>
+ class propFinder : public std::unary_function <shared_ptr <property>, bool>
{
public:
propFinder(const string& name) : m_name(utility::stringUtils::toLower(name)) { }
- bool operator()(ref <property> p) const
+ bool operator()(shared_ptr <property> p) const
{
return (utility::stringUtils::toLower(p->getName()) == m_name);
}
@@ -351,10 +351,10 @@ private:
const string m_name;
};
- ref <property> find(const string& name) const;
- ref <property> findOrCreate(const string& name);
+ shared_ptr <property> find(const string& name) const;
+ shared_ptr <property> findOrCreate(const string& name);
- typedef std::list <ref <property> > list_type;
+ typedef std::list <shared_ptr <property> > list_type;
list_type m_props;
public:
@@ -427,13 +427,13 @@ public:
*
* @return list of properties
*/
- const std::vector <ref <const property> > getPropertyList() const;
+ const std::vector <shared_ptr <const property> > getPropertyList() const;
/** Return the property list.
*
* @return list of properties
*/
- const std::vector <ref <property> > getPropertyList();
+ const std::vector <shared_ptr <property> > getPropertyList();
};
diff --git a/vmime/relay.hpp b/vmime/relay.hpp
index f778a0bc..62ed5bf0 100644
--- a/vmime/relay.hpp
+++ b/vmime/relay.hpp
@@ -47,11 +47,11 @@ public:
public:
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
relay& operator=(const relay& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
const string& getFrom() const;
void setFrom(const string& from);
diff --git a/vmime/security/authenticator.hpp b/vmime/security/authenticator.hpp
index 5efdb321..bef07b4a 100644
--- a/vmime/security/authenticator.hpp
+++ b/vmime/security/authenticator.hpp
@@ -114,7 +114,7 @@ public:
*
* @param serv messaging service instance
*/
- virtual void setService(ref <net::service> serv) = 0;
+ virtual void setService(shared_ptr <net::service> serv) = 0;
};
diff --git a/vmime/security/cert/X509Certificate.hpp b/vmime/security/cert/X509Certificate.hpp
index 20ebfe5a..215a86cf 100644
--- a/vmime/security/cert/X509Certificate.hpp
+++ b/vmime/security/cert/X509Certificate.hpp
@@ -74,7 +74,7 @@ public:
* @return a X.509 certificate, or NULL if the given data does not
* represent a valid certificate
*/
- static ref <X509Certificate> import(utility::inputStream& is);
+ static shared_ptr <X509Certificate> import(utility::inputStream& is);
/** Imports a DER or PEM encoded X.509 certificate.
*
@@ -83,7 +83,7 @@ public:
* @return a X.509 certificate, or NULL if the given data does not
* represent a valid certificate
*/
- static ref <X509Certificate> import(const byte_t* data, const size_t length);
+ static shared_ptr <X509Certificate> import(const byte_t* data, const size_t length);
/** Exports this X.509 certificate to the specified format.
*
@@ -107,14 +107,14 @@ public:
* @return true if this certificate was issued by the given issuer,
* false otherwise
*/
- virtual bool checkIssuer(ref <const X509Certificate> issuer) const = 0;
+ virtual bool checkIssuer(shared_ptr <const X509Certificate> issuer) const = 0;
/** Verifies this certificate against a given trusted one.
*
* @param caCert a certificate that is considered to be trusted one
* @return true if the verification succeeded, false otherwise
*/
- virtual bool verify(ref <const X509Certificate> caCert) const = 0;
+ virtual bool verify(shared_ptr <const X509Certificate> caCert) const = 0;
/** Verify certificate's subject name against the given hostname.
*
diff --git a/vmime/security/cert/certificate.hpp b/vmime/security/cert/certificate.hpp
index e4a57fb4..aef1f1f9 100644
--- a/vmime/security/cert/certificate.hpp
+++ b/vmime/security/cert/certificate.hpp
@@ -64,7 +64,7 @@ public:
* @return true if the two certificates are the same,
* false otherwise
*/
- virtual bool equals(ref <const certificate> other) const = 0;
+ virtual bool equals(shared_ptr <const certificate> other) const = 0;
/** Returns a pointer to internal binary data for this certificate.
* The actual type of data depends on the library used for TLS support.
diff --git a/vmime/security/cert/certificateChain.hpp b/vmime/security/cert/certificateChain.hpp
index 8daa4cb5..0ce6bda3 100644
--- a/vmime/security/cert/certificateChain.hpp
+++ b/vmime/security/cert/certificateChain.hpp
@@ -47,7 +47,7 @@ public:
*
* @param certs chain of certificates
*/
- certificateChain(const std::vector <ref <certificate> >& certs);
+ certificateChain(const std::vector <shared_ptr <certificate> >& certs);
/** Return the number of certificates in the chain.
*
@@ -62,11 +62,11 @@ public:
* @param index position at which to retrieve certificate
* @return certificate at the specified position
*/
- ref <certificate> getAt(const unsigned int index);
+ shared_ptr <certificate> getAt(const unsigned int index);
protected:
- std::vector <ref <certificate> > m_certs;
+ std::vector <shared_ptr <certificate> > m_certs;
};
diff --git a/vmime/security/cert/certificateVerifier.hpp b/vmime/security/cert/certificateVerifier.hpp
index 349ab46d..c72c84cb 100644
--- a/vmime/security/cert/certificateVerifier.hpp
+++ b/vmime/security/cert/certificateVerifier.hpp
@@ -49,7 +49,7 @@ public:
* or more certificates can not be trusted, or the server identity
* cannot be verified
*/
- virtual void verify(ref <certificateChain> chain, const string& hostname) = 0;
+ virtual void verify(shared_ptr <certificateChain> chain, const string& hostname) = 0;
};
diff --git a/vmime/security/cert/defaultCertificateVerifier.hpp b/vmime/security/cert/defaultCertificateVerifier.hpp
index 84e08e64..fddcc4f5 100644
--- a/vmime/security/cert/defaultCertificateVerifier.hpp
+++ b/vmime/security/cert/defaultCertificateVerifier.hpp
@@ -53,17 +53,17 @@ public:
*
* @param trustedCerts list of trusted certificates
*/
- void setX509TrustedCerts(const std::vector <ref <X509Certificate> >& trustedCerts);
+ void setX509TrustedCerts(const std::vector <shared_ptr <X509Certificate> >& trustedCerts);
/** Sets the X.509 root CAs used for certificate verification.
*
* @param caCerts list of root CAs
*/
- void setX509RootCAs(const std::vector <ref <X509Certificate> >& caCerts);
+ void setX509RootCAs(const std::vector <shared_ptr <X509Certificate> >& caCerts);
// Implementation of 'certificateVerifier'
- void verify(ref <certificateChain> chain, const string& hostname);
+ void verify(shared_ptr <certificateChain> chain, const string& hostname);
private:
@@ -72,11 +72,11 @@ private:
* @param chain list of X.509 certificates
* @param hostname server hostname
*/
- void verifyX509(ref <certificateChain> chain, const string& hostname);
+ void verifyX509(shared_ptr <certificateChain> chain, const string& hostname);
- std::vector <ref <X509Certificate> > m_x509RootCAs;
- std::vector <ref <X509Certificate> > m_x509TrustedCerts;
+ std::vector <shared_ptr <X509Certificate> > m_x509RootCAs;
+ std::vector <shared_ptr <X509Certificate> > m_x509TrustedCerts;
};
diff --git a/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp b/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp
index bd38342d..76ee6d4d 100644
--- a/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp
+++ b/vmime/security/cert/gnutls/X509Certificate_GnuTLS.hpp
@@ -41,16 +41,14 @@ namespace cert {
class X509Certificate_GnuTLS : public X509Certificate
{
- friend class vmime::creator;
friend class X509Certificate;
-protected:
-
- X509Certificate_GnuTLS();
X509Certificate_GnuTLS(const X509Certificate&);
public:
+ X509Certificate_GnuTLS();
+
~X509Certificate_GnuTLS();
@@ -58,9 +56,9 @@ public:
const byteArray getSerialNumber() const;
- bool checkIssuer(ref <const X509Certificate> issuer) const;
+ bool checkIssuer(shared_ptr <const X509Certificate> issuer) const;
- bool verify(ref <const X509Certificate> caCert) const;
+ bool verify(shared_ptr <const X509Certificate> caCert) const;
bool verifyHostName(const string& hostname) const;
@@ -74,7 +72,7 @@ public:
const byteArray getEncoded() const;
const string getType() const;
int getVersion() const;
- bool equals(ref <const certificate> other) const;
+ bool equals(shared_ptr <const certificate> other) const;
void* getInternalData();
private:
diff --git a/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp b/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp
index 60ecda08..bddb4b6c 100644
--- a/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp
+++ b/vmime/security/cert/openssl/X509Certificate_OpenSSL.hpp
@@ -43,17 +43,15 @@ namespace cert {
class X509Certificate_OpenSSL : public X509Certificate
{
- friend class vmime::creator;
friend class X509Certificate;
-protected:
-
- X509Certificate_OpenSSL();
- X509Certificate_OpenSSL(X509* cert);
X509Certificate_OpenSSL(const X509Certificate_OpenSSL&);
public:
+ X509Certificate_OpenSSL();
+ X509Certificate_OpenSSL(X509* cert);
+
~X509Certificate_OpenSSL();
@@ -61,9 +59,9 @@ public:
const byteArray getSerialNumber() const;
- bool checkIssuer(ref <const X509Certificate> issuer) const;
+ bool checkIssuer(shared_ptr <const X509Certificate> issuer) const;
- bool verify(ref <const X509Certificate> caCert) const;
+ bool verify(shared_ptr <const X509Certificate> caCert) const;
bool verifyHostName(const string& hostname) const;
@@ -73,14 +71,14 @@ public:
const byteArray getFingerprint(const DigestAlgorithm algo) const;
- static ref <X509Certificate> importInternal(X509* cert);
+ static shared_ptr <X509Certificate> importInternal(X509* cert);
// Implementation of 'certificate'
const byteArray getEncoded() const;
const string getType() const;
int getVersion() const;
- bool equals(ref <const certificate> other) const;
+ bool equals(shared_ptr <const certificate> other) const;
void* getInternalData();
private:
diff --git a/vmime/security/defaultAuthenticator.hpp b/vmime/security/defaultAuthenticator.hpp
index 780dc310..eead3d14 100644
--- a/vmime/security/defaultAuthenticator.hpp
+++ b/vmime/security/defaultAuthenticator.hpp
@@ -54,12 +54,12 @@ public:
const string getAnonymousToken() const;
const string getServiceName() const;
- void setService(ref <net::service> serv);
- weak_ref <net::service> getService() const;
+ void setService(shared_ptr <net::service> serv);
+ weak_ptr <net::service> getService() const;
private:
- weak_ref <net::service> m_service;
+ weak_ptr <net::service> m_service;
};
diff --git a/vmime/security/digest/messageDigestFactory.hpp b/vmime/security/digest/messageDigestFactory.hpp
index 2a1a4083..15fd8a28 100644
--- a/vmime/security/digest/messageDigestFactory.hpp
+++ b/vmime/security/digest/messageDigestFactory.hpp
@@ -55,7 +55,7 @@ private:
{
public:
- virtual ref <messageDigest> create() const = 0;
+ virtual shared_ptr <messageDigest> create() const = 0;
};
template <class E>
@@ -63,14 +63,14 @@ private:
{
public:
- ref <messageDigest> create() const
+ shared_ptr <messageDigest> create() const
{
- return vmime::create <E>();
+ return vmime::make_shared <E>();
}
};
- typedef std::map <string, ref <digestAlgorithmFactory> > MapType;
+ typedef std::map <string, shared_ptr <digestAlgorithmFactory> > MapType;
MapType m_algos;
public:
@@ -83,7 +83,7 @@ public:
void registerAlgorithm(const string& name)
{
m_algos.insert(MapType::value_type(utility::stringUtils::toLower(name),
- vmime::create <digestAlgorithmFactoryImpl <E> >()));
+ vmime::make_shared <digestAlgorithmFactoryImpl <E> >()));
}
/** Create a new algorithm instance from its name.
@@ -93,7 +93,7 @@ public:
* @throw exceptions::no_digest_algorithm_available if no algorithm is
* registered with this name
*/
- ref <messageDigest> create(const string& name);
+ shared_ptr <messageDigest> create(const string& name);
/** Return a list of supported digest algorithms.
*
diff --git a/vmime/security/sasl/SASLAuthenticator.hpp b/vmime/security/sasl/SASLAuthenticator.hpp
index 56588fc8..9f1881f5 100644
--- a/vmime/security/sasl/SASLAuthenticator.hpp
+++ b/vmime/security/sasl/SASLAuthenticator.hpp
@@ -64,15 +64,15 @@ public:
* @return ordered list of mechanism to use among the available
* mechanisms (from the first to try to the last)
*/
- virtual const std::vector <ref <SASLMechanism> > getAcceptableMechanisms
- (const std::vector <ref <SASLMechanism> >& available,
- ref <SASLMechanism> suggested) const = 0;
+ virtual const std::vector <shared_ptr <SASLMechanism> > getAcceptableMechanisms
+ (const std::vector <shared_ptr <SASLMechanism> >& available,
+ shared_ptr <SASLMechanism> suggested) const = 0;
/** Set the SASL session which is using this authenticator.
*
* @param sess SASL session
*/
- virtual void setSASLSession(ref <SASLSession> sess) = 0;
+ virtual void setSASLSession(shared_ptr <SASLSession> sess) = 0;
/** Set the SASL mechanism which has been selected for the
* SASL authentication process. This may be called several times
@@ -81,7 +81,7 @@ public:
*
* @param mech SASL mechanism
*/
- virtual void setSASLMechanism(ref <SASLMechanism> mech) = 0;
+ virtual void setSASLMechanism(shared_ptr <SASLMechanism> mech) = 0;
};
diff --git a/vmime/security/sasl/SASLContext.hpp b/vmime/security/sasl/SASLContext.hpp
index 8f6e177c..7afcddf2 100644
--- a/vmime/security/sasl/SASLContext.hpp
+++ b/vmime/security/sasl/SASLContext.hpp
@@ -64,9 +64,9 @@ public:
* @param mech SASL mechanism
* @return a new SASL session
*/
- ref <SASLSession> createSession
+ shared_ptr <SASLSession> createSession
(const string& serviceName,
- ref <authenticator> auth, ref <SASLMechanism> mech);
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech);
/** Create an instance of an SASL mechanism.
*
@@ -75,7 +75,7 @@ public:
* @throw exceptions::no_such_mechanism if no mechanism is
* registered for the specified name
*/
- ref <SASLMechanism> createMechanism(const string& name);
+ shared_ptr <SASLMechanism> createMechanism(const string& name);
/** Suggests an SASL mechanism among a set of mechanisms
* supported by the server.
@@ -84,8 +84,8 @@ public:
* @return suggested mechanism (usually the safest mechanism
* supported by both the client and the server)
*/
- ref <SASLMechanism> suggestMechanism
- (const std::vector <ref <SASLMechanism> >& mechs);
+ shared_ptr <SASLMechanism> suggestMechanism
+ (const std::vector <shared_ptr <SASLMechanism> >& mechs);
/** Helper function for decoding Base64-encoded challenge.
*
diff --git a/vmime/security/sasl/SASLMechanism.hpp b/vmime/security/sasl/SASLMechanism.hpp
index 56566a42..623069d5 100644
--- a/vmime/security/sasl/SASLMechanism.hpp
+++ b/vmime/security/sasl/SASLMechanism.hpp
@@ -71,7 +71,7 @@ public:
* 'responseLen' are undetermined)
*/
virtual bool step
- (ref <SASLSession> sess,
+ (shared_ptr <SASLSession> sess,
const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen) = 0;
@@ -97,7 +97,7 @@ public:
* the encoding of data (in this case, the values in 'output' and
* 'outputLen' are undetermined)
*/
- virtual void encode(ref <SASLSession> sess,
+ virtual void encode(shared_ptr <SASLSession> sess,
const byte_t* input, const long inputLen,
byte_t** output, long* outputLen) = 0;
@@ -114,7 +114,7 @@ public:
* the encoding of data (in this case, the values in 'output' and
* 'outputLen' are undetermined)
*/
- virtual void decode(ref <SASLSession> sess,
+ virtual void decode(shared_ptr <SASLSession> sess,
const byte_t* input, const long inputLen,
byte_t** output, long* outputLen) = 0;
};
diff --git a/vmime/security/sasl/SASLMechanismFactory.hpp b/vmime/security/sasl/SASLMechanismFactory.hpp
index 920b78fc..3503f71b 100644
--- a/vmime/security/sasl/SASLMechanismFactory.hpp
+++ b/vmime/security/sasl/SASLMechanismFactory.hpp
@@ -61,8 +61,8 @@ private:
{
public:
- virtual ref <SASLMechanism> create
- (ref <SASLContext> ctx, const string& name) = 0;
+ virtual shared_ptr <SASLMechanism> create
+ (shared_ptr <SASLContext> ctx, const string& name) = 0;
};
template <typename T>
@@ -70,13 +70,13 @@ private:
{
public:
- ref <SASLMechanism> create(ref <SASLContext> ctx, const string& name)
+ shared_ptr <SASLMechanism> create(shared_ptr <SASLContext> ctx, const string& name)
{
- return vmime::create <T>(ctx, name);
+ return vmime::make_shared <T>(ctx, name);
}
};
- typedef std::map <string, ref <registeredMechanism> > MapType;
+ typedef std::map <string, shared_ptr <registeredMechanism> > MapType;
MapType m_mechs;
public:
@@ -92,7 +92,7 @@ public:
void registerMechanism(const string& name)
{
m_mechs.insert(MapType::value_type(name,
- vmime::create <registeredMechanismImpl <MECH_CLASS> >()));
+ vmime::make_shared <registeredMechanismImpl <MECH_CLASS> >()));
}
/** Create a mechanism object given its name.
@@ -103,7 +103,7 @@ public:
* @throw exceptions::no_such_mechanism if no mechanism is
* registered for the specified name
*/
- ref <SASLMechanism> create(ref <SASLContext> ctx, const string& name);
+ shared_ptr <SASLMechanism> create(shared_ptr <SASLContext> ctx, const string& name);
/** Return a list of supported mechanisms. This includes mechanisms
* registered using registerMechanism() as well as the ones that
diff --git a/vmime/security/sasl/SASLSession.hpp b/vmime/security/sasl/SASLSession.hpp
index a196e06d..830d9970 100644
--- a/vmime/security/sasl/SASLSession.hpp
+++ b/vmime/security/sasl/SASLSession.hpp
@@ -64,8 +64,8 @@ public:
* @param auth authenticator to use for this session
* @param mech SASL mechanism
*/
- SASLSession(const string& serviceName, ref <SASLContext> ctx,
- ref <authenticator> auth, ref <SASLMechanism> mech);
+ SASLSession(const string& serviceName, shared_ptr <SASLContext> ctx,
+ shared_ptr <authenticator> auth, shared_ptr <SASLMechanism> mech);
/** Initialize this SASL session. This must be called before
* calling any other method on this object (except accessors).
@@ -78,19 +78,19 @@ public:
*
* @return authenticator object
*/
- ref <authenticator> getAuthenticator();
+ shared_ptr <authenticator> getAuthenticator();
/** Return the mechanism used for this session.
*
* @return SASL mechanism
*/
- ref <SASLMechanism> getMechanism();
+ shared_ptr <SASLMechanism> getMechanism();
/** Return the SASL context.
*
* @return SASL context
*/
- ref <SASLContext> getContext();
+ shared_ptr <SASLContext> getContext();
/** Perform one step of SASL authentication. Accept data from the
* server (challenge), process it and return data to be returned
@@ -118,7 +118,7 @@ public:
* @param sok socket to wrap
* @return secured socket
*/
- ref <net::socket> getSecuredSocket(ref <net::socket> sok);
+ shared_ptr <net::socket> getSecuredSocket(shared_ptr <net::socket> sok);
/** Return the name of the service which is using this
* SASL session (eg. "imap"). This value should be returned
@@ -132,9 +132,9 @@ private:
const string m_serviceName;
- ref <SASLContext> m_context;
- ref <authenticator> m_auth;
- ref <SASLMechanism> m_mech;
+ shared_ptr <SASLContext> m_context;
+ shared_ptr <authenticator> m_auth;
+ shared_ptr <SASLMechanism> m_mech;
#ifdef GSASL_VERSION
Gsasl* m_gsaslContext;
diff --git a/vmime/security/sasl/SASLSocket.hpp b/vmime/security/sasl/SASLSocket.hpp
index 3c1cf12c..33487eba 100644
--- a/vmime/security/sasl/SASLSocket.hpp
+++ b/vmime/security/sasl/SASLSocket.hpp
@@ -50,7 +50,7 @@ class VMIME_EXPORT SASLSocket : public net::socket
{
public:
- SASLSocket(ref <SASLSession> sess, ref <net::socket> wrapped);
+ SASLSocket(shared_ptr <SASLSession> sess, shared_ptr <net::socket> wrapped);
~SASLSocket();
void connect(const string& address, const port_t port);
@@ -74,8 +74,8 @@ public:
private:
- ref <SASLSession> m_session;
- ref <net::socket> m_wrapped;
+ shared_ptr <SASLSession> m_session;
+ shared_ptr <net::socket> m_wrapped;
byte_t* m_pendingBuffer;
size_type m_pendingPos;
diff --git a/vmime/security/sasl/builtinSASLMechanism.hpp b/vmime/security/sasl/builtinSASLMechanism.hpp
index 3507dc45..e7081a27 100644
--- a/vmime/security/sasl/builtinSASLMechanism.hpp
+++ b/vmime/security/sasl/builtinSASLMechanism.hpp
@@ -49,30 +49,30 @@ class VMIME_EXPORT builtinSASLMechanism : public SASLMechanism
{
public:
- builtinSASLMechanism(ref <SASLContext> ctx, const string& name);
+ builtinSASLMechanism(shared_ptr <SASLContext> ctx, const string& name);
~builtinSASLMechanism();
const string getName() const;
- bool step(ref <SASLSession> sess,
+ bool step(shared_ptr <SASLSession> sess,
const byte_t* challenge, const long challengeLen,
byte_t** response, long* responseLen);
bool isComplete() const;
- void encode(ref <SASLSession> sess,
+ void encode(shared_ptr <SASLSession> sess,
const byte_t* input, const long inputLen,
byte_t** output, long* outputLen);
- void decode(ref <SASLSession> sess,
+ void decode(shared_ptr <SASLSession> sess,
const byte_t* input, const long inputLen,
byte_t** output, long* outputLen);
private:
/** SASL context */
- ref <SASLContext> m_context;
+ shared_ptr <SASLContext> m_context;
/** Mechanism name */
const string m_name;
diff --git a/vmime/security/sasl/defaultSASLAuthenticator.hpp b/vmime/security/sasl/defaultSASLAuthenticator.hpp
index 68ae7946..6ea9af80 100644
--- a/vmime/security/sasl/defaultSASLAuthenticator.hpp
+++ b/vmime/security/sasl/defaultSASLAuthenticator.hpp
@@ -50,9 +50,9 @@ public:
defaultSASLAuthenticator();
~defaultSASLAuthenticator();
- const std::vector <ref <SASLMechanism> > getAcceptableMechanisms
- (const std::vector <ref <SASLMechanism> >& available,
- ref <SASLMechanism> suggested) const;
+ const std::vector <shared_ptr <SASLMechanism> > getAcceptableMechanisms
+ (const std::vector <shared_ptr <SASLMechanism> >& available,
+ shared_ptr <SASLMechanism> suggested) const;
const string getUsername() const;
const string getPassword() const;
@@ -60,22 +60,22 @@ public:
const string getAnonymousToken() const;
const string getServiceName() const;
- void setService(ref <net::service> serv);
- weak_ref <net::service> getService() const;
+ void setService(shared_ptr <net::service> serv);
+ weak_ptr <net::service> getService() const;
- void setSASLSession(ref <SASLSession> sess);
- ref <SASLSession> getSASLSession() const;
+ void setSASLSession(shared_ptr <SASLSession> sess);
+ shared_ptr <SASLSession> getSASLSession() const;
- void setSASLMechanism(ref <SASLMechanism> mech);
- ref <SASLMechanism> getSASLMechanism() const;
+ void setSASLMechanism(shared_ptr <SASLMechanism> mech);
+ shared_ptr <SASLMechanism> getSASLMechanism() const;
private:
defaultAuthenticator m_default;
- weak_ref <net::service> m_service;
- weak_ref <SASLSession> m_saslSession;
- ref <SASLMechanism> m_saslMech;
+ weak_ptr <net::service> m_service;
+ weak_ptr <SASLSession> m_saslSession;
+ shared_ptr <SASLMechanism> m_saslMech;
};
diff --git a/vmime/streamContentHandler.hpp b/vmime/streamContentHandler.hpp
index bf2eb449..52f6718a 100644
--- a/vmime/streamContentHandler.hpp
+++ b/vmime/streamContentHandler.hpp
@@ -58,7 +58,7 @@ public:
* @return a reference to a new content handler
*/
streamContentHandler
- (ref <utility::inputStream> is,
+ (shared_ptr <utility::inputStream> is,
const utility::stream::size_type length,
const vmime::encoding& enc = NO_ENCODING);
@@ -67,7 +67,7 @@ public:
streamContentHandler(const streamContentHandler& cts);
streamContentHandler& operator=(const streamContentHandler& cts);
- ref <contentHandler> clone() const;
+ shared_ptr <contentHandler> clone() const;
/** Sets the data managed by this content handler.
*
@@ -79,7 +79,7 @@ public:
* from the stream is already encoded with the specified encoding
*/
void setData
- (ref <utility::inputStream> is,
+ (shared_ptr <utility::inputStream> is,
const utility::stream::size_type length,
const vmime::encoding& enc = NO_ENCODING);
@@ -111,7 +111,7 @@ private:
vmime::encoding m_encoding;
// Actual data
- mutable ref <utility::inputStream> m_stream;
+ mutable shared_ptr <utility::inputStream> m_stream;
string::size_type m_length;
};
diff --git a/vmime/stringContentHandler.hpp b/vmime/stringContentHandler.hpp
index 4565ceb8..b8fdaa71 100644
--- a/vmime/stringContentHandler.hpp
+++ b/vmime/stringContentHandler.hpp
@@ -46,7 +46,7 @@ public:
stringContentHandler(const stringContentHandler& cts);
stringContentHandler& operator=(const stringContentHandler& cts);
- ref <contentHandler> clone() const;
+ shared_ptr <contentHandler> clone() const;
// Set the data contained in the body.
//
diff --git a/vmime/text.hpp b/vmime/text.hpp
index be55bf08..98e2459a 100644
--- a/vmime/text.hpp
+++ b/vmime/text.hpp
@@ -53,18 +53,18 @@ public:
bool operator==(const text& t) const;
bool operator!=(const text& t) const;
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
void copyFrom(const component& other);
text& operator=(const component& other);
text& operator=(const text& other);
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
/** Add a word at the end of the list.
*
* @param w word to append
*/
- void appendWord(ref <word> w);
+ void appendWord(shared_ptr <word> w);
/** Insert a new word before the specified position.
*
@@ -72,14 +72,14 @@ public:
* the beginning of the list)
* @param w word to insert
*/
- void insertWordBefore(const size_t pos, ref <word> w);
+ void insertWordBefore(const size_t pos, shared_ptr <word> w);
/** Insert a new word after the specified position.
*
* @param pos position of the word before the new word
* @param w word to insert
*/
- void insertWordAfter(const size_t pos, ref <word> w);
+ void insertWordAfter(const size_t pos, shared_ptr <word> w);
/** Remove the word at the specified position.
*
@@ -108,26 +108,26 @@ public:
* @param pos position
* @return word at position 'pos'
*/
- const ref <word> getWordAt(const size_t pos);
+ const shared_ptr <word> getWordAt(const size_t pos);
/** Return the word at the specified position.
*
* @param pos position
* @return word at position 'pos'
*/
- const ref <const word> getWordAt(const size_t pos) const;
+ const shared_ptr <const word> getWordAt(const size_t pos) const;
/** Return the word list.
*
* @return list of words
*/
- const std::vector <ref <const word> > getWordList() const;
+ const std::vector <shared_ptr <const word> > getWordList() const;
/** Return the word list.
*
* @return list of words
*/
- const std::vector <ref <word> > getWordList();
+ const std::vector <shared_ptr <word> > getWordList();
/** Return the text converted into the specified charset.
@@ -166,7 +166,7 @@ public:
* @param ch input charset
* @return new text object
*/
- static ref <text> newFromString(const string& in, const charset& ch);
+ static shared_ptr <text> newFromString(const string& in, const charset& ch);
/** This function can be used to make several encoded words from a text.
* All the characters in the text must be in the same specified charset.
@@ -216,7 +216,7 @@ public:
* @param in input string
* @return new text object
*/
- static ref <text> decodeAndUnfold(const string& in);
+ static shared_ptr <text> decodeAndUnfold(const string& in);
/** Decode and unfold text (RFC-2047).
*
@@ -224,7 +224,7 @@ public:
* @param in input string
* @return new text object
*/
- static ref <text> decodeAndUnfold(const parsingContext& ctx, const string& in);
+ static shared_ptr <text> decodeAndUnfold(const parsingContext& ctx, const string& in);
/** Decode and unfold text (RFC-2047), using the default parsing context.
*
@@ -267,7 +267,7 @@ protected:
private:
- std::vector <ref <word> > m_words;
+ std::vector <shared_ptr <word> > m_words;
};
diff --git a/vmime/textPart.hpp b/vmime/textPart.hpp
index 0548de3f..6348f8d7 100644
--- a/vmime/textPart.hpp
+++ b/vmime/textPart.hpp
@@ -73,13 +73,13 @@ public:
*
* @return text of the part
*/
- virtual const ref <const contentHandler> getText() const = 0;
+ virtual const shared_ptr <const contentHandler> getText() const = 0;
/** Set the text contained in the part.
*
* @param text text of the part
*/
- virtual void setText(ref <contentHandler> text) = 0;
+ virtual void setText(shared_ptr <contentHandler> text) = 0;
/** Return the actual body parts this text part is composed of.
* For example, HTML parts are composed of two parts: one "text/html"
@@ -94,7 +94,7 @@ public:
* @param message the message
* @param parent body part into which generate this part
*/
- virtual void generateIn(ref <bodyPart> message, ref <bodyPart> parent) const = 0;
+ virtual void generateIn(shared_ptr <bodyPart> message, shared_ptr <bodyPart> parent) const = 0;
/** Parse the text part(s) from the specified message.
*
@@ -102,7 +102,7 @@ public:
* @param parent part containing the text part
* @param textPart actual text part
*/
- virtual void parse(ref <const bodyPart> message, ref <const bodyPart> parent, ref <const bodyPart> textPart) = 0;
+ virtual void parse(shared_ptr <const bodyPart> message, shared_ptr <const bodyPart> parent, shared_ptr <const bodyPart> textPart) = 0;
};
diff --git a/vmime/textPartFactory.hpp b/vmime/textPartFactory.hpp
index 4112f1ba..f5ce3774 100644
--- a/vmime/textPartFactory.hpp
+++ b/vmime/textPartFactory.hpp
@@ -40,7 +40,7 @@ protected:
textPartFactory();
~textPartFactory();
- typedef ref <textPart> (*AllocFunc)(void);
+ typedef shared_ptr <textPart> (*AllocFunc)(void);
typedef std::vector <std::pair <mediaType, AllocFunc> > MapType;
MapType m_map;
@@ -51,10 +51,10 @@ protected:
{
public:
- static ref <textPart> creator()
+ static shared_ptr <textPart> creator()
{
// Allocate a new object
- return vmime::create <TYPE>();
+ return vmime::make_shared <TYPE>();
}
};
#endif // VMIME_BUILDING_DOC
@@ -69,7 +69,7 @@ public:
m_map.push_back(MapType::value_type(type, &registerer<T>::creator));
}
- ref <textPart> create(const mediaType& type);
+ shared_ptr <textPart> create(const mediaType& type);
};
diff --git a/vmime/types.hpp b/vmime/types.hpp
index d9f5bec6..1a36ea7a 100644
--- a/vmime/types.hpp
+++ b/vmime/types.hpp
@@ -30,7 +30,51 @@
#include <vector>
#include "vmime/config.hpp"
-#include "vmime/utility/smartPtr.hpp"
+
+
+#ifndef VMIME_BUILDING_DOC
+
+#if VMIME_SHARED_PTR_USE_CXX
+ // If we are compiling with C++11, use shared_ptr<> from the standard lib
+ #include <memory>
+
+ #define VMIME_SHARED_PTR_NAMESPACE std
+#elif VMIME_SHARED_PTR_USE_BOOST
+ // Else, use boost's shared_ptr<>
+ #include <boost/shared_ptr.hpp>
+ #include <boost/weak_ptr.hpp>
+ #include <boost/make_shared.hpp>
+ #include <boost/enable_shared_from_this.hpp>
+ #include <boost/shared_ptr.hpp>
+
+ #define VMIME_SHARED_PTR_NAMESPACE boost
+#else
+ #error Either VMIME_SHAREDPTR_USE_CXX or VMIME_SHAREDPTR_USE_BOOST must be set to ON
+#endif
+
+namespace vmime
+{
+ using VMIME_SHARED_PTR_NAMESPACE::shared_ptr;
+ using VMIME_SHARED_PTR_NAMESPACE::weak_ptr;
+ using VMIME_SHARED_PTR_NAMESPACE::make_shared;
+ using VMIME_SHARED_PTR_NAMESPACE::enable_shared_from_this;
+ using VMIME_SHARED_PTR_NAMESPACE::dynamic_pointer_cast;
+ using VMIME_SHARED_PTR_NAMESPACE::const_pointer_cast;
+
+ /** Custom deleter to be used with shared_ptr.
+ * This is does not actually delete the pointer, and is used
+ * only for the singleton classes allocated on the stack.
+ */
+ template <typename T>
+ struct noop_shared_ptr_deleter
+ {
+ void operator()(T*) const {}
+ };
+}
+
+#undef VMIME_SHARED_PTR_NAMESPACE
+
+#endif // VMIME_BUILDING_DOC
namespace vmime
@@ -48,22 +92,12 @@ namespace vmime
typedef unsigned long size_t;
#endif // !VMIME_HAVE_SIZE_T
- // Some aliases
- namespace utils = utility;
-
- using vmime::utility::ref;
- using vmime::utility::weak_ref;
- using vmime::utility::null_ref;
-
- extern const null_ref VMIME_EXPORT null;
-
// For compatibility with versions <= 0.7.1 (deprecated)
namespace net { }
namespace messaging = net;
}
-// This is here because 'vmime::ref' need to be declared...
#include "vmime/object.hpp"
diff --git a/vmime/utility/childProcess.hpp b/vmime/utility/childProcess.hpp
index 637240c1..ebefcf0a 100644
--- a/vmime/utility/childProcess.hpp
+++ b/vmime/utility/childProcess.hpp
@@ -65,13 +65,13 @@ public:
*
* @return output stream wrapper for child's stdin
*/
- virtual ref <utility::outputStream> getStdIn() = 0;
+ virtual shared_ptr <utility::outputStream> getStdIn() = 0;
/** Return a wrapper to the child process standard output.
*
* @return input stream wrapper for child's stdout
*/
- virtual ref <utility::inputStream> getStdOut() = 0;
+ virtual shared_ptr <utility::inputStream> getStdOut() = 0;
/** Wait for the process to finish.
*
@@ -95,7 +95,7 @@ public:
*
* @param path full path of the process executable file
*/
- virtual ref <childProcess> create(const utility::file::path& path) const = 0;
+ virtual shared_ptr <childProcess> create(const utility::file::path& path) const = 0;
};
diff --git a/vmime/utility/encoder/encoderFactory.hpp b/vmime/utility/encoder/encoderFactory.hpp
index 9324ba57..763cbd5c 100644
--- a/vmime/utility/encoder/encoderFactory.hpp
+++ b/vmime/utility/encoder/encoderFactory.hpp
@@ -46,10 +46,10 @@ private:
public:
- static encoderFactory* getInstance();
+ static shared_ptr <encoderFactory> getInstance();
/** Information about a registered encoder. */
- class registeredEncoder : public object
+ class VMIME_EXPORT registeredEncoder : public object
{
protected:
@@ -57,7 +57,7 @@ public:
public:
- virtual ref <encoder> create() const = 0;
+ virtual shared_ptr <encoder> create() const = 0;
virtual const string& getName() const = 0;
};
@@ -67,17 +67,13 @@ private:
template <class E>
class registeredEncoderImpl : public registeredEncoder
{
- friend class vmime::creator;
-
- protected:
+ public:
registeredEncoderImpl(const string& name) : m_name(name) { }
- public:
-
- ref <encoder> create() const
+ shared_ptr <encoder> create() const
{
- return vmime::create <E>();
+ return vmime::make_shared <E>();
}
const string& getName() const
@@ -91,7 +87,7 @@ private:
};
- std::vector <ref <registeredEncoder> > m_encoders;
+ std::vector <shared_ptr <registeredEncoder> > m_encoders;
public:
@@ -102,7 +98,7 @@ public:
template <class E>
void registerName(const string& name)
{
- m_encoders.push_back(vmime::create <registeredEncoderImpl <E> >(utility::stringUtils::toLower(name)));
+ m_encoders.push_back(vmime::make_shared <registeredEncoderImpl <E> >(utility::stringUtils::toLower(name)));
}
/** Create a new encoder instance from an encoding name.
@@ -112,7 +108,7 @@ public:
* @throw exceptions::no_encoder_available if no encoder is registered
* for this encoding
*/
- ref <encoder> create(const string& name);
+ shared_ptr <encoder> create(const string& name);
/** Return information about a registered encoder.
*
@@ -121,7 +117,7 @@ public:
* @throw exceptions::no_encoder_available if no encoder is registered
* for this encoding
*/
- const ref <const registeredEncoder> getEncoderByName(const string& name) const;
+ const shared_ptr <const registeredEncoder> getEncoderByName(const string& name) const;
/** Return the number of registered encoders.
*
@@ -134,13 +130,13 @@ public:
* @param pos position of the registered encoder to return
* @return registered encoder at the specified position
*/
- const ref <const registeredEncoder> getEncoderAt(const size_t pos) const;
+ const shared_ptr <const registeredEncoder> getEncoderAt(const size_t pos) const;
/** Return a list of all registered encoders.
*
* @return list of registered encoders
*/
- const std::vector <ref <const registeredEncoder> > getEncoderList() const;
+ const std::vector <shared_ptr <const registeredEncoder> > getEncoderList() const;
};
diff --git a/vmime/utility/file.hpp b/vmime/utility/file.hpp
index df7962e9..c0ba2c5b 100644
--- a/vmime/utility/file.hpp
+++ b/vmime/utility/file.hpp
@@ -61,7 +61,7 @@ public:
*
* @return next file or NULL
*/
- virtual ref <file> nextElement() = 0;
+ virtual shared_ptr <file> nextElement() = 0;
};
@@ -74,7 +74,7 @@ public:
virtual ~fileWriter() { }
- virtual ref <utility::outputStream> getOutputStream() = 0;
+ virtual shared_ptr <utility::outputStream> getOutputStream() = 0;
};
@@ -87,7 +87,7 @@ public:
virtual ~fileReader() { }
- virtual ref <utility::inputStream> getInputStream() = 0;
+ virtual shared_ptr <utility::inputStream> getInputStream() = 0;
};
@@ -165,7 +165,7 @@ public:
*
* @return parent directory (or NULL if root)
*/
- virtual ref <file> getParent() const = 0;
+ virtual shared_ptr <file> getParent() const = 0;
/** Rename the file/directory.
*
@@ -185,13 +185,13 @@ public:
*
* @return file writer object
*/
- virtual ref <fileWriter> getFileWriter() = 0;
+ virtual shared_ptr <fileWriter> getFileWriter() = 0;
/** Return an object capable of reading from this file.
*
* @return file reader object
*/
- virtual ref <fileReader> getFileReader() = 0;
+ virtual shared_ptr <fileReader> getFileReader() = 0;
/** Enumerate files contained in this directory.
*
@@ -199,7 +199,7 @@ public:
* @throw exceptions::not_a_directory if this is not a directory,
* exceptions::filesystem_exception if another error occurs
*/
- virtual ref <fileIterator> getFiles() const = 0;
+ virtual shared_ptr <fileIterator> getFiles() const = 0;
protected:
@@ -225,7 +225,7 @@ public:
* @param path full path (absolute) of the file
* @return new file object for the path
*/
- virtual ref <file> create(const file::path& path) const = 0;
+ virtual shared_ptr <file> create(const file::path& path) const = 0;
/** Parse a path contained in a string.
*
diff --git a/vmime/utility/parserInputStreamAdapter.hpp b/vmime/utility/parserInputStreamAdapter.hpp
index 00d38279..16ed6f68 100644
--- a/vmime/utility/parserInputStreamAdapter.hpp
+++ b/vmime/utility/parserInputStreamAdapter.hpp
@@ -43,9 +43,9 @@ public:
/** @param stream input stream to wrap
*/
- parserInputStreamAdapter(ref <seekableInputStream> stream);
+ parserInputStreamAdapter(shared_ptr <seekableInputStream> stream);
- ref <seekableInputStream> getUnderlyingStream();
+ shared_ptr <seekableInputStream> getUnderlyingStream();
bool eof() const;
void reset();
@@ -161,7 +161,7 @@ public:
private:
- mutable ref <seekableInputStream> m_stream;
+ mutable shared_ptr <seekableInputStream> m_stream;
};
diff --git a/vmime/utility/seekableInputStreamRegionAdapter.hpp b/vmime/utility/seekableInputStreamRegionAdapter.hpp
index 8947dfc8..ce73b456 100644
--- a/vmime/utility/seekableInputStreamRegionAdapter.hpp
+++ b/vmime/utility/seekableInputStreamRegionAdapter.hpp
@@ -45,7 +45,7 @@ public:
* @param begin start position in source stream
* @param length region length in source stream
*/
- seekableInputStreamRegionAdapter(ref <seekableInputStream> stream,
+ seekableInputStreamRegionAdapter(shared_ptr <seekableInputStream> stream,
const size_type begin, const size_type length);
bool eof() const;
@@ -57,7 +57,7 @@ public:
private:
- ref <seekableInputStream> m_stream;
+ shared_ptr <seekableInputStream> m_stream;
size_type m_begin;
size_type m_length;
size_type m_position;
diff --git a/vmime/utility/smartPtr.hpp b/vmime/utility/smartPtr.hpp
deleted file mode 100644
index 791dbc7f..00000000
--- a/vmime/utility/smartPtr.hpp
+++ /dev/null
@@ -1,550 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#ifndef VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
-#define VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
-
-
-#include <map>
-
-#include "vmime/config.hpp"
-
-
-// Forward reference to 'object'
-namespace vmime { class object; }
-
-
-namespace vmime {
-namespace utility {
-
-
-/** Simple auto-delete pointer.
- */
-
-template <class T>
-class VMIME_EXPORT auto_ptr
-{
-private:
-
- T* const m_ptr;
-
-public:
-
- auto_ptr(T* const ptr) : m_ptr(ptr) { }
- ~auto_ptr() { delete (m_ptr); }
-
- operator T*() { return (m_ptr); }
-
- T* operator ->() { return (m_ptr); }
- T& operator *() { return (*m_ptr); }
-};
-
-
-/** Manage the life cycle of an object.
- */
-
-class VMIME_EXPORT refManager
-{
-protected:
-
- refManager() {}
-
-public:
-
- virtual ~refManager() {}
-
- /** Create a ref manager for the specified object.
- *
- * @return a new manager
- */
- static refManager* create(object* obj);
-
- /** Add a strong reference to the managed object.
- */
- virtual bool addStrong() = 0;
-
- /** Release a strong reference to the managed object.
- * If it is the last reference, the object is destroyed.
- */
- virtual void releaseStrong() = 0;
-
- /** Add a weak reference to the managed object.
- */
- virtual void addWeak() = 0;
-
- /** Release a weak reference to the managed object.
- * If it is the last weak reference, the manager is destroyed.
- */
- virtual void releaseWeak() = 0;
-
- /** Return a raw pointer to the managed object.
- *
- * @return pointer to the managed object
- */
- virtual object* getObject() = 0;
-
- /** Return the number of strong refs to this object.
- * For debugging purposes only.
- *
- * @return strong reference count
- */
- virtual long getStrongRefCount() const = 0;
-
- /** Return the number of weak refs to this object.
- * For debugging purposes only.
- *
- * @return weak reference count
- */
- virtual long getWeakRefCount() const = 0;
-
-protected:
-
- void deleteObjectImpl(object* obj);
-};
-
-
-/** Null reference.
- */
-
-class VMIME_EXPORT null_ref
-{
-};
-
-
-template <class T>
-class weak_ref;
-
-
-/** Shared ownership (strong reference to an object).
- */
-
-template <class T>
-class VMIME_EXPORT ref
-{
-public:
-
- template <class U> friend class ref;
- template <class U> friend class weak_ref;
-
-
- ref() : m_ptr(0) { }
- ref(const ref& r) : m_ptr(0) { attach(r); }
- ref(const null_ref&) : m_ptr(0) { }
-
- virtual ~ref() throw() { detach(); }
-
- // Allow creating NULL ref (NULL casts to anything*)
- ref(class null_pointer*) : m_ptr(0) { }
-
-
- // Access to wrapped object
-// operator const T*() const { return m_ptr; }
- operator const void*() const { return m_ptr; }
-
- T& operator *() { return *m_ptr; }
- const T& operator *() const { return *m_ptr; }
-
- T* operator ->() { return m_ptr; }
- const T* operator ->() const { return m_ptr; }
-
- const T* get() const { return m_ptr; }
- T* get() { return m_ptr; }
-
-
- // dynamic_cast
- template <class U>
- ref <U> dynamicCast() const
- {
- U* p = dynamic_cast <U*>(const_cast <T*>(m_ptr));
- if (!p) return ref <U>();
-
- if (m_ptr)
- m_ptr->getRefManager()->addStrong();
-
- return ref <U>::fromPtrImpl(p);
- }
-
- // static_cast
- template <class U>
- ref <U> staticCast() const
- {
- U* p = static_cast <U*>(const_cast <T*>(m_ptr));
- if (!p) return ref <U>();
-
- if (m_ptr)
- m_ptr->getRefManager()->addStrong();
-
- return ref <U>::fromPtrImpl(p);
- }
-
- // const_cast
- template <class U>
- ref <U> constCast() const
- {
- U* p = const_cast <U*>(m_ptr);
- if (!p) return ref <U>();
-
- if (m_ptr)
- m_ptr->getRefManager()->addStrong();
-
- return ref <U>::fromPtrImpl(p);
- }
-
- // Implicit downcast
- template <class U>
- operator ref <const U>() const
- {
- if (m_ptr)
- m_ptr->getRefManager()->addStrong();
-
- ref <const U> r;
- r.m_ptr = m_ptr; // will type check at compile-time (prevent from implicit upcast)
-
- return r;
- }
-
- template <class U>
- operator ref <U>()
- {
- if (m_ptr)
- m_ptr->getRefManager()->addStrong();
-
- ref <U> r;
- r.m_ptr = m_ptr; // will type check at compile-time (prevent from implicit upcast)
-
- return r;
- }
-
- template <class U>
- ref <T>& operator=(const ref <U>& other)
- {
- U* ptr = other.m_ptr; // will type check at compile-time (prevent from implicit upcast)
-
- if (ptr)
- ptr->getRefManager()->addStrong();
-
- detach();
-
- m_ptr = ptr;
-
- return *this;
- }
-
- // Implicit non-const => const conversion
- operator ref <const T>() const
- {
- if (m_ptr)
- m_ptr->getRefManager()->addStrong();
-
-#if defined(_MSC_VER) // VC++ compiler bug (stack overflow)
- ref <const T> r;
- r.m_ptr = m_ptr;
- return r;
-#else
- return ref <const T>::fromPtrImpl(m_ptr);
-#endif // defined(_MSC_VER)
-
- }
-
- // Copy
- ref& operator=(const ref& p)
- {
- attach(p);
- return *this;
- }
-
- // NULL-pointer comparison
- bool operator==(const class null_pointer*) const { return m_ptr == 0; }
- bool operator!=(const class null_pointer*) const { return m_ptr != 0; }
-
- bool operator==(const null_ref&) const { return m_ptr == 0; }
- bool operator!=(const null_ref&) const { return m_ptr != 0; }
-
- /** Create a ref<> from a raw pointer.
- *
- * WARNING: you should use this function only if you know what
- * you are doing. In general, you should create ref objects using
- * vmime::create().
- *
- * When this function returns, the pointer is owned by the ref,
- * you should not attempt to delete it manually.
- *
- * @param ptr raw pointer to encapsulate
- * @return a ref which encapsulates the specified raw pointer
- */
- static ref <T> fromPtr(T* const ptr)
- {
- return ref <T>::fromPtrImpl(ptr);
- }
-
- static ref <const T> fromPtrConst(const T* const ptr)
- {
- return ref <const T>::fromPtrImpl(ptr);
- }
-
- static ref <T> fromWeak(weak_ref <T> wr)
- {
- refManager* mgr = wr.getManager();
-
- if (mgr && mgr->addStrong())
- return ref <T>::fromPtrImpl(dynamic_cast <T*>(mgr->getObject()));
- else
- return ref <T>();
- }
-
- static ref <const T> fromWeakConst(weak_ref <const T> wr)
- {
- refManager* mgr = wr.getManager();
-
- if (mgr && mgr->addStrong())
- return ref <const T>::fromPtrImpl(dynamic_cast <const T*>(mgr->getObject()));
- else
- return ref <const T>();
- }
-
-protected:
-
- template <class U>
- static ref <U> fromPtrImpl(U* ptr)
- {
- ref <U> r;
- r.m_ptr = ptr;
-
- return r;
- }
-
- void detach()
- {
- if (m_ptr)
- {
- if (m_ptr->getRefManager())
- m_ptr->getRefManager()->releaseStrong();
-
- m_ptr = 0;
- }
- }
-
- template <class U>
- void attach(U* const ptr)
- {
- if (ptr)
- ptr->getRefManager()->addStrong();
-
- detach();
-
- m_ptr = ptr;
- }
-
- template <class U>
- void attach(const ref <U>& r)
- {
- if (r.m_ptr)
- r.m_ptr->getRefManager()->addStrong();
-
- detach();
-
- m_ptr = r.m_ptr;
- }
-
-private:
-
- T* m_ptr;
-};
-
-
-
-template <class T, class U>
-bool operator==(const ref <T>& a, const ref <U>& b)
-{
- return (a.get() == b.get());
-}
-
-template <class T, class U>
-bool operator!=(const ref <T>& a, const ref <U>& b)
-{
- return (a.get() != b.get());
-}
-
-template <class T>
-bool operator==(const ref <T>& a, T* const p)
-{
- return (a.get() == p);
-}
-
-template <class T>
-bool operator!=(const ref <T>& a, T* const p)
-{
- return (a.get() != p);
-}
-
-template <class T>
-bool operator==(T* const p, const ref <T>& a)
-{
- return (a.get() == p);
-}
-
-template <class T>
-bool operator!=(T* const p, const ref <T>& a)
-{
- return (a.get() != p);
-}
-
-template <class T>
-bool operator==(const null_ref&, const ref <T>& r)
-{
- return (r.get() == 0);
-}
-
-template <class T>
-bool operator!=(const null_ref&, const ref <T>& r)
-{
- return (r.get() != 0);
-}
-
-
-
-/** Weak reference.
- * Avoid circular references.
- */
-
-template <class T>
-class VMIME_EXPORT weak_ref
-{
-public:
-
- template <class U> friend class weak_ref;
-
-
- weak_ref() : m_mgr(0) { }
- weak_ref(const ref <T>& r) : m_mgr(0) { attach(r); }
- weak_ref(const weak_ref& r) : m_mgr(0) { attach(r); }
- weak_ref(const null_ref&) : m_mgr(0) { }
- weak_ref(class null_pointer*) : m_mgr(0) { }
-
- ~weak_ref() { detach(); }
-
- /** Return the manager for the object.
- *
- * @return pointer to the object which manages the object
- * or NULL if the weak reference points to nothing
- */
- refManager* getManager()
- {
- return m_mgr;
- }
-
- /** Try to acquire a strong reference to the object (const version).
- *
- * @return strong reference or null reference if the
- * object is not available anymore
- */
- ref <const T> acquire() const
- {
- return ref <const T>::fromWeakConst(*this);
- }
-
- /** Try to acquire a strong reference to the object.
- *
- * @return strong reference or null reference if the
- * object is not available anymore
- */
- ref <T> acquire()
- {
- return ref <T>::fromWeak(*this);
- }
-
- // Implicit non-const => const conversion
- operator weak_ref <const T>() const
- {
- if (m_mgr)
- m_mgr->addWeak();
-
- weak_ref <const T> r;
- r.m_mgr = m_mgr;
-
- return r;
- }
-
- template <class U>
- operator weak_ref <const U>() const
- {
- if (m_mgr)
- m_mgr->addWeak();
-
- weak_ref <const U> r;
- r.m_mgr = m_mgr;
-
- return r;
- }
-
- // Copy
- weak_ref& operator=(const weak_ref& p)
- {
- attach(p);
- return *this;
- }
-
-private:
-
- void detach()
- {
- if (m_mgr)
- {
- m_mgr->releaseWeak();
- m_mgr = 0;
- }
- }
-
- void attach(const ref <T>& r)
- {
- if (r.m_ptr)
- r.m_ptr->getRefManager()->addWeak();
-
- detach();
-
- if (r.m_ptr)
- m_mgr = r.m_ptr->getRefManager();
- else
- m_mgr = 0;
- }
-
- void attach(const weak_ref& r)
- {
- if (r.m_mgr)
- r.m_mgr->addWeak();
-
- detach();
-
- m_mgr = r.m_mgr;
- }
-
-
- refManager* m_mgr;
-};
-
-
-} // utility
-} // vmime
-
-
-#endif // VMIME_UTILITY_SMARTPTR_HPP_INCLUDED
diff --git a/vmime/utility/smartPtrInt.hpp b/vmime/utility/smartPtrInt.hpp
deleted file mode 100644
index 36c4ff01..00000000
--- a/vmime/utility/smartPtrInt.hpp
+++ /dev/null
@@ -1,113 +0,0 @@
-//
-// VMime library (http://www.vmime.org)
-// Copyright (C) 2002-2013 Vincent Richard <[email protected]>
-//
-// This program is free software; you can redistribute it and/or
-// modify it under the terms of the GNU General Public License as
-// published by the Free Software Foundation; either version 3 of
-// the License, or (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
-// General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License along
-// with this program; if not, write to the Free Software Foundation, Inc.,
-// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
-//
-// Linking this library statically or dynamically with other modules is making
-// a combined work based on this library. Thus, the terms and conditions of
-// the GNU General Public License cover the whole combination.
-//
-
-#ifndef VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED
-#define VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED
-
-
-#include "vmime/config.hpp"
-#include "vmime/utility/smartPtr.hpp"
-
-#if defined(_WIN32)
-# include <windows.h>
-#elif defined(VMIME_HAVE_PTHREAD)
-# include <pthread.h>
-#endif
-
-
-namespace vmime {
-namespace utility {
-
-
-/** Reference counter for shared pointers.
- */
-
-class refCounter
-{
-public:
-
- refCounter(const long initialValue);
- ~refCounter();
-
- long increment();
- long decrement();
-
- operator long() const;
-
-private:
-
-#if defined(_WIN32)
- long m_value;
-#elif defined(__GNUC__) && (defined(__GLIBCPP__) || defined(__GLIBCXX__))
- mutable volatile int m_value;
-#elif defined (VMIME_HAVE_PTHREAD)
- volatile long m_value;
- pthread_mutex_t m_mutex;
-#else // not thread-safe implementation
- long m_value;
-#endif
-
-};
-
-
-/** Separate implementation of refManager, to avoid polluting global
- * namespace with system-specific inclusions/definitions.
- */
-
-class refManagerImpl : public refManager
-{
-public:
-
- refManagerImpl(object* obj);
- ~refManagerImpl();
-
- bool addStrong();
- void releaseStrong();
-
- void addWeak();
- void releaseWeak();
-
- object* getObject();
-
- long getStrongRefCount() const;
- long getWeakRefCount() const;
-
-private:
-
- void deleteManager();
- void deleteObject();
-
-
- object* m_object;
-
- refCounter m_strongCount;
- refCounter m_weakCount;
-};
-
-
-} // utility
-} // vmime
-
-
-#endif // VMIME_UTILITY_SMARTPTRIMPL_HPP_INCLUDED
-
diff --git a/vmime/utility/sync/autoLock.hpp b/vmime/utility/sync/autoLock.hpp
index 3f1231b7..c058429d 100644
--- a/vmime/utility/sync/autoLock.hpp
+++ b/vmime/utility/sync/autoLock.hpp
@@ -41,7 +41,7 @@ class VMIME_EXPORT autoLock : public object
{
public:
- autoLock(ref <M> mutex)
+ autoLock(shared_ptr <M> mutex)
: m_mutex(mutex)
{
m_mutex->lock();
@@ -54,7 +54,7 @@ public:
private:
- ref <M> m_mutex;
+ shared_ptr <M> m_mutex;
};
diff --git a/vmime/word.hpp b/vmime/word.hpp
index d460ccad..29d2969c 100644
--- a/vmime/word.hpp
+++ b/vmime/word.hpp
@@ -111,7 +111,7 @@ public:
*
* @return a copy of this word
*/
- ref <component> clone() const;
+ shared_ptr <component> clone() const;
#ifndef VMIME_BUILDING_DOC
@@ -160,11 +160,11 @@ public:
generatorState* state) const;
#endif
- const std::vector <ref <component> > getChildComponents();
+ const std::vector <shared_ptr <component> > getChildComponents();
private:
- static ref <word> parseNext
+ static shared_ptr <word> parseNext
(const parsingContext& ctx,
const string& buffer,
const string::size_type position,
@@ -174,7 +174,7 @@ private:
bool* isEncoded,
bool isFirst);
- static const std::vector <ref <word> > parseMultiple
+ static const std::vector <shared_ptr <word> > parseMultiple
(const parsingContext& ctx,
const string& buffer,
const string::size_type position,
diff --git a/vmime/wordEncoder.hpp b/vmime/wordEncoder.hpp
index b2003ac7..557578fa 100644
--- a/vmime/wordEncoder.hpp
+++ b/vmime/wordEncoder.hpp
@@ -101,7 +101,7 @@ private:
charset m_charset;
Encoding m_encoding;
- ref <utility::encoder::encoder> m_encoder;
+ shared_ptr <utility::encoder::encoder> m_encoder;
};