From 9c197e0ed1c1b6fff5134ddd8db4ea5dcc9bc9df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Sun, 15 Dec 2019 09:40:40 +0100 Subject: [PATCH] finally get rid of std::auto_ptr --- ApacheConnector/src/ApacheConnector.cpp | 41 ++++++------------- CppUnit/include/CppUnit/TestCaller.h | 8 +--- Crypto/include/Poco/Crypto/PKCS12Container.h | 4 -- Foundation/include/Poco/DynamicFactory.h | 20 ++++----- Foundation/src/NumericString.cpp | 16 +++----- .../testsuite/src/DynamicFactoryTest.cpp | 27 ++++-------- .../testsuite/src/LoggingFactoryTest.cpp | 16 +++----- Net/samples/download/src/download.cpp | 8 +--- Net/src/HTTPServerConnection.cpp | 10 ++--- Net/src/TCPServerDispatcher.cpp | 28 ++++++------- Net/testsuite/src/FTPStreamFactoryTest.cpp | 36 ++++------------ Net/testsuite/src/HTTPStreamFactoryTest.cpp | 16 -------- .../samples/download/src/download.cpp | 12 ++---- .../testsuite/src/HTTPSStreamFactoryTest.cpp | 16 -------- .../testsuite/src/WebSocketTest.cpp | 20 ++++----- NetSSL_Win/samples/download/src/download.cpp | 10 ++--- .../testsuite/src/HTTPSStreamFactoryTest.cpp | 18 +------- PageCompiler/src/PageCompiler.cpp | 4 -- PocoDoc/src/PocoDoc.cpp | 4 -- 19 files changed, 85 insertions(+), 229 deletions(-) diff --git a/ApacheConnector/src/ApacheConnector.cpp b/ApacheConnector/src/ApacheConnector.cpp index ac5e0cd87..af0eac4a1 100644 --- a/ApacheConnector/src/ApacheConnector.cpp +++ b/ApacheConnector/src/ApacheConnector.cpp @@ -175,19 +175,19 @@ extern "C" int ApacheConnector_handler(request_rec *r) { ApacheRequestRec rec(r); ApacheApplication& app(ApacheApplication::instance()); - + try { // ensure application is ready app.setup(); - + // if the ApacheRequestHandler declines handling - we stop // request handling here and let other modules do their job! if (!app.factory().mustHandle(r->uri)) return DECLINED; apr_status_t rv; - if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) + if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK))) return rv; // The properties conn_rec->remote_ip and conn_rec->remote_addr have undergone significant changes in Apache 2.4. @@ -199,16 +199,6 @@ extern "C" int ApacheConnector_handler(request_rec *r) const char* clientIp = r->connection->client_ip; apr_port_t clientPort = r->connection->client_addr->port; #endif -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pRequest(new ApacheServerRequest( - &rec, - r->connection->local_ip, - r->connection->local_addr->port, - clientIp, - clientPort)); - - std::auto_ptr pResponse(new ApacheServerResponse(pRequest.get())); -#else std::unique_ptr pRequest(new ApacheServerRequest( &rec, r->connection->local_ip, @@ -217,22 +207,17 @@ extern "C" int ApacheConnector_handler(request_rec *r) clientPort)); std::unique_ptr pResponse(new ApacheServerResponse(pRequest.get())); -#endif // POCO_ENABLE_CPP11 // add header information to request rec.copyHeaders(*pRequest); - + try { -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pHandler(app.factory().createRequestHandler(*pRequest)); -#else std::unique_ptr pHandler(app.factory().createRequestHandler(*pRequest)); -#endif // POCO_ENABLE_CPP11 if (pHandler.get()) - { + { pHandler->handleRequest(*pRequest, *pResponse); } else @@ -300,25 +285,25 @@ extern "C" const char* ApacheConnector_config(cmd_parms *cmd, void *in_dconf, co } -extern "C" const command_rec ApacheConnector_cmds[] = +extern "C" const command_rec ApacheConnector_cmds[] = { AP_INIT_RAW_ARGS( - "AddPocoRequestHandler", - reinterpret_cast(ApacheConnector_uris), + "AddPocoRequestHandler", + reinterpret_cast(ApacheConnector_uris), NULL, - RSRC_CONF, + RSRC_CONF, "POCO RequestHandlerFactory class name followed by shared library path followed by a list of ' ' separated URIs that must be handled by this module."), AP_INIT_RAW_ARGS( - "AddPocoConfig", - reinterpret_cast(ApacheConnector_config), + "AddPocoConfig", + reinterpret_cast(ApacheConnector_config), NULL, - RSRC_CONF, + RSRC_CONF, "Path of the POCO configuration file."), { NULL } }; -module AP_MODULE_DECLARE_DATA poco_module = +module AP_MODULE_DECLARE_DATA poco_module = { STANDARD20_MODULE_STUFF, NULL, diff --git a/CppUnit/include/CppUnit/TestCaller.h b/CppUnit/include/CppUnit/TestCaller.h index 77009df2b..46f29c15c 100644 --- a/CppUnit/include/CppUnit/TestCaller.h +++ b/CppUnit/include/CppUnit/TestCaller.h @@ -54,8 +54,8 @@ class TestCaller: public TestCase typedef void (Fixture::*TestMethod)(); public: - TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal): - TestCase(name, testType), + TestCaller(const std::string& name, TestMethod test, Test::Type testType = Test::Normal): + TestCase(name, testType), _test(test), _fixture(new Fixture(name)) { @@ -81,11 +81,7 @@ protected: private: TestMethod _test; -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr _fixture; -#else std::unique_ptr _fixture; -#endif // POCO_ENABLE_CPP11 }; diff --git a/Crypto/include/Poco/Crypto/PKCS12Container.h b/Crypto/include/Poco/Crypto/PKCS12Container.h index 63cc224d8..7bb614488 100644 --- a/Crypto/include/Poco/Crypto/PKCS12Container.h +++ b/Crypto/include/Poco/Crypto/PKCS12Container.h @@ -90,11 +90,7 @@ private: void load(PKCS12* pPKCS12, const std::string& password = ""); std::string extractFriendlyName(X509* pCert); -#ifdef POCO_ENABLE_CPP11 typedef std::unique_ptr CertPtr; -#else - typedef std::auto_ptr CertPtr; -#endif // #ifdef POCO_ENABLE_CPP11 OpenSSLInitializer _openSSLInitializer; EVP_PKEY* _pKey; diff --git a/Foundation/include/Poco/DynamicFactory.h b/Foundation/include/Poco/DynamicFactory.h index 5f9420493..12a2ce286 100644 --- a/Foundation/include/Poco/DynamicFactory.h +++ b/Foundation/include/Poco/DynamicFactory.h @@ -42,7 +42,7 @@ public: } ~DynamicFactory() - /// Destroys the DynamicFactory and deletes the instantiators for + /// Destroys the DynamicFactory and deletes the instantiators for /// all registered classes. { for (typename FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it) @@ -50,7 +50,7 @@ public: delete it->second; } } - + Base* createInstance(const std::string& className) const /// Creates a new instance of the class with the given name. /// The class must have been registered with registerClass. @@ -64,8 +64,8 @@ public: else throw NotFoundException(className); } - - template + + template void registerClass(const std::string& className) /// Registers the instantiator for the given class with the DynamicFactory. /// The DynamicFactory takes ownership of the instantiator and deletes @@ -75,7 +75,7 @@ public: { registerClass(className, new Instantiator); } - + void registerClass(const std::string& className, AbstractFactory* pAbstractFactory) /// Registers the instantiator for the given class with the DynamicFactory. /// The DynamicFactory takes ownership of the instantiator and deletes @@ -87,11 +87,7 @@ public: FastMutex::ScopedLock lock(_mutex); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr ptr(pAbstractFactory); -#else std::unique_ptr ptr(pAbstractFactory); -#endif // POCO_ENABLE_CPP11 typename FactoryMap::iterator it = _map.find(className); if (it == _map.end()) @@ -99,7 +95,7 @@ public: else throw ExistsException(className); } - + void unregisterClass(const std::string& className) /// Unregisters the given class and deletes the instantiator /// for the class. @@ -115,7 +111,7 @@ public: } else throw NotFoundException(className); } - + bool isClass(const std::string& className) const /// Returns true iff the given class has been registered. { @@ -129,7 +125,7 @@ private: DynamicFactory& operator = (const DynamicFactory&); typedef std::map FactoryMap; - + FactoryMap _map; mutable FastMutex _mutex; }; diff --git a/Foundation/src/NumericString.cpp b/Foundation/src/NumericString.cpp index 3c2c4c8c8..4724b5e83 100644 --- a/Foundation/src/NumericString.cpp +++ b/Foundation/src/NumericString.cpp @@ -58,11 +58,7 @@ void pad(std::string& str, int precision, int width, char prefix = ' ', char dec std::string::size_type frac = str.length() - decSepPos - 1; std::string::size_type ePos = str.find_first_of("eE"); -#ifdef POCO_ENABLE_CPP11 std::unique_ptr eStr; -#else - std::auto_ptr eStr; -#endif if (ePos != std::string::npos) { eStr.reset(new std::string(str.substr(ePos, std::string::npos))); @@ -201,7 +197,7 @@ std::string& floatToStr(std::string& str, float value, int precision, int width, char buffer[POCO_MAX_FLT_STRING_LEN]; floatToStr(buffer, POCO_MAX_FLT_STRING_LEN, value); str = buffer; - + if (decSep && (decSep != '.') && (str.find('.') != std::string::npos)) replaceInPlace(str, '.', decSep); @@ -219,7 +215,7 @@ std::string& floatToFixedStr(std::string& str, float value, int precision, int w char buffer[POCO_MAX_FLT_STRING_LEN]; floatToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision); str = buffer; - + if (decSep && (decSep != '.') && (str.find('.') != std::string::npos)) replaceInPlace(str, '.', decSep); @@ -263,9 +259,9 @@ std::string& doubleToStr(std::string& str, double value, int precision, int widt char buffer[POCO_MAX_FLT_STRING_LEN]; doubleToStr(buffer, POCO_MAX_FLT_STRING_LEN, value); - + str = buffer; - + if (decSep && (decSep != '.') && (str.find('.') != std::string::npos)) replaceInPlace(str, '.', decSep); @@ -282,9 +278,9 @@ std::string& doubleToFixedStr(std::string& str, double value, int precision, int char buffer[POCO_MAX_FLT_STRING_LEN]; doubleToFixedStr(buffer, POCO_MAX_FLT_STRING_LEN, value, precision); - + str = buffer; - + if (decSep && (decSep != '.') && (str.find('.') != std::string::npos)) replaceInPlace(str, '.', decSep); diff --git a/Foundation/testsuite/src/DynamicFactoryTest.cpp b/Foundation/testsuite/src/DynamicFactoryTest.cpp index 5456fc749..cb1e4c0f4 100644 --- a/Foundation/testsuite/src/DynamicFactoryTest.cpp +++ b/Foundation/testsuite/src/DynamicFactoryTest.cpp @@ -28,16 +28,16 @@ namespace Base() { } - + virtual ~Base() { } }; - + class A: public Base { }; - + class B: public Base { }; @@ -57,26 +57,21 @@ DynamicFactoryTest::~DynamicFactoryTest() void DynamicFactoryTest::testDynamicFactory() { DynamicFactory dynFactory; - + dynFactory.registerClass("A"); dynFactory.registerClass("B"); - + assertTrue (dynFactory.isClass("A")); assertTrue (dynFactory.isClass("B")); - + assertTrue (!dynFactory.isClass("C")); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr a(dynamic_cast(dynFactory.createInstance("A"))); - std::auto_ptr b(dynamic_cast(dynFactory.createInstance("B"))); -#else std::unique_ptr a(dynamic_cast(dynFactory.createInstance("A"))); std::unique_ptr b(dynamic_cast(dynFactory.createInstance("B"))); -#endif // POCO_ENABLE_CPP11 assertNotNull(a.get()); assertNotNull(b.get()); - + try { dynFactory.registerClass("A"); @@ -85,18 +80,14 @@ void DynamicFactoryTest::testDynamicFactory() catch (Poco::ExistsException&) { } - + dynFactory.unregisterClass("B"); assertTrue (dynFactory.isClass("A")); assertTrue (!dynFactory.isClass("B")); - + try { -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr b(dynamic_cast(dynFactory.createInstance("B"))); -#else std::unique_ptr b(dynamic_cast(dynFactory.createInstance("B"))); -#endif // POCO_ENABLE_CPP11 fail("unregistered - must throw"); } catch (Poco::NotFoundException&) diff --git a/Foundation/testsuite/src/LoggingFactoryTest.cpp b/Foundation/testsuite/src/LoggingFactoryTest.cpp index 1e7c2dd5b..056f4943a 100644 --- a/Foundation/testsuite/src/LoggingFactoryTest.cpp +++ b/Foundation/testsuite/src/LoggingFactoryTest.cpp @@ -49,7 +49,7 @@ namespace { } }; - + class CustomFormatter: public Formatter { void format(const Message& msg, std::string& text) @@ -72,7 +72,7 @@ LoggingFactoryTest::~LoggingFactoryTest() void LoggingFactoryTest::testBuiltins() { LoggingFactory& fact = LoggingFactory::defaultFactory(); - + AutoPtr pConsoleChannel = fact.createChannel("ConsoleChannel"); #if defined(_WIN32) && !defined(_WIN32_WCE) assertTrue (dynamic_cast(pConsoleChannel.get()) != 0); @@ -82,10 +82,10 @@ void LoggingFactoryTest::testBuiltins() AutoPtr pFileChannel = fact.createChannel("FileChannel"); assertTrue (dynamic_cast(pFileChannel.get()) != 0); - + AutoPtr pSplitterChannel = fact.createChannel("SplitterChannel"); assertTrue (dynamic_cast(pSplitterChannel.get()) != 0); - + try { AutoPtr pUnknownChannel = fact.createChannel("UnknownChannel"); @@ -94,10 +94,10 @@ void LoggingFactoryTest::testBuiltins() catch (Poco::NotFoundException&) { } - + AutoPtr pPatternFormatter = fact.createFormatter("PatternFormatter"); assertTrue (dynamic_cast(pPatternFormatter.get()) != 0); - + try { AutoPtr pUnknownFormatter = fact.createFormatter("UnknownFormatter"); @@ -111,11 +111,7 @@ void LoggingFactoryTest::testBuiltins() void LoggingFactoryTest::testCustom() { -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr fact(new LoggingFactory); -#else std::unique_ptr fact(new LoggingFactory); -#endif // POCO_ENABLE_CPP11 fact->registerChannelClass("CustomChannel", new Instantiator); fact->registerFormatterClass("CustomFormatter", new Instantiator); diff --git a/Net/samples/download/src/download.cpp b/Net/samples/download/src/download.cpp index eb7e40324..028edcac8 100644 --- a/Net/samples/download/src/download.cpp +++ b/Net/samples/download/src/download.cpp @@ -34,7 +34,7 @@ int main(int argc, char** argv) { HTTPStreamFactory::registerFactory(); FTPStreamFactory::registerFactory(); - + if (argc != 2) { Path p(argv[0]); @@ -47,11 +47,7 @@ int main(int argc, char** argv) try { URI uri(argv[1]); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(URIStreamOpener::defaultOpener().open(uri)); -#else std::unique_ptr pStr(URIStreamOpener::defaultOpener().open(uri)); -#endif // POCO_ENABLE_CPP11 StreamCopier::copyStream(*pStr.get(), std::cout); } catch (Exception& exc) @@ -59,6 +55,6 @@ int main(int argc, char** argv) std::cerr << exc.displayText() << std::endl; return 1; } - + return 0; } diff --git a/Net/src/HTTPServerConnection.cpp b/Net/src/HTTPServerConnection.cpp index a6c27ce8c..eb822812c 100644 --- a/Net/src/HTTPServerConnection.cpp +++ b/Net/src/HTTPServerConnection.cpp @@ -36,7 +36,7 @@ HTTPServerConnection::HTTPServerConnection(const StreamSocket& socket, HTTPServe _stopped(false) { poco_check_ptr (pFactory); - + _pFactory->serverStopped += Poco::delegate(this, &HTTPServerConnection::onServerStopped); } @@ -67,7 +67,7 @@ void HTTPServerConnection::run() { HTTPServerResponseImpl response(session); HTTPServerRequestImpl request(response, session, _pParams); - + Poco::Timestamp now; response.setDate(now); response.setVersion(request.getVersion()); @@ -76,16 +76,12 @@ void HTTPServerConnection::run() response.set("Server", server); try { -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pHandler(_pFactory->createRequestHandler(request)); -#else std::unique_ptr pHandler(_pFactory->createRequestHandler(request)); -#endif if (pHandler.get()) { if (request.getExpectContinue() && response.getStatus() == HTTPResponse::HTTP_OK) response.sendContinue(); - + pHandler->handleRequest(request, response); session.setKeepAlive(_pParams->getKeepAlive() && response.getKeepAlive() && session.canKeepAlive()); } diff --git a/Net/src/TCPServerDispatcher.cpp b/Net/src/TCPServerDispatcher.cpp index ee2f36b33..5134beca8 100644 --- a/Net/src/TCPServerDispatcher.cpp +++ b/Net/src/TCPServerDispatcher.cpp @@ -35,11 +35,11 @@ public: _socket(socket) { } - + ~TCPConnectionNotification() { } - + const StreamSocket& socket() const { return _socket; @@ -66,7 +66,7 @@ TCPServerDispatcher::TCPServerDispatcher(TCPServerConnectionFactory::Ptr pFactor if (!_pParams) _pParams = new TCPServerParams; - + if (_pParams->getMaxThreads() == 0) _pParams->setMaxThreads(threadPool.capacity()); } @@ -108,18 +108,14 @@ void TCPServerDispatcher::run() TCPConnectionNotification* pCNf = dynamic_cast(pNf.get()); if (pCNf) { -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pConnection(_pConnectionFactory->createConnection(pCNf->socket())); -#else std::unique_ptr pConnection(_pConnectionFactory->createConnection(pCNf->socket())); -#endif // POCO_ENABLE_CPP11 poco_check_ptr(pConnection.get()); beginConnection(); pConnection->start(); endConnection(); } } - + FastMutex::ScopedLock lock(_mutex); if (_stopped || (_currentThreads > 1 && _queue.empty())) { @@ -135,7 +131,7 @@ namespace static const std::string threadName("TCPServerConnection"); } - + void TCPServerDispatcher::enqueue(const StreamSocket& socket) { FastMutex::ScopedLock lock(_mutex); @@ -179,14 +175,14 @@ void TCPServerDispatcher::stop() int TCPServerDispatcher::currentThreads() const { FastMutex::ScopedLock lock(_mutex); - + return _currentThreads; } int TCPServerDispatcher::maxThreads() const { FastMutex::ScopedLock lock(_mutex); - + return _threadPool.capacity(); } @@ -194,7 +190,7 @@ int TCPServerDispatcher::maxThreads() const int TCPServerDispatcher::totalConnections() const { FastMutex::ScopedLock lock(_mutex); - + return _totalConnections; } @@ -202,7 +198,7 @@ int TCPServerDispatcher::totalConnections() const int TCPServerDispatcher::currentConnections() const { FastMutex::ScopedLock lock(_mutex); - + return _currentConnections; } @@ -210,7 +206,7 @@ int TCPServerDispatcher::currentConnections() const int TCPServerDispatcher::maxConcurrentConnections() const { FastMutex::ScopedLock lock(_mutex); - + return _maxConcurrentConnections; } @@ -224,7 +220,7 @@ int TCPServerDispatcher::queuedConnections() const int TCPServerDispatcher::refusedConnections() const { FastMutex::ScopedLock lock(_mutex); - + return _refusedConnections; } @@ -232,7 +228,7 @@ int TCPServerDispatcher::refusedConnections() const void TCPServerDispatcher::beginConnection() { FastMutex::ScopedLock lock(_mutex); - + ++_totalConnections; ++_currentConnections; if (_currentConnections > _maxConcurrentConnections) diff --git a/Net/testsuite/src/FTPStreamFactoryTest.cpp b/Net/testsuite/src/FTPStreamFactoryTest.cpp index 2d8b08119..0f3b7b129 100644 --- a/Net/testsuite/src/FTPStreamFactoryTest.cpp +++ b/Net/testsuite/src/FTPStreamFactoryTest.cpp @@ -79,16 +79,12 @@ void FTPStreamFactoryTest::testDownload() uri.setPort(server.port()); uri.setPath("/test.txt;type=a"); FTPStreamFactory sf; -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(sf.open(uri)); -#else std::unique_ptr pStr(sf.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream dataStr; StreamCopier::copyStream(*pStr.get(), dataStr); - + pStr.reset(); - + std::string s(dataStr.str()); assertTrue (s == "line1\r\nline2\r\n"); } @@ -120,17 +116,13 @@ void FTPStreamFactoryTest::testList() uri.setPort(server.port()); uri.setPath("/usr/guest/data;type=d"); FTPStreamFactory sf; -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(sf.open(uri)); -#else std::unique_ptr pStr(sf.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream dataStr; StreamCopier::copyStream(*pStr.get(), dataStr); - + pStr.reset(); - + std::string s(dataStr.str()); assertTrue (s == "file1\r\nfile2\r\n"); } @@ -162,17 +154,13 @@ void FTPStreamFactoryTest::testUserInfo() uri.setPath("/test.txt;type=a"); uri.setUserInfo("user:secret"); FTPStreamFactory sf; -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(sf.open(uri)); -#else std::unique_ptr pStr(sf.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream dataStr; StreamCopier::copyStream(*pStr.get(), dataStr); - + pStr.reset(); - + std::string s(dataStr.str()); assertTrue (s == "line1\r\nline2\r\n"); } @@ -205,17 +193,13 @@ void FTPStreamFactoryTest::testPasswordProvider() uri.setPath("/test.txt;type=a"); uri.setUserInfo("user"); FTPStreamFactory sf; -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(sf.open(uri)); -#else std::unique_ptr pStr(sf.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream dataStr; StreamCopier::copyStream(*pStr.get(), dataStr); - + pStr.reset(); - + std::string s(dataStr.str()); assertTrue (s == "line1\r\nline2\r\n"); } @@ -239,11 +223,7 @@ void FTPStreamFactoryTest::testMissingPasswordProvider() try { FTPStreamFactory sf; -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(sf.open(uri)); -#else std::unique_ptr pStr(sf.open(uri)); -#endif // POCO_ENABLE_CPP11 fail("no password provider - must throw"); } catch (FTPException&) diff --git a/Net/testsuite/src/HTTPStreamFactoryTest.cpp b/Net/testsuite/src/HTTPStreamFactoryTest.cpp index 5b80c9c19..abd591e41 100644 --- a/Net/testsuite/src/HTTPStreamFactoryTest.cpp +++ b/Net/testsuite/src/HTTPStreamFactoryTest.cpp @@ -44,11 +44,7 @@ void HTTPStreamFactoryTest::testNoRedirect() HTTPStreamFactory factory; URI uri("http://127.0.0.1/large"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY); @@ -61,11 +57,7 @@ void HTTPStreamFactoryTest::testEmptyPath() HTTPStreamFactory factory; URI uri("http://127.0.0.1"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPTestServer::SMALL_BODY); @@ -79,11 +71,7 @@ void HTTPStreamFactoryTest::testRedirect() opener.registerStreamFactory("http", new HTTPStreamFactory); URI uri("http://127.0.0.1/redirect"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(opener.open(uri)); -#else std::unique_ptr pStr(opener.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY); @@ -95,11 +83,7 @@ void HTTPStreamFactoryTest::testProxy() HTTPTestServer server; HTTPStreamFactory factory("127.0.0.1", server.port()); URI uri("http://www.somehost.com/large"); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPTestServer::LARGE_BODY); diff --git a/NetSSL_OpenSSL/samples/download/src/download.cpp b/NetSSL_OpenSSL/samples/download/src/download.cpp index dcf60614b..99911c9bd 100644 --- a/NetSSL_OpenSSL/samples/download/src/download.cpp +++ b/NetSSL_OpenSSL/samples/download/src/download.cpp @@ -50,7 +50,7 @@ public: { Poco::Net::initializeSSL(); } - + ~SSLInitializer() { Poco::Net::uninitializeSSL(); @@ -64,7 +64,7 @@ int main(int argc, char** argv) HTTPStreamFactory::registerFactory(); HTTPSStreamFactory::registerFactory(); FTPStreamFactory::registerFactory(); - + if (argc != 2) { Path p(argv[0]); @@ -74,7 +74,7 @@ int main(int argc, char** argv) return 1; } - // Note: we must create the passphrase handler prior Context + // Note: we must create the passphrase handler prior Context SharedPtr ptrCert = new ConsoleCertificateHandler(false); // ask the user via console Context::Ptr ptrContext = new Context(Context::CLIENT_USE, "", "", "rootcert.pem", Context::VERIFY_RELAXED, 9, false, "ALL:!ADH:!LOW:!EXP:!MD5:@STRENGTH"); SSLManager::instance().initializeClient(0, ptrCert, ptrContext); @@ -82,11 +82,7 @@ int main(int argc, char** argv) try { URI uri(argv[1]); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(URIStreamOpener::defaultOpener().open(uri)); -#else std::unique_ptr pStr(URIStreamOpener::defaultOpener().open(uri)); -#endif StreamCopier::copyStream(*pStr.get(), std::cout); } catch (Exception& exc) @@ -94,6 +90,6 @@ int main(int argc, char** argv) std::cerr << exc.displayText() << std::endl; return 1; } - + return 0; } diff --git a/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp b/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp index 9b1c80cb7..ab2003c50 100644 --- a/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp +++ b/NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp @@ -47,11 +47,7 @@ void HTTPSStreamFactoryTest::testNoRedirect() HTTPSStreamFactory factory; URI uri("https://127.0.0.1/large"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY); @@ -64,11 +60,7 @@ void HTTPSStreamFactoryTest::testEmptyPath() HTTPSStreamFactory factory; URI uri("https://127.0.0.1"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPSTestServer::SMALL_BODY); @@ -81,11 +73,7 @@ void HTTPSStreamFactoryTest::testRedirect() HTTPSStreamFactory factory; URI uri("https://127.0.0.1/redirect"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY); @@ -100,11 +88,7 @@ void HTTPSStreamFactoryTest::testProxy() Application::instance().config().getInt("testsuite.proxy.port") ); URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str().length() > 0); diff --git a/NetSSL_OpenSSL/testsuite/src/WebSocketTest.cpp b/NetSSL_OpenSSL/testsuite/src/WebSocketTest.cpp index 1203f54e5..453b6687f 100644 --- a/NetSSL_OpenSSL/testsuite/src/WebSocketTest.cpp +++ b/NetSSL_OpenSSL/testsuite/src/WebSocketTest.cpp @@ -49,11 +49,7 @@ namespace try { WebSocket ws(request, response); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pBuffer(new char[_bufSize]); -#else std::unique_ptr pBuffer(new char[_bufSize]); -#endif // POCO_ENABLE_CPP11 int flags; int n; do @@ -86,7 +82,7 @@ namespace private: std::size_t _bufSize; }; - + class WebSocketRequestHandlerFactory: public Poco::Net::HTTPRequestHandlerFactory { public: @@ -120,9 +116,9 @@ void WebSocketTest::testWebSocket() Poco::Net::SecureServerSocket ss(0); Poco::Net::HTTPServer server(new WebSocketRequestHandlerFactory, ss, new Poco::Net::HTTPServerParams); server.start(); - + Poco::Thread::sleep(200); - + HTTPSClientSession cs("127.0.0.1", ss.address().port()); HTTPRequest request(HTTPRequest::HTTP_GET, "/ws"); HTTPResponse response; @@ -163,19 +159,19 @@ void WebSocketTest::testWebSocket() assertTrue (n == payload.size()); assertTrue (payload.compare(0, payload.size(), buffer, 0, n) == 0); assertTrue (flags == WebSocket::FRAME_TEXT); - + payload = "Hello, universe!"; ws.sendFrame(payload.data(), (int) payload.size(), WebSocket::FRAME_BINARY); n = ws.receiveFrame(buffer, sizeof(buffer), flags); assertTrue (n == payload.size()); assertTrue (payload.compare(0, payload.size(), buffer, 0, n) == 0); - assertTrue (flags == WebSocket::FRAME_BINARY); - + assertTrue (flags == WebSocket::FRAME_BINARY); + ws.shutdown(); n = ws.receiveFrame(buffer, sizeof(buffer), flags); assertTrue (n == 2); assertTrue ((flags & WebSocket::FRAME_OP_BITMASK) == WebSocket::FRAME_OP_CLOSE); - + server.stop(); } @@ -189,7 +185,7 @@ void WebSocketTest::testWebSocketLarge() server.start(); Poco::Thread::sleep(200); - + HTTPSClientSession cs("127.0.0.1", ss.address().port()); HTTPRequest request(HTTPRequest::HTTP_GET, "/ws"); HTTPResponse response; diff --git a/NetSSL_Win/samples/download/src/download.cpp b/NetSSL_Win/samples/download/src/download.cpp index 896410a05..820149830 100644 --- a/NetSSL_Win/samples/download/src/download.cpp +++ b/NetSSL_Win/samples/download/src/download.cpp @@ -48,7 +48,7 @@ public: { Poco::Net::initializeSSL(); } - + ~SSLInitializer() { Poco::Net::uninitializeSSL(); @@ -62,7 +62,7 @@ int main(int argc, char** argv) HTTPStreamFactory::registerFactory(); HTTPSStreamFactory::registerFactory(); FTPStreamFactory::registerFactory(); - + if (argc != 2) { Path p(argv[0]); @@ -79,11 +79,7 @@ int main(int argc, char** argv) try { URI uri(argv[1]); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(URIStreamOpener::defaultOpener().open(uri)); -#else std::unique_ptr pStr(URIStreamOpener::defaultOpener().open(uri)); -#endif // POCO_ENABLE_CPP11 StreamCopier::copyStream(*pStr.get(), std::cout); } catch (Exception& exc) @@ -91,6 +87,6 @@ int main(int argc, char** argv) std::cerr << exc.displayText() << std::endl; return 1; } - + return 0; } diff --git a/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp b/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp index 52b8a2535..cafcaaae7 100644 --- a/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp +++ b/NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp @@ -47,11 +47,7 @@ void HTTPSStreamFactoryTest::testNoRedirect() HTTPSStreamFactory factory; URI uri("https://127.0.0.1/large"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY); @@ -64,11 +60,7 @@ void HTTPSStreamFactoryTest::testEmptyPath() HTTPSStreamFactory factory; URI uri("https://127.0.0.1"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPSTestServer::SMALL_BODY); @@ -81,11 +73,7 @@ void HTTPSStreamFactoryTest::testRedirect() HTTPSStreamFactory factory; URI uri("https://127.0.0.1/redirect"); uri.setPort(server.port()); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str() == HTTPSTestServer::LARGE_BODY); @@ -96,15 +84,11 @@ void HTTPSStreamFactoryTest::testProxy() { HTTPSTestServer server; HTTPSStreamFactory factory( - Application::instance().config().getString("testsuite.proxy.host"), + Application::instance().config().getString("testsuite.proxy.host"), Application::instance().config().getInt("testsuite.proxy.port") ); URI uri("https://secure.appinf.com/public/poco/NetSSL.txt"); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pStr(factory.open(uri)); -#else std::unique_ptr pStr(factory.open(uri)); -#endif // POCO_ENABLE_CPP11 std::ostringstream ostr; StreamCopier::copyStream(*pStr.get(), ostr); assertTrue (ostr.str().length() > 0); diff --git a/PageCompiler/src/PageCompiler.cpp b/PageCompiler/src/PageCompiler.cpp index 8d3bbd17d..1fd7e51ba 100644 --- a/PageCompiler/src/PageCompiler.cpp +++ b/PageCompiler/src/PageCompiler.cpp @@ -295,11 +295,7 @@ protected: p.setBaseName(clazz); } -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pCodeWriter(createCodeWriter(page, clazz)); -#else std::unique_ptr pCodeWriter(createCodeWriter(page, clazz)); -#endif if (!_outputDir.empty()) { diff --git a/PocoDoc/src/PocoDoc.cpp b/PocoDoc/src/PocoDoc.cpp index 56604a995..045b8bffe 100644 --- a/PocoDoc/src/PocoDoc.cpp +++ b/PocoDoc/src/PocoDoc.cpp @@ -303,11 +303,7 @@ protected: void parse(const std::string& file) { logger().information("Preprocessing " + file); -#ifndef POCO_ENABLE_CPP11 - std::auto_ptr pPreProc(preprocess(file)); -#else std::unique_ptr pPreProc(preprocess(file)); -#endif // POCO_ENABLE_CPP11 logger().information("Parsing " + file); if (pPreProc->stream().good()) {