ifdef auto_ptr

This commit is contained in:
Alex Fabijanic 2017-10-24 21:55:33 -05:00
parent 87ec631b4a
commit 1a18621ff8
17 changed files with 130 additions and 18 deletions

View File

@ -172,6 +172,7 @@ extern "C" int ApacheConnector_handler(request_rec *r)
if ((rv = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)))
return rv;
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<ApacheServerRequest> pRequest(new ApacheServerRequest(
&rec,
r->connection->local_ip,
@ -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())
{

View File

@ -79,11 +79,11 @@ protected:
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
};

View File

@ -87,11 +87,12 @@ public:
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();

View File

@ -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)));

View File

@ -66,8 +66,13 @@ void DynamicFactoryTest::testDynamicFactory()
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());
@ -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&)

View File

@ -111,7 +111,11 @@ 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>);

View File

@ -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)

View File

@ -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));

View File

@ -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();

View File

@ -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);
@ -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);
@ -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);
@ -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);
@ -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&)

View File

@ -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);
@ -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);
@ -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);
@ -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);

View File

@ -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)

View File

@ -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);
@ -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);
@ -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);
@ -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);

View File

@ -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)

View File

@ -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);
@ -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);
@ -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);
@ -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);

View File

@ -283,7 +283,7 @@ protected:
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));

View File

@ -261,8 +261,11 @@ protected:
void parse(const std::string& file)
{
logger().information("Preprocessing " + file);
#ifndef POCO_ENABLE_CPP11
std::auto_ptr<Preprocessor> pPreProc(preprocess(file));
#else
std::unique_ptr<Preprocessor> pPreProc(preprocess(file));
#endif // POCO_ENABLE_CPP11
logger().information("Parsing " + file);
if (pPreProc->stream().good())
{