Skip to content

Commit f24547c

Browse files
matejkaleks-f
andcommitted
enh(Poco): Mark deprecated functionality with C++ attributes and resolve internal usage of deprecated functions (pocoproject#4551)
* enh(poco): Replace deprecated comments with C++ deprecated attribute. * enh(Poco): Replace some deprecated functionality in Poco sources. (pocoproject#4426) * enh(Poco): Replace more deprecated functionality in Poco sources. (pocoproject#4426) * fix(CMake): Variable BUILD_SHARED_LIBS must be defined properly to create valid binaries. * enh: Code improvements done while resolving deprecated functionality (pocoproject#4426) * Un-deprecate LocalDateTme (pocoproject#4426) * enh(Poco): Replace usage of deprecated functionality with other functions/classes (pocoproject#4426) * chore(SSL): temporarily un-deprecate SSL-related functionality (pocoproject#4426) * chore(SSL): temporarily un-deprecate old MongoDB protocol functionality (pocoproject#4426) * enh(Poco): Minor Hash improvements (pocoproject#4426) * enh(Foundation): Compile deprecated hash tests only when POCO_TEST_DEPRECATED is enabled (pocoproject#4426) * enh(Net): Compile deprecated Socket::select functionality only when POCO_TEST_DEPRECATED is enabled (pocoproject#4426) * enh(Bonjour): Replace deprecated Socket::select with PollSet (pocoproject#4426) * enh(Poco): Introduce POCO_DEPRECATED macro to have the ability to disable deprecation warnings in applications (pocoproject#4426) * test(ODBC): add few asserts to testStoredProcedureDynamicVar * fix(ODBC): rename DynamicAny -> DynamicVar in tests * fix(ODBC): make Dignostics static members inline to prevent explicit instantiation warnings on windows --------- Co-authored-by: Alex Fabijanic <[email protected]>
1 parent 5117e27 commit f24547c

File tree

112 files changed

+586
-550
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

112 files changed

+586
-550
lines changed

CMakeLists.txt

+1-6
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,7 @@ include(GNUInstallDirs)
6565
# Include some common macros to simpilfy the Poco CMake files
6666
include(PocoMacros)
6767

68-
if(POCO_STATIC)
69-
message(WARNING "POCO_STATIC has been deprecated. Please use BUILD_SHARED_LIBS=NO to build static libraries.")
70-
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)
71-
else()
72-
option(BUILD_SHARED_LIBS "Build shared libraries" ON)
73-
endif()
68+
option(BUILD_SHARED_LIBS "Build using shared libraries" ON)
7469

7570
if(MSVC)
7671
option(POCO_MT "Set to OFF|ON (default is OFF) to control build of POCO as /MT instead of /MD" OFF)

CppUnit/src/TestCase.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ void TestCase::assertEquals(const char* expected, const std::string& actual, lon
8181

8282
void TestCase::assertNotNull(const void* pointer, const std::string& pointerExpression, long lineNumber, const std::string& fileName)
8383
{
84-
if (pointer == NULL)
84+
if (pointer == nullptr)
8585
throw CppUnitException(pointerExpression + " must not be NULL", lineNumber, fileName);
8686
}
8787

8888

8989
void TestCase::assertNull(const void* pointer, const std::string& pointerExpression, long lineNumber, const std::string& fileName)
9090
{
91-
if (pointer != NULL)
91+
if (pointer != nullptr)
9292
throw CppUnitException(pointerExpression + " must be NULL", lineNumber, fileName);
9393
}
9494

CppUnit/src/TextTestResult.cpp

+6-8
Original file line numberDiff line numberDiff line change
@@ -162,19 +162,18 @@ void TextTestResult::printErrors(std::ostream& stream)
162162
stream << "There were " << testErrors() << " errors: " << std::endl;
163163

164164
int i = 1;
165-
for (std::vector<TestFailure*>::iterator it = errors().begin(); it != errors().end(); ++it)
165+
for (const auto& failure : errors())
166166
{
167-
TestFailure* failure = *it;
168167
CppUnitException* e = failure->thrownException();
169168

170169
stream << std::setw(2) << i
171170
<< ": "
172171
<< failure->failedTest()->toString() << "\n"
173-
<< " \"" << (e ? e->what() : "") << "\"\n"
172+
<< " \"" << (e ? e->what() : "") << "\"\n"
174173
<< " in \""
175174
<< (e ? e->fileName() : std::string())
176175
<< "\", line ";
177-
if (e == 0)
176+
if (e == nullptr)
178177
{
179178
stream << "0";
180179
}
@@ -210,10 +209,9 @@ void TextTestResult::printFailures(std::ostream& stream)
210209

211210
int i = 1;
212211

213-
for (std::vector<TestFailure*>::iterator it = failures().begin(); it != failures().end(); ++it)
212+
for (const auto& failure : failures())
214213
{
215-
TestFailure* failure = *it;
216-
CppUnitException* e = failure->thrownException();
214+
CppUnitException* e = failure->thrownException();
217215

218216
stream << std::setw(2) << i
219217
<< ": "
@@ -222,7 +220,7 @@ void TextTestResult::printFailures(std::ostream& stream)
222220
<< " in \""
223221
<< (e ? e->fileName() : std::string())
224222
<< "\", line ";
225-
if (e == 0)
223+
if (e == nullptr)
226224
{
227225
stream << "0";
228226
}

Crypto/include/Poco/Crypto/ECKey.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ namespace Crypto {
3131
class X509Certificate;
3232
class PKCS12Container;
3333

34+
//class [[deprecated]] ECKey;
3435

35-
//@ deprecated
3636
class Crypto_API ECKey: public KeyPair
3737
/// This class stores an EC key pair, consisting
3838
/// of private and public key. Storage of the private

Crypto/include/Poco/Crypto/ECKeyImpl.h

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222
#include "Poco/Crypto/Crypto.h"
2323
#include "Poco/Crypto/EVPPKey.h"
2424
#include "Poco/Crypto/KeyPairImpl.h"
25-
#include "Poco/Crypto/OpenSSLInitializer.h"
26-
#include "Poco/RefCountedObject.h"
2725
#include "Poco/AutoPtr.h"
2826
#include <istream>
2927
#include <ostream>

Crypto/include/Poco/Crypto/EVPPKey.h

+10-10
Original file line numberDiff line numberDiff line change
@@ -28,16 +28,15 @@
2828
#include <openssl/evp.h>
2929
#include <openssl/pem.h>
3030
#include <sstream>
31-
#include <typeinfo>
3231
#include <map>
3332

3433

3534
namespace Poco {
3635
namespace Crypto {
3736

38-
//@deprecated
37+
//class [[deprecated]] ECKey;
38+
//class [[deprecated]] RSAKey;
3939
class ECKey;
40-
//@deprecated
4140
class RSAKey;
4241
class PKCS12Container;
4342
class X509Certificate;
@@ -93,8 +92,8 @@ class Crypto_API EVPPKey
9392
/// Constructs EVPPKey from EVP_PKEY pointer.
9493
/// The content behind the supplied pointer is internally duplicated.
9594

96-
//@ deprecated
9795
template<typename K>
96+
//[[deprecated]] explicit EVPPKey(K* pKey): _pEVPPKey(EVP_PKEY_new())
9897
explicit EVPPKey(K* pKey): _pEVPPKey(EVP_PKEY_new())
9998
/// Constructs EVPPKey from a "native" OpenSSL (RSA or EC_KEY),
10099
/// or a Poco wrapper (RSAKey, ECKey) key pointer.
@@ -185,13 +184,16 @@ class Crypto_API EVPPKey
185184
void newECKey(const char* group);
186185
void duplicate(EVP_PKEY* pEVPPKey);
187186

188-
//@ deprecated
187+
//[[deprecated]]
189188
void setKey(ECKey* pKey);
190-
//@ deprecated
189+
190+
//[[deprecated]]
191191
void setKey(RSAKey* pKey);
192-
//@ deprecated
192+
193+
//[[deprecated]]
193194
void setKey(EC_KEY* pKey);
194-
//@ deprecated
195+
196+
//[[deprecated]]
195197
void setKey(RSA* pKey);
196198

197199
static int passCB(char* buf, int size, int, void* pass);
@@ -336,9 +338,7 @@ class Crypto_API EVPPKey
336338
EVP_PKEY* _pEVPPKey = 0;
337339
static const std::map<int, std::string> KNOWN_TYPES;
338340

339-
//@deprecated
340341
friend class ECKeyImpl;
341-
//@deprecated
342342
friend class RSAKeyImpl;
343343
};
344344

Crypto/include/Poco/Crypto/RSADigestEngine.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class Crypto_API RSADigestEngine: public Poco::DigestEngine
5151
DIGEST_SHA1
5252
};
5353

54-
//@ deprecated
54+
//[[deprecated]] RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1);
5555
RSADigestEngine(const RSAKey& key, DigestType digestType = DIGEST_SHA1);
5656
/// Creates the RSADigestEngine with the given RSA key,
5757
/// using the MD5 or SHA-1 hash algorithm.

Crypto/include/Poco/Crypto/RSAKey.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,8 @@ namespace Crypto {
3030
class X509Certificate;
3131
class PKCS12Container;
3232

33+
//class [[deprecated]] RSAKey;
3334

34-
//@ deprecated
3535
class Crypto_API RSAKey: public KeyPair
3636
/// This class stores an RSA key pair, consisting
3737
/// of private and public key. Storage of the private
@@ -81,7 +81,7 @@ class Crypto_API RSAKey: public KeyPair
8181
/// OpenSSL will auto-create the public key from the private key.
8282

8383
RSAKey(std::istream* pPublicKeyStream,
84-
std::istream* pPrivateKeyStream = 0,
84+
std::istream* pPrivateKeyStream = nullptr,
8585
const std::string& privateKeyPassphrase = "");
8686
/// Creates the RSAKey, by reading public and private key from the given streams and
8787
/// using the given passphrase for the private key.
@@ -132,4 +132,4 @@ inline RSAKeyImpl::Ptr RSAKey::impl() const
132132
} } // namespace Poco::Crypto
133133

134134

135-
#endif // Crypto_RSAKey_INCLUDED
135+
#endif // Crypto_RSAKey_INCLUDED

Crypto/testsuite/src/ECTest.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ ECTest::~ECTest()
3232
{
3333
}
3434

35+
#if defined(POCO_TEST_DEPRECATED)
3536

3637
void ECTest::testECNewKeys()
3738
{
@@ -176,6 +177,7 @@ void ECTest::testECDSASignManipulated()
176177
}
177178
}
178179

180+
#endif
179181

180182
void ECTest::setUp()
181183
{
@@ -191,10 +193,13 @@ CppUnit::Test* ECTest::suite()
191193
{
192194
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ECTest");
193195

196+
#if defined(POCO_TEST_DEPRECATED)
197+
194198
CppUnit_addTest(pSuite, ECTest, testECNewKeys);
195199
CppUnit_addTest(pSuite, ECTest, testECNewKeysNoPassphrase);
196200
CppUnit_addTest(pSuite, ECTest, testECDSASignSha256);
197201
CppUnit_addTest(pSuite, ECTest, testECDSASignManipulated);
198202

203+
#endif
199204
return pSuite;
200205
}

Crypto/testsuite/src/ECTest.h

+4
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,15 @@ class ECTest: public CppUnit::TestCase
2525
ECTest(const std::string& name);
2626
~ECTest();
2727

28+
#if defined(POCO_TEST_DEPRECATED)
29+
2830
void testECNewKeys();
2931
void testECNewKeysNoPassphrase();
3032
void testECDSASignSha256();
3133
void testECDSASignManipulated();
3234

35+
#endif
36+
3337
void setUp();
3438
void tearDown();
3539

DNSSD/Bonjour/include/Poco/DNSSD/Bonjour/EventLoop.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DNSSD_Bonjour_API EventLoop: public Poco::Runnable
4141
/// Bonjour machinery.
4242
{
4343
public:
44-
typedef Poco::ScopedLock<EventLoop> ScopedLock;
44+
using ScopedLock = Poco::ScopedLock<EventLoop>;
4545

4646
enum
4747
{
@@ -51,7 +51,7 @@ class DNSSD_Bonjour_API EventLoop: public Poco::Runnable
5151
EventLoop();
5252
/// Creates the EventLoop.
5353

54-
~EventLoop();
54+
~EventLoop() override;
5555
/// Destroys the EventLoop.
5656

5757
void add(DNSServiceRef sdRef);

DNSSD/Bonjour/src/EventLoop.cpp

+30-38
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
#include "Poco/DNSSD/Bonjour/EventLoop.h"
18+
#include "Poco/Net/PollSet.h"
1819
#include "Poco/Net/StreamSocket.h"
1920
#include "Poco/Net/StreamSocketImpl.h"
2021
#include <dns_sd.h>
@@ -46,11 +47,9 @@ EventLoop::~EventLoop()
4647

4748
void EventLoop::shutdown()
4849
{
49-
RefToSock::iterator it = _refs.begin();
50-
RefToSock::iterator itEnd = _refs.end();
51-
for (; it != itEnd; ++it)
50+
for (auto& it: _refs)
5251
{
53-
DNSServiceRefDeallocate(it->first);
52+
DNSServiceRefDeallocate(it.first);
5453
}
5554
_refs.clear();
5655
_sockets.clear();
@@ -83,7 +82,7 @@ void EventLoop::remove(DNSServiceRef sdRef)
8382

8483
void EventLoop::removeImpl(DNSServiceRef sdRef)
8584
{
86-
RefToSock::iterator it = _refs.find(sdRef);
85+
auto it = _refs.find(sdRef);
8786
if (it != _refs.end())
8887
{
8988
_sockets.erase(it->second);
@@ -95,59 +94,52 @@ void EventLoop::removeImpl(DNSServiceRef sdRef)
9594

9695
void EventLoop::run()
9796
{
98-
Poco::Net::Socket::SocketList readList;
99-
Poco::Net::Socket::SocketList writeList;
100-
Poco::Net::Socket::SocketList errList;
97+
Poco::Net::PollSet pollSet;
10198

10299
while (!_stop)
103100
{
104-
readList.clear();
105101
if (!_refs.empty() || _refAdded.tryWait(EVENTLOOP_TIMEOUT))
106102
{
107-
Poco::Mutex::ScopedLock lock(_mutex);
108-
109-
RefToSock::const_iterator it = _refs.begin();
110-
RefToSock::const_iterator itEnd = _refs.end();
111-
for (; it != itEnd; ++it)
103+
Poco::Mutex::ScopedLock lock(_mutex);
104+
for (const auto& r: _refs)
112105
{
113-
readList.push_back(it->second);
106+
pollSet.add(r.second, Net::Socket::SELECT_READ);
114107
}
115108
}
116109

117-
if (!readList.empty())
110+
if (!pollSet.empty())
118111
{
119-
Poco::Timespan timeout(1000*EVENTLOOP_TIMEOUT);
120-
int ready = Poco::Net::Socket::select(readList, writeList, errList, timeout);
121-
if (ready > 0)
112+
Poco::Timespan timeout(1000LL * EVENTLOOP_TIMEOUT);
113+
const auto sm = pollSet.poll(timeout);
114+
if (!sm.empty())
122115
{
123-
Poco::Net::Socket::SocketList::iterator it = readList.begin();
124-
Poco::Net::Socket::SocketList::iterator itEnd = readList.end();
125-
for (; it != itEnd; ++it)
116+
for (const auto& it: sm)
126117
{
127118
Poco::Mutex::ScopedLock lock(_mutex);
128-
129-
SockToRef::iterator itSock = _sockets.find(*it);
130-
poco_assert_dbg (itSock != _sockets.end());
131-
RefSet::iterator itSet = _invalidatedRefs.find(itSock->second);
132-
if (itSet != _invalidatedRefs.end())
119+
if (it.second & Net::PollSet::POLL_READ)
133120
{
134-
removeImpl(itSock->second);
135-
_invalidatedRefs.erase(itSet);
136-
}
137-
else
138-
{
139-
DNSServiceProcessResult(itSock->second);
121+
auto& socket = it.first;
122+
const auto itSock = _sockets.find(socket);
123+
poco_assert_dbg (itSock != _sockets.end());
124+
auto itSet = _invalidatedRefs.find(itSock->second);
125+
if (itSet != _invalidatedRefs.end())
126+
{
127+
removeImpl(itSock->second);
128+
_invalidatedRefs.erase(itSet);
129+
}
130+
else
131+
{
132+
DNSServiceProcessResult(itSock->second);
133+
}
140134
}
141135
}
142136
}
143137
}
144138

145-
Poco::Mutex::ScopedLock lock(_mutex);
146-
RefSet::iterator itSet =_invalidatedRefs.begin();
147-
RefSet::iterator itSetEnd = _invalidatedRefs.end();
148-
for (; itSet != itSetEnd; ++itSet)
139+
Poco::Mutex::ScopedLock lock(_mutex);
140+
for (auto& ir: _invalidatedRefs)
149141
{
150-
removeImpl(*itSet);
142+
removeImpl(ir);
151143
}
152144
_invalidatedRefs.clear();
153145
}

Data/DataTest/src/SQLExecutor.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2983,7 +2983,7 @@ void SQLExecutor::filter(const std::string& query, const std::string& intFldName
29832983
{
29842984
Statement stmt = (session() << query, now);
29852985
RecordSet rset(stmt);
2986-
assertTrue (rset.totalRowCount() == 4);
2986+
assertTrue (rset.getTotalRowCount() == 4);
29872987
RowFilter::Ptr pRF = new RowFilter(&rset);
29882988
assertTrue (pRF->isEmpty());
29892989
pRF->add(intFldName, RowFilter::VALUE_EQUAL, 1);

Data/ODBC/include/Poco/Data/ODBC/Diagnostics.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@ class Diagnostics
4545
{
4646
public:
4747

48-
static const unsigned int SQL_STATE_SIZE = SQL_SQLSTATE_SIZE + 1;
49-
static const unsigned int SQL_MESSAGE_LENGTH = SQL_MAX_MESSAGE_LENGTH + 1;
50-
static const unsigned int SQL_NAME_LENGTH = 128;
51-
static const std::string DATA_TRUNCATED;
48+
inline static const unsigned int SQL_STATE_SIZE = SQL_SQLSTATE_SIZE + 1;
49+
inline static const unsigned int SQL_MESSAGE_LENGTH = SQL_MAX_MESSAGE_LENGTH + 1;
50+
inline static const unsigned int SQL_NAME_LENGTH = 128;
51+
inline static const std::string DATA_TRUNCATED;
5252

5353
struct DiagnosticFields
5454
{

0 commit comments

Comments
 (0)