Skip to content

Commit

Permalink
ifdef auto_ptr
Browse files Browse the repository at this point in the history
  • Loading branch information
aleks-f committed Oct 25, 2017
1 parent 87ec631 commit 1a18621
Show file tree
Hide file tree
Showing 17 changed files with 130 additions and 18 deletions.
18 changes: 17 additions & 1 deletion ApacheConnector/src/ApacheConnector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,9 @@ extern "C" int ApacheConnector_handler(request_rec *r)

apr_status_t rv;
if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)))
return rv;
return rv;

#ifndef POCO_ENABLE_CPP11
std::auto_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
&rec,
r->connection->local_ip,
Expand All @@ -180,13 +181,28 @@ extern "C" int ApacheConnector_handler(request_rec *r)
r->connection->remote_addr->port));

std::auto_ptr<ApacheServerResponse> pResponse(new ApacheServerResponse(pRequest.get()));
#else
std::unique_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
&rec,
r->connection->local_ip,
r->connection->local_addr->port,
r->connection->remote_ip,
r->connection->remote_addr->port));

std::unique_ptr<ApacheServerResponse> 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<HTTPRequestHandler> pHandler(app.factory().createRequestHandler(*pRequest));
#else
std::unique_ptr<HTTPRequestHandler> pHandler(app.factory().createRequestHandler(*pRequest));
#endif // POCO_ENABLE_CPP11

if (pHandler.get())
{
Expand Down
4 changes: 2 additions & 2 deletions CppUnit/include/CppUnit/TestCaller.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ class TestCaller: public TestCase

private:
TestMethod _test;
#if __cplusplus < 201103L
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<Fixture> _fixture;
#else
std::unique_ptr<Fixture> _fixture;
#endif
#endif // POCO_ENABLE_CPP11
};


Expand Down
5 changes: 3 additions & 2 deletions Foundation/include/Poco/DynamicFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,12 @@ class DynamicFactory

FastMutex::ScopedLock lock(_mutex);

#if __cplusplus < 201103L
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<AbstractFactory> ptr(pAbstractFactory);
#else
std::unique_ptr<AbstractFactory> ptr(pAbstractFactory);
#endif
#endif // POCO_ENABLE_CPP11

typename FactoryMap::iterator it = _map.find(className);
if (it == _map.end())
_map[className] = ptr.release();
Expand Down
4 changes: 2 additions & 2 deletions Foundation/src/NumericString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,11 @@ 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");
#if __cplusplus < 201103L
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::string> eStr;
#else
std::unique_ptr<std::string> eStr;
#endif
#endif // POCO_ENABLE_CPP11
if (ePos != std::string::npos)
{
eStr.reset(new std::string(str.substr(ePos, std::string::npos)));
Expand Down
13 changes: 11 additions & 2 deletions Foundation/testsuite/src/DynamicFactoryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,15 @@ void DynamicFactoryTest::testDynamicFactory()
assert (dynFactory.isClass("B"));

assert (!dynFactory.isClass("C"));


#ifndef POCO_ENABLE_CPP11
std::auto_ptr<A> a(dynamic_cast<A*>(dynFactory.createInstance("A")));
std::auto_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));

#else
std::unique_ptr<A> a(dynamic_cast<A*>(dynFactory.createInstance("A")));
std::unique_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));
#endif // POCO_ENABLE_CPP11

assertNotNull(a.get());
assertNotNull(b.get());

Expand All @@ -87,7 +92,11 @@ void DynamicFactoryTest::testDynamicFactory()

try
{
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));
#else
std::unique_ptr<B> b(dynamic_cast<B*>(dynFactory.createInstance("B")));
#endif // POCO_ENABLE_CPP11
fail("unregistered - must throw");
}
catch (Poco::NotFoundException&)
Expand Down
6 changes: 5 additions & 1 deletion Foundation/testsuite/src/LoggingFactoryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,12 @@ void LoggingFactoryTest::testBuiltins()

void LoggingFactoryTest::testCustom()
{
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<LoggingFactory> fact(new LoggingFactory);

#else
std::unique_ptr<LoggingFactory> fact(new LoggingFactory);
#endif // POCO_ENABLE_CPP11

fact->registerChannelClass("CustomChannel", new Instantiator<CustomChannel, Channel>);
fact->registerFormatterClass("CustomFormatter", new Instantiator<CustomFormatter, Formatter>);

Expand Down
4 changes: 4 additions & 0 deletions Net/samples/download/src/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ int main(int argc, char** argv)
try
{
URI uri(argv[1]);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#else
std::unique_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#endif // POCO_ENABLE_CPP11
StreamCopier::copyStream(*pStr.get(), std::cout);
}
catch (Exception& exc)
Expand Down
2 changes: 1 addition & 1 deletion Net/src/HTTPServerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ void HTTPServerConnection::run()
response.set("Server", server);
try
{
#if __cplusplus < 201103L
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
#else
std::unique_ptr<HTTPRequestHandler> pHandler(_pFactory->createRequestHandler(request));
Expand Down
4 changes: 2 additions & 2 deletions Net/src/TCPServerDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ void TCPServerDispatcher::run()
TCPConnectionNotification* pCNf = dynamic_cast<TCPConnectionNotification*>(pNf.get());
if (pCNf)
{
#if __cplusplus < 201103L
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket()));
#else
std::unique_ptr<TCPServerConnection> pConnection(_pConnectionFactory->createConnection(pCNf->socket()));
#endif
#endif // POCO_ENABLE_CPP11
poco_check_ptr(pConnection.get());
beginConnection();
pConnection->start();
Expand Down
21 changes: 20 additions & 1 deletion Net/testsuite/src/FTPStreamFactoryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,11 @@ void FTPStreamFactoryTest::testDownload()
uri.setPort(server.port());
uri.setPath("/test.txt;type=a");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));

#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);

Expand Down Expand Up @@ -117,7 +120,11 @@ void FTPStreamFactoryTest::testList()
uri.setPort(server.port());
uri.setPath("/usr/guest/data;type=d");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11

std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
Expand Down Expand Up @@ -155,7 +162,11 @@ void FTPStreamFactoryTest::testUserInfo()
uri.setPath("/test.txt;type=a");
uri.setUserInfo("user:secret");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11

std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
Expand Down Expand Up @@ -194,7 +205,11 @@ void FTPStreamFactoryTest::testPasswordProvider()
uri.setPath("/test.txt;type=a");
uri.setUserInfo("user");
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11

std::ostringstream dataStr;
StreamCopier::copyStream(*pStr.get(), dataStr);
Expand Down Expand Up @@ -224,7 +239,11 @@ void FTPStreamFactoryTest::testMissingPasswordProvider()
try
{
FTPStreamFactory sf;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(sf.open(uri));
#else
std::unique_ptr<std::istream> pStr(sf.open(uri));
#endif // POCO_ENABLE_CPP11
fail("no password provider - must throw");
}
catch (FTPException&)
Expand Down
16 changes: 16 additions & 0 deletions Net/testsuite/src/HTTPStreamFactoryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ void HTTPStreamFactoryTest::testNoRedirect()
HTTPStreamFactory factory;
URI uri("http://localhost/large");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPTestServer::LARGE_BODY);
Expand All @@ -57,7 +61,11 @@ void HTTPStreamFactoryTest::testEmptyPath()
HTTPStreamFactory factory;
URI uri("http://localhost");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPTestServer::SMALL_BODY);
Expand All @@ -71,7 +79,11 @@ void HTTPStreamFactoryTest::testRedirect()
opener.registerStreamFactory("http", new HTTPStreamFactory);
URI uri("http://localhost/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(opener.open(uri));
#else
std::unique_ptr<std::istream> pStr(opener.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPTestServer::LARGE_BODY);
Expand All @@ -83,7 +95,11 @@ void HTTPStreamFactoryTest::testProxy()
HTTPTestServer server;
HTTPStreamFactory factory("localhost", server.port());
URI uri("http://www.somehost.com/large");
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPTestServer::LARGE_BODY);
Expand Down
4 changes: 4 additions & 0 deletions NetSSL_OpenSSL/samples/download/src/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,11 @@ int main(int argc, char** argv)
try
{
URI uri(argv[1]);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#else
std::unique_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#endif
StreamCopier::copyStream(*pStr.get(), std::cout);
}
catch (Exception& exc)
Expand Down
16 changes: 16 additions & 0 deletions NetSSL_OpenSSL/testsuite/src/HTTPSStreamFactoryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ void HTTPSStreamFactoryTest::testNoRedirect()
HTTPSStreamFactory factory;
URI uri("https://localhost/large");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
Expand All @@ -60,7 +64,11 @@ void HTTPSStreamFactoryTest::testEmptyPath()
HTTPSStreamFactory factory;
URI uri("https://localhost");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::SMALL_BODY);
Expand All @@ -73,7 +81,11 @@ void HTTPSStreamFactoryTest::testRedirect()
HTTPSStreamFactory factory;
URI uri("https://localhost/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
Expand All @@ -88,7 +100,11 @@ 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<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str().length() > 0);
Expand Down
4 changes: 4 additions & 0 deletions NetSSL_Win/samples/download/src/download.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ int main(int argc, char** argv)
try
{
URI uri(argv[1]);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#else
std::unique_ptr<std::istream> pStr(URIStreamOpener::defaultOpener().open(uri));
#endif // POCO_ENABLE_CPP11
StreamCopier::copyStream(*pStr.get(), std::cout);
}
catch (Exception& exc)
Expand Down
16 changes: 16 additions & 0 deletions NetSSL_Win/testsuite/src/HTTPSStreamFactoryTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,11 @@ void HTTPSStreamFactoryTest::testNoRedirect()
HTTPSStreamFactory factory;
URI uri("https://localhost/large");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
Expand All @@ -60,7 +64,11 @@ void HTTPSStreamFactoryTest::testEmptyPath()
HTTPSStreamFactory factory;
URI uri("https://localhost");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::SMALL_BODY);
Expand All @@ -73,7 +81,11 @@ void HTTPSStreamFactoryTest::testRedirect()
HTTPSStreamFactory factory;
URI uri("https://localhost/redirect");
uri.setPort(server.port());
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPSTestServer::LARGE_BODY);
Expand All @@ -88,7 +100,11 @@ 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<std::istream> pStr(factory.open(uri));
#else
std::unique_ptr<std::istream> pStr(factory.open(uri));
#endif // POCO_ENABLE_CPP11
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str().length() > 0);
Expand Down
2 changes: 1 addition & 1 deletion PageCompiler/src/PageCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class CompilerApp: public Application
p.setBaseName(clazz);
}

#if __cplusplus < 201103L
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<CodeWriter> pCodeWriter(createCodeWriter(page, clazz));
#else
std::unique_ptr<CodeWriter> pCodeWriter(createCodeWriter(page, clazz));
Expand Down
Loading

0 comments on commit 1a18621

Please sign in to comment.