From 1bf40a0cd28be83e6243a0524be19118792c8cd1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=BCnter=20Obiltschnig?= Date: Thu, 9 Jan 2020 10:08:09 +0100 Subject: [PATCH 01/43] merge some changes from develop branch; modernize and clean-up code; remove support for compiling without POCO_WIN32_UTF8 --- CppUnit/include/CppUnit/estring.h | 10 +- Data/include/Poco/Data/AbstractBinder.h | 4 +- Data/include/Poco/Data/AbstractBinding.h | 10 +- Data/include/Poco/Data/AbstractExtraction.h | 18 +- Data/include/Poco/Data/AbstractExtractor.h | 2 +- Data/include/Poco/Data/AbstractPreparation.h | 4 +- Data/include/Poco/Data/AbstractPreparator.h | 2 +- Data/include/Poco/Data/AbstractSessionImpl.h | 6 +- Data/include/Poco/Data/ArchiveStrategy.h | 4 +- Data/include/Poco/Data/AutoTransaction.h | 2 +- Data/include/Poco/Data/Binding.h | 193 +++-- Data/include/Poco/Data/BulkBinding.h | 12 +- Data/include/Poco/Data/BulkExtraction.h | 32 +- Data/include/Poco/Data/Column.h | 51 +- Data/include/Poco/Data/DynamicLOB.h | 4 +- Data/include/Poco/Data/Extraction.h | 99 ++- Data/include/Poco/Data/LOB.h | 22 +- Data/include/Poco/Data/LOBStream.h | 18 +- Data/include/Poco/Data/Limit.h | 2 +- Data/include/Poco/Data/MetaColumn.h | 17 +- Data/include/Poco/Data/PooledSessionImpl.h | 2 +- Data/include/Poco/Data/Preparation.h | 12 +- Data/include/Poco/Data/RecordSet.h | 54 +- Data/include/Poco/Data/Row.h | 12 +- Data/include/Poco/Data/RowFilter.h | 10 +- Data/include/Poco/Data/RowFormatter.h | 8 +- Data/include/Poco/Data/RowIterator.h | 16 +- Data/include/Poco/Data/SQLChannel.h | 10 +- Data/include/Poco/Data/Session.h | 6 + Data/include/Poco/Data/SessionImpl.h | 2 +- Data/include/Poco/Data/SimpleRowFormatter.h | 6 +- Data/include/Poco/Data/Statement.h | 17 +- Data/include/Poco/Data/StatementCreator.h | 6 + Data/include/Poco/Data/StatementImpl.h | 28 +- Data/include/Poco/Data/TypeHandler.h | 134 ++-- Data/src/MetaColumn.cpp | 52 ++ Data/src/RecordSet.cpp | 24 + Data/src/RowIterator.cpp | 14 + Data/src/SQLChannel.cpp | 2 +- Data/src/Session.cpp | 17 +- Data/src/Statement.cpp | 23 + Data/src/StatementCreator.cpp | 12 + Data/testsuite/src/DataTest.cpp | 24 +- Data/testsuite/src/TestStatementImpl.cpp | 2 +- Foundation/include/Poco/AbstractCache.h | 32 +- Foundation/include/Poco/AbstractEvent.h | 13 +- Foundation/include/Poco/AbstractStrategy.h | 2 +- .../include/Poco/AccessExpireLRUCache.h | 2 +- Foundation/include/Poco/ActiveDispatcher.h | 2 +- Foundation/include/Poco/ActiveMethod.h | 2 +- Foundation/include/Poco/ActiveResult.h | 4 +- Foundation/include/Poco/ActiveRunnable.h | 2 +- Foundation/include/Poco/Activity.h | 8 +- Foundation/include/Poco/Alignment.h | 231 +----- Foundation/include/Poco/Any.h | 78 +- Foundation/include/Poco/Array.h | 21 +- Foundation/include/Poco/Ascii.h | 9 + Foundation/include/Poco/AsyncChannel.h | 11 +- Foundation/include/Poco/AtomicCounter.h | 320 +------- Foundation/include/Poco/AtomicFlag.h | 10 +- Foundation/include/Poco/AutoPtr.h | 28 +- Foundation/include/Poco/AutoReleasePool.h | 2 +- Foundation/include/Poco/Base32Decoder.h | 2 + Foundation/include/Poco/Base32Encoder.h | 2 + Foundation/include/Poco/Base64Decoder.h | 2 + Foundation/include/Poco/Base64Encoder.h | 2 + Foundation/include/Poco/BasicEvent.h | 2 +- Foundation/include/Poco/BinaryWriter.h | 4 +- Foundation/include/Poco/Buffer.h | 43 +- Foundation/include/Poco/BufferAllocator.h | 2 +- .../Poco/BufferedBidirectionalStreamBuf.h | 6 +- Foundation/include/Poco/BufferedStreamBuf.h | 17 +- Foundation/include/Poco/ByteOrder.h | 29 + Foundation/include/Poco/Channel.h | 3 + Foundation/include/Poco/ClassLibrary.h | 6 + Foundation/include/Poco/ClassLoader.h | 10 +- Foundation/include/Poco/Clock.h | 4 +- Foundation/include/Poco/Config.h | 10 - Foundation/include/Poco/ConsoleChannel.h | 2 + Foundation/include/Poco/CountingStream.h | 54 +- Foundation/include/Poco/DateTime.h | 29 +- Foundation/include/Poco/DateTimeParser.h | 2 +- Foundation/include/Poco/DefaultStrategy.h | 16 +- Foundation/include/Poco/DigestEngine.h | 2 +- .../include/Poco/DirectoryIteratorStrategy.h | 6 +- Foundation/include/Poco/Dynamic/Pair.h | 8 +- Foundation/include/Poco/Dynamic/Struct.h | 71 +- Foundation/include/Poco/Dynamic/Var.h | 113 ++- Foundation/include/Poco/Dynamic/VarHolder.h | 7 +- Foundation/include/Poco/DynamicFactory.h | 4 +- Foundation/include/Poco/Event.h | 14 +- Foundation/include/Poco/EventChannel.h | 2 + Foundation/include/Poco/EventLogChannel.h | 6 +- Foundation/include/Poco/Exception.h | 20 +- Foundation/include/Poco/ExpireLRUCache.h | 2 +- Foundation/include/Poco/FIFOEvent.h | 2 +- Foundation/include/Poco/File.h | 7 +- Foundation/include/Poco/FileStream.h | 12 +- Foundation/include/Poco/File_UNIX.h | 4 +- Foundation/include/Poco/File_WIN32.h | 4 +- Foundation/include/Poco/File_WIN32U.h | 4 +- Foundation/include/Poco/Format.h | 66 +- Foundation/include/Poco/Formatter.h | 9 +- Foundation/include/Poco/FormattingChannel.h | 20 +- Foundation/include/Poco/Foundation.h | 8 +- Foundation/include/Poco/Glob.h | 4 +- Foundation/include/Poco/HMACEngine.h | 5 +- Foundation/include/Poco/HashMap.h | 2 +- Foundation/include/Poco/HashSet.h | 2 +- Foundation/include/Poco/HashTable.h | 2 +- Foundation/include/Poco/JSONString.h | 2 +- Foundation/include/Poco/LRUCache.h | 2 +- Foundation/include/Poco/LinearHashTable.h | 28 +- Foundation/include/Poco/ListMap.h | 89 ++- Foundation/include/Poco/LocalDateTime.h | 8 +- Foundation/include/Poco/LogFile.h | 4 +- Foundation/include/Poco/Logger.h | 691 +++--------------- Foundation/include/Poco/LoggingFactory.h | 4 +- Foundation/include/Poco/LoggingRegistry.h | 10 +- Foundation/include/Poco/MD4Engine.h | 2 +- Foundation/include/Poco/MD5Engine.h | 2 +- Foundation/include/Poco/Manifest.h | 4 +- Foundation/include/Poco/MemoryStream.h | 2 +- Foundation/include/Poco/Message.h | 6 + Foundation/include/Poco/MetaObject.h | 4 +- Foundation/include/Poco/Mutex.h | 8 +- Foundation/include/Poco/NamedEvent.h | 4 +- Foundation/include/Poco/NamedMutex.h | 6 +- Foundation/include/Poco/Notification.h | 2 +- Foundation/include/Poco/NotificationQueue.h | 4 + .../include/Poco/NotificationStrategy.h | 4 +- Foundation/include/Poco/NullChannel.h | 2 + Foundation/include/Poco/Nullable.h | 19 +- Foundation/include/Poco/NumericString.h | 4 +- Foundation/include/Poco/ObjectPool.h | 10 +- Foundation/include/Poco/Optional.h | 16 + Foundation/include/Poco/OrderedMap.h | 2 - Foundation/include/Poco/OrderedSet.h | 6 - Foundation/include/Poco/PBKDF2Engine.h | 4 +- Foundation/include/Poco/Path.h | 12 +- Foundation/include/Poco/PatternFormatter.h | 15 +- Foundation/include/Poco/Platform_WIN32.h | 17 - Foundation/include/Poco/PriorityStrategy.h | 16 +- Foundation/include/Poco/Process.h | 4 +- Foundation/include/Poco/RWLock.h | 6 +- .../include/Poco/RecursiveDirectoryIterator.h | 2 +- Foundation/include/Poco/RefCountedObject.h | 4 +- Foundation/include/Poco/RegularExpression.h | 2 +- Foundation/include/Poco/SHA1Engine.h | 2 +- Foundation/include/Poco/SharedLibrary.h | 4 +- Foundation/include/Poco/SharedMemory_WIN32.h | 2 +- Foundation/include/Poco/SharedPtr.h | 59 +- Foundation/include/Poco/SimpleFileChannel.h | 4 +- Foundation/include/Poco/SimpleHashTable.h | 22 +- Foundation/include/Poco/SplitterChannel.h | 9 +- Foundation/include/Poco/StrategyCollection.h | 8 +- Foundation/include/Poco/StreamChannel.h | 2 + Foundation/include/Poco/String.h | 2 +- Foundation/include/Poco/StringTokenizer.h | 2 +- Foundation/include/Poco/SynchronizedObject.h | 2 +- Foundation/include/Poco/SyslogChannel.h | 2 + Foundation/include/Poco/Task.h | 10 + Foundation/include/Poco/TaskManager.h | 4 +- Foundation/include/Poco/TaskNotification.h | 2 +- Foundation/include/Poco/TextEncoding.h | 4 +- Foundation/include/Poco/Timer.h | 4 +- Foundation/include/Poco/Timespan.h | 2 +- Foundation/include/Poco/Timestamp.h | 9 +- Foundation/include/Poco/TypeList.h | 18 +- Foundation/include/Poco/Types.h | 142 +--- Foundation/include/Poco/URI.h | 10 +- Foundation/include/Poco/UnWindows.h | 3 +- Foundation/include/Poco/UnbufferedStreamBuf.h | 4 +- .../include/Poco/UniqueAccessExpireLRUCache.h | 4 +- .../include/Poco/UniqueExpireLRUCache.h | 4 +- .../include/Poco/WindowsConsoleChannel.h | 10 +- Foundation/src/ASCIIEncoding.cpp | 3 +- Foundation/src/AbstractObserver.cpp | 4 +- Foundation/src/ArchiveStrategy.cpp | 2 +- Foundation/src/AsyncChannel.cpp | 13 +- Foundation/src/AtomicCounter.cpp | 173 ----- Foundation/src/AtomicFlag.cpp | 25 +- Foundation/src/Base32Decoder.cpp | 2 +- Foundation/src/Base64Decoder.cpp | 16 +- Foundation/src/Channel.cpp | 2 +- Foundation/src/Condition.cpp | 4 +- Foundation/src/CountingStream.cpp | 28 +- Foundation/src/DateTime.cpp | 13 - Foundation/src/Debugger.cpp | 7 - Foundation/src/DigestEngine.cpp | 7 +- Foundation/src/DirectoryIterator.cpp | 4 +- Foundation/src/DirectoryWatcher.cpp | 18 +- Foundation/src/Error.cpp | 6 - Foundation/src/Event.cpp | 5 + Foundation/src/EventLogChannel.cpp | 73 -- Foundation/src/Exception.cpp | 8 +- Foundation/src/File.cpp | 8 +- Foundation/src/FileStream_WIN32.cpp | 6 - Foundation/src/Format.cpp | 227 +----- Foundation/src/Formatter.cpp | 4 +- Foundation/src/FormattingChannel.cpp | 22 +- Foundation/src/LogFile.cpp | 4 +- Foundation/src/Logger.cpp | 105 +-- Foundation/src/LoggingFactory.cpp | 8 +- Foundation/src/LoggingRegistry.cpp | 12 +- Foundation/src/MemoryPool.cpp | 4 +- Foundation/src/Message.cpp | 37 + Foundation/src/NamedEvent.cpp | 4 +- Foundation/src/NamedMutex.cpp | 4 +- Foundation/src/NestedDiagnosticContext.cpp | 12 +- Foundation/src/NotificationCenter.cpp | 8 +- Foundation/src/NotificationQueue.cpp | 17 +- Foundation/src/Path.cpp | 45 +- Foundation/src/PatternFormatter.cpp | 48 +- Foundation/src/PriorityNotificationQueue.cpp | 4 +- Foundation/src/Process.cpp | 16 +- Foundation/src/Process_UNIX.cpp | 8 +- Foundation/src/Process_WIN32.cpp | 4 +- Foundation/src/Process_WIN32U.cpp | 4 +- Foundation/src/PurgeStrategy.cpp | 6 +- Foundation/src/RandomStream.cpp | 2 +- Foundation/src/RegularExpression.cpp | 6 +- Foundation/src/RotateStrategy.cpp | 4 +- Foundation/src/SharedLibrary.cpp | 4 +- Foundation/src/SharedMemory_WIN32.cpp | 14 - Foundation/src/SortedDirectoryIterator.cpp | 4 +- Foundation/src/SplitterChannel.cpp | 16 +- Foundation/src/StreamTokenizer.cpp | 4 +- Foundation/src/Task.cpp | 10 +- Foundation/src/TaskManager.cpp | 4 +- Foundation/src/TeeStream.cpp | 4 +- Foundation/src/TemporaryFile.cpp | 8 +- Foundation/src/ThreadLocal.cpp | 4 +- Foundation/src/ThreadPool.cpp | 34 +- Foundation/src/Timezone_WIN32.cpp | 18 - Foundation/src/URI.cpp | 61 +- Foundation/src/URIStreamOpener.cpp | 3 +- Foundation/src/Var.cpp | 10 +- Foundation/src/WindowsConsoleChannel.cpp | 12 - Foundation/testsuite/src/AutoPtrTest.cpp | 31 + Foundation/testsuite/src/AutoPtrTest.h | 1 + Foundation/testsuite/src/CoreTestSuite.cpp | 2 - Foundation/testsuite/src/FormatTest.cpp | 100 +++ Foundation/testsuite/src/LoggerTest.cpp | 38 +- .../testsuite/src/LoggingFactoryTest.cpp | 39 +- .../testsuite/src/LoggingRegistryTest.cpp | 32 +- .../testsuite/src/OrderedContainersTest.cpp | 6 +- .../testsuite/src/OrderedContainersTest.h | 4 - Foundation/testsuite/src/StringTest.cpp | 2 - Foundation/testsuite/src/VarTest.cpp | 8 - JSON/include/Poco/JSON/Array.h | 12 +- JSON/include/Poco/JSON/Handler.h | 2 +- JSON/include/Poco/JSON/Object.h | 24 +- JSON/include/Poco/JSON/PrintHandler.h | 2 +- JSON/include/Poco/JSON/Template.h | 2 +- JSON/src/Array.cpp | 22 +- JSON/src/Object.cpp | 38 +- JSON/src/Query.cpp | 14 +- JSON/src/Template.cpp | 10 +- JSON/src/TemplateCache.cpp | 4 +- JSON/testsuite/src/JSONTest.cpp | 12 - Net/include/Poco/Net/HTTPBasicStreamBuf.h | 2 +- Net/include/Poco/Net/HTTPChunkedStream.h | 2 +- Net/include/Poco/Net/HTTPFixedLengthStream.h | 6 +- Net/include/Poco/Net/HTTPHeaderStream.h | 2 +- .../Poco/Net/HTTPRequestHandlerFactory.h | 2 +- Net/include/Poco/Net/HTTPServerParams.h | 2 +- Net/include/Poco/Net/HTTPStream.h | 2 +- Net/include/Poco/Net/HostEntry.h | 4 +- Net/include/Poco/Net/IPAddress.h | 4 +- Net/include/Poco/Net/IPAddressImpl.h | 2 +- Net/include/Poco/Net/MailMessage.h | 4 +- Net/include/Poco/Net/MediaType.h | 6 + Net/include/Poco/Net/NameValueCollection.h | 12 +- Net/include/Poco/Net/POP3ClientSession.h | 2 +- Net/include/Poco/Net/ParallelSocketAcceptor.h | 4 +- Net/include/Poco/Net/ParallelSocketReactor.h | 2 +- Net/include/Poco/Net/PollSet.h | 2 +- Net/include/Poco/Net/RemoteSyslogChannel.h | 3 + Net/include/Poco/Net/SMTPChannel.h | 3 + Net/include/Poco/Net/SMTPClientSession.h | 2 +- Net/include/Poco/Net/Socket.h | 4 +- Net/include/Poco/Net/SocketAcceptor.h | 2 +- Net/include/Poco/Net/SocketAddress.h | 2 +- Net/include/Poco/Net/SocketAddressImpl.h | 2 +- Net/include/Poco/Net/SocketReactor.h | 6 - Net/include/Poco/Net/TCPServer.h | 2 +- .../Poco/Net/TCPServerConnectionFactory.h | 2 +- Net/include/Poco/Net/TCPServerParams.h | 2 +- Net/include/Poco/Net/UDPServer.h | 6 +- Net/src/DNS.cpp | 4 +- Net/src/FTPClientSession.cpp | 4 +- Net/src/HTMLForm.cpp | 22 +- Net/src/HTTPCookie.cpp | 6 +- Net/src/HTTPDigestCredentials.cpp | 8 +- Net/src/HTTPSessionFactory.cpp | 4 +- Net/src/MailMessage.cpp | 42 +- Net/src/MediaType.cpp | 18 + Net/src/MessageHeader.cpp | 4 +- Net/src/MulticastSocket.cpp | 24 +- Net/src/NameValueCollection.cpp | 21 +- Net/src/NetworkInterface.cpp | 37 +- Net/src/OAuth10Credentials.cpp | 6 +- Net/src/PollSet.cpp | 12 +- Net/src/SMTPClientSession.cpp | 13 +- Net/src/Socket.cpp | 2 +- Net/src/SocketAddress.cpp | 6 +- Net/src/SocketReactor.cpp | 8 +- Net/testsuite/src/SyslogTest.cpp | 42 +- .../include/Poco/Util/AbstractConfiguration.h | 18 +- Util/include/Poco/Util/Application.h | 35 +- Util/include/Poco/Util/ConfigurationMapper.h | 8 +- Util/include/Poco/Util/ConfigurationView.h | 8 +- Util/include/Poco/Util/LayeredConfiguration.h | 90 +-- Util/include/Poco/Util/LoggingConfigurator.h | 20 +- Util/include/Poco/Util/Option.h | 8 +- Util/include/Poco/Util/OptionSet.h | 4 +- Util/include/Poco/Util/ServerApplication.h | 11 +- Util/include/Poco/Util/TimerTask.h | 2 +- Util/include/Poco/Util/WinRegistryKey.h | 4 +- Util/include/Poco/Util/WinService.h | 14 +- Util/src/AbstractConfiguration.cpp | 8 +- Util/src/Application.cpp | 55 +- Util/src/ConfigurationMapper.cpp | 5 +- Util/src/ConfigurationView.cpp | 5 +- Util/src/FilesystemConfiguration.cpp | 4 +- Util/src/HelpFormatter.cpp | 38 +- Util/src/IniFileConfiguration.cpp | 10 +- Util/src/LayeredConfiguration.cpp | 114 +-- Util/src/LoggingConfigurator.cpp | 99 ++- Util/src/LoggingSubsystem.cpp | 2 +- Util/src/MapConfiguration.cpp | 14 +- Util/src/OptionProcessor.cpp | 6 +- Util/src/OptionSet.cpp | 16 +- Util/src/PropertyFileConfiguration.cpp | 6 +- Util/src/ServerApplication.cpp | 37 +- Util/src/WinRegistryKey.cpp | 168 +---- Util/src/WinService.cpp | 58 +- .../src/AbstractConfigurationTest.cpp | 10 +- .../testsuite/src/AbstractConfigurationTest.h | 4 +- .../testsuite/src/ConfigurationMapperTest.cpp | 2 +- Util/testsuite/src/ConfigurationMapperTest.h | 2 +- Util/testsuite/src/ConfigurationViewTest.cpp | 6 +- Util/testsuite/src/ConfigurationViewTest.h | 2 +- .../src/FilesystemConfigurationTest.cpp | 2 +- .../src/FilesystemConfigurationTest.h | 2 +- .../src/IniFileConfigurationTest.cpp | 2 +- Util/testsuite/src/IniFileConfigurationTest.h | 2 +- Util/testsuite/src/JSONConfigurationTest.cpp | 3 +- Util/testsuite/src/JSONConfigurationTest.h | 2 +- .../src/LayeredConfigurationTest.cpp | 13 +- Util/testsuite/src/LayeredConfigurationTest.h | 2 +- .../testsuite/src/LoggingConfiguratorTest.cpp | 22 +- Util/testsuite/src/MapConfigurationTest.cpp | 2 +- Util/testsuite/src/MapConfigurationTest.h | 2 +- .../src/PropertyFileConfigurationTest.cpp | 2 +- .../src/PropertyFileConfigurationTest.h | 2 +- Util/testsuite/src/WinServiceTest.cpp | 50 +- Util/testsuite/src/WinServiceTest.h | 3 - Util/testsuite/src/WindowsTestSuite.cpp | 2 + Util/testsuite/src/XMLConfigurationTest.cpp | 2 +- Util/testsuite/src/XMLConfigurationTest.h | 2 +- XML/include/Poco/DOM/DOMException.h | 6 +- XML/include/Poco/DOM/Document.h | 2 +- XML/include/Poco/DOM/EventException.h | 6 +- XML/include/Poco/DOM/Node.h | 2 +- XML/include/Poco/SAX/AttributesImpl.h | 17 +- XML/include/Poco/SAX/NamespaceSupport.h | 2 +- XML/include/Poco/SAX/SAXException.h | 6 +- XML/include/Poco/XML/Name.h | 6 + XML/include/Poco/XML/QName.h | 6 + XML/include/Poco/XML/XMLStream.h | 12 +- XML/include/Poco/XML/XMLStreamParser.h | 10 +- .../Poco/XML/XMLStreamParserException.h | 2 +- XML/include/Poco/XML/XMLString.h | 8 +- XML/include/Poco/XML/XMLWriter.h | 2 +- XML/src/AttributesImpl.cpp | 31 +- XML/src/DOMBuilder.cpp | 4 +- XML/src/DOMException.cpp | 6 +- XML/src/EventException.cpp | 6 +- XML/src/Name.cpp | 18 + XML/src/NamespaceSupport.cpp | 6 +- XML/src/ParserEngine.cpp | 4 +- XML/src/QName.cpp | 42 ++ XML/src/SAXException.cpp | 6 +- XML/src/XMLStreamParser.cpp | 14 +- XML/src/XMLStreamParserException.cpp | 2 +- XML/src/XMLString.cpp | 4 +- XML/src/XMLWriter.cpp | 52 +- 389 files changed, 3029 insertions(+), 4111 deletions(-) diff --git a/CppUnit/include/CppUnit/estring.h b/CppUnit/include/CppUnit/estring.h index 0d0458a43..8adf030b3 100644 --- a/CppUnit/include/CppUnit/estring.h +++ b/CppUnit/include/CppUnit/estring.h @@ -9,7 +9,7 @@ #include "CppUnit/CppUnit.h" #include -#include +#include namespace CppUnit { @@ -33,7 +33,7 @@ inline std::string estring(std::string& expandedString) inline std::string estring(int number) { char buffer[50]; - sprintf(buffer, "%d", number); + std::snprintf(buffer, sizeof(buffer), "%d", number); return std::string (buffer); } @@ -42,7 +42,7 @@ inline std::string estring(int number) inline std::string estring(long number) { char buffer[50]; - sprintf(buffer, "%ld", number); + std::snprintf(buffer, sizeof(buffer), "%ld", number); return std::string (buffer); } @@ -51,7 +51,7 @@ inline std::string estring(long number) inline std::string estring(double number) { char buffer[50]; - sprintf(buffer, "%lf", number); + std::snprintf(buffer, sizeof(buffer), "%lf", number); return std::string(buffer); } @@ -60,7 +60,7 @@ inline std::string estring(double number) inline std::string estring(const void* ptr) { char buffer[50]; - sprintf(buffer, "%p", ptr); + std::snprintf(buffer, sizeof(buffer), "%p", ptr); return std::string(buffer); } diff --git a/Data/include/Poco/Data/AbstractBinder.h b/Data/include/Poco/Data/AbstractBinder.h index d88efba0a..2f821213c 100644 --- a/Data/include/Poco/Data/AbstractBinder.h +++ b/Data/include/Poco/Data/AbstractBinder.h @@ -37,7 +37,7 @@ namespace Poco { namespace Data { -typedef NullType NullData; +using NullData = NullType; namespace Keywords { @@ -53,7 +53,7 @@ class Data_API AbstractBinder /// Interface for Binding data types to placeholders. { public: - typedef SharedPtr Ptr; + using Ptr = SharedPtr; enum Direction /// Binding direction for a parameter. diff --git a/Data/include/Poco/Data/AbstractBinding.h b/Data/include/Poco/Data/AbstractBinding.h index 1c16da1a6..aaed3e6f8 100644 --- a/Data/include/Poco/Data/AbstractBinding.h +++ b/Data/include/Poco/Data/AbstractBinding.h @@ -37,8 +37,8 @@ class Data_API AbstractBinding /// AbstractBinding connects a value with a placeholder via an AbstractBinder interface. { public: - typedef SharedPtr Ptr; - typedef AbstractBinder::Ptr BinderPtr; + using Ptr = SharedPtr; + using BinderPtr = AbstractBinder::Ptr; enum Direction { @@ -100,9 +100,9 @@ private: }; -typedef std::vector AbstractBindingVec; -typedef std::deque AbstractBindingDeq; -typedef std::list AbstractBindingLst; +using AbstractBindingVec = std::vector; +using AbstractBindingDeq = std::deque; +using AbstractBindingLst = std::list; // diff --git a/Data/include/Poco/Data/AbstractExtraction.h b/Data/include/Poco/Data/AbstractExtraction.h index 2da6d3c6f..dc5f59197 100644 --- a/Data/include/Poco/Data/AbstractExtraction.h +++ b/Data/include/Poco/Data/AbstractExtraction.h @@ -43,9 +43,9 @@ class Data_API AbstractExtraction /// retrieved via an AbstractExtractor. { public: - typedef SharedPtr Ptr; - typedef SharedPtr ExtractorPtr; - typedef SharedPtr PreparatorPtr; + using Ptr = SharedPtr; + using ExtractorPtr = SharedPtr; + using PreparatorPtr = SharedPtr; AbstractExtraction(Poco::UInt32 limit = Limit::LIMIT_UNLIMITED, Poco::UInt32 position = 0, bool bulk = false); @@ -172,12 +172,12 @@ private: }; -typedef std::vector AbstractExtractionVec; -typedef std::vector AbstractExtractionVecVec; -typedef std::deque AbstractExtractionDeq; -typedef std::vector AbstractExtractionDeqVec; -typedef std::list AbstractExtractionLst; -typedef std::vector AbstractExtractionLstVec; +using AbstractExtractionVec = std::vector; +using AbstractExtractionVecVec = std::vector; +using AbstractExtractionDeq = std::deque; +using AbstractExtractionDeqVec = std::vector; +using AbstractExtractionLst = std::list; +using AbstractExtractionLstVec = std::vector; // diff --git a/Data/include/Poco/Data/AbstractExtractor.h b/Data/include/Poco/Data/AbstractExtractor.h index aa973bc29..1613fc5a2 100644 --- a/Data/include/Poco/Data/AbstractExtractor.h +++ b/Data/include/Poco/Data/AbstractExtractor.h @@ -51,7 +51,7 @@ class Data_API AbstractExtractor /// If an extractor receives null it is not allowed to change val! { public: - typedef SharedPtr Ptr; + using Ptr = SharedPtr; AbstractExtractor(); /// Creates the AbstractExtractor. diff --git a/Data/include/Poco/Data/AbstractPreparation.h b/Data/include/Poco/Data/AbstractPreparation.h index 6d921572d..af02e45b2 100644 --- a/Data/include/Poco/Data/AbstractPreparation.h +++ b/Data/include/Poco/Data/AbstractPreparation.h @@ -32,8 +32,8 @@ class Data_API AbstractPreparation /// Interface for calling the appropriate AbstractPreparator method { public: - typedef SharedPtr Ptr; - typedef AbstractPreparator::Ptr PreparatorPtr; + using Ptr = SharedPtr; + using PreparatorPtr = AbstractPreparator::Ptr; AbstractPreparation(PreparatorPtr pPreparator); /// Creates the AbstractPreparation. diff --git a/Data/include/Poco/Data/AbstractPreparator.h b/Data/include/Poco/Data/AbstractPreparator.h index da086b051..1432bf8c3 100644 --- a/Data/include/Poco/Data/AbstractPreparator.h +++ b/Data/include/Poco/Data/AbstractPreparator.h @@ -57,7 +57,7 @@ class Data_API AbstractPreparator /// after SQL execution (e.g. SQLite) do not need this functionality at all. { public: - typedef SharedPtr Ptr; + using Ptr = SharedPtr; AbstractPreparator(Poco::UInt32 length = 1u); /// Creates the AbstractPreparator. diff --git a/Data/include/Poco/Data/AbstractSessionImpl.h b/Data/include/Poco/Data/AbstractSessionImpl.h index 7cd76cdea..c4d5232cd 100644 --- a/Data/include/Poco/Data/AbstractSessionImpl.h +++ b/Data/include/Poco/Data/AbstractSessionImpl.h @@ -59,7 +59,7 @@ public: /// Creates the AbstractSessionImpl. /// /// Adds "storage" property and sets the default internal storage container - /// type to std::deque. + /// type to std::vector. /// The storage is created by statements automatically whenever a query /// returning results is executed but external storage is provided by the user. /// Storage type can be reconfigured at runtime both globally (for the @@ -296,8 +296,8 @@ private: PropertyGetter getter; }; - typedef std::map FeatureMap; - typedef std::map PropertyMap; + using FeatureMap = std::map; + using PropertyMap = std::map; FeatureMap _features; PropertyMap _properties; diff --git a/Data/include/Poco/Data/ArchiveStrategy.h b/Data/include/Poco/Data/ArchiveStrategy.h index 3b644c5f2..2f4befac9 100644 --- a/Data/include/Poco/Data/ArchiveStrategy.h +++ b/Data/include/Poco/Data/ArchiveStrategy.h @@ -70,8 +70,8 @@ public: /// Sets the archive threshold. protected: - typedef Poco::SharedPtr SessionPtr; - typedef Poco::SharedPtr StatementPtr; + using SessionPtr = Poco::SharedPtr; + using StatementPtr = Poco::SharedPtr; Session& session(); diff --git a/Data/include/Poco/Data/AutoTransaction.h b/Data/include/Poco/Data/AutoTransaction.h index 6d88184f0..4d6603217 100644 --- a/Data/include/Poco/Data/AutoTransaction.h +++ b/Data/include/Poco/Data/AutoTransaction.h @@ -26,7 +26,7 @@ namespace Poco { namespace Data { -typedef Transaction AutoTransaction; +using AutoTransaction = Transaction; } } // namespace Poco::Data diff --git a/Data/include/Poco/Data/Binding.h b/Data/include/Poco/Data/Binding.h index 464c3143e..537543a7d 100644 --- a/Data/include/Poco/Data/Binding.h +++ b/Data/include/Poco/Data/Binding.h @@ -51,10 +51,10 @@ class Binding: public AbstractBinding /// function. An attempt to pass a constant by reference shall result in compile-time error. { public: - typedef T ValType; - typedef SharedPtr ValPtr; - typedef Binding Type; - typedef SharedPtr Ptr; + using ValType = T; + using ValPtr = SharedPtr; + using Type = Binding; + using Ptr = SharedPtr; explicit Binding(T& val, const std::string& name = "", @@ -121,10 +121,10 @@ class CopyBinding: public AbstractBinding /// Variables can be passed as either copies or references (i.e. using either use() or bind()). { public: - typedef T ValType; - typedef SharedPtr ValPtr; - typedef CopyBinding Type; - typedef SharedPtr Ptr; + using ValType = T; + using ValPtr = SharedPtr; + using Type = CopyBinding; + using Ptr = SharedPtr; explicit CopyBinding(T& val, const std::string& name = "", @@ -184,10 +184,10 @@ class Binding: public AbstractBinding /// Binding const char* specialization wraps char pointer into string. { public: - typedef const char* ValType; - typedef SharedPtr ValPtr; - typedef Binding Type; - typedef SharedPtr Ptr; + using ValType = const char*; + using ValPtr = SharedPtr; + using Type = Binding; + using Ptr = SharedPtr; explicit Binding(const char* pVal, const std::string& name = "", @@ -246,10 +246,10 @@ class CopyBinding: public AbstractBinding /// Binding const char* specialization wraps char pointer into string. { public: - typedef const char* ValType; - typedef SharedPtr ValPtr; - typedef CopyBinding Type; - typedef SharedPtr Ptr; + using ValType = const char*; + using ValPtr = SharedPtr; + using Type = CopyBinding; + using Ptr = SharedPtr; explicit CopyBinding(const char* pVal, const std::string& name = "", @@ -303,14 +303,14 @@ private: template -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::vector. { public: - typedef std::vector ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::vector; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit Binding(std::vector& val, const std::string& name = "", @@ -369,15 +369,15 @@ private: template -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::vector. { public: - typedef std::vector ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::vector; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit CopyBinding(std::vector& val, const std::string& name = "", @@ -436,7 +436,7 @@ private: template <> -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::vector. /// This specialization is necessary due to the nature of std::vector. /// For details, see the standard library implementation of std::vector @@ -451,10 +451,10 @@ class Binding >: public AbstractBinding /// Only IN binding is supported. { public: - typedef std::vector ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef ValType::const_iterator Iterator; + using ValType = std::vector; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = ValType::const_iterator; explicit Binding(const std::vector& val, const std::string& name = "", @@ -500,7 +500,6 @@ public: poco_assert_dbg(canBind()); TypeHandler::bind(pos, *_begin, getBinder(), getDirection()); ++_begin; - } void reset() @@ -518,7 +517,7 @@ private: template <> -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::vector. /// This specialization is necessary due to the nature of std::vector. /// For details, see the standard library implementation of std::vector @@ -533,10 +532,10 @@ class CopyBinding >: public AbstractBinding /// Only IN binding is supported. { public: - typedef std::vector ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef ValType::const_iterator Iterator; + using ValType = std::vector; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = ValType::const_iterator; explicit CopyBinding(const std::vector& val, const std::string& name = "", @@ -598,14 +597,14 @@ private: template -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::list. { public: - typedef std::list ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::list; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit Binding(std::list& val, const std::string& name = "", @@ -663,14 +662,14 @@ private: template -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::list. { public: - typedef typename std::list ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = typename std::list; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit CopyBinding(ValType& val, const std::string& name = "", @@ -728,14 +727,14 @@ private: template -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::deque. { public: - typedef std::deque ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::deque; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit Binding(std::deque& val, const std::string& name = "", @@ -793,14 +792,14 @@ private: template -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::deque. { public: - typedef std::deque ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::deque; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit CopyBinding(std::deque& val, const std::string& name = "", @@ -858,14 +857,14 @@ private: template -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::set. { public: - typedef std::set ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::set; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit Binding(std::set& val, const std::string& name = "", @@ -923,14 +922,14 @@ private: template -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::set. { public: - typedef std::set ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::set; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit CopyBinding(std::set& val, const std::string& name = "", @@ -988,14 +987,14 @@ private: template -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::multiset. { public: - typedef std::multiset ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::multiset; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit Binding(std::multiset& val, const std::string& name = "", @@ -1053,14 +1052,14 @@ private: template -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::multiset. { public: - typedef std::multiset ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::multiset; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit CopyBinding(std::multiset& val, const std::string& name = "", @@ -1118,14 +1117,14 @@ private: template -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::map. { public: - typedef std::map ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::map; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit Binding(std::map& val, const std::string& name = "", @@ -1183,14 +1182,14 @@ private: template -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::map. { public: - typedef std::map ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::map; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit CopyBinding(std::map& val, const std::string& name = "", @@ -1248,14 +1247,14 @@ private: template -class Binding >: public AbstractBinding +class Binding>: public AbstractBinding /// Specialization for std::multimap. { public: - typedef std::multimap ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::multimap; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit Binding(std::multimap& val, const std::string& name = "", @@ -1313,14 +1312,14 @@ private: template -class CopyBinding >: public AbstractBinding +class CopyBinding>: public AbstractBinding /// Specialization for std::multimap. { public: - typedef std::multimap ValType; - typedef SharedPtr ValPtr; - typedef SharedPtr > Ptr; - typedef typename ValType::const_iterator Iterator; + using ValType = std::multimap; + using ValPtr = SharedPtr; + using Ptr = SharedPtr>; + using Iterator = typename ValType::const_iterator; explicit CopyBinding(std::multimap& val, const std::string& name = "", diff --git a/Data/include/Poco/Data/BulkBinding.h b/Data/include/Poco/Data/BulkBinding.h index a28213ea4..a1a4004b2 100644 --- a/Data/include/Poco/Data/BulkBinding.h +++ b/Data/include/Poco/Data/BulkBinding.h @@ -95,7 +95,7 @@ template AbstractBinding::Ptr use(const std::vector& t, BulkFnType, const std::string& name = "") /// Convenience function for a more compact BulkBinding creation for std::vector. { - return new BulkBinding >(t, static_cast(t.size()), name); + return new BulkBinding>(t, static_cast(t.size()), name); } @@ -103,7 +103,7 @@ template AbstractBinding::Ptr in(const std::vector& t, BulkFnType, const std::string& name = "") /// Convenience function for a more compact BulkBinding creation for std::vector. { - return new BulkBinding >(t, static_cast(t.size()), name); + return new BulkBinding>(t, static_cast(t.size()), name); } @@ -111,7 +111,7 @@ template AbstractBinding::Ptr use(const std::deque& t, BulkFnType, const std::string& name = "") /// Convenience function for a more compact BulkBinding creation for std::deque. { - return new BulkBinding >(t, static_cast(t.size()), name); + return new BulkBinding>(t, static_cast(t.size()), name); } @@ -119,7 +119,7 @@ template AbstractBinding::Ptr in(const std::deque& t, BulkFnType, const std::string& name = "") /// Convenience function for a more compact BulkBinding creation for std::deque. { - return new BulkBinding >(t, static_cast(t.size()), name); + return new BulkBinding>(t, static_cast(t.size()), name); } @@ -127,7 +127,7 @@ template AbstractBinding::Ptr use(const std::list& t, BulkFnType, const std::string& name = "") /// Convenience function for a more compact BulkBinding creation for std::list. { - return new BulkBinding >(t, static_cast(t.size()), name); + return new BulkBinding>(t, static_cast(t.size()), name); } @@ -135,7 +135,7 @@ template AbstractBinding::Ptr in(const std::list& t, BulkFnType, const std::string& name = "") /// Convenience function for a more compact BulkBinding creation for std::list. { - return new BulkBinding >(t, static_cast(t.size()), name); + return new BulkBinding>(t, static_cast(t.size()), name); } diff --git a/Data/include/Poco/Data/BulkExtraction.h b/Data/include/Poco/Data/BulkExtraction.h index 75c25f69b..bb61a1500 100644 --- a/Data/include/Poco/Data/BulkExtraction.h +++ b/Data/include/Poco/Data/BulkExtraction.h @@ -38,11 +38,11 @@ class BulkExtraction: public AbstractExtraction /// - std::list { public: - typedef C ValType; - typedef typename C::value_type CValType; - typedef SharedPtr ValPtr; - typedef BulkExtraction Type; - typedef SharedPtr Ptr; + using ValType = C; + using CValType = typename C::value_type; + using ValPtr = SharedPtr; + using Type = BulkExtraction; + using Ptr = SharedPtr; BulkExtraction(C& result, Poco::UInt32 limit, const Position& pos = Position(0)): AbstractExtraction(limit, pos.value(), true), @@ -146,11 +146,11 @@ class InternalBulkExtraction: public BulkExtraction /// InternalBulkExtraction objects can not be copied or assigned. { public: - typedef C ValType; - typedef typename C::value_type CValType; - typedef SharedPtr ValPtr; - typedef InternalBulkExtraction Type; - typedef SharedPtr Ptr; + using ValType = C; + using CValType = typename C::value_type; + using ValPtr = SharedPtr; + using Type = InternalBulkExtraction; + using Ptr = SharedPtr; InternalBulkExtraction(C& result, Column* pColumn, @@ -212,7 +212,7 @@ AbstractExtraction::Ptr into(std::vector& t, const Bulk& bulk, const Position /// Convenience function to allow for a more compact creation of an extraction object /// with std::vector bulk extraction support. { - return new BulkExtraction >(t, bulk.size(), pos); + return new BulkExtraction>(t, bulk.size(), pos); } @@ -223,7 +223,7 @@ AbstractExtraction::Ptr into(std::vector& t, BulkFnType, const Position& pos { Poco::UInt32 size = static_cast(t.size()); if (0 == size) throw InvalidArgumentException("Zero length not allowed."); - return new BulkExtraction >(t, size, pos); + return new BulkExtraction>(t, size, pos); } @@ -232,7 +232,7 @@ AbstractExtraction::Ptr into(std::deque& t, const Bulk& bulk, const Position& /// Convenience function to allow for a more compact creation of an extraction object /// with std::deque bulk extraction support. { - return new BulkExtraction >(t, bulk.size(), pos); + return new BulkExtraction>(t, bulk.size(), pos); } @@ -243,7 +243,7 @@ AbstractExtraction::Ptr into(std::deque& t, BulkFnType, const Position& pos = { Poco::UInt32 size = static_cast(t.size()); if (0 == size) throw InvalidArgumentException("Zero length not allowed."); - return new BulkExtraction >(t, size, pos); + return new BulkExtraction>(t, size, pos); } @@ -252,7 +252,7 @@ AbstractExtraction::Ptr into(std::list& t, const Bulk& bulk, const Position& /// Convenience function to allow for a more compact creation of an extraction object /// with std::list bulk extraction support. { - return new BulkExtraction >(t, bulk.size(), pos); + return new BulkExtraction>(t, bulk.size(), pos); } @@ -263,7 +263,7 @@ AbstractExtraction::Ptr into(std::list& t, BulkFnType, const Position& pos = { Poco::UInt32 size = static_cast(t.size()); if (0 == size) throw InvalidArgumentException("Zero length not allowed."); - return new BulkExtraction >(t, size, pos); + return new BulkExtraction>(t, size, pos); } diff --git a/Data/include/Poco/Data/Column.h b/Data/include/Poco/Data/Column.h index 22c44a2fa..c6764b4c9 100644 --- a/Data/include/Poco/Data/Column.h +++ b/Data/include/Poco/Data/Column.h @@ -39,12 +39,12 @@ class Column /// This class owns the data assigned to it and deletes the storage on destruction. { public: - typedef C Container; - typedef Poco::SharedPtr ContainerPtr; - typedef typename C::const_iterator Iterator; - typedef typename C::const_reverse_iterator RIterator; - typedef typename C::size_type Size; - typedef typename C::value_type Type; + using Container = C; + using ContainerPtr = Poco::SharedPtr; + using Iterator = typename C::const_iterator; + using RIterator = typename C::const_reverse_iterator; + using Size = typename C::size_type; + using Type = typename C::value_type; Column(const MetaColumn& metaColumn, Container* pData): _metaColumn(metaColumn), @@ -62,6 +62,13 @@ public: { } + Column(Column&& col) noexcept: + _metaColumn(std::move(col._metaColumn)), + _pData(std::move(col._pData)) + /// Creates the Column. + { + } + ~Column() /// Destroys the Column. { @@ -75,6 +82,14 @@ public: return *this; } + Column& operator = (Column&& col) noexcept + /// Assignment operator. + { + _metaColumn = std::move(col._metaColumn); + _pData = std::move(col._pData); + return *this; + } + void swap(Column& other) /// Swaps the column with another one. { @@ -172,7 +187,7 @@ private: template <> -class Column > +class Column> /// The std::vector specialization for the Column class. /// /// This specialization is necessary due to the nature of std::vector. @@ -186,11 +201,11 @@ class Column > /// column data. { public: - typedef std::vector Container; - typedef Poco::SharedPtr ContainerPtr; - typedef Container::const_iterator Iterator; - typedef Container::const_reverse_iterator RIterator; - typedef Container::size_type Size; + using Container = std::vector; + using ContainerPtr = Poco::SharedPtr; + using Iterator = Container::const_iterator; + using RIterator = Container::const_reverse_iterator; + using Size = Container::size_type; Column(const MetaColumn& metaColumn, Container* pData): _metaColumn(metaColumn), @@ -325,15 +340,15 @@ private: template -class Column > +class Column> /// Column specialization for std::list { public: - typedef std::list Container; - typedef Poco::SharedPtr ContainerPtr; - typedef typename Container::const_iterator Iterator; - typedef typename Container::const_reverse_iterator RIterator; - typedef typename Container::size_type Size; + using Container = std::list; + using ContainerPtr = Poco::SharedPtr; + using Iterator = typename Container::const_iterator; + using RIterator = typename Container::const_reverse_iterator; + using Size = typename Container::size_type; Column(const MetaColumn& metaColumn, std::list* pData): _metaColumn(metaColumn), diff --git a/Data/include/Poco/Data/DynamicLOB.h b/Data/include/Poco/Data/DynamicLOB.h index 1ed817d26..fc33bbba6 100644 --- a/Data/include/Poco/Data/DynamicLOB.h +++ b/Data/include/Poco/Data/DynamicLOB.h @@ -27,8 +27,8 @@ namespace Poco { namespace Data { template class LOB; -typedef LOB BLOB; -typedef LOB CLOB; +using BLOB = LOB; +using CLOB = LOB; } } // namespace Poco::Data diff --git a/Data/include/Poco/Data/Extraction.h b/Data/include/Poco/Data/Extraction.h index 45821357c..90e773d95 100644 --- a/Data/include/Poco/Data/Extraction.h +++ b/Data/include/Poco/Data/Extraction.h @@ -42,10 +42,10 @@ class Extraction: public AbstractExtraction /// Concrete Data Type specific extraction of values from a query result set. { public: - typedef T ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = T; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(T& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -129,15 +129,14 @@ private: template -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// Vector Data Type specialization for extraction of values from a query result set. { public: - - typedef std::vector ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = std::vector; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(std::vector& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -220,14 +219,14 @@ private: template <> -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// Vector bool specialization for extraction of values from a query result set. { public: - typedef std::vector ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = std::vector; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(std::vector& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -312,14 +311,14 @@ private: template -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// List Data Type specialization for extraction of values from a query result set. { public: - typedef std::list ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = std::list; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(std::list& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -402,14 +401,14 @@ private: template -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// Deque Data Type specialization for extraction of values from a query result set. { public: - typedef std::deque ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = std::deque; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(std::deque& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -504,10 +503,10 @@ class InternalExtraction: public Extraction /// InternalExtraction objects can not be copied or assigned. { public: - typedef typename C::value_type ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = typename C::value_type; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; InternalExtraction(C& result, Column* pColumn, const Position& pos = Position(0)): @@ -561,15 +560,15 @@ private: template -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// Set Data Type specialization for extraction of values from a query result set. { public: - typedef std::set ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; - typedef typename ValType::iterator Iterator; + using ValType = std::set; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; + using Iterator = typename ValType::iterator; Extraction(std::set& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -626,14 +625,14 @@ private: template -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// Multiset Data Type specialization for extraction of values from a query result set. { public: - typedef std::multiset ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = std::multiset; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(std::multiset& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -690,14 +689,14 @@ private: template -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// Map Data Type specialization for extraction of values from a query result set. { public: - typedef std::map ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = std::map; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(std::map& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), @@ -754,14 +753,14 @@ private: template -class Extraction >: public AbstractExtraction +class Extraction>: public AbstractExtraction /// Multimap Data Type specialization for extraction of values from a query result set. { public: - typedef std::multimap ValType; - typedef SharedPtr ValPtr; - typedef Extraction Type; - typedef SharedPtr Ptr; + using ValType = std::multimap; + using ValPtr = SharedPtr; + using Type = Extraction; + using Ptr = SharedPtr; Extraction(std::multimap& result, const Position& pos = Position(0)): AbstractExtraction(Limit::LIMIT_UNLIMITED, pos.value()), diff --git a/Data/include/Poco/Data/LOB.h b/Data/include/Poco/Data/LOB.h index 99c1e7b71..f5022ffc2 100644 --- a/Data/include/Poco/Data/LOB.h +++ b/Data/include/Poco/Data/LOB.h @@ -41,10 +41,10 @@ class LOB /// a convenient way to access the data in a LOB. { public: - typedef typename std::vector::const_iterator Iterator; - typedef T ValueType; - typedef typename std::vector Container; - typedef Poco::SharedPtr ContentPtr; + using Iterator = typename std::vector::const_iterator; + using ValueType = T; + using Container = std::vector; + using ContentPtr = Poco::SharedPtr; LOB(): _pContent(new std::vector()) /// Creates an empty LOB. @@ -74,6 +74,10 @@ public: { } + LOB(LOB&& other) noexcept: _pContent(std::move(other._pContent)) + { + } + ~LOB() /// Destroys the LOB. { @@ -87,6 +91,12 @@ public: return *this; } + LOB& operator = (LOB&& other) noexcept + { + _pContent = std::move(other._pContent); + return *this; + } + bool operator == (const LOB& other) const /// Compares for equality LOB by value. { @@ -180,8 +190,8 @@ private: }; -typedef LOB BLOB; -typedef LOB CLOB; +using BLOB = LOB; +using CLOB = LOB; // diff --git a/Data/include/Poco/Data/LOBStream.h b/Data/include/Poco/Data/LOBStream.h index d363457c2..b3cbc5c34 100644 --- a/Data/include/Poco/Data/LOBStream.h +++ b/Data/include/Poco/Data/LOBStream.h @@ -30,7 +30,7 @@ namespace Data { template -class LOBStreamBuf: public BasicUnbufferedStreamBuf > +class LOBStreamBuf: public BasicUnbufferedStreamBuf> /// This is the streambuf class used for reading from and writing to a LOB. { public: @@ -46,8 +46,8 @@ public: } protected: - typedef std::char_traits TraitsType; - typedef BasicUnbufferedStreamBuf BaseType; + using TraitsType = std::char_traits; + using BaseType = BasicUnbufferedStreamBuf; typename BaseType::int_type readFromDevice() { @@ -101,7 +101,7 @@ protected: template -class LOBOutputStream: public LOBIOS, public std::basic_ostream > +class LOBOutputStream: public LOBIOS, public std::basic_ostream> /// An output stream for writing to a LOB. { public: @@ -120,7 +120,7 @@ public: template -class LOBInputStream: public LOBIOS, public std::basic_istream > +class LOBInputStream: public LOBIOS, public std::basic_istream> /// An input stream for reading from a LOB. { public: @@ -138,11 +138,11 @@ public: }; -typedef LOBOutputStream BLOBOutputStream; -typedef LOBOutputStream CLOBOutputStream; +using BLOBOutputStream = LOBOutputStream; +using CLOBOutputStream = LOBOutputStream; -typedef LOBInputStream BLOBInputStream; -typedef LOBInputStream CLOBInputStream; +using BLOBInputStream = LOBInputStream; +using CLOBInputStream = LOBInputStream; } } // namespace Poco::Data diff --git a/Data/include/Poco/Data/Limit.h b/Data/include/Poco/Data/Limit.h index f45ec3e98..73bccf90b 100644 --- a/Data/include/Poco/Data/Limit.h +++ b/Data/include/Poco/Data/Limit.h @@ -29,7 +29,7 @@ class Data_API Limit /// Limit stores information how many rows a query should return. { public: - typedef Poco::UInt32 SizeT; + using SizeT = Poco::UInt32; enum Type { diff --git a/Data/include/Poco/Data/MetaColumn.h b/Data/include/Poco/Data/MetaColumn.h index 65410a07d..525085911 100644 --- a/Data/include/Poco/Data/MetaColumn.h +++ b/Data/include/Poco/Data/MetaColumn.h @@ -64,7 +64,22 @@ public: bool nullable = false); /// Creates the MetaColumn. - virtual ~MetaColumn(); + MetaColumn(const MetaColumn& other); + /// Copy constructor. + + MetaColumn(MetaColumn&& other) noexcept; + /// Move constructor. + + MetaColumn& operator = (const MetaColumn& other); + /// Assignment operator. + + MetaColumn& operator = (MetaColumn&& other) noexcept; + /// Assignment operator. + + void swap(MetaColumn& other); + /// Swaps the contents with another instance. + + ~MetaColumn(); /// Destroys the MetaColumn. const std::string& name() const; diff --git a/Data/include/Poco/Data/PooledSessionImpl.h b/Data/include/Poco/Data/PooledSessionImpl.h index e4a83cdee..e96491905 100644 --- a/Data/include/Poco/Data/PooledSessionImpl.h +++ b/Data/include/Poco/Data/PooledSessionImpl.h @@ -55,7 +55,7 @@ public: void setConnectionTimeout(std::size_t timeout); std::size_t getConnectionTimeout() const; bool canTransact() const; - bool isTransaction()const ; + bool isTransaction() const; void setTransactionIsolation(Poco::UInt32); Poco::UInt32 getTransactionIsolation() const; bool hasTransactionIsolation(Poco::UInt32) const; diff --git a/Data/include/Poco/Data/Preparation.h b/Data/include/Poco/Data/Preparation.h index f573a2099..6515063d9 100644 --- a/Data/include/Poco/Data/Preparation.h +++ b/Data/include/Poco/Data/Preparation.h @@ -60,7 +60,7 @@ private: template -class Preparation >: public AbstractPreparation +class Preparation>: public AbstractPreparation /// Preparation specialization for std::vector. /// This specialization is needed for bulk operations to enforce /// the whole vector preparation, rather than only individual contained values. @@ -82,7 +82,7 @@ public: void prepare() /// Prepares data. { - TypeHandler >::prepare(_pos, _val, preparation()); + TypeHandler>::prepare(_pos, _val, preparation()); } private: @@ -92,7 +92,7 @@ private: template -class Preparation >: public AbstractPreparation +class Preparation>: public AbstractPreparation /// Preparation specialization for std::deque. /// This specialization is needed for bulk operations to enforce /// the whole deque preparation, rather than only individual contained values. @@ -114,7 +114,7 @@ public: void prepare() /// Prepares data. { - TypeHandler >::prepare(_pos, _val, preparation()); + TypeHandler>::prepare(_pos, _val, preparation()); } private: @@ -124,7 +124,7 @@ private: template -class Preparation >: public AbstractPreparation +class Preparation>: public AbstractPreparation /// Preparation specialization for std::list. /// This specialization is needed for bulk operations to enforce /// the whole list preparation, rather than only individual contained values. @@ -146,7 +146,7 @@ public: void prepare() /// Prepares data. { - TypeHandler >::prepare(_pos, _val, preparation()); + TypeHandler>::prepare(_pos, _val, preparation()); } private: diff --git a/Data/include/Poco/Data/RecordSet.h b/Data/include/Poco/Data/RecordSet.h index 050b38927..d3733cfe2 100644 --- a/Data/include/Poco/Data/RecordSet.h +++ b/Data/include/Poco/Data/RecordSet.h @@ -69,9 +69,9 @@ class Data_API RecordSet: private Statement /// a limit for the Statement. { public: - typedef std::map RowMap; - typedef const RowIterator ConstIterator; - typedef RowIterator Iterator; + using RowMap = std::map; + using ConstIterator = const RowIterator; + using Iterator = RowIterator; using Statement::isNull; using Statement::subTotalRowCount; @@ -107,15 +107,24 @@ public: RecordSet(const RecordSet& other); /// Copy-creates the recordset. + RecordSet(RecordSet&& other) noexcept; + /// Move-creates the recordset. + ~RecordSet(); /// Destroys the RecordSet. void setRowFormatter(RowFormatter::Ptr pRowFormatter); /// Assigns the row formatter to the statement and all recordset rows. - Statement& operator = (const Statement& stmt); + RecordSet& operator = (const Statement& stmt); /// Assignment operator. + RecordSet& operator = (const RecordSet& other); + /// Assignment operator. + + RecordSet& operator = (RecordSet&& other) noexcept; + /// Move assignment. + std::size_t rowCount() const; /// Returns the number of rows in the RecordSet. /// The number of rows reported is dependent on filtering. @@ -159,12 +168,12 @@ public: { if (isBulkExtraction()) { - typedef InternalBulkExtraction E; + using E = InternalBulkExtraction; return columnImpl(name); } else { - typedef InternalExtraction E; + using E = InternalExtraction; return columnImpl(name); } } @@ -175,12 +184,12 @@ public: { if (isBulkExtraction()) { - typedef InternalBulkExtraction E; + using E = InternalBulkExtraction; return columnImpl(pos); } else { - typedef InternalExtraction E; + using E = InternalExtraction; return columnImpl(pos); } } @@ -200,18 +209,18 @@ public: { case STORAGE_VECTOR: { - typedef typename std::vector C; + using C = typename std::vector; return column(col).value(row); } case STORAGE_LIST: { - typedef typename std::list C; + using C = typename std::list; return column(col).value(row); } case STORAGE_DEQUE: case STORAGE_UNKNOWN: { - typedef typename std::deque C; + using C = typename std::deque; return column(col).value(row); } default: @@ -230,18 +239,18 @@ public: { case STORAGE_VECTOR: { - typedef typename std::vector C; + using C = typename std::vector; return column(name).value(row); } case STORAGE_LIST: { - typedef typename std::list C; + using C = typename std::list; return column(name).value(row); } case STORAGE_DEQUE: case STORAGE_UNKNOWN: { - typedef typename std::deque C; + using C = typename std::deque; return column(name).value(row); } default: @@ -404,8 +413,8 @@ private: std::size_t columnPosition(const std::string& name) const /// Returns the position of the column with specified name. { - typedef typename C::value_type T; - typedef const E* ExtractionVecPtr; + using T = typename C::value_type; + using ExtractionVecPtr = const E*; bool typeFound = false; @@ -443,8 +452,8 @@ private: const Column& columnImpl(std::size_t pos) const /// Returns the reference to column at specified position. { - typedef typename C::value_type T; - typedef const E* ExtractionVecPtr; + using T = typename C::value_type; + using ExtractionVecPtr = const E*; const AbstractExtractionVec& rExtractions = extractions(); @@ -532,13 +541,20 @@ inline std::size_t RecordSet::columnCount() const } -inline Statement& RecordSet::operator = (const Statement& stmt) +inline RecordSet& RecordSet::operator = (const Statement& stmt) { reset(stmt); return *this; } +inline RecordSet& RecordSet::operator = (const RecordSet& other) +{ + reset(other); + return *this; +} + + inline Poco::Dynamic::Var RecordSet::value(const std::string& name) { return value(name, _currentRow); diff --git a/Data/include/Poco/Data/Row.h b/Data/include/Poco/Data/Row.h index 614496780..110be6f0d 100644 --- a/Data/include/Poco/Data/Row.h +++ b/Data/include/Poco/Data/Row.h @@ -57,9 +57,9 @@ class Data_API Row /// The stream operator is provided for Row data type as a free-standing function. { public: - typedef RowFormatter::NameVec NameVec; - typedef RowFormatter::NameVecPtr NameVecPtr; - typedef RowFormatter::ValueVec ValueVec; + using NameVec = RowFormatter::NameVec; + using NameVecPtr = RowFormatter::NameVecPtr; + using ValueVec = RowFormatter::ValueVec; enum ComparisonType { @@ -69,14 +69,14 @@ public: COMPARE_AS_STRING }; - typedef Tuple SortTuple; - typedef std::vector SortMap; + using SortTuple = Tuple; + using SortMap = std::vector; /// The type for map holding fields used for sorting criteria. /// Fields are added sequentially and have precedence that /// corresponds to field adding sequence order (rather than field's /// position in the row). /// This requirement rules out use of std::map due to its sorted nature. - typedef SharedPtr SortMapPtr; + using SortMapPtr = SharedPtr; Row(); /// Creates the Row. diff --git a/Data/include/Poco/Data/RowFilter.h b/Data/include/Poco/Data/RowFilter.h index 0b0febd2d..37d2c903d 100644 --- a/Data/include/Poco/Data/RowFilter.h +++ b/Data/include/Poco/Data/RowFilter.h @@ -68,11 +68,11 @@ public: }; typedef bool (*CompT)(const Poco::Dynamic::Var&, const Poco::Dynamic::Var&); - typedef AutoPtr Ptr; - typedef std::map Comparisons; - typedef Tuple ComparisonEntry; - typedef std::multimap ComparisonMap; - typedef std::map, LogicOperator> FilterMap; + using Ptr = AutoPtr; + using Comparisons = std::map; + using ComparisonEntry = Tuple; + using ComparisonMap = std::multimap; + using FilterMap = std::map, LogicOperator>; RowFilter(RecordSet* pRecordSet); /// Creates the top-level RowFilter and associates it with the recordset. diff --git a/Data/include/Poco/Data/RowFormatter.h b/Data/include/Poco/Data/RowFormatter.h index a2a0c8614..a56fe6646 100644 --- a/Data/include/Poco/Data/RowFormatter.h +++ b/Data/include/Poco/Data/RowFormatter.h @@ -68,10 +68,10 @@ class Data_API RowFormatter /// { public: - typedef SharedPtr Ptr; - typedef std::vector NameVec; - typedef SharedPtr > NameVecPtr; - typedef std::vector ValueVec; + using Ptr = SharedPtr; + using NameVec = std::vector; + using NameVecPtr = SharedPtr>; + using ValueVec = std::vector; static const int INVALID_ROW_COUNT = -1; diff --git a/Data/include/Poco/Data/RowIterator.h b/Data/include/Poco/Data/RowIterator.h index 32ca45bd4..0960b3a75 100644 --- a/Data/include/Poco/Data/RowIterator.h +++ b/Data/include/Poco/Data/RowIterator.h @@ -36,11 +36,11 @@ class Data_API RowIterator /// RowIterator class. { public: - typedef std::bidirectional_iterator_tag iterator_category; - typedef Row value_type; - typedef std::ptrdiff_t difference_type; - typedef Row* pointer; - typedef Row& reference; + using iterator_category = std::bidirectional_iterator_tag; + using value_type = Row; + using difference_type = std::ptrdiff_t; + using pointer = Row*; + using reference = Row&; static const std::size_t POSITION_END; /// End position indicator. @@ -53,12 +53,18 @@ public: RowIterator(const RowIterator& other); /// Creates a copy of other RowIterator. + RowIterator(RowIterator&& other) noexcept; + /// Move constructor. + ~RowIterator(); /// Destroys the RowIterator. RowIterator& operator = (const RowIterator& other); /// Assigns the other RowIterator. + RowIterator& operator = (RowIterator&& other) noexcept; + /// Move assignment. + bool operator == (const RowIterator& other) const; /// Equality operator. diff --git a/Data/include/Poco/Data/SQLChannel.h b/Data/include/Poco/Data/SQLChannel.h index 286629f90..c64e91c45 100644 --- a/Data/include/Poco/Data/SQLChannel.h +++ b/Data/include/Poco/Data/SQLChannel.h @@ -61,6 +61,8 @@ class Data_API SQLChannel: public Poco::Channel /// a risk of long blocking periods in case of remote server communication delays. { public: + using Ptr = Poco::AutoPtr; + SQLChannel(); /// Creates SQLChannel. @@ -140,10 +142,10 @@ protected: ~SQLChannel(); private: - typedef Poco::SharedPtr SessionPtr; - typedef Poco::SharedPtr StatementPtr; - typedef Poco::Message::Priority Priority; - typedef Poco::SharedPtr StrategyPtr; + using SessionPtr = Poco::SharedPtr; + using StatementPtr = Poco::SharedPtr; + using Priority = Poco::Message::Priority; + using StrategyPtr = Poco::SharedPtr; void initLogStatement(); /// Initiallizes the log statement. diff --git a/Data/include/Poco/Data/Session.h b/Data/include/Poco/Data/Session.h index 817ce6835..a3d4ec09e 100644 --- a/Data/include/Poco/Data/Session.h +++ b/Data/include/Poco/Data/Session.h @@ -176,9 +176,15 @@ public: Session(const Session&); /// Creates a session by copying another one. + Session(Session&&) noexcept; + /// Creates a session by moving another one. + Session& operator = (const Session&); /// Assignment operator. + Session& operator = (Session&&) noexcept; + /// Move assignment. + ~Session(); /// Destroys the Session. diff --git a/Data/include/Poco/Data/SessionImpl.h b/Data/include/Poco/Data/SessionImpl.h index bc8537f7b..f86a93249 100644 --- a/Data/include/Poco/Data/SessionImpl.h +++ b/Data/include/Poco/Data/SessionImpl.h @@ -39,7 +39,7 @@ class Data_API SessionImpl: public Poco::RefCountedObject /// SessionImpl objects are noncopyable. { public: - typedef Poco::AutoPtr Ptr; + using Ptr = Poco::AutoPtr; static const std::size_t LOGIN_TIMEOUT_INFINITE = 0; /// Infinite connection/login timeout. diff --git a/Data/include/Poco/Data/SimpleRowFormatter.h b/Data/include/Poco/Data/SimpleRowFormatter.h index 2ddfdac9c..67d82c6a8 100644 --- a/Data/include/Poco/Data/SimpleRowFormatter.h +++ b/Data/include/Poco/Data/SimpleRowFormatter.h @@ -30,9 +30,9 @@ class Data_API SimpleRowFormatter: public RowFormatter /// A simple row formatting class. { public: - //typedef RowFormatter::NameVec NameVec; - //typedef RowFormatter::NameVecPtr NameVecPtr; - //typedef RowFormatter::ValueVec ValueVec; + //using NameVec = RowFormatter::NameVec; + //using NameVecPtr = RowFormatter::NameVecPtr; + //using ValueVec = RowFormatter::ValueVec; static const int DEFAULT_COLUMN_WIDTH = 16; static const int DEFAULT_SPACING = 1; diff --git a/Data/include/Poco/Data/Statement.h b/Data/include/Poco/Data/Statement.h index 5373e092c..f17f9ddb5 100644 --- a/Data/include/Poco/Data/Statement.h +++ b/Data/include/Poco/Data/Statement.h @@ -74,10 +74,10 @@ class Data_API Statement public: typedef void (*Manipulator)(Statement&); - typedef ActiveResult Result; - typedef SharedPtr ResultPtr; - typedef ActiveMethod AsyncExecMethod; - typedef SharedPtr AsyncExecMethodPtr; + using Result = ActiveResult; + using ResultPtr = SharedPtr; + using AsyncExecMethod = ActiveMethod; + using AsyncExecMethodPtr = SharedPtr; static const int WAIT_FOREVER = -1; @@ -115,9 +115,15 @@ public: /// synchronized prior to copy operation (i.e. is copied while executing), /// this constructor shall synchronize it. + Statement(Statement&& other) noexcept; + /// Move constructor. + Statement& operator = (const Statement& stmt); /// Assignment operator. + Statement& operator = (Statement&& stmt) noexcept; + /// Move assignment. + void swap(Statement& other); /// Swaps the statement with another one. @@ -379,7 +385,7 @@ public: /// Statement takes the ownership of the formatter. protected: - typedef StatementImpl::Ptr ImplPtr; + using ImplPtr = StatementImpl::Ptr; const AbstractExtractionVec& extractions() const; /// Returns the extractions vector. @@ -406,7 +412,6 @@ protected: /// Returns the underlying session. private: - const Result& doAsyncExec(bool reset = true); /// Asynchronously executes the statement. diff --git a/Data/include/Poco/Data/StatementCreator.h b/Data/include/Poco/Data/StatementCreator.h index ca2780417..635de7e1d 100644 --- a/Data/include/Poco/Data/StatementCreator.h +++ b/Data/include/Poco/Data/StatementCreator.h @@ -41,11 +41,17 @@ public: StatementCreator(const StatementCreator& other); /// Creates a StatementCreator by copying another one. + StatementCreator(StatementCreator&& other) noexcept; + /// Creates a StatementCreator by moving another one. + ~StatementCreator(); /// Destroys the StatementCreator. StatementCreator& operator = (const StatementCreator& other); /// Assignment operator. + + StatementCreator& operator = (StatementCreator&& other) noexcept; + /// Assignment operator. void swap(StatementCreator& other); /// Swaps the StatementCreator with another one. diff --git a/Data/include/Poco/Data/StatementImpl.h b/Data/include/Poco/Data/StatementImpl.h index d9371a740..39d06f745 100644 --- a/Data/include/Poco/Data/StatementImpl.h +++ b/Data/include/Poco/Data/StatementImpl.h @@ -48,7 +48,7 @@ class Data_API StatementImpl /// StatementImpl's are noncopyable. { public: - typedef Poco::SharedPtr Ptr; + using Ptr = Poco::SharedPtr; enum State { @@ -243,11 +243,11 @@ protected: /// session is queried for container type setting. If the /// session container type setting is found, it is used. /// 3. If neither session nor statement have the internal - /// container type set, std::deque is used. + /// container type set, std::vector is used. /// /// Supported internal extraction container types are: - /// - std::deque (default) - /// - std::vector + /// - std::vector (default) + /// - std::deque /// - std::list SessionImpl& session(); @@ -317,7 +317,7 @@ private: /// Resets extraction so it can be reused again. template - SharedPtr > createExtract(const MetaColumn& mc) + SharedPtr> createExtract(const MetaColumn& mc) { C* pData = new C; Column* pCol = new Column(mc, pData); @@ -325,7 +325,7 @@ private: } template - SharedPtr > createBulkExtract(const MetaColumn& mc) + SharedPtr> createBulkExtract(const MetaColumn& mc) { C* pData = new C; Column* pCol = new Column(mc, pData); @@ -346,7 +346,7 @@ private: /// overrides the session setting for storage, otherwise the /// session setting is used. /// If neither this statement nor the session have the storage - /// type set, std::deque is the default container type used. + /// type set, std::vector is the default container type used. { std::string storage; @@ -368,23 +368,23 @@ private: if (0 == icompare(DEQUE, storage)) { if (!isBulkExtraction()) - addExtract(createExtract >(mc)); + addExtract(createExtract>(mc)); else - addExtract(createBulkExtract >(mc)); + addExtract(createBulkExtract>(mc)); } else if (0 == icompare(VECTOR, storage)) { if (!isBulkExtraction()) - addExtract(createExtract >(mc)); + addExtract(createExtract>(mc)); else - addExtract(createBulkExtract >(mc)); + addExtract(createBulkExtract>(mc)); } else if (0 == icompare(LIST, storage)) { if (!isBulkExtraction()) - addExtract(createExtract >(mc)); + addExtract(createExtract>(mc)); else - addExtract(createBulkExtract >(mc)); + addExtract(createBulkExtract>(mc)); } } @@ -430,7 +430,7 @@ private: StatementImpl(const StatementImpl& stmt); StatementImpl& operator = (const StatementImpl& stmt); - typedef std::vector CountVec; + using CountVec = std::vector; State _state; Limit _extrLimit; diff --git a/Data/include/Poco/Data/TypeHandler.h b/Data/include/Poco/Data/TypeHandler.h index 4a2424cd1..4cb6efc1d 100644 --- a/Data/include/Poco/Data/TypeHandler.h +++ b/Data/include/Poco/Data/TypeHandler.h @@ -145,7 +145,7 @@ private: template -class TypeHandler >: public AbstractTypeHandler +class TypeHandler>: public AbstractTypeHandler /// Specialization of type handler for std::deque. { public: @@ -180,7 +180,7 @@ private: template -class TypeHandler >: public AbstractTypeHandler +class TypeHandler>: public AbstractTypeHandler /// Specialization of type handler for std::vector. { public: @@ -215,7 +215,7 @@ private: template -class TypeHandler >: public AbstractTypeHandler +class TypeHandler>: public AbstractTypeHandler /// Specialization of type handler for std::list. { public: @@ -249,7 +249,7 @@ private: }; template -class TypeHandler > +class TypeHandler> /// Specialization of type handler for Nullable. { public: @@ -363,11 +363,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -493,11 +493,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -618,11 +618,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -738,11 +738,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -853,11 +853,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -963,11 +963,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1068,11 +1068,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1168,11 +1168,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1263,11 +1263,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1353,11 +1353,11 @@ template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1429,11 +1429,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1501,11 +1501,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1569,11 +1569,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1633,11 +1633,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1693,11 +1693,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1749,11 +1749,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1801,11 +1801,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1849,11 +1849,11 @@ private: template - class TypeHandler > + class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1893,11 +1893,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1933,11 +1933,11 @@ private: template -class TypeHandler > +class TypeHandler> { public: - typedef typename Poco::TypeWrapper >::CONSTREFTYPE TupleConstRef; - typedef typename Poco::TypeWrapper >::REFTYPE TupleRef; + using TupleConstRef = typename Poco::TypeWrapper>::CONSTREFTYPE; + using TupleRef = typename Poco::TypeWrapper>::REFTYPE; static void bind(std::size_t pos, TupleConstRef tuple, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) { @@ -1970,7 +1970,7 @@ private: template -class TypeHandler >: public AbstractTypeHandler +class TypeHandler>: public AbstractTypeHandler { public: static void bind(std::size_t pos, const std::pair& obj, AbstractBinder::Ptr pBinder, AbstractBinder::Direction dir) @@ -2006,7 +2006,7 @@ private: template -class TypeHandler >: public AbstractTypeHandler +class TypeHandler>: public AbstractTypeHandler /// Specialization of type handler for Poco::AutoPtr { public: @@ -2046,7 +2046,7 @@ private: template -class TypeHandler >: public AbstractTypeHandler +class TypeHandler>: public AbstractTypeHandler /// Specialization of type handler for Poco::SharedPtr { public: diff --git a/Data/src/MetaColumn.cpp b/Data/src/MetaColumn.cpp index 7b937e6a4..940a10a03 100644 --- a/Data/src/MetaColumn.cpp +++ b/Data/src/MetaColumn.cpp @@ -45,9 +45,61 @@ MetaColumn::MetaColumn(std::size_t position, } +MetaColumn::MetaColumn(const MetaColumn& other): + _name(other._name), + _length(other._length), + _precision(other._precision), + _position(other._position), + _type(other._type), + _nullable(other._nullable) +{ +} + + +MetaColumn::MetaColumn(MetaColumn&& other) noexcept: + _name(std::move(other._name)), + _length(other._length), + _precision(other._precision), + _position(other._position), + _type(other._type), + _nullable(other._nullable) +{ +} + + MetaColumn::~MetaColumn() { } +MetaColumn& MetaColumn::operator = (const MetaColumn& other) +{ + MetaColumn tmp(other); + swap(tmp); + return *this; +} + + +MetaColumn& MetaColumn::operator = (MetaColumn&& other) noexcept +{ + _name = std::move(other._name); + _length = other._length; + _precision = other._precision; + _position = other._position; + _type = other._type; + _nullable = other._nullable; + return *this; +} + +void MetaColumn::swap(MetaColumn& other) +{ + std::swap(_name, other._name); + std::swap(_length, other._length); + std::swap(_precision, other._precision); + std::swap(_position, other._position); + std::swap(_type, other._type); + std::swap(_nullable, other._nullable); +} + + } } // namespace Poco::Data diff --git a/Data/src/RecordSet.cpp b/Data/src/RecordSet.cpp index 0d8c143a9..d0028f301 100644 --- a/Data/src/RecordSet.cpp +++ b/Data/src/RecordSet.cpp @@ -69,6 +69,17 @@ RecordSet::RecordSet(const RecordSet& other): } +RecordSet::RecordSet(RecordSet&& other) noexcept: + Statement(std::move(other)), + _currentRow(std::move(other._currentRow)), + _pBegin(std::move(other._pBegin)), + _pEnd(std::move(other._pEnd)), + _pFilter(std::move(other._pFilter)), + _totalRowCount(std::move(other._totalRowCount)) +{ +} + + RecordSet::~RecordSet() { try @@ -87,6 +98,19 @@ RecordSet::~RecordSet() } +RecordSet& RecordSet::operator = (RecordSet&& other) noexcept +{ + Statement::operator = (std::move(other)); + _currentRow = std::move(other._currentRow); + _pBegin = std::move(other._pBegin); + _pEnd = std::move(other._pEnd); + _pFilter = std::move(other._pFilter); + _totalRowCount = std::move(other._totalRowCount); + + return *this; +} + + void RecordSet::reset(const Statement& stmt) { delete _pBegin; diff --git a/Data/src/RowIterator.cpp b/Data/src/RowIterator.cpp index c7e1f45c3..912002111 100644 --- a/Data/src/RowIterator.cpp +++ b/Data/src/RowIterator.cpp @@ -40,6 +40,12 @@ RowIterator::RowIterator(const RowIterator& other): } +RowIterator::RowIterator(RowIterator&& other) noexcept: + _pRecordSet(std::move(other._pRecordSet)), + _position(std::move(other._position)) +{ +} + RowIterator::~RowIterator() { } @@ -53,6 +59,14 @@ RowIterator& RowIterator::operator = (const RowIterator& other) } +RowIterator& RowIterator::operator = (RowIterator&& other) noexcept +{ + _pRecordSet = std::move(other._pRecordSet); + _position = std::move(other._position); + return *this; +} + + void RowIterator::swap(RowIterator& other) { using std::swap; diff --git a/Data/src/SQLChannel.cpp b/Data/src/SQLChannel.cpp index bd23fc9a5..7818aa327 100644 --- a/Data/src/SQLChannel.cpp +++ b/Data/src/SQLChannel.cpp @@ -244,7 +244,7 @@ std::string SQLChannel::getProperty(const std::string& name) const } else if (name == PROP_ARCHIVE_TABLE) { - return _pArchiveStrategy ? _pArchiveStrategy->getDestination() : "" ; + return _pArchiveStrategy ? _pArchiveStrategy->getDestination() : ""; } else if (name == PROP_MAX_AGE) { diff --git a/Data/src/Session.cpp b/Data/src/Session.cpp index e2cc6b6dd..0bd9f90d1 100644 --- a/Data/src/Session.cpp +++ b/Data/src/Session.cpp @@ -48,12 +48,19 @@ Session::Session(const std::string& connection, } -Session::Session(const Session& other): _pImpl(other._pImpl), +Session::Session(const Session& other): + _pImpl(other._pImpl), _statementCreator(other._pImpl) { } +Session::Session(Session&& other) noexcept: + _pImpl(std::move(other._pImpl)), + _statementCreator(std::move(other._pImpl)) +{ +} + Session::~Session() { } @@ -67,6 +74,14 @@ Session& Session::operator = (const Session& other) } +Session& Session::operator = (Session&& other) noexcept +{ + _pImpl = std::move(other._pImpl); + _statementCreator = std::move(other._statementCreator); + return *this; +} + + void Session::swap(Session& other) { using std::swap; diff --git a/Data/src/Statement.cpp b/Data/src/Statement.cpp index d4c470ae8..d67ba0553 100644 --- a/Data/src/Statement.cpp +++ b/Data/src/Statement.cpp @@ -53,6 +53,17 @@ Statement::Statement(const Statement& stmt): } +Statement::Statement(Statement&& stmt) noexcept: + _pImpl(std::move(stmt._pImpl)), + _async(std::move(stmt._async)), + _pResult(std::move(stmt._pResult)), + _pAsyncExec(std::move(stmt._pAsyncExec)), + _arguments(std::move(stmt._arguments)), + _pRowFormatter(std::move(stmt._pRowFormatter)) +{ +} + + Statement::~Statement() { } @@ -66,6 +77,18 @@ Statement& Statement::operator = (const Statement& stmt) } +Statement& Statement::operator = (Statement&& stmt) noexcept +{ + _pImpl = std::move(stmt._pImpl); + _async = std::move(stmt._async); + _pResult = std::move(stmt._pResult); + _pAsyncExec = std::move(stmt._pAsyncExec); + _arguments = std::move(stmt._arguments); + _pRowFormatter = std::move(stmt._pRowFormatter); + + return *this; +} + void Statement::swap(Statement& other) { using std::swap; diff --git a/Data/src/StatementCreator.cpp b/Data/src/StatementCreator.cpp index 6fd944aa0..56d9bc679 100644 --- a/Data/src/StatementCreator.cpp +++ b/Data/src/StatementCreator.cpp @@ -37,6 +37,12 @@ StatementCreator::StatementCreator(const StatementCreator& other): } +StatementCreator::StatementCreator(StatementCreator&& other) noexcept: + _ptrImpl(std::move(other._ptrImpl)) +{ +} + + StatementCreator& StatementCreator::operator = (const StatementCreator& other) { StatementCreator tmp(other); @@ -45,6 +51,12 @@ StatementCreator& StatementCreator::operator = (const StatementCreator& other) } +StatementCreator& StatementCreator::operator = (StatementCreator&& other) noexcept +{ + _ptrImpl = std::move(other._ptrImpl); + return *this; +} + void StatementCreator::swap(StatementCreator& other) { using std::swap; diff --git a/Data/testsuite/src/DataTest.cpp b/Data/testsuite/src/DataTest.cpp index d837538c1..297d0acdb 100644 --- a/Data/testsuite/src/DataTest.cpp +++ b/Data/testsuite/src/DataTest.cpp @@ -482,7 +482,7 @@ void DataTest::testColumnVector() pData->push_back(4); pData->push_back(5); - Column > c(mc, pData); + Column> c(mc, pData); assertTrue (c.rowCount() == 5); assertTrue (c[0] == 1); @@ -503,7 +503,7 @@ void DataTest::testColumnVector() } catch (RangeException&) { } - Column > c1 = c; + Column> c1 = c; assertTrue (c1.rowCount() == 5); assertTrue (c1[0] == 1); @@ -512,7 +512,7 @@ void DataTest::testColumnVector() assertTrue (c1[3] == 4); assertTrue (c1[4] == 5); - Column > c2(c1); + Column> c2(c1); assertTrue (c2.rowCount() == 5); assertTrue (c2[0] == 1); @@ -547,8 +547,8 @@ void DataTest::testColumnVector() pV2->push_back(3); pV2->push_back(2); pV2->push_back(1); - Column > c3(mc, pV1); - Column > c4(mc, pV2); + Column> c3(mc, pV1); + Column> c4(mc, pV2); Poco::Data::swap(c3, c4); assertTrue (c3[0] == 5); @@ -589,7 +589,7 @@ void DataTest::testColumnVectorBool() pData->push_back(false); pData->push_back(true); - Column > c(mc, pData); + Column> c(mc, pData); assertTrue (c.rowCount() == 5); assertTrue (c[0] == true); @@ -606,7 +606,7 @@ void DataTest::testColumnVectorBool() } catch (RangeException&) { } - Column > c1 = c; + Column> c1 = c; assertTrue (c1.rowCount() == 5); assertTrue (c1[0] == true); @@ -615,7 +615,7 @@ void DataTest::testColumnVectorBool() assertTrue (c1[3] == false); assertTrue (c1[4] == true); - Column > c2(c1); + Column> c2(c1); assertTrue (c2.rowCount() == 5); assertTrue (c2[0] == true); @@ -642,8 +642,8 @@ void DataTest::testColumnVectorBool() void DataTest::testColumnDeque() { - typedef std::deque ContainerType; - typedef Column ColumnType; + using ContainerType = std::deque; + using ColumnType = Column; MetaColumn mc(0, "mc", MetaColumn::FDT_DOUBLE, 2, 3, true); @@ -759,8 +759,8 @@ void DataTest::testColumnDeque() void DataTest::testColumnList() { - typedef std::list ContainerType; - typedef Column ColumnType; + using ContainerType = std::list; + using ColumnType = Column; MetaColumn mc(0, "mc", MetaColumn::FDT_DOUBLE, 2, 3, true); diff --git a/Data/testsuite/src/TestStatementImpl.cpp b/Data/testsuite/src/TestStatementImpl.cpp index e4f4bca08..09cfca2a3 100644 --- a/Data/testsuite/src/TestStatementImpl.cpp +++ b/Data/testsuite/src/TestStatementImpl.cpp @@ -48,7 +48,7 @@ bool TestStatementImpl::canBind() const void TestStatementImpl::bindImpl() { // bind - typedef Poco::Data::AbstractBindingVec Bindings; + using Bindings = Poco::Data::AbstractBindingVec; Bindings& binds = bindings(); if (binds.empty()) return; diff --git a/Foundation/include/Poco/AbstractCache.h b/Foundation/include/Poco/AbstractCache.h index 37cfc25b1..15decc492 100644 --- a/Foundation/include/Poco/AbstractCache.h +++ b/Foundation/include/Poco/AbstractCache.h @@ -39,13 +39,13 @@ class AbstractCache /// An AbstractCache is the interface of all caches. { public: - FIFOEvent, TEventMutex > Add; - FIFOEvent, TEventMutex > Update; - FIFOEvent Remove; - FIFOEvent Get; - FIFOEvent Clear; + FIFOEvent, TEventMutex> Add; + FIFOEvent, TEventMutex> Update; + FIFOEvent Remove; + FIFOEvent Get; + FIFOEvent Clear; - typedef std::map > DataHolder; + typedef std::map> DataHolder; typedef typename DataHolder::iterator Iterator; typedef typename DataHolder::const_iterator ConstIterator; typedef std::set KeySet; @@ -85,7 +85,7 @@ public: /// If for the key already an entry exists, it will be overwritten. /// The difference to add is that no remove or add events are thrown in this case, /// just a simply silent update is performed - /// If the key doesnot exist the behavior is equal to add, ie. an add event is thrown + /// If the key does not exist the behavior is equal to add, ie. an add event is thrown { typename TMutex::ScopedLock lock(_mutex); doUpdate(key, val); @@ -105,7 +105,7 @@ public: /// If for the key already an entry exists, it will be overwritten. /// The difference to add is that no remove or add events are thrown in this case, /// just an Update is thrown - /// If the key doesnot exist the behavior is equal to add, ie. an add event is thrown + /// If the key does not exist the behavior is equal to add, ie. an add event is thrown { typename TMutex::ScopedLock lock(_mutex); doUpdate(key, val); @@ -177,30 +177,30 @@ public: } protected: - mutable FIFOEvent > IsValid; - mutable FIFOEvent Replace; + mutable FIFOEvent> IsValid; + mutable FIFOEvent Replace; void initialize() /// Sets up event registration. { - Add += Delegate >(&_strategy, &TStrategy::onAdd); - Update += Delegate >(&_strategy, &TStrategy::onUpdate); + Add += Delegate>(&_strategy, &TStrategy::onAdd); + Update += Delegate>(&_strategy, &TStrategy::onUpdate); Remove += Delegate(&_strategy, &TStrategy::onRemove); Get += Delegate(&_strategy, &TStrategy::onGet); Clear += Delegate(&_strategy, &TStrategy::onClear); - IsValid += Delegate >(&_strategy, &TStrategy::onIsValid); + IsValid += Delegate>(&_strategy, &TStrategy::onIsValid); Replace += Delegate(&_strategy, &TStrategy::onReplace); } void uninitialize() /// Reverts event registration. { - Add -= Delegate >(&_strategy, &TStrategy::onAdd ); - Update -= Delegate >(&_strategy, &TStrategy::onUpdate); + Add -= Delegate>(&_strategy, &TStrategy::onAdd ); + Update -= Delegate>(&_strategy, &TStrategy::onUpdate); Remove -= Delegate(&_strategy, &TStrategy::onRemove); Get -= Delegate(&_strategy, &TStrategy::onGet); Clear -= Delegate(&_strategy, &TStrategy::onClear); - IsValid -= Delegate >(&_strategy, &TStrategy::onIsValid); + IsValid -= Delegate>(&_strategy, &TStrategy::onIsValid); Replace -= Delegate(&_strategy, &TStrategy::onReplace); } diff --git a/Foundation/include/Poco/AbstractEvent.h b/Foundation/include/Poco/AbstractEvent.h index 917092a9a..d3724c909 100644 --- a/Foundation/include/Poco/AbstractEvent.h +++ b/Foundation/include/Poco/AbstractEvent.h @@ -244,14 +244,16 @@ public: strategy.notify(pSender, args); } - bool hasDelegates() const { + bool hasDelegates() const + /// Returns true if there are registered delegates. + { return !empty(); } ActiveResult notifyAsync(const void* pSender, const TArgs& args) /// Sends a notification to all registered delegates. The order is /// determined by the TStrategy. This method is not blocking and will - /// immediately return. The delegates are invoked in a seperate thread. + /// immediately return. The delegates are invoked in a separate thread. /// Call activeResult.wait() to wait until the notification has ended. /// While executing, other objects can change the delegate list. These changes don't /// influence the current active notifications but are activated with @@ -293,6 +295,7 @@ public: } bool isEnabled() const + /// Returns true if event is enabled. { typename TMutex::ScopedLock lock(_mutex); return _enabled; @@ -342,7 +345,7 @@ protected: } TStrategy _strategy; /// The strategy used to notify observers. - bool _enabled; /// Stores if an event is enabled. Notfies on disabled events have no effect + bool _enabled; /// Stores if an event is enabled. Notifies on disabled events have no effect /// but it is possible to change the observers. mutable TMutex _mutex; @@ -453,7 +456,7 @@ public: ActiveResult notifyAsync(const void* pSender) /// Sends a notification to all registered delegates. The order is /// determined by the TStrategy. This method is not blocking and will - /// immediately return. The delegates are invoked in a seperate thread. + /// immediately return. The delegates are invoked in a separate thread. /// Call activeResult.wait() to wait until the notification has ended. /// While executing, other objects can change the delegate list. These changes don't /// influence the current active notifications but are activated with @@ -542,7 +545,7 @@ protected: } TStrategy _strategy; /// The strategy used to notify observers. - bool _enabled; /// Stores if an event is enabled. Notfies on disabled events have no effect + bool _enabled; /// Stores if an event is enabled. Notifies on disabled events have no effect /// but it is possible to change the observers. mutable TMutex _mutex; diff --git a/Foundation/include/Poco/AbstractStrategy.h b/Foundation/include/Poco/AbstractStrategy.h index 8d0ac25a2..0bd8b548f 100644 --- a/Foundation/include/Poco/AbstractStrategy.h +++ b/Foundation/include/Poco/AbstractStrategy.h @@ -67,7 +67,7 @@ public: virtual void onReplace(const void* pSender, std::set& elemsToRemove) = 0; /// Used by the Strategy to indicate which elements should be removed from /// the cache. Note that onReplace does not change the current list of keys. - /// The cache object is reponsible to remove the elements. + /// The cache object is responsible to remove the elements. }; diff --git a/Foundation/include/Poco/AccessExpireLRUCache.h b/Foundation/include/Poco/AccessExpireLRUCache.h index 278cbbccd..2833894b6 100644 --- a/Foundation/include/Poco/AccessExpireLRUCache.h +++ b/Foundation/include/Poco/AccessExpireLRUCache.h @@ -39,7 +39,7 @@ class AccessExpireLRUCache: public AbstractCache, TMutex, TEventMutex >(StrategyCollection()) { this->_strategy.pushBack(new LRUStrategy(cacheSize)); diff --git a/Foundation/include/Poco/ActiveDispatcher.h b/Foundation/include/Poco/ActiveDispatcher.h index 7550a2dea..578a42087 100644 --- a/Foundation/include/Poco/ActiveDispatcher.h +++ b/Foundation/include/Poco/ActiveDispatcher.h @@ -55,7 +55,7 @@ class Foundation_API ActiveDispatcher: protected Runnable /// { /// } /// - /// ActiveMethod > exampleActiveMethod; + /// ActiveMethod> exampleActiveMethod; /// /// protected: /// std::string exampleActiveMethodImpl(const std::string& arg) diff --git a/Foundation/include/Poco/ActiveMethod.h b/Foundation/include/Poco/ActiveMethod.h index cefd8f76d..8ab483572 100644 --- a/Foundation/include/Poco/ActiveMethod.h +++ b/Foundation/include/Poco/ActiveMethod.h @@ -28,7 +28,7 @@ namespace Poco { -template > +template > class ActiveMethod /// An active method is a method that, when called, executes /// in its own thread. ActiveMethod's take exactly one diff --git a/Foundation/include/Poco/ActiveResult.h b/Foundation/include/Poco/ActiveResult.h index 4cdc0ed0b..04bd15304 100644 --- a/Foundation/include/Poco/ActiveResult.h +++ b/Foundation/include/Poco/ActiveResult.h @@ -41,7 +41,7 @@ public: ActiveResultHolder(): _pData(0), _pExc(0), - _event(false) + _event(Event::EVENT_MANUALRESET) /// Creates an ActiveResultHolder. { } @@ -147,7 +147,7 @@ class ActiveResultHolder: public RefCountedObject public: ActiveResultHolder(): _pExc(0), - _event(false) + _event(Event::EVENT_MANUALRESET) /// Creates an ActiveResultHolder. { } diff --git a/Foundation/include/Poco/ActiveRunnable.h b/Foundation/include/Poco/ActiveRunnable.h index 95317b0b3..051f3478d 100644 --- a/Foundation/include/Poco/ActiveRunnable.h +++ b/Foundation/include/Poco/ActiveRunnable.h @@ -33,7 +33,7 @@ class ActiveRunnableBase: public Runnable, public RefCountedObject /// The base class for all ActiveRunnable instantiations. { public: - typedef AutoPtr Ptr; + using Ptr = AutoPtr; }; diff --git a/Foundation/include/Poco/Activity.h b/Foundation/include/Poco/Activity.h index a7297f144..8329e6d5c 100644 --- a/Foundation/include/Poco/Activity.h +++ b/Foundation/include/Poco/Activity.h @@ -82,7 +82,7 @@ public: _runnable(*pOwner, method), _stopped(true), _running(false), - _done(false) + _done(Event::EVENT_MANUALRESET) /// Creates the activity. Call start() to /// start it. { @@ -134,8 +134,6 @@ public: void stop() /// Requests to stop the activity. { - FastMutex::ScopedLock lock(_mutex); - _stopped = true; } @@ -195,8 +193,8 @@ private: C* _pOwner; RunnableAdapterType _runnable; - volatile bool _stopped; - volatile bool _running; + std::atomic _stopped; + std::atomic _running; Event _done; FastMutex _mutex; }; diff --git a/Foundation/include/Poco/Alignment.h b/Foundation/include/Poco/Alignment.h index d655a3d9f..bf88db046 100644 --- a/Foundation/include/Poco/Alignment.h +++ b/Foundation/include/Poco/Alignment.h @@ -14,233 +14,12 @@ // -// Adapted for POCO from LLVM Compiler Infrastructure code: -// -// The LLVM Compiler Infrastructure -// -// This file is distributed under the University of Illinois Open Source License -// -//===----------------------------------------------------------------------===// -// -// This file defines the AlignOf function that computes alignments for -// arbitrary types. -// -//===----------------------------------------------------------------------===// +#ifndef Foundation_Alignment_INCLUDED +#define Foundation_Alignment_INCLUDED -#ifndef Foundation_AlignOf_INCLUDED -#define Foundation_AlignOf_INCLUDED +#include +#define POCO_HAVE_ALIGNMENT -#include - - -#ifdef POCO_ENABLE_CPP11 - - - #include - #define POCO_HAVE_ALIGNMENT - - -#else - - - namespace Poco { - - - template - struct AlignmentCalcImpl - { - char x; - T t; - private: - AlignmentCalcImpl() {} // Never instantiate. - }; - - - template - struct AlignOf - /// A templated class that contains an enum value representing - /// the alignment of the template argument. For example, - /// AlignOf::Alignment represents the alignment of type "int". The - /// alignment calculated is the minimum alignment, and not necessarily - /// the "desired" alignment returned by GCC's __alignof__ (for example). Note - /// that because the alignment is an enum value, it can be used as a - /// compile-time constant (e.g., for template instantiation). - { - enum - { - Alignment = static_cast(sizeof(AlignmentCalcImpl) - sizeof(T)) - }; - - enum { Alignment_GreaterEqual_2Bytes = Alignment >= 2 ? 1 : 0 }; - enum { Alignment_GreaterEqual_4Bytes = Alignment >= 4 ? 1 : 0 }; - enum { Alignment_GreaterEqual_8Bytes = Alignment >= 8 ? 1 : 0 }; - enum { Alignment_GreaterEqual_16Bytes = Alignment >= 16 ? 1 : 0 }; - - enum { Alignment_LessEqual_2Bytes = Alignment <= 2 ? 1 : 0 }; - enum { Alignment_LessEqual_4Bytes = Alignment <= 4 ? 1 : 0 }; - enum { Alignment_LessEqual_8Bytes = Alignment <= 8 ? 1 : 0 }; - enum { Alignment_LessEqual_16Bytes = Alignment <= 16 ? 1 : 0 }; - - }; - - - template - inline unsigned alignOf() - /// A templated function that returns the minimum alignment of - /// of a type. This provides no extra functionality beyond the AlignOf - /// class besides some cosmetic cleanliness. Example usage: - /// alignOf() returns the alignment of an int. - { - return AlignOf::Alignment; - } - - - template struct AlignedCharArrayImpl; - /// Helper for building an aligned character array type. - /// - /// This template is used to explicitly build up a collection of aligned - /// character types. We have to build these up using a macro and explicit - /// specialization to cope with old versions of MSVC and GCC where only an - /// integer literal can be used to specify an alignment constraint. Once built - /// up here, we can then begin to indirect between these using normal C++ - /// template parameters. - - - // MSVC requires special handling here. - #ifndef _MSC_VER - - #ifdef POCO_COMPILER_CLANG - - #if __has_feature(cxx_alignas) - #define POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \ - template <> struct AlignedCharArrayImpl \ - { \ - char aligned alignas(x); \ - } - #define POCO_HAVE_ALIGNMENT - #endif - - #elif defined(__GNUC__) || defined(__IBM_ATTRIBUTES) - - #define POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \ - template <> struct AlignedCharArrayImpl \ - { \ - char aligned __attribute__((aligned(x))); \ - } - #define POCO_HAVE_ALIGNMENT - - #endif - - #ifdef POCO_HAVE_ALIGNMENT - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(512); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1024); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2048); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4096); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8192); - - #undef POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT - #endif // POCO_HAVE_ALIGNMENT - - #else // _MSC_VER - - // We provide special variations of this template for the most common - // alignments because __declspec(align(...)) doesn't actually work when it is - // a member of a by-value function argument in MSVC, even if the alignment - // request is something reasonably like 8-byte or 16-byte. - template <> struct AlignedCharArrayImpl<1> { char aligned; }; - template <> struct AlignedCharArrayImpl<2> { short aligned; }; - template <> struct AlignedCharArrayImpl<4> { int aligned; }; - template <> struct AlignedCharArrayImpl<8> { double aligned; }; - - #define POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(x) \ - template <> struct AlignedCharArrayImpl { \ - __declspec(align(x)) char aligned; \ - } - - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(16); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(32); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(64); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(128); - - #if (_MSC_VER > 1600) // MSVC 2010 complains on alignment larger than 128 - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(512); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(1024); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(2048); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(4096); - POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT(8192); - #endif // _MSC_VER > 1600 - - // Any larger and MSVC complains. - #undef POCO_ALIGNEDCHARARRAY_TEMPLATE_ALIGNMENT - - #define POCO_HAVE_ALIGNMENT - #endif // _MSC_VER - - // POCO_HAVE_ALIGNMENT will be defined on the pre-C++11 platforms/compilers where - // it can be reliably determined and used. Uncomment the line below to explicitly - // disable use of alignment even for those platforms. - // #undef POCO_HAVE_ALIGNMENT - - - #ifdef POCO_HAVE_ALIGNMENT - - template - union AlignedCharArrayUnion - /// This union template exposes a suitably aligned and sized character - /// array member which can hold elements of any of up to four types. - /// - /// These types may be arrays, structs, or any other types. The goal is to - /// produce a union type containing a character array which, when used, forms - /// storage suitable to placement new any of these types over. Support for more - /// than four types can be added at the cost of more boiler plate. - { - private: - class AlignerImpl - { - T1 t1; - T2 t2; - T3 t3; - T4 t4; - - AlignerImpl(); // Never defined or instantiated. - }; - - union SizerImpl - { - char arr1[sizeof(T1)]; - char arr2[sizeof(T2)]; - char arr3[sizeof(T3)]; - char arr4[sizeof(T4)]; - }; - - public: - char buffer[sizeof(SizerImpl)]; - /// The character array buffer for use by clients. - /// - /// No other member of this union should be referenced. They exist purely to - /// constrain the layout of this character array. - - private: - Poco::AlignedCharArrayImpl::Alignment> _nonceMember; - - }; - - #endif // POCO_HAVE_ALIGNMENT - - } // namespace Poco - - -#endif // POCO_ENABLE_CPP11 - - -#endif // Foundation_AlignOf_INCLUDED +#endif // Foundation_Alignment_INCLUDED diff --git a/Foundation/include/Poco/Any.h b/Foundation/include/Poco/Any.h index 30f5b7641..30181bc2a 100644 --- a/Foundation/include/Poco/Any.h +++ b/Foundation/include/Poco/Any.h @@ -33,16 +33,13 @@ namespace Dynamic { class Var; class VarHolder; -template class VarHolderImpl; +template class VarHolderImpl; } + #ifndef POCO_NO_SOO -#ifndef POCO_ENABLE_CPP11 - // C++11 needed for std::aligned_storage - #error "Any SOO can only be enabled with C++11 support" -#endif template union Placeholder @@ -61,7 +58,7 @@ public: static const unsigned int value = SizeV; }; - Placeholder () + Placeholder() { erase(); } @@ -96,7 +93,7 @@ private: typedef typename std::aligned_storage::type AlignerType; PlaceholderT* pHolder; - mutable char holder [SizeV + 1]; + mutable char holder[SizeV + 1]; AlignerType aligner; friend class Any; @@ -121,7 +118,6 @@ union Placeholder /// where the object was allocated (0 => heap, 1 => local). { public: - Placeholder () { } @@ -136,7 +132,7 @@ public: private: #endif - PlaceholderT* pHolder; + PlaceholderT* pHolder; friend class Any; friend class Dynamic::Var; @@ -201,7 +197,7 @@ public: Any& swap(Any& other) /// Swaps the content of the two Anys. /// - /// When small object optimizaton is enabled, swap only + /// When small object optimization is enabled, swap only /// has no-throw guarantee when both (*this and other) /// objects are allocated on the heap. { @@ -270,14 +266,10 @@ public: } private: - class ValueHolder { public: - - virtual ~ValueHolder() - { - } + virtual ~ValueHolder() = default; virtual const std::type_info & type() const = 0; virtual void clone(Placeholder*) const = 0; @@ -427,9 +419,7 @@ private: class ValueHolder { public: - virtual ~ValueHolder() - { - } + virtual ~ValueHolder() = default; virtual const std::type_info& type() const = 0; virtual ValueHolder* clone() const = 0; @@ -457,7 +447,7 @@ private: ValueType _held; private: - Holder & operator=(const Holder &); + Holder & operator = (const Holder &); }; ValueHolder* content() const @@ -476,6 +466,14 @@ private: template friend ValueType* UnsafeAnyCast(Any*); + template + friend const ValueType& RefAnyCast(const Any&); + + template + friend ValueType& RefAnyCast(Any&); + + template + friend ValueType AnyCast(Any&); }; @@ -514,14 +512,26 @@ ValueType AnyCast(Any& operand) /// Example Usage: /// MyType tmp = AnyCast(anAny). /// Will throw a BadCastException if the cast fails. - /// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ... + /// Do not use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& tmp = ... /// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in /// these cases. { typedef typename TypeWrapper::TYPE NonRef; NonRef* result = AnyCast(&operand); - if (!result) throw BadCastException("Failed to convert between Any types"); + if (!result) + { + std::string s = "RefAnyCast: Failed to convert between Any types "; + if (operand._pHolder) + { + s.append(1, '('); + s.append(operand._pHolder->type().name()); + s.append(" => "); + s.append(typeid(ValueType).name()); + s.append(1, ')'); + } + throw BadCastException(s); + } return *result; } @@ -533,7 +543,7 @@ ValueType AnyCast(const Any& operand) /// Example Usage: /// MyType tmp = AnyCast(anAny). /// Will throw a BadCastException if the cast fails. - /// Dont use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ... + /// Do not use an AnyCast in combination with references, i.e. MyType& tmp = ... or const MyType& = ... /// Some compilers will accept this code although a copy is returned. Use the RefAnyCast in /// these cases. { @@ -551,7 +561,15 @@ const ValueType& RefAnyCast(const Any & operand) /// const MyType& tmp = RefAnyCast(anAny); { ValueType* result = AnyCast(const_cast(&operand)); - if (!result) throw BadCastException("RefAnyCast: Failed to convert between const Any types"); + std::string s = "RefAnyCast: Failed to convert between Any types "; + if (operand._pHolder) + { + s.append(1, '('); + s.append(operand._pHolder->type().name()); + s.append(" => "); + s.append(typeid(ValueType).name()); + s.append(1, ')'); + } return *result; } @@ -564,7 +582,19 @@ ValueType& RefAnyCast(Any& operand) /// MyType& tmp = RefAnyCast(anAny); { ValueType* result = AnyCast(&operand); - if (!result) throw BadCastException("RefAnyCast: Failed to convert between Any types"); + if (!result) + { + std::string s = "RefAnyCast: Failed to convert between Any types "; + if (operand._pHolder) + { + s.append(1, '('); + s.append(operand._pHolder->type().name()); + s.append(" => "); + s.append(typeid(ValueType).name()); + s.append(1, ')'); + } + throw BadCastException(s); + } return *result; } diff --git a/Foundation/include/Poco/Array.h b/Foundation/include/Poco/Array.h index 76e5faed8..e25851e40 100644 --- a/Foundation/include/Poco/Array.h +++ b/Foundation/include/Poco/Array.h @@ -24,12 +24,15 @@ #ifndef Foundation_Array_INCLUDED #define Foundation_Array_INCLUDED + #include "Poco/Exception.h" #include "Poco/Bugcheck.h" #include + namespace Poco { + template class Array /// STL container like C-style array replacement class. @@ -37,9 +40,7 @@ class Array /// This implementation is based on the idea of Nicolai Josuttis. /// His original implementation can be found at http://www.josuttis.com/cppcode/array.html . { - public: - typedef T value_type; typedef T* iterator; typedef const T* const_iterator; @@ -158,7 +159,8 @@ public: enum { static_size = N }; - void swap (Array& y) { + void swap (Array& y) + { std::swap_ranges(begin(),end(),y.begin()); } @@ -173,7 +175,8 @@ public: return elems; } - T* c_array(){ + T* c_array() + { /// Use array as C array (direct read/write access to data) return elems; } @@ -193,12 +196,12 @@ public: } public: - T elems[N]; /// Fixed-size array of elements of type T, public specifier used to make this class a aggregate. }; + // comparisons template bool operator== (const Array& x, const Array& y) @@ -206,36 +209,42 @@ bool operator== (const Array& x, const Array& y) return std::equal(x.begin(), x.end(), y.begin()); } + template bool operator< (const Array& x, const Array& y) { return std::lexicographical_compare(x.begin(),x.end(),y.begin(),y.end()); } + template bool operator!= (const Array& x, const Array& y) { return !(x==y); } + template bool operator> (const Array& x, const Array& y) { return y bool operator<= (const Array& x, const Array& y) { return !(y bool operator>= (const Array& x, const Array& y) { return !(x inline void swap (Array& x, Array& y) /// global swap() @@ -243,7 +252,9 @@ inline void swap (Array& x, Array& y) x.swap(y); } + }// namespace Poco + #endif // Foundation_Array_INCLUDED diff --git a/Foundation/include/Poco/Ascii.h b/Foundation/include/Poco/Ascii.h index 5dd741df3..e7a8b855d 100644 --- a/Foundation/include/Poco/Ascii.h +++ b/Foundation/include/Poco/Ascii.h @@ -103,6 +103,9 @@ public: /// Returns true iff the given character is an uppercase alphabetic /// character. + static bool isPrintable(int ch); + /// Returns true iff the given character is printable. + static int toLower(int ch); /// If the given character is an uppercase character, /// return its lowercase counterpart, otherwise return @@ -196,6 +199,12 @@ inline bool Ascii::isUpper(int ch) } +inline bool Ascii::isPrintable(int ch) +{ + return hasProperties(ch, ACP_PRINT); +} + + inline int Ascii::toLower(int ch) { if (isUpper(ch)) diff --git a/Foundation/include/Poco/AsyncChannel.h b/Foundation/include/Poco/AsyncChannel.h index 9756edc3e..937c9d098 100644 --- a/Foundation/include/Poco/AsyncChannel.h +++ b/Foundation/include/Poco/AsyncChannel.h @@ -23,6 +23,7 @@ #include "Poco/Thread.h" #include "Poco/Mutex.h" #include "Poco/Runnable.h" +#include "Poco/AutoPtr.h" #include "Poco/NotificationQueue.h" @@ -40,15 +41,17 @@ class Foundation_API AsyncChannel: public Channel, public Runnable /// then processed by a separate thread. { public: - AsyncChannel(Channel* pChannel = 0, Thread::Priority prio = Thread::PRIO_NORMAL); + using Ptr = AutoPtr; + + AsyncChannel(Channel::Ptr pChannel = 0, Thread::Priority prio = Thread::PRIO_NORMAL); /// Creates the AsyncChannel and connects it to /// the given channel. - void setChannel(Channel* pChannel); + void setChannel(Channel::Ptr pChannel); /// Connects the AsyncChannel to the given target channel. /// All messages will be forwarded to this channel. - Channel* getChannel() const; + Channel::Ptr getChannel() const; /// Returns the target channel. void open(); @@ -86,7 +89,7 @@ protected: void setPriority(const std::string& value); private: - Channel* _pChannel; + Channel::Ptr _pChannel; Thread _thread; FastMutex _threadMutex; FastMutex _channelMutex; diff --git a/Foundation/include/Poco/AtomicCounter.h b/Foundation/include/Poco/AtomicCounter.h index 4c7c7884f..1377fd4c9 100644 --- a/Foundation/include/Poco/AtomicCounter.h +++ b/Foundation/include/Poco/AtomicCounter.h @@ -19,33 +19,7 @@ #include "Poco/Foundation.h" -#if POCO_OS == POCO_OS_WINDOWS_NT - #include "Poco/UnWindows.h" -#elif POCO_OS == POCO_OS_MAC_OS_X - #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 101200 || __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000 || __TV_OS_VERSION_MAX_ALLOWED >= 100000 || __WATCH_OS_VERSION_MAX_ALLOWED >= 30000 - #if __cplusplus >= 201103L - #ifndef POCO_HAVE_STD_ATOMICS - #define POCO_HAVE_STD_ATOMICS - #endif - #else - #include - #endif - #else - #include - #endif -#elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 2) || __GNUC__ > 4) && (defined(__x86_64__) || defined(__i386__)) - #if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS) - #define POCO_HAVE_GCC_ATOMICS - #endif -#elif ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3) || __GNUC__ > 4) - #if !defined(POCO_HAVE_GCC_ATOMICS) && !defined(POCO_NO_GCC_ATOMICS) - #define POCO_HAVE_GCC_ATOMICS - #endif -#endif // POCO_OS -#include "Poco/Mutex.h" -#ifdef POCO_HAVE_STD_ATOMICS #include -#endif namespace Poco { @@ -57,81 +31,53 @@ class Foundation_API AtomicCounter /// use in a multithreaded environment. /// /// Typical usage of AtomicCounter is for implementing - /// reference counting and similar things. - /// - /// On some platforms, the implementation of AtomicCounter - /// is based on atomic primitives specific to the platform - /// (such as InterlockedIncrement, etc. on Windows), and - /// thus very efficient. On platforms that do not support - /// atomic primitives, operations are guarded by a FastMutex. - /// - /// The following platforms currently have atomic - /// primitives: - /// - Windows - /// - Mac OS X - /// - GCC 4.1+ (Intel platforms only) + /// reference counting and similar functionality. { public: typedef int ValueType; /// The underlying integer type. - + AtomicCounter(); /// Creates a new AtomicCounter and initializes it to zero. - + explicit AtomicCounter(ValueType initialValue); /// Creates a new AtomicCounter and initializes it with /// the given value. - + AtomicCounter(const AtomicCounter& counter); /// Creates the counter by copying another one. - + ~AtomicCounter(); /// Destroys the AtomicCounter. AtomicCounter& operator = (const AtomicCounter& counter); /// Assigns the value of another AtomicCounter. - + AtomicCounter& operator = (ValueType value); /// Assigns a value to the counter. operator ValueType () const; - /// Returns the value of the counter. - + /// Converts the AtomicCounter to ValueType. + ValueType value() const; /// Returns the value of the counter. - + ValueType operator ++ (); // prefix /// Increments the counter and returns the result. - + ValueType operator ++ (int); // postfix /// Increments the counter and returns the previous value. - + ValueType operator -- (); // prefix /// Decrements the counter and returns the result. - + ValueType operator -- (int); // postfix /// Decrements the counter and returns the previous value. - + bool operator ! () const; /// Returns true if the counter is zero, false otherwise. private: -#if defined(POCO_HAVE_STD_ATOMICS) - typedef std::atomic ImplType; -#elif POCO_OS == POCO_OS_WINDOWS_NT - typedef volatile LONG ImplType; -#elif POCO_OS == POCO_OS_MAC_OS_X - typedef int32_t ImplType; -#elif defined(POCO_HAVE_GCC_ATOMICS) - typedef int ImplType; -#else // generic implementation based on FastMutex - struct ImplType - { - mutable FastMutex mutex; - volatile int value; - }; -#endif // POCO_OS - - ImplType _counter; + std::atomic _counter; }; @@ -139,17 +85,12 @@ private: // inlines // - -#if defined(POCO_HAVE_STD_ATOMICS) -// -// C++11 atomics -// inline AtomicCounter::operator AtomicCounter::ValueType () const { return _counter.load(); } - + inline AtomicCounter::ValueType AtomicCounter::value() const { return _counter.load(); @@ -161,7 +102,7 @@ inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix return ++_counter; } - + inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix { return _counter++; @@ -173,244 +114,19 @@ inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix return --_counter; } - + inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix { return _counter--; } - + inline bool AtomicCounter::operator ! () const { return _counter.load() == 0; } -#elif POCO_OS == POCO_OS_WINDOWS_NT -// -// Windows -// -inline AtomicCounter::operator AtomicCounter::ValueType () const -{ - return _counter; -} - - -inline AtomicCounter::ValueType AtomicCounter::value() const -{ - return _counter; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix -{ - return InterlockedIncrement(&_counter); -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix -{ - ValueType result = InterlockedIncrement(&_counter); - return --result; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix -{ - return InterlockedDecrement(&_counter); -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix -{ - ValueType result = InterlockedDecrement(&_counter); - return ++result; -} - - -inline bool AtomicCounter::operator ! () const -{ - return _counter == 0; -} - - -#elif POCO_OS == POCO_OS_MAC_OS_X -// -// Mac OS X -// -inline AtomicCounter::operator AtomicCounter::ValueType () const -{ - return _counter; -} - - -inline AtomicCounter::ValueType AtomicCounter::value() const -{ - return _counter; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix -{ - return OSAtomicIncrement32(&_counter); -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix -{ - ValueType result = OSAtomicIncrement32(&_counter); - return --result; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix -{ - return OSAtomicDecrement32(&_counter); -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix -{ - ValueType result = OSAtomicDecrement32(&_counter); - return ++result; -} - - -inline bool AtomicCounter::operator ! () const -{ - return _counter == 0; -} - -#elif defined(POCO_HAVE_GCC_ATOMICS) -// -// GCC 4.1+ atomic builtins. -// -inline AtomicCounter::operator AtomicCounter::ValueType () const -{ - return _counter; -} - - -inline AtomicCounter::ValueType AtomicCounter::value() const -{ - return _counter; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix -{ - return __sync_add_and_fetch(&_counter, 1); -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix -{ - return __sync_fetch_and_add(&_counter, 1); -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix -{ - return __sync_sub_and_fetch(&_counter, 1); -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix -{ - return __sync_fetch_and_sub(&_counter, 1); -} - - -inline bool AtomicCounter::operator ! () const -{ - return _counter == 0; -} - - -#else -// -// Generic implementation based on FastMutex -// -inline AtomicCounter::operator AtomicCounter::ValueType () const -{ - ValueType result; - { - FastMutex::ScopedLock lock(_counter.mutex); - result = _counter.value; - } - return result; -} - - -inline AtomicCounter::ValueType AtomicCounter::value() const -{ - ValueType result; - { - FastMutex::ScopedLock lock(_counter.mutex); - result = _counter.value; - } - return result; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ () // prefix -{ - ValueType result; - { - FastMutex::ScopedLock lock(_counter.mutex); - result = ++_counter.value; - } - return result; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator ++ (int) // postfix -{ - ValueType result; - { - FastMutex::ScopedLock lock(_counter.mutex); - result = _counter.value++; - } - return result; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- () // prefix -{ - ValueType result; - { - FastMutex::ScopedLock lock(_counter.mutex); - result = --_counter.value; - } - return result; -} - - -inline AtomicCounter::ValueType AtomicCounter::operator -- (int) // postfix -{ - ValueType result; - { - FastMutex::ScopedLock lock(_counter.mutex); - result = _counter.value--; - } - return result; -} - - -inline bool AtomicCounter::operator ! () const -{ - bool result; - { - FastMutex::ScopedLock lock(_counter.mutex); - result = _counter.value == 0; - } - return result; -} - - -#endif // POCO_OS - - } // namespace Poco diff --git a/Foundation/include/Poco/AtomicFlag.h b/Foundation/include/Poco/AtomicFlag.h index 6d6f83907..d9191ea72 100644 --- a/Foundation/include/Poco/AtomicFlag.h +++ b/Foundation/include/Poco/AtomicFlag.h @@ -14,9 +14,6 @@ // -#ifdef POCO_HAVE_STD_ATOMICS - - #ifndef Foundation_AtomicFlag_INCLUDED #define Foundation_AtomicFlag_INCLUDED @@ -67,10 +64,10 @@ class Foundation_API AtomicFlag /// while (++i < 10) myClass.myFunc(); { public: - AtomicFlag(); + AtomicFlag() = default; /// Creates AtomicFlag. - ~AtomicFlag(); + ~AtomicFlag() = default; /// Destroys AtomicFlag. bool set(); @@ -98,6 +95,7 @@ private: // inlines // + inline bool AtomicFlag::set() { return _flag.test_and_set(std::memory_order_acquire); @@ -121,5 +119,3 @@ inline AtomicFlag::operator bool () #endif // Foundation_AtomicFlag_INCLUDED - -#endif // POCO_HAVE_STD_ATOMICS diff --git a/Foundation/include/Poco/AutoPtr.h b/Foundation/include/Poco/AutoPtr.h index c3235715a..4db70dbe5 100644 --- a/Foundation/include/Poco/AutoPtr.h +++ b/Foundation/include/Poco/AutoPtr.h @@ -61,7 +61,7 @@ class AutoPtr /// Note that AutoPtr allows casting of its encapsulated data types. { public: - AutoPtr(): _ptr(0) + AutoPtr(): _ptr(nullptr) { } @@ -79,6 +79,11 @@ public: if (_ptr) _ptr->duplicate(); } + AutoPtr(AutoPtr&& ptr) noexcept: _ptr(std::move(ptr._ptr)) + { + ptr._ptr = nullptr; + } + template AutoPtr(const AutoPtr& ptr): _ptr(const_cast(ptr.get())) { @@ -139,7 +144,7 @@ public: if (_ptr) { _ptr->release(); - _ptr = 0; + _ptr = nullptr; } } @@ -173,6 +178,14 @@ public: { return assign(ptr); } + + AutoPtr& operator = (AutoPtr&& ptr) noexcept + { + if (_ptr) _ptr->release(); + _ptr = std::move(ptr._ptr); + ptr._ptr = nullptr; + return *this; + } template AutoPtr& operator = (const AutoPtr& ptr) @@ -264,12 +277,12 @@ public: bool operator ! () const { - return _ptr == 0; + return _ptr == nullptr; } bool isNull() const { - return _ptr == 0; + return _ptr == nullptr; } C* duplicate() @@ -380,6 +393,13 @@ inline void swap(AutoPtr& p1, AutoPtr& p2) } +template +AutoPtr makeAuto(Args&&... args) +{ + return AutoPtr(new T(std::forward(args)...)); +} + + } // namespace Poco diff --git a/Foundation/include/Poco/AutoReleasePool.h b/Foundation/include/Poco/AutoReleasePool.h index 0b13956e8..42c8de7c4 100644 --- a/Foundation/include/Poco/AutoReleasePool.h +++ b/Foundation/include/Poco/AutoReleasePool.h @@ -29,7 +29,7 @@ template class AutoReleasePool /// An AutoReleasePool implements simple garbage collection for /// reference-counted objects. - /// It temporarily takes ownwership of reference-counted objects that + /// It temporarily takes ownership of reference-counted objects that /// nobody else wants to take ownership of and releases them /// at a later, appropriate point in time. /// diff --git a/Foundation/include/Poco/Base32Decoder.h b/Foundation/include/Poco/Base32Decoder.h index 54367c588..c592e552c 100644 --- a/Foundation/include/Poco/Base32Decoder.h +++ b/Foundation/include/Poco/Base32Decoder.h @@ -82,6 +82,8 @@ class Foundation_API Base32Decoder: public Base32DecoderIOS, public std::istream /// This istream base32-decodes all data /// read from the istream connected to it. /// + /// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648 + /// /// Note: For performance reasons, the characters /// are read directly from the given istream's /// underlying streambuf, so the state diff --git a/Foundation/include/Poco/Base32Encoder.h b/Foundation/include/Poco/Base32Encoder.h index 246f8483b..47d2e1a11 100644 --- a/Foundation/include/Poco/Base32Encoder.h +++ b/Foundation/include/Poco/Base32Encoder.h @@ -89,6 +89,8 @@ class Foundation_API Base32Encoder: public Base32EncoderIOS, public std::ostream /// writing data, to ensure proper /// completion of the encoding operation. /// + /// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648 + /// /// Note: The characters are directly written /// to the ostream's streambuf, thus bypassing /// the ostream. The ostream's state is therefore diff --git a/Foundation/include/Poco/Base64Decoder.h b/Foundation/include/Poco/Base64Decoder.h index 51958231e..dbccc6f6c 100644 --- a/Foundation/include/Poco/Base64Decoder.h +++ b/Foundation/include/Poco/Base64Decoder.h @@ -86,6 +86,8 @@ class Foundation_API Base64Decoder: public Base64DecoderIOS, public std::istream /// This istream base64-decodes all data /// read from the istream connected to it. /// + /// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648 + /// /// Note: For performance reasons, the characters /// are read directly from the given istream's /// underlying streambuf, so the state diff --git a/Foundation/include/Poco/Base64Encoder.h b/Foundation/include/Poco/Base64Encoder.h index 4371803a5..071b9018d 100644 --- a/Foundation/include/Poco/Base64Encoder.h +++ b/Foundation/include/Poco/Base64Encoder.h @@ -117,6 +117,8 @@ class Foundation_API Base64Encoder: public Base64EncoderIOS, public std::ostream /// writing data, to ensure proper /// completion of the encoding operation. /// + /// The class implements RFC 4648 - https://tools.ietf.org/html/rfc4648 + /// /// Note: The characters are directly written /// to the ostream's streambuf, thus bypassing /// the ostream. The ostream's state is therefore diff --git a/Foundation/include/Poco/BasicEvent.h b/Foundation/include/Poco/BasicEvent.h index bc2dd516c..47e37dbde 100644 --- a/Foundation/include/Poco/BasicEvent.h +++ b/Foundation/include/Poco/BasicEvent.h @@ -29,7 +29,7 @@ namespace Poco { template class BasicEvent: public AbstractEvent < - TArgs, DefaultStrategy >, + TArgs, DefaultStrategy>, AbstractDelegate, TMutex > diff --git a/Foundation/include/Poco/BinaryWriter.h b/Foundation/include/Poco/BinaryWriter.h index 7941117c0..7b0af6e29 100644 --- a/Foundation/include/Poco/BinaryWriter.h +++ b/Foundation/include/Poco/BinaryWriter.h @@ -94,9 +94,9 @@ public: Poco::UInt32 size(static_cast(value.size())); *this << size; - for (typename std::vector::const_iterator it = value.begin(); it != value.end(); ++it) + for (const auto& v: value) { - *this << *it; + *this << v; } return *this; diff --git a/Foundation/include/Poco/Buffer.h b/Foundation/include/Poco/Buffer.h index 7d239b159..f6b418bab 100644 --- a/Foundation/include/Poco/Buffer.h +++ b/Foundation/include/Poco/Buffer.h @@ -36,16 +36,16 @@ class Buffer /// is needed. { public: - Buffer(std::size_t capacity): - _capacity(capacity), - _used(capacity), + Buffer(std::size_t length): + _capacity(length), + _used(length), _ptr(0), _ownMem(true) /// Creates and allocates the Buffer. { - if (capacity > 0) + if (length > 0) { - _ptr = new T[capacity]; + _ptr = new T[length]; } } @@ -94,6 +94,19 @@ public: } } + Buffer(Buffer&& other) : + /// Copy constructor. + _capacity(other._capacity), + _used(other._used), + _ptr(other._ptr), + _ownMem(other._ownMem) + { + other._capacity = 0; + other._used = 0; + other._ownMem = false; + other._ptr = nullptr; + } + Buffer& operator = (const Buffer& other) /// Assignment operator. { @@ -106,6 +119,25 @@ public: return *this; } + Buffer& operator = (Buffer&& other) + /// Assignment operator. + { + if (this != &other) + { + _capacity = other._capacity; + _used = other._used; + _ptr = other._ptr; + _ownMem = other._ownMem; + + other._capacity = 0; + other._used = 0; + other._ownMem = false; + other._ptr = nullptr; + } + + return *this; + } + ~Buffer() /// Destroys the Buffer. { @@ -225,6 +257,7 @@ public: swap(_ptr, other._ptr); swap(_capacity, other._capacity); swap(_used, other._used); + swap(_ownMem, other._ownMem); } bool operator == (const Buffer& other) const diff --git a/Foundation/include/Poco/BufferAllocator.h b/Foundation/include/Poco/BufferAllocator.h index ac71746b2..c767fe4ad 100644 --- a/Foundation/include/Poco/BufferAllocator.h +++ b/Foundation/include/Poco/BufferAllocator.h @@ -39,7 +39,7 @@ public: return new char_type[static_cast(size)]; } - static void deallocate(char_type* ptr, std::streamsize /*size*/) throw() + static void deallocate(char_type* ptr, std::streamsize /*size*/) noexcept { delete [] ptr; } diff --git a/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h b/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h index 321c3b1ad..5872c1289 100644 --- a/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h +++ b/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h @@ -29,7 +29,7 @@ namespace Poco { -template > +template > class BasicBufferedBidirectionalStreamBuf: public std::basic_streambuf /// This is an implementation of a buffered bidirectional /// streambuf that greatly simplifies the implementation of @@ -170,9 +170,9 @@ private: // instantiations in different libraries. // #if defined(_MSC_VER) && defined(POCO_DLL) && !defined(Foundation_EXPORTS) -template class Foundation_API BasicBufferedBidirectionalStreamBuf >; +template class Foundation_API BasicBufferedBidirectionalStreamBuf>; #endif -typedef BasicBufferedBidirectionalStreamBuf > BufferedBidirectionalStreamBuf; +typedef BasicBufferedBidirectionalStreamBuf> BufferedBidirectionalStreamBuf; } // namespace Poco diff --git a/Foundation/include/Poco/BufferedStreamBuf.h b/Foundation/include/Poco/BufferedStreamBuf.h index 3e3921526..80de74071 100644 --- a/Foundation/include/Poco/BufferedStreamBuf.h +++ b/Foundation/include/Poco/BufferedStreamBuf.h @@ -29,7 +29,7 @@ namespace Poco { -template > +template > class BasicBufferedStreamBuf: public std::basic_streambuf /// This is an implementation of a buffered streambuf /// that greatly simplifies the implementation of @@ -59,13 +59,20 @@ public: _pBuffer(Allocator::allocate(_bufsize)), _mode(mode) { - this->setg(_pBuffer + 4, _pBuffer + 4, _pBuffer + 4); + this->setg(_pBuffer + 4, _pBuffer + 4, _pBuffer + 4); this->setp(_pBuffer, _pBuffer + _bufsize); } ~BasicBufferedStreamBuf() { - Allocator::deallocate(_pBuffer, _bufsize); + try + { + Allocator::deallocate(_pBuffer, _bufsize); + } + catch (...) + { + poco_unexpected(); + } } virtual int_type overflow(int_type c) @@ -162,9 +169,9 @@ private: // instantiations in different libraries. // #if defined(_MSC_VER) && defined(POCO_DLL) && !defined(Foundation_EXPORTS) -template class Foundation_API BasicBufferedStreamBuf >; +template class Foundation_API BasicBufferedStreamBuf>; #endif -typedef BasicBufferedStreamBuf > BufferedStreamBuf; +typedef BasicBufferedStreamBuf> BufferedStreamBuf; } // namespace Poco diff --git a/Foundation/include/Poco/ByteOrder.h b/Foundation/include/Poco/ByteOrder.h index 97732bcd4..a2f8735d1 100644 --- a/Foundation/include/Poco/ByteOrder.h +++ b/Foundation/include/Poco/ByteOrder.h @@ -36,6 +36,8 @@ public: static UInt16 flipBytes(UInt16 value); static Int32 flipBytes(Int32 value); static UInt32 flipBytes(UInt32 value); + static float flipBytes(float value); + static double flipBytes(double value); #if defined(POCO_HAVE_INT64) static Int64 flipBytes(Int64 value); static UInt64 flipBytes(UInt64 value); @@ -94,6 +96,21 @@ public: static Int64 fromNetwork(Int64 value); static UInt64 fromNetwork (UInt64 value); #endif + +private: + template + static T flip(T value) + { + T flip = value; + std::size_t halfSize = sizeof(T) / 2; + char* flipP = reinterpret_cast(&flip); + + for (std::size_t i = 0; i < halfSize; i++) + { + std::swap(flipP[i], flipP[sizeof(T) - i - 1]); + } + return flip; + } }; @@ -150,6 +167,18 @@ inline Int32 ByteOrder::flipBytes(Int32 value) } +inline float ByteOrder::flipBytes(float value) +{ + return flip(value); +} + + +inline double ByteOrder::flipBytes(double value) +{ + return flip(value); +} + + #if defined(POCO_HAVE_INT64) inline UInt64 ByteOrder::flipBytes(UInt64 value) { diff --git a/Foundation/include/Poco/Channel.h b/Foundation/include/Poco/Channel.h index f820a2c3c..94caf144d 100644 --- a/Foundation/include/Poco/Channel.h +++ b/Foundation/include/Poco/Channel.h @@ -22,6 +22,7 @@ #include "Poco/Configurable.h" #include "Poco/Mutex.h" #include "Poco/RefCountedObject.h" +#include "Poco/AutoPtr.h" namespace Poco { @@ -38,6 +39,8 @@ class Foundation_API Channel: public Configurable, public RefCountedObject /// of getProperty() and setProperty(). { public: + using Ptr = AutoPtr; + Channel(); /// Creates the channel and initializes /// the reference count to one. diff --git a/Foundation/include/Poco/ClassLibrary.h b/Foundation/include/Poco/ClassLibrary.h index 14b10acb3..d2a54bdee 100644 --- a/Foundation/include/Poco/ClassLibrary.h +++ b/Foundation/include/Poco/ClassLibrary.h @@ -25,6 +25,8 @@ #if defined(_WIN32) #define POCO_LIBRARY_API __declspec(dllexport) +#elif defined(__GNUC__) && (__GNUC__ >= 4) + #define POCO_LIBRARY_API __attribute__ ((visibility ("default"))) #else #define POCO_LIBRARY_API #endif @@ -94,6 +96,10 @@ extern "C" \ pManifest->insert(new Poco::MetaObject(#cls)); +#define POCO_EXPORT_INTERFACE(cls, itf) \ + pManifest->insert(new Poco::MetaObject(itf)); + + #define POCO_EXPORT_SINGLETON(cls) \ pManifest->insert(new Poco::MetaSingleton(#cls)); diff --git a/Foundation/include/Poco/ClassLoader.h b/Foundation/include/Poco/ClassLoader.h index 450aec292..09f20bb6e 100644 --- a/Foundation/include/Poco/ClassLoader.h +++ b/Foundation/include/Poco/ClassLoader.h @@ -132,10 +132,10 @@ public: virtual ~ClassLoader() /// Destroys the ClassLoader. { - for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it) + for (auto& p: _map) { - delete it->second.pLibrary; - delete it->second.pManifest; + delete p.second.pLibrary; + delete p.second.pManifest; } } @@ -247,9 +247,9 @@ public: { FastMutex::ScopedLock lock(_mutex); - for (typename LibraryMap::const_iterator it = _map.begin(); it != _map.end(); ++it) + for (const auto& p: _map) { - const Manif* pManif = it->second.pManifest; + const Manif* pManif = p.second.pManifest; typename Manif::Iterator itm = pManif->find(className); if (itm != pManif->end()) return *itm; diff --git a/Foundation/include/Poco/Clock.h b/Foundation/include/Poco/Clock.h index 43bb22f64..1a97851ce 100644 --- a/Foundation/include/Poco/Clock.h +++ b/Foundation/include/Poco/Clock.h @@ -28,7 +28,7 @@ class Foundation_API Clock /// A Clock stores a monotonic* clock value /// with (theoretical) microseconds resolution. /// Clocks can be compared with each other - /// and simple arithmetics are supported. + /// and simple arithmetic is supported. /// /// [*] Note that Clock values are only monotonic if /// the operating system provides a monotonic clock. @@ -108,7 +108,7 @@ public: static ClockDiff resolution(); /// Returns the resolution in units per second. - /// Since the Clock clas has microsecond resolution, + /// Since the Clock class has microsecond resolution, /// the returned value is always 1000000. static ClockDiff accuracy(); diff --git a/Foundation/include/Poco/Config.h b/Foundation/include/Poco/Config.h index 7dbe01823..17ba48eac 100644 --- a/Foundation/include/Poco/Config.h +++ b/Foundation/include/Poco/Config.h @@ -18,16 +18,6 @@ #define Foundation_Config_INCLUDED -// Define to enable Windows Unicode (UTF-8) support -// NOTE: As of POCO C++ Libraries release 1.6.0, compiling POCO -// without POCO_WIN32_UTF8 defined on Windows is deprecated. -#define POCO_WIN32_UTF8 - - -// Define to enable C++11 support -// #define POCO_ENABLE_CPP11 - - // Define to disable implicit linking // #define POCO_NO_AUTOMATIC_LIBS diff --git a/Foundation/include/Poco/ConsoleChannel.h b/Foundation/include/Poco/ConsoleChannel.h index 28aab6e3e..0c133abe7 100644 --- a/Foundation/include/Poco/ConsoleChannel.h +++ b/Foundation/include/Poco/ConsoleChannel.h @@ -43,6 +43,8 @@ class Foundation_API ConsoleChannel: public Channel /// same stream. { public: + using Ptr = AutoPtr; + ConsoleChannel(); /// Creates the channel and attaches std::clog. diff --git a/Foundation/include/Poco/CountingStream.h b/Foundation/include/Poco/CountingStream.h index 17da1e4e7..730205dee 100644 --- a/Foundation/include/Poco/CountingStream.h +++ b/Foundation/include/Poco/CountingStream.h @@ -46,34 +46,34 @@ public: ~CountingStreamBuf(); /// Destroys the CountingStream. - int chars() const; + std::streamsize chars() const; /// Returns the total number of characters. - int lines() const; + std::streamsize lines() const; /// Returns the total number of lines. - int pos() const; + std::streamsize pos() const; /// Returns the number of characters on the current line. void reset(); /// Resets all counters. - void setCurrentLineNumber(int line); + void setCurrentLineNumber(std::streamsize line); /// Sets the current line number. /// /// This is mainly useful when parsing C/C++ /// preprocessed source code containing #line directives. - int getCurrentLineNumber() const; + std::streamsize getCurrentLineNumber() const; /// Returns the current line number (same as lines()). - void addChars(int chars); + void addChars(std::streamsize chars); /// Add to the total number of characters. - void addLines(int lines); + void addLines(std::streamsize lines); /// Add to the total number of lines. - void addPos(int pos); + void addPos(std::streamsize pos); /// Add to the number of characters on the current line. protected: @@ -83,9 +83,9 @@ protected: private: std::istream* _pIstr; std::ostream* _pOstr; - int _chars; - int _lines; - int _pos; + std::streamsize _chars; + std::streamsize _lines; + std::streamsize _pos; }; @@ -110,34 +110,34 @@ public: ~CountingIOS(); /// Destroys the stream. - int chars() const; + std::streamsize chars() const; /// Returns the total number of characters. - int lines() const; + std::streamsize lines() const; /// Returns the total number of lines. - int pos() const; + std::streamsize pos() const; /// Returns the number of characters on the current line. void reset(); /// Resets all counters. - void setCurrentLineNumber(int line); + void setCurrentLineNumber(std::streamsize line); /// Sets the current line number. /// /// This is mainly useful when parsing C/C++ /// preprocessed source code containing #line directives. - int getCurrentLineNumber() const; + std::streamsize getCurrentLineNumber() const; /// Returns the current line number (same as lines()). - void addChars(int chars); + void addChars(std::streamsize chars); /// Add to the total number of characters. - void addLines(int lines); + void addLines(std::streamsize lines); /// Add to the total number of lines. - void addPos(int pos); + void addPos(std::streamsize pos); /// Add to the number of characters on the current line. CountingStreamBuf* rdbuf(); @@ -183,49 +183,49 @@ public: // // inlines // -inline int CountingStreamBuf::chars() const +inline std::streamsize CountingStreamBuf::chars() const { return _chars; } -inline int CountingStreamBuf::lines() const +inline std::streamsize CountingStreamBuf::lines() const { return _lines; } -inline int CountingStreamBuf::pos() const +inline std::streamsize CountingStreamBuf::pos() const { return _pos; } -inline int CountingStreamBuf::getCurrentLineNumber() const +inline std::streamsize CountingStreamBuf::getCurrentLineNumber() const { return _lines; } -inline int CountingIOS::chars() const +inline std::streamsize CountingIOS::chars() const { return _buf.chars(); } -inline int CountingIOS::lines() const +inline std::streamsize CountingIOS::lines() const { return _buf.lines(); } -inline int CountingIOS::pos() const +inline std::streamsize CountingIOS::pos() const { return _buf.pos(); } -inline int CountingIOS::getCurrentLineNumber() const +inline std::streamsize CountingIOS::getCurrentLineNumber() const { return _buf.getCurrentLineNumber(); } diff --git a/Foundation/include/Poco/DateTime.h b/Foundation/include/Poco/DateTime.h index 1a59a0384..f0ee41b99 100644 --- a/Foundation/include/Poco/DateTime.h +++ b/Foundation/include/Poco/DateTime.h @@ -107,9 +107,11 @@ public: /// * day is from 1 to 31. /// * hour is from 0 to 23. /// * minute is from 0 to 59. - /// * second is from 0 to 60 (allowing leap seconds). + /// * second is from 0 to 60. /// * millisecond is from 0 to 999. /// * microsecond is from 0 to 999. + /// + /// Throws an InvalidArgumentException if an argument date is out of range. DateTime(double julianDay); /// Creates a DateTime for the given Julian day. @@ -141,9 +143,11 @@ public: /// * day is from 1 to 31. /// * hour is from 0 to 23. /// * minute is from 0 to 59. - /// * second is from 0 to 60 (allowing leap seconds). + /// * second is from 0 to 60. /// * millisecond is from 0 to 999. /// * microsecond is from 0 to 999. + /// + /// Throws an InvalidArgumentException if an argument date is out of range. void swap(DateTime& dateTime); /// Swaps the DateTime with another one. @@ -164,11 +168,11 @@ public: /// on a Saturday, week 1 will be the week starting on Monday, January 3. /// January 1 and 2 will fall within week 0 (or the last week of the previous year). /// - /// For 2007, which starts on a Monday, week 1 will be the week startung on Monday, January 1. + /// For 2007, which starts on a Monday, week 1 will be the week starting on Monday, January 1. /// There will be no week 0 in 2007. int day() const; - /// Returns the day witin the month (1 to 31). + /// Returns the day within the month (1 to 31). int dayOfWeek() const; /// Returns the weekday (0 to 6, where @@ -254,7 +258,7 @@ protected: /// Computes the Julian day for an UTC time. static double toJulianDay(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int millisecond = 0, int microsecond = 0); - /// Computes the Julian day for a gregorian calendar date and time. + /// Computes the Julian day for a Gregorian calendar date and time. /// See , section 2.3.1 for the algorithm. static Timestamp::UtcTimeVal toUtcTime(double julianDay); @@ -287,6 +291,21 @@ private: // // inlines // + + +inline double DateTime::toJulianDay(Timestamp::UtcTimeVal utcTime) +{ + double utcDays = double(utcTime)/864000000000.0; + return utcDays + 2299160.5; // first day of Gregorian reform (Oct 15 1582) +} + + +inline Timestamp::UtcTimeVal DateTime::toUtcTime(double julianDay) +{ + return Timestamp::UtcTimeVal((julianDay - 2299160.5)*864000000000.0); +} + + inline Timestamp DateTime::timestamp() const { return Timestamp::fromUtcTime(_utcTime); diff --git a/Foundation/include/Poco/DateTimeParser.h b/Foundation/include/Poco/DateTimeParser.h index 28ebbe756..bd8daf383 100644 --- a/Foundation/include/Poco/DateTimeParser.h +++ b/Foundation/include/Poco/DateTimeParser.h @@ -101,7 +101,7 @@ public: static int parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end); /// Tries to interpret the given range as a weekday name. The range must be at least /// three characters long. - /// Returns the weekday number (0 .. 6, where 0 = Synday, 1 = Monday, etc.) if the + /// Returns the weekday number (0 .. 6, where 0 = Sunday, 1 = Monday, etc.) if the /// weekday name is valid. Otherwise throws a SyntaxException. protected: diff --git a/Foundation/include/Poco/DefaultStrategy.h b/Foundation/include/Poco/DefaultStrategy.h index 6a095114e..0291f3553 100644 --- a/Foundation/include/Poco/DefaultStrategy.h +++ b/Foundation/include/Poco/DefaultStrategy.h @@ -35,10 +35,10 @@ class DefaultStrategy: public NotificationStrategy /// order in which they have been registered. { public: - typedef TDelegate* DelegateHandle; - typedef SharedPtr DelegatePtr; - typedef std::vector Delegates; - typedef typename Delegates::iterator Iterator; + using DelegateHandle = TDelegate*; + using DelegatePtr = SharedPtr; + using Delegates = std::vector; + using Iterator = typename Delegates::iterator; public: DefaultStrategy() @@ -132,10 +132,10 @@ class DefaultStrategy: public NotificationStrategy DelegatePtr; - typedef std::vector Delegates; - typedef typename Delegates::iterator Iterator; + using DelegateHandle = TDelegate*; + using DelegatePtr = SharedPtr; + using Delegates = std::vector; + using Iterator = typename Delegates::iterator; public: DefaultStrategy() diff --git a/Foundation/include/Poco/DigestEngine.h b/Foundation/include/Poco/DigestEngine.h index b22ab6d89..7ea34d564 100644 --- a/Foundation/include/Poco/DigestEngine.h +++ b/Foundation/include/Poco/DigestEngine.h @@ -36,7 +36,7 @@ class Foundation_API DigestEngine /// digest. { public: - typedef std::vector Digest; + using Digest = std::vector; DigestEngine(); virtual ~DigestEngine(); diff --git a/Foundation/include/Poco/DirectoryIteratorStrategy.h b/Foundation/include/Poco/DirectoryIteratorStrategy.h index 4e5f49242..495fcab7c 100644 --- a/Foundation/include/Poco/DirectoryIteratorStrategy.h +++ b/Foundation/include/Poco/DirectoryIteratorStrategy.h @@ -31,8 +31,8 @@ namespace Poco { class Foundation_API TraverseBase { public: - typedef std::stack Stack; - typedef std::function DepthFun; + using Stack = std::stack; + using DepthFun = std::function; enum { @@ -82,7 +82,7 @@ private: SiblingsFirstTraverse(const SiblingsFirstTraverse&); SiblingsFirstTraverse& operator=(const SiblingsFirstTraverse&); - std::stack > _dirsStack; + std::stack> _dirsStack; }; diff --git a/Foundation/include/Poco/Dynamic/Pair.h b/Foundation/include/Poco/Dynamic/Pair.h index c64eecece..e51921cd5 100644 --- a/Foundation/include/Poco/Dynamic/Pair.h +++ b/Foundation/include/Poco/Dynamic/Pair.h @@ -33,7 +33,7 @@ class Pair /// Pair allows to define a pair of values. { public: - typedef typename std::pair Data; + using Data = typename std::pair; Pair(): _data() /// Creates an empty Pair @@ -96,7 +96,7 @@ public: std::string toString() { std::string str; - Var(*this).convert(str); + Var(*this).template convert(str); return str; } @@ -106,7 +106,7 @@ private: template <> -class VarHolderImpl >: public VarHolder +class VarHolderImpl>: public VarHolder { public: VarHolderImpl(const Pair& val): _val(val) @@ -255,7 +255,7 @@ private: template <> -class VarHolderImpl >: public VarHolder +class VarHolderImpl>: public VarHolder { public: VarHolderImpl(const Pair& val): _val(val) diff --git a/Foundation/include/Poco/Dynamic/Struct.h b/Foundation/include/Poco/Dynamic/Struct.h index b843d22c5..1e52c31f2 100644 --- a/Foundation/include/Poco/Dynamic/Struct.h +++ b/Foundation/include/Poco/Dynamic/Struct.h @@ -32,7 +32,7 @@ namespace Poco { namespace Dynamic { -template , typename S = std::set > +template , typename S = std::set> class Struct /// Struct allows to define a named collection of Var objects. { @@ -44,7 +44,7 @@ public: typedef typename Struct::Data::value_type ValueType; typedef typename Struct::Data::size_type SizeType; typedef typename std::pair::Iterator, bool> InsRetVal; - typedef typename Poco::SharedPtr > Ptr; + typedef typename Poco::SharedPtr> Ptr; Struct(): _data() /// Creates an empty Struct @@ -62,16 +62,12 @@ public: assignMap(val); } -#ifdef POCO_ENABLE_CPP11 - template Struct(const OrderedMap& val) { assignMap(val); } -#endif // POCO_ENABLE_CPP11 - virtual ~Struct() /// Destroys the Struct. { @@ -171,18 +167,24 @@ public: _data.erase(it); } + inline void clear() + /// Remove all elements from the struct + { + _data.clear(); + } + + inline void swap(Struct& other) + /// Swap content of Struct with another Struct + { + _data.swap(other._data); + } + inline bool empty() const /// Returns true if the Struct doesn't contain any members { return _data.empty(); } - inline void clear() - /// Clears the Struct contents - { - _data.clear(); - } - SizeType size() const /// Returns the number of members the Struct contains { @@ -199,10 +201,35 @@ public: return keys; } + inline Var getVar(const K& key) const + /// Returns the var value of the element with the given name. + /// Throws a NotFoundException if the key does not exist. + { + ConstIterator it = find(key); + if(it == end()) + { + throw NotFoundException("Key not found in Struct"); + } + return it->second; + } + + template + inline Var getVar(const K& key, const DefT& defaultValue) const + /// Returns the var value of the element with the given name. + /// or defaultValue if none is found. + { + ConstIterator it = find(key); + if(it == end()) + { + return defaultValue; + } + return it->second; + } + std::string toString() const { std::string str; - Var(*this).convert(str); + Var(*this).template convert(str); return str; } @@ -222,7 +249,7 @@ private: template <> -class VarHolderImpl, std::set > >: public VarHolder +class VarHolderImpl, std::set>>: public VarHolder { public: typedef std::string KeyType; @@ -408,7 +435,7 @@ private: template <> -class VarHolderImpl, std::set > > : public VarHolder +class VarHolderImpl, std::set>> : public VarHolder { public: typedef int KeyType; @@ -593,11 +620,8 @@ private: }; -#ifdef POCO_ENABLE_CPP11 - - template <> -class VarHolderImpl, Poco::OrderedSet > > : public VarHolder +class VarHolderImpl, Poco::OrderedSet>> : public VarHolder { public: typedef std::string KeyType; @@ -783,7 +807,7 @@ private: template <> -class VarHolderImpl, Poco::OrderedSet > > : public VarHolder +class VarHolderImpl, Poco::OrderedSet>> : public VarHolder { public: typedef int KeyType; @@ -968,17 +992,12 @@ private: }; -#endif // POCO_ENABLE_CPP11 - - } // namespace Dynamic typedef Dynamic::Struct DynamicStruct; +typedef Dynamic::Struct, Poco::OrderedSet> OrderedDynamicStruct; -#ifdef POCO_ENABLE_CPP11 -typedef Dynamic::Struct, Poco::OrderedSet > OrderedDynamicStruct; -#endif // POCO_ENABLE_CPP11 } // namespace Poco diff --git a/Foundation/include/Poco/Dynamic/Var.h b/Foundation/include/Poco/Dynamic/Var.h index acc0d1326..941bf14de 100644 --- a/Foundation/include/Poco/Dynamic/Var.h +++ b/Foundation/include/Poco/Dynamic/Var.h @@ -81,9 +81,9 @@ class Foundation_API Var /// VarHolderImpl is available. For supported types, see VarHolder documentation. { public: - typedef SharedPtr Ptr; - typedef Poco::Dynamic::VarIterator Iterator; - typedef const VarIterator ConstIterator; + using Ptr = SharedPtr; + using Iterator = Poco::Dynamic::VarIterator; + using ConstIterator = const VarIterator; Var(); /// Creates an empty Var. @@ -798,8 +798,7 @@ inline bool Var::isEmpty() const inline bool Var::isArray() const { - if (isEmpty() || - isString()) return false; + if (isEmpty() || isString()) return false; VarHolder* pHolder = content(); return pHolder ? pHolder->isArray() : false; @@ -2231,6 +2230,110 @@ inline bool operator >= (const long& other, const Var& da) } +inline unsigned long operator + (const unsigned long& other, const Var& da) + /// Addition operator for adding Var to unsigned long +{ + return other + da.convert(); +} + + +inline unsigned long operator - (const unsigned long& other, const Var& da) + /// Subtraction operator for subtracting Var from unsigned long +{ + return other - da.convert(); +} + + +inline unsigned long operator * (const unsigned long& other, const Var& da) + /// Multiplication operator for multiplying Var with unsigned long +{ + return other * da.convert(); +} + + +inline unsigned long operator / (const unsigned long& other, const Var& da) + /// Division operator for dividing Var with unsigned long +{ + return other / da.convert(); +} + + +inline unsigned long operator += (unsigned long& other, const Var& da) + /// Addition assignment operator for adding Var to unsigned long +{ + return other += da.convert(); +} + + +inline unsigned long operator -= (unsigned long& other, const Var& da) + /// Subtraction assignment operator for subtracting Var from unsigned long +{ + return other -= da.convert(); +} + + +inline unsigned long operator *= (unsigned long& other, const Var& da) + /// Multiplication assignment operator for multiplying Var with unsigned long +{ + return other *= da.convert(); +} + + +inline unsigned long operator /= (unsigned long& other, const Var& da) + /// Division assignment operator for dividing Var with unsigned long +{ + return other /= da.convert(); +} + + +inline bool operator == (const unsigned long& other, const Var& da) + /// Equality operator for comparing Var with unsigned long +{ + if (da.isEmpty()) return false; + return other == da.convert(); +} + + +inline bool operator != (const unsigned long& other, const Var& da) + /// Inequality operator for comparing Var with unsigned long +{ + if (da.isEmpty()) return true; + return other != da.convert(); +} + + +inline bool operator < (const unsigned long& other, const Var& da) + /// Less than operator for comparing Var with unsigned long +{ + if (da.isEmpty()) return false; + return other < da.convert(); +} + + +inline bool operator <= (const unsigned long& other, const Var& da) + /// Less than or equal operator for comparing Var with unsigned long +{ + if (da.isEmpty()) return false; + return other <= da.convert(); +} + + +inline bool operator > (const unsigned long& other, const Var& da) + /// Greater than operator for comparing Var with unsigned long +{ + if (da.isEmpty()) return false; + return other > da.convert(); +} + + +inline bool operator >= (const unsigned long& other, const Var& da) + /// Greater than or equal operator for comparing Var with unsigned long +{ + if (da.isEmpty()) return false; + return other >= da.convert(); +} + + #endif // POCO_LONG_IS_64_BIT diff --git a/Foundation/include/Poco/Dynamic/VarHolder.h b/Foundation/include/Poco/Dynamic/VarHolder.h index 39a4fcb0a..aeb5860c9 100644 --- a/Foundation/include/Poco/Dynamic/VarHolder.h +++ b/Foundation/include/Poco/Dynamic/VarHolder.h @@ -670,6 +670,7 @@ inline bool VarHolder::isDateTime() const return false; } + inline std::size_t VarHolder::size() const { return 1u; @@ -3576,7 +3577,7 @@ private: template -class VarHolderImpl >: public VarHolder +class VarHolderImpl>: public VarHolder { public: VarHolderImpl(const std::vector& val): _val(val) @@ -3641,7 +3642,7 @@ private: template -class VarHolderImpl >: public VarHolder +class VarHolderImpl>: public VarHolder { public: VarHolderImpl(const std::list& val): _val(val) @@ -3716,7 +3717,7 @@ private: template -class VarHolderImpl >: public VarHolder +class VarHolderImpl>: public VarHolder { public: VarHolderImpl(const std::deque& val): _val(val) diff --git a/Foundation/include/Poco/DynamicFactory.h b/Foundation/include/Poco/DynamicFactory.h index 12a2ce286..f8d10ef3d 100644 --- a/Foundation/include/Poco/DynamicFactory.h +++ b/Foundation/include/Poco/DynamicFactory.h @@ -45,9 +45,9 @@ public: /// Destroys the DynamicFactory and deletes the instantiators for /// all registered classes. { - for (typename FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it) + for (auto& p: _map) { - delete it->second; + delete p.second; } } diff --git a/Foundation/include/Poco/Event.h b/Foundation/include/Poco/Event.h index c6e20b65a..924961780 100644 --- a/Foundation/include/Poco/Event.h +++ b/Foundation/include/Poco/Event.h @@ -44,11 +44,21 @@ class Foundation_API Event: private EventImpl /// for an event to become signalled. { public: - Event(bool autoReset = true); - /// Creates the event. If autoReset is true, + enum EventType + { + EVENT_MANUALRESET, /// Manual reset event + EVENT_AUTORESET /// Auto-reset event + }; + + explicit Event(EventType type = EVENT_AUTORESET); + /// Creates the event. If type is EVENT_AUTORESET, /// the event is automatically reset after /// a wait() successfully returns. + //@ deprecated + explicit Event(bool autoReset); + /// Please use Event::Event(EventType) instead. + ~Event(); /// Destroys the event. diff --git a/Foundation/include/Poco/EventChannel.h b/Foundation/include/Poco/EventChannel.h index 07975167d..47761ab3e 100644 --- a/Foundation/include/Poco/EventChannel.h +++ b/Foundation/include/Poco/EventChannel.h @@ -33,6 +33,8 @@ class Foundation_API EventChannel: public Channel /// the logging framework. { public: + using Ptr = AutoPtr; + Poco::BasicEvent messageLogged; /// Fired when a message is logged by calling the log() method. diff --git a/Foundation/include/Poco/EventLogChannel.h b/Foundation/include/Poco/EventLogChannel.h index bcaf3a42e..fcd18d363 100644 --- a/Foundation/include/Poco/EventLogChannel.h +++ b/Foundation/include/Poco/EventLogChannel.h @@ -35,6 +35,8 @@ class Foundation_API EventLogChannel: public Channel /// containing the message definition resources can be found in $PATH. { public: + using Ptr = AutoPtr; + EventLogChannel(); /// Creates the EventLogChannel. /// The name of the current application (or more correctly, @@ -85,11 +87,7 @@ protected: static int getType(const Message& msg); static int getCategory(const Message& msg); void setUpRegistry() const; -#if defined(POCO_WIN32_UTF8) static std::wstring findLibrary(const wchar_t* name); -#else - static std::string findLibrary(const char* name); -#endif private: std::string _name; diff --git a/Foundation/include/Poco/Exception.h b/Foundation/include/Poco/Exception.h index e211c3057..c2d9c8db8 100644 --- a/Foundation/include/Poco/Exception.h +++ b/Foundation/include/Poco/Exception.h @@ -43,19 +43,19 @@ public: Exception(const Exception& exc); /// Copy constructor. - ~Exception() throw(); + ~Exception() noexcept; /// Destroys the exception and deletes the nested exception. Exception& operator = (const Exception& exc); /// Assignment operator. - virtual const char* name() const throw(); + virtual const char* name() const noexcept; /// Returns a static string describing the exception. - virtual const char* className() const throw(); + virtual const char* className() const noexcept; /// Returns the name of the exception class. - virtual const char* what() const throw(); + virtual const char* what() const noexcept; /// Returns a static string describing the exception. /// /// Same as name(), but for compatibility with std::exception. @@ -146,10 +146,10 @@ inline int Exception::code() const CLS(const std::string& msg, const std::string& arg, int code = CODE); \ CLS(const std::string& msg, const Poco::Exception& exc, int code = CODE); \ CLS(const CLS& exc); \ - ~CLS() throw(); \ + ~CLS() noexcept; \ CLS& operator = (const CLS& exc); \ - const char* name() const throw(); \ - const char* className() const throw(); \ + const char* name() const noexcept; \ + const char* className() const noexcept; \ Poco::Exception* clone() const; \ void rethrow() const; \ }; @@ -173,7 +173,7 @@ inline int Exception::code() const CLS::CLS(const CLS& exc): BASE(exc) \ { \ } \ - CLS::~CLS() throw() \ + CLS::~CLS() noexcept \ { \ } \ CLS& CLS::operator = (const CLS& exc) \ @@ -181,11 +181,11 @@ inline int Exception::code() const BASE::operator = (exc); \ return *this; \ } \ - const char* CLS::name() const throw() \ + const char* CLS::name() const noexcept \ { \ return NAME; \ } \ - const char* CLS::className() const throw() \ + const char* CLS::className() const noexcept \ { \ return typeid(*this).name(); \ } \ diff --git a/Foundation/include/Poco/ExpireLRUCache.h b/Foundation/include/Poco/ExpireLRUCache.h index d79281a8e..b58badcc5 100644 --- a/Foundation/include/Poco/ExpireLRUCache.h +++ b/Foundation/include/Poco/ExpireLRUCache.h @@ -39,7 +39,7 @@ class ExpireLRUCache: public AbstractCache, TMutex, TEventMutex>(StrategyCollection()) { this->_strategy.pushBack(new LRUStrategy(cacheSize)); diff --git a/Foundation/include/Poco/FIFOEvent.h b/Foundation/include/Poco/FIFOEvent.h index 404044c39..b461d9631 100644 --- a/Foundation/include/Poco/FIFOEvent.h +++ b/Foundation/include/Poco/FIFOEvent.h @@ -30,7 +30,7 @@ namespace Poco { template class FIFOEvent: public AbstractEvent < TArgs, - FIFOStrategy >, + FIFOStrategy>, AbstractDelegate, TMutex > diff --git a/Foundation/include/Poco/File.h b/Foundation/include/Poco/File.h index d62be6fcd..26ee82ff6 100644 --- a/Foundation/include/Poco/File.h +++ b/Foundation/include/Poco/File.h @@ -23,14 +23,12 @@ #include -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(_WIN32_WCE) #include "File_WINCE.h" #else #include "Poco/File_WIN32U.h" #endif -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Poco/File_WIN32.h" #elif defined(POCO_VXWORKS) #include "Poco/File_VX.h" #elif defined(POCO_OS_FAMILY_UNIX) @@ -51,8 +49,7 @@ class Foundation_API File: private FileImpl /// platform-specific limitations regarding maximum length /// of the entire path and its components apply. /// - /// On Windows, if compiled with UTF-8 support (POCO_WIN32_UTF8) - /// the implementation tries to work around the rather low + /// On Windows, the implementation tries to work around the rather low /// 260 characters MAX_PATH limit by adding the "\\?\" prefix if /// a path is absolute and exceeds MAX_PATH characters in length. /// Note that various limitations regarding usage of the "\\?\" diff --git a/Foundation/include/Poco/FileStream.h b/Foundation/include/Poco/FileStream.h index cea56c947..ba1aa0a4f 100644 --- a/Foundation/include/Poco/FileStream.h +++ b/Foundation/include/Poco/FileStream.h @@ -44,8 +44,7 @@ class Foundation_API FileIOS: public virtual std::ios /// Use an InputLineEndingConverter or OutputLineEndingConverter /// if you require CR-LF translation. /// - /// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, - /// UTF-8 encoded Unicode paths are correctly handled. + /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled. { public: FileIOS(std::ios::openmode defaultMode); @@ -86,8 +85,7 @@ class Foundation_API FileInputStream: public FileIOS, public std::istream /// was specified. /// Use an InputLineEndingConverter if you require CR-LF translation. /// - /// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, - /// UTF-8 encoded Unicode paths are correctly handled. + /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled. { public: FileInputStream(); @@ -117,8 +115,7 @@ class Foundation_API FileOutputStream: public FileIOS, public std::ostream /// was specified. /// Use an OutputLineEndingConverter if you require CR-LF translation. /// - /// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, - /// UTF-8 encoded Unicode paths are correctly handled. + /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled. { public: FileOutputStream(); @@ -154,8 +151,7 @@ class Foundation_API FileStream: public FileIOS, public std::iostream /// read position and the write position simultaneously to the /// same value. /// - /// On Windows platforms, if POCO_WIN32_UTF8 is #define'd, - /// UTF-8 encoded Unicode paths are correctly handled. + /// On Windows platforms, UTF-8 encoded Unicode paths are correctly handled. { public: FileStream(); diff --git a/Foundation/include/Poco/File_UNIX.h b/Foundation/include/Poco/File_UNIX.h index ced4a9d52..34110620f 100644 --- a/Foundation/include/Poco/File_UNIX.h +++ b/Foundation/include/Poco/File_UNIX.h @@ -27,8 +27,8 @@ namespace Poco { class FileImpl { protected: - - enum Options { + enum Options + { OPT_FAIL_ON_OVERWRITE_IMPL = 0x01 }; diff --git a/Foundation/include/Poco/File_WIN32.h b/Foundation/include/Poco/File_WIN32.h index b5e9459b2..b3aa00085 100644 --- a/Foundation/include/Poco/File_WIN32.h +++ b/Foundation/include/Poco/File_WIN32.h @@ -28,8 +28,8 @@ namespace Poco { class Foundation_API FileImpl { protected: - - enum Options { + enum Options + { OPT_FAIL_ON_OVERWRITE_IMPL = 0x01 }; diff --git a/Foundation/include/Poco/File_WIN32U.h b/Foundation/include/Poco/File_WIN32U.h index d77e4db8f..7c2e0a935 100644 --- a/Foundation/include/Poco/File_WIN32U.h +++ b/Foundation/include/Poco/File_WIN32U.h @@ -28,8 +28,8 @@ namespace Poco { class Foundation_API FileImpl { protected: - - enum Options { + enum Options + { OPT_FAIL_ON_OVERWRITE_IMPL = 0x01 }; diff --git a/Foundation/include/Poco/Format.h b/Foundation/include/Poco/Format.h index e4b093a40..8ca9c4a5d 100644 --- a/Foundation/include/Poco/Format.h +++ b/Foundation/include/Poco/Format.h @@ -21,6 +21,7 @@ #include "Poco/Foundation.h" #include "Poco/Any.h" #include +#include namespace Poco { @@ -80,11 +81,13 @@ std::string Foundation_API format(const std::string& fmt, const Any& value); /// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G) /// * ? argument is any signed or unsigned int, short, long, or 64-bit integer (d, i, o, x, X) /// - /// The width argument is a nonnegative decimal integer controlling the minimum number of characters printed. + /// The width argument is a nonnegative decimal integer or '*' with an additional nonnegative integer value + /// preceding the value to be formated, controlling the minimum number of characters printed. /// If the number of characters in the output value is less than the specified width, blanks or /// leading zeros are added, according to the specified flags (-, +, 0). /// - /// Precision is a nonnegative decimal integer, preceded by a period (.), which specifies the number of characters + /// Precision is a nonnegative decimal integer or '*' with an additional nonnegative integer value preceding + /// the value to be formated, preceded by a period (.), which specifies the number of characters /// to be printed, the number of decimal places, or the number of significant digits. /// /// Throws an InvalidArgumentException if an argument index is out of range. @@ -102,36 +105,47 @@ std::string Foundation_API format(const std::string& fmt, const Any& value); /// std::string s1 = format("The answer to life, the universe, and everything is %d", 42); /// std::string s2 = format("second: %[1]d, first: %[0]d", 1, 2); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); -std::string Foundation_API format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); - - -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value); - /// Appends the formatted string to result. - -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); -void Foundation_API format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); - +void Foundation_API format(std::string& result, const char *fmt, const std::vector& values); + /// Supports a variable number of arguments and is used by + /// all other variants of format(). void Foundation_API format(std::string& result, const std::string& fmt, const std::vector& values); /// Supports a variable number of arguments and is used by /// all other variants of format(). +template < + typename T, + typename... Args> +void format(std::string &result, const std::string &fmt, T arg1, Args... args) + /// Appends the formatted string to result. +{ + std::vector values; + values.reserve(sizeof...(Args) + 1); + values.emplace_back(arg1); + values.insert(values.end(), { args... }); + format(result, fmt, values); +} + + +template < + typename FMT, + typename T, + typename... Args, + typename std::enable_if::type>::value, int>::type = 0> +std::string format(FMT &fmt, T arg1, Args... args) + /// Returns the formatted string. +{ + std::vector values; + values.reserve(sizeof...(Args) + 1); + values.emplace_back(arg1); + values.insert(values.end(), { args... }); + std::string result; + format(result, fmt, values); + return result; +} + + } // namespace Poco diff --git a/Foundation/include/Poco/Formatter.h b/Foundation/include/Poco/Formatter.h index 678d594b7..f638a5135 100644 --- a/Foundation/include/Poco/Formatter.h +++ b/Foundation/include/Poco/Formatter.h @@ -20,6 +20,7 @@ #include "Poco/Foundation.h" #include "Poco/Configurable.h" +#include "Poco/AutoPtr.h" #include "Poco/RefCountedObject.h" @@ -40,9 +41,9 @@ class Foundation_API Formatter: public Configurable, public RefCountedObject /// A useful implementation should at least take the Message's /// Time, Priority and Text fields and put them into a string. /// - /// The Formatter class supports the Configurable - /// interface, so the behaviour of certain formatters - /// is configurable. + /// The Formatter class supports the Configurable interface, + /// so the behaviour of certain formatters is configurable. + /// It also supports reference counting based garbage collection. /// /// Trivial implementations of of getProperty() and /// setProperty() are provided. @@ -50,6 +51,8 @@ class Foundation_API Formatter: public Configurable, public RefCountedObject /// Subclasses must at least provide a format() method. { public: + using Ptr = AutoPtr; + Formatter(); /// Creates the formatter. diff --git a/Foundation/include/Poco/FormattingChannel.h b/Foundation/include/Poco/FormattingChannel.h index f4dfded2a..493e52b87 100644 --- a/Foundation/include/Poco/FormattingChannel.h +++ b/Foundation/include/Poco/FormattingChannel.h @@ -20,6 +20,8 @@ #include "Poco/Foundation.h" #include "Poco/Channel.h" +#include "Poco/Formatter.h" +#include "Poco/AutoPtr.h" namespace Poco { @@ -34,30 +36,32 @@ class Foundation_API FormattingChannel: public Channel /// to the destination channel. { public: + using Ptr = AutoPtr; + FormattingChannel(); /// Creates a FormattingChannel. - FormattingChannel(Formatter* pFormatter); + FormattingChannel(Formatter::Ptr pFormatter); /// Creates a FormattingChannel and attaches a Formatter. - FormattingChannel(Formatter* pFormatter, Channel* pChannel); + FormattingChannel(Formatter::Ptr pFormatter, Channel::Ptr pChannel); /// Creates a FormattingChannel and attaches a Formatter /// and a Channel. - void setFormatter(Formatter* pFormatter); + void setFormatter(Formatter::Ptr pFormatter); /// Sets the Formatter used to format the messages /// before they are passed on. If null, the message /// is passed on unmodified. - Formatter* getFormatter() const; + Formatter::Ptr getFormatter() const; /// Returns the Formatter used to format messages, /// which may be null. - void setChannel(Channel* pChannel); + void setChannel(Channel::Ptr pChannel); /// Sets the destination channel to which the formatted /// messages are passed on. - Channel* getChannel() const; + Channel::Ptr getChannel() const; /// Returns the channel to which the formatted /// messages are passed on. @@ -85,8 +89,8 @@ protected: ~FormattingChannel(); private: - Formatter* _pFormatter; - Channel* _pChannel; + Formatter::Ptr _pFormatter; + Channel::Ptr _pChannel; }; diff --git a/Foundation/include/Poco/Foundation.h b/Foundation/include/Poco/Foundation.h index 750c7775e..74a3bf975 100644 --- a/Foundation/include/Poco/Foundation.h +++ b/Foundation/include/Poco/Foundation.h @@ -114,12 +114,8 @@ // Cleanup inconsistencies // #ifdef POCO_OS_FAMILY_WINDOWS - #if defined(POCO_WIN32_UTF8) && defined(POCO_NO_WSTRING) - #error POCO_WIN32_UTF8 and POCO_NO_WSTRING are mutually exclusive. - #endif -#else - #ifdef POCO_WIN32_UTF8 - #undef POCO_WIN32_UTF8 + #if defined(POCO_NO_WSTRING) + #error POCO_NO_WSTRING is not supported on Windows. #endif #endif diff --git a/Foundation/include/Poco/Glob.h b/Foundation/include/Poco/Glob.h index bdaccc605..0de6eaebe 100644 --- a/Foundation/include/Poco/Glob.h +++ b/Foundation/include/Poco/Glob.h @@ -78,7 +78,7 @@ public: static void glob(const std::string& pathPattern, std::set& files, int options = 0); /// Creates a set of files that match the given pathPattern. /// - /// The path may be give in either Unix, Windows or VMS syntax and + /// The path may be give in either Unix or Windows syntax and /// is automatically expanded by calling Path::expand(). /// /// The pattern may contain wildcard expressions even in intermediate @@ -93,7 +93,7 @@ public: static void glob(const char* pathPattern, std::set& files, int options = 0); /// Creates a set of files that match the given pathPattern. /// - /// The path may be give in either Unix, Windows or VMS syntax and + /// The path may be give in either Unix or Windows syntax and /// is automatically expanded by calling Path::expand(). /// /// The pattern may contain wildcard expressions even in intermediate diff --git a/Foundation/include/Poco/HMACEngine.h b/Foundation/include/Poco/HMACEngine.h index 0593e7d2c..1e4d6c5ce 100644 --- a/Foundation/include/Poco/HMACEngine.h +++ b/Foundation/include/Poco/HMACEngine.h @@ -28,7 +28,7 @@ namespace Poco { template class HMACEngine: public DigestEngine - /// This class implementes the HMAC message + /// This class implements the HMAC message /// authentication code algorithm, as specified /// in RFC 2104. The underlying DigestEngine /// (MD5Engine, SHA1Engine, etc.) must be given as @@ -80,8 +80,7 @@ public: const DigestEngine::Digest& d = _engine.digest(); char db[DIGEST_SIZE]; char* pdb = db; - for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end(); ++it) - *pdb++ = *it; + for (auto v: d) *pdb++ = v; _engine.reset(); _engine.update(_opad, BLOCK_SIZE); _engine.update(db, DIGEST_SIZE); diff --git a/Foundation/include/Poco/HashMap.h b/Foundation/include/Poco/HashMap.h index 5153f2b16..70845b707 100644 --- a/Foundation/include/Poco/HashMap.h +++ b/Foundation/include/Poco/HashMap.h @@ -78,7 +78,7 @@ private: }; -template > +template > class HashMap /// This class implements a map using a LinearHashTable. /// diff --git a/Foundation/include/Poco/HashSet.h b/Foundation/include/Poco/HashSet.h index e24560c00..a0c080699 100644 --- a/Foundation/include/Poco/HashSet.h +++ b/Foundation/include/Poco/HashSet.h @@ -25,7 +25,7 @@ namespace Poco { -template > +template > class HashSet /// This class implements a set using a LinearHashTable. /// diff --git a/Foundation/include/Poco/HashTable.h b/Foundation/include/Poco/HashTable.h index e71af1e12..f2d8eb680 100644 --- a/Foundation/include/Poco/HashTable.h +++ b/Foundation/include/Poco/HashTable.h @@ -32,7 +32,7 @@ namespace Poco { //@ deprecated -template > +template > class HashTable /// A HashTable stores a key value pair that can be looked up via a hashed key. /// diff --git a/Foundation/include/Poco/JSONString.h b/Foundation/include/Poco/JSONString.h index b4446efce..d3d15ef76 100644 --- a/Foundation/include/Poco/JSONString.h +++ b/Foundation/include/Poco/JSONString.h @@ -42,7 +42,7 @@ enum JSONOptions /// If specified, the object will preserve the items /// insertion order. Otherwise, items will be sorted /// by keys. - }; +}; //@ deprecated diff --git a/Foundation/include/Poco/LRUCache.h b/Foundation/include/Poco/LRUCache.h index 7f8f0debd..9c7bfcad7 100644 --- a/Foundation/include/Poco/LRUCache.h +++ b/Foundation/include/Poco/LRUCache.h @@ -35,7 +35,7 @@ class LRUCache: public AbstractCache, TM /// An LRUCache implements Least Recently Used caching. The default size for a cache is 1024 entries. { public: - LRUCache(long size = 1024): + LRUCache(std::size_t size = 1024): AbstractCache, TMutex, TEventMutex>(LRUStrategy(size)) { } diff --git a/Foundation/include/Poco/LinearHashTable.h b/Foundation/include/Poco/LinearHashTable.h index ac18b4b95..1db5b0088 100644 --- a/Foundation/include/Poco/LinearHashTable.h +++ b/Foundation/include/Poco/LinearHashTable.h @@ -30,12 +30,12 @@ namespace Poco { -template > +template > class LinearHashTable /// This class implements a linear hash table. /// /// In a linear hash table, the available address space - /// grows or shrinks dynamically. A linar hash table thus + /// grows or shrinks dynamically. A linear hash table thus /// supports any number of insertions or deletions without /// lookup or insertion performance deterioration. /// @@ -279,15 +279,15 @@ public: /// Returns an iterator pointing to the first entry, if one exists. { BucketVecIterator it(_buckets.begin()); - BucketVecIterator end(_buckets.end()); - while (it != end && it->empty()) + BucketVecIterator itEnd(_buckets.end()); + while (it != itEnd && it->empty()) { ++it; } - if (it == end) - return this->end(); + if (it == itEnd) + return end(); else - return ConstIterator(it, end, it->begin()); + return ConstIterator(it, itEnd, it->begin()); } ConstIterator end() const @@ -300,15 +300,15 @@ public: /// Returns an iterator pointing to the first entry, if one exists. { BucketVecIterator it(_buckets.begin()); - BucketVecIterator end(_buckets.end()); - while (it != end && it->empty()) + BucketVecIterator itEnd(_buckets.end()); + while (it != itEnd && it->empty()) { ++it; } - if (it == end) - return this->end(); + if (it == itEnd) + return end(); else - return Iterator(it, end, it->begin()); + return Iterator(it, itEnd, it->begin()); } Iterator end() @@ -398,8 +398,8 @@ public: void clear() /// Erases all elements. { - LinearHashTable empty; - swap(empty); + LinearHashTable emptyTable; + swap(emptyTable); } std::size_t size() const diff --git a/Foundation/include/Poco/ListMap.h b/Foundation/include/Poco/ListMap.h index 03c056d81..51844d7f1 100644 --- a/Foundation/include/Poco/ListMap.h +++ b/Foundation/include/Poco/ListMap.h @@ -2,7 +2,7 @@ // ListMap.h // // Library: Foundation -// Package: Hashing +// Package: Core // Module: ListMap // // Definition of the ListMap class. @@ -21,14 +21,14 @@ #include "Poco/Foundation.h" #include "Poco/String.h" #include "Poco/Exception.h" -#include +#include #include namespace Poco { -template >, bool CaseSensitive = false > +template >, bool CaseSensitive = false> class ListMap /// This class implements a multimap in terms of a sequential container. /// The use for this type of associative container is wherever automatic @@ -39,28 +39,38 @@ class ListMap /// header entry reordering. { public: - typedef Key KeyType; - typedef Mapped MappedType; - typedef Mapped& Reference; - typedef const Mapped& ConstReference; - typedef Mapped* Pointer; - typedef const Mapped* ConstPointer; + using KeyType = Key; + using MappedType = Mapped; + using Reference = Mapped&; + using ConstReference = const Mapped&; + using Pointer = Mapped*; + using ConstPointer = const Mapped*; - typedef typename Container::value_type ValueType; - typedef typename Container::size_type SizeType; - typedef typename Container::iterator Iterator; - typedef typename Container::const_iterator ConstIterator; + using ValueType = typename Container::value_type; + using SizeType = typename Container::size_type; + using Iterator = typename Container::iterator; + using ConstIterator = typename Container::const_iterator; ListMap() /// Creates an empty ListMap. { } - ListMap(std::size_t initialReserve): - _list(initialReserve) + explicit ListMap(std::size_t initialReserve): + _container(initialReserve) /// Creates the ListMap with room for initialReserve entries. { } + + ListMap(const ListMap& other): + _container(other._container) + { + } + + ListMap(ListMap&& other) noexcept: + _container(std::move(other._container)) + { + } ListMap& operator = (const ListMap& map) /// Assigns another ListMap. @@ -70,34 +80,41 @@ public: return *this; } + ListMap& operator = (ListMap&& map) noexcept + /// Assigns another ListMap. + { + _container = std::move(map._container); + return *this; + } + void swap(ListMap& map) /// Swaps the ListMap with another one. { - _list.swap(map._list); + _container.swap(map._container); } ConstIterator begin() const /// Returns the beginning of the map. { - return _list.begin(); + return _container.begin(); } ConstIterator end() const /// Returns the end of the map. { - return _list.end(); + return _container.end(); } Iterator begin() /// Returns the beginning of the map. { - return _list.begin(); + return _container.begin(); } Iterator end() /// Returns the end of the map. { - return _list.end(); + return _container.end(); } ConstIterator find(const KeyType& key) const @@ -106,8 +123,8 @@ public: /// or iterator pointing to the end if entry is /// not found. { - typename Container::const_iterator it = _list.begin(); - typename Container::const_iterator itEnd = _list.end(); + typename Container::const_iterator it = _container.begin(); + typename Container::const_iterator itEnd = _container.end(); for(; it != itEnd; ++it) { if (isEqual(it->first, key)) return it; @@ -121,8 +138,8 @@ public: /// or iterator pointing to the end if entry is /// not found. { - typename Container::iterator it = _list.begin(); - typename Container::iterator itEnd = _list.end(); + typename Container::iterator it = _container.begin(); + typename Container::iterator itEnd = _container.end(); for(; it != itEnd; ++it) { if (isEqual(it->first, key)) return it; @@ -138,13 +155,13 @@ public: /// Returns iterator pointing to the newly inserted value { Iterator it = find(val.first); - while (it != _list.end() && isEqual(it->first, val.first)) ++it; - return _list.insert(it, val); + while (it != _container.end() && isEqual(it->first, val.first)) ++it; + return _container.insert(it, val); } void erase(Iterator it) { - _list.erase(it); + _container.erase(it); } SizeType erase(const KeyType& key) @@ -152,12 +169,12 @@ public: SizeType count = 0; Iterator it = find(key); bool removed = false; - while (it != _list.end()) + while (it != _container.end()) { if (isEqual(it->first, key)) { ++count; - it = _list.erase(it); + it = _container.erase(it); removed = true; } else @@ -171,23 +188,23 @@ public: void clear() { - _list.clear(); + _container.clear(); } std::size_t size() const { - return _list.size(); + return _container.size(); } bool empty() const { - return _list.empty(); + return _container.empty(); } ConstReference operator [] (const KeyType& key) const { ConstIterator it = find(key); - if (it != _list.end()) + if (it != _container.end()) return it->second; else throw NotFoundException(); @@ -196,8 +213,10 @@ public: Reference operator [] (const KeyType& key) { Iterator it = find(key); - if (it != _list.end()) + if (it != _container.end()) + { return it->second; + } else { ValueType value(key, Mapped()); @@ -236,7 +255,7 @@ private: return isEqual(std::string(s1), std::string(s2)); } - Container _list; + Container _container; }; diff --git a/Foundation/include/Poco/LocalDateTime.h b/Foundation/include/Poco/LocalDateTime.h index 08c90b658..47206671a 100644 --- a/Foundation/include/Poco/LocalDateTime.h +++ b/Foundation/include/Poco/LocalDateTime.h @@ -37,7 +37,7 @@ class Foundation_API LocalDateTime /// i.e. UTC = local time - time zone differential. /// /// Although LocalDateTime supports relational and arithmetic - /// operators, all date/time comparisons and date/time arithmetics + /// operators, all date/time comparisons and date/time arithmetic /// should be done in UTC, using the DateTime or Timestamp /// class for better performance. The relational operators /// normalize the dates/times involved to UTC before carrying out @@ -169,11 +169,11 @@ public: /// on a Saturday, week 1 will be the week starting on Monday, January 3. /// January 1 and 2 will fall within week 0 (or the last week of the previous year). /// - /// For 2007, which starts on a Monday, week 1 will be the week startung on Monday, January 1. + /// For 2007, which starts on a Monday, week 1 will be the week starting on Monday, January 1. /// There will be no week 0 in 2007. int day() const; - /// Returns the day witin the month (1 to 31). + /// Returns the day within the month (1 to 31). int dayOfWeek() const; /// Returns the weekday (0 to 6, where @@ -208,7 +208,7 @@ public: /// Returns the microsecond (0 to 999) double julianDay() const; - /// Returns the julian day for the date. + /// Returns the Julian day for the date. int tzd() const; /// Returns the time zone differential. diff --git a/Foundation/include/Poco/LogFile.h b/Foundation/include/Poco/LogFile.h index 37872b535..3e1ec21f4 100644 --- a/Foundation/include/Poco/LogFile.h +++ b/Foundation/include/Poco/LogFile.h @@ -21,10 +21,8 @@ #include "Poco/Foundation.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #include "Poco/LogFile_WIN32U.h" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Poco/LogFile_WIN32.h" #else #include "Poco/LogFile_STD.h" #endif diff --git a/Foundation/include/Poco/Logger.h b/Foundation/include/Poco/Logger.h index 956b1d8ec..0c9cf21c2 100644 --- a/Foundation/include/Poco/Logger.h +++ b/Foundation/include/Poco/Logger.h @@ -22,9 +22,11 @@ #include "Poco/Channel.h" #include "Poco/Message.h" #include "Poco/Format.h" +#include "Poco/AutoPtr.h" #include #include #include +#include namespace Poco { @@ -53,17 +55,16 @@ class Foundation_API Logger: public Channel /// The name of a logger determines the logger's place within the logger hierarchy. /// The name of the root logger is always "", the empty string. For all other /// loggers, the name is made up of one or more components, separated by a period. - /// For example, the loggers with the name HTTPServer.RequestHandler and HTTPServer.Listener - /// are descendants of the logger HTTPServer, which itself is a descendant of - /// the root logger. There is not limit as to how deep - /// the logger hierarchy can become. Once a logger has been created and it has - /// inherited the channel and level from its ancestor, it loses the connection - /// to it. So changes to the level or channel of a logger do not affect its - /// descendants. This greatly simplifies the implementation of the framework - /// and is no real restriction, because almost always levels and channels are - /// set up at application startup and never changed afterwards. Nevertheless, - /// there are methods to simultaneously change the level and channel of all - /// loggers in a certain hierarchy. + /// For example, the loggers with the name HTTPServer.RequestHandler and + /// HTTPServer.Listener are descendants of the logger HTTPServer, which itself is a + /// descendant of the root logger. There is no limit as to how deep the logger hierarchy + /// can become. Once a logger has been created and it has inherited the channel and level + /// from its ancestor, it loses the connection to it. So, changes to the level or + /// channel of a logger do not affect its descendants. This greatly simplifies the + /// implementation of the framework and is no real restriction, because almost always + /// levels and channels are set up at application startup and never changed afterwards. + /// Nevertheless, there are methods to simultaneously change the level and channel of + /// all loggers in a certain hierarchy. /// /// There are also convenience macros available that wrap the actual /// logging statement into a check whether the Logger's log level @@ -72,21 +73,23 @@ class Foundation_API Logger: public Channel /// are used. The macros also add the source file path and line /// number into the log message so that it is available to formatters. /// Variants of these macros that allow message formatting with Poco::format() - /// are also available. Up to four arguments are supported. + /// are also available. /// /// Examples: /// poco_warning(logger, "This is a warning"); - /// poco_information_f2(logger, "An informational message with args: %d, %d", 1, 2); + /// poco_information_f(logger, "An informational message with args: %d, %d", 1, 2); { public: + using Ptr = AutoPtr; + const std::string& name() const; /// Returns the name of the logger, which is set as the /// message source on all messages created by the logger. - void setChannel(Channel* pChannel); + void setChannel(Channel::Ptr pChannel); /// Attaches the given Channel to the Logger. - Channel* getChannel() const; + Channel::Ptr getChannel() const; /// Returns the Channel attached to the logger. void setLevel(int level); @@ -150,16 +153,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void fatal(const std::string& fmt, const Any& value1); - void fatal(const std::string& fmt, const Any& value1, const Any& value2); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void fatal(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_FATAL); + } void critical(const std::string& msg); /// If the Logger's log level is at least PRIO_CRITICAL, @@ -177,16 +175,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void critical(const std::string& fmt, const Any& value1); - void critical(const std::string& fmt, const Any& value1, const Any& value2); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void critical(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_CRITICAL); + } void error(const std::string& msg); /// If the Logger's log level is at least PRIO_ERROR, @@ -204,16 +197,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void error(const std::string& fmt, const Any& value1); - void error(const std::string& fmt, const Any& value1, const Any& value2); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void error(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_ERROR); + } void warning(const std::string& msg); /// If the Logger's log level is at least PRIO_WARNING, @@ -231,16 +219,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void warning(const std::string& fmt, const Any& value1); - void warning(const std::string& fmt, const Any& value1, const Any& value2); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void warning(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_WARNING); + } void notice(const std::string& msg); /// If the Logger's log level is at least PRIO_NOTICE, @@ -258,16 +241,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void notice(const std::string& fmt, const Any& value1); - void notice(const std::string& fmt, const Any& value1, const Any& value2); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void notice(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_NOTICE); + } void information(const std::string& msg); /// If the Logger's log level is at least PRIO_INFORMATION, @@ -285,16 +263,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void information(const std::string& fmt, const Any& value1); - void information(const std::string& fmt, const Any& value1, const Any& value2); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void information(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_INFORMATION); + } void debug(const std::string& msg); /// If the Logger's log level is at least PRIO_DEBUG, @@ -312,16 +285,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void debug(const std::string& fmt, const Any& value1); - void debug(const std::string& fmt, const Any& value1, const Any& value2); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void debug(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_DEBUG); + } void trace(const std::string& msg); /// If the Logger's log level is at least PRIO_TRACE, @@ -339,16 +307,11 @@ public: /// the __FILE__ macro. The string is not copied /// internally for performance reasons. - void trace(const std::string& fmt, const Any& value1); - void trace(const std::string& fmt, const Any& value1, const Any& value2); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9); - void trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10); + template + void trace(const std::string &fmt, T arg1, Args&&... args) + { + log(Poco::format(fmt, arg1, std::forward(args)...), Message::PRIO_TRACE); + } void dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio = Message::PRIO_DEBUG); /// Logs the given message, followed by the data in buffer. @@ -387,22 +350,22 @@ public: /// Returns true if the log level is at least PRIO_TRACE. static std::string format(const std::string& fmt, const std::string& arg); - /// Replaces all occurences of $0 in fmt with the string given in arg and + /// Replaces all occurrences of $0 in fmt with the string given in arg and /// returns the result. To include a dollar sign in the result string, /// specify two dollar signs ($$) in the format string. static std::string format(const std::string& fmt, const std::string& arg0, const std::string& arg1); - /// Replaces all occurences of $ in fmt with the string given in arg and + /// Replaces all occurrences of $ in fmt with the string given in arg and /// returns the result. To include a dollar sign in the result string, /// specify two dollar signs ($$) in the format string. static std::string format(const std::string& fmt, const std::string& arg0, const std::string& arg1, const std::string& arg2); - /// Replaces all occurences of $ in fmt with the string given in arg and + /// Replaces all occurrences of $ in fmt with the string given in arg and /// returns the result. To include a dollar sign in the result string, /// specify two dollar signs ($$) in the format string. static std::string format(const std::string& fmt, const std::string& arg0, const std::string& arg1, const std::string& arg2, const std::string& arg3); - /// Replaces all occurences of $ in fmt with the string given in arg and + /// Replaces all occurrences of $ in fmt with the string given in arg and /// returns the result. To include a dollar sign in the result string, /// specify two dollar signs ($$) in the format string. @@ -414,7 +377,7 @@ public: /// Sets the given log level on all loggers that are /// descendants of the Logger with the given name. - static void setChannel(const std::string& name, Channel* pChannel); + static void setChannel(const std::string& name, Channel::Ptr pChannel); /// Attaches the given Channel to all loggers that are /// descendants of the Logger with the given name. @@ -437,7 +400,7 @@ public: /// The only time this method should be used is during /// program initialization, when only one thread is running. - static Logger& create(const std::string& name, Channel* pChannel, int level = Message::PRIO_INFORMATION); + static Logger& create(const std::string& name, Channel::Ptr pChannel, int level = Message::PRIO_INFORMATION); /// Creates and returns a reference to a Logger with the /// given name. The Logger's Channel and log level as set as /// specified. @@ -446,9 +409,9 @@ public: /// Returns a reference to the root logger, which is the ultimate /// ancestor of all Loggers. - static Logger* has(const std::string& name); + static Ptr has(const std::string& name); /// Returns a pointer to the Logger with the given name if it - /// exists, or a null pointer otherwse. + /// exists, or a null pointer otherwise. static void destroy(const std::string& name); /// Destroys the logger with the specified name. Does nothing @@ -485,9 +448,9 @@ public: static const std::string ROOT; /// The name of the root logger (""). protected: - typedef std::map LoggerMap; + typedef std::map LoggerMap; - Logger(const std::string& name, Channel* pChannel, int level); + Logger(const std::string& name, Channel::Ptr pChannel, int level); ~Logger(); void log(const std::string& text, Message::Priority prio); @@ -495,19 +458,22 @@ protected: static std::string format(const std::string& fmt, int argc, std::string argv[]); static Logger& parent(const std::string& name); - static void add(Logger* pLogger); - static Logger* find(const std::string& name); + static void add(Ptr pLogger); + static Ptr find(const std::string& name); private: + typedef std::unique_ptr LoggerMapPtr; + Logger(); Logger(const Logger&); Logger& operator = (const Logger&); std::string _name; - Channel* _pChannel; + Channel::Ptr _pChannel; int _level; - static LoggerMap* _pLoggerMap; + // definitions in Foundation.cpp + static LoggerMapPtr _pLoggerMap; static Mutex _mapMtx; }; @@ -530,6 +496,9 @@ private: #define poco_fatal_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).fatal()) (logger).fatal(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 +#define poco_fatal_f(logger, fmt, ...) \ + if ((logger).fatal()) (logger).fatal(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 + #define poco_critical(logger, msg) \ if ((logger).critical()) (logger).critical(msg, __FILE__, __LINE__); else (void) 0 @@ -545,6 +514,9 @@ private: #define poco_critical_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).critical()) (logger).critical(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 +#define poco_critical_f(logger, fmt, ...) \ + if ((logger).critical()) (logger).critical(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 + #define poco_error(logger, msg) \ if ((logger).error()) (logger).error(msg, __FILE__, __LINE__); else (void) 0 @@ -560,6 +532,9 @@ private: #define poco_error_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).error()) (logger).error(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 +#define poco_error_f(logger, fmt, ...) \ + if ((logger).error()) (logger).error(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 + #define poco_warning(logger, msg) \ if ((logger).warning()) (logger).warning(msg, __FILE__, __LINE__); else (void) 0 @@ -574,7 +549,10 @@ private: #define poco_warning_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).warning()) (logger).warning(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 - + +#define poco_warning_f(logger, fmt, ...) \ + if ((logger).warning()) (logger).warning(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 + #define poco_notice(logger, msg) \ if ((logger).notice()) (logger).notice(msg, __FILE__, __LINE__); else (void) 0 @@ -590,6 +568,9 @@ private: #define poco_notice_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).notice()) (logger).notice(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 +#define poco_notice_f(logger, fmt, ...) \ + if ((logger).notice()) (logger).notice(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 + #define poco_information(logger, msg) \ if ((logger).information()) (logger).information(msg, __FILE__, __LINE__); else (void) 0 @@ -605,6 +586,9 @@ private: #define poco_information_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).information()) (logger).information(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 +#define poco_information_f(logger, fmt, ...) \ + if ((logger).information()) (logger).information(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 + #if defined(_DEBUG) || defined(POCO_LOG_DEBUG) #define poco_debug(logger, msg) \ if ((logger).debug()) (logger).debug(msg, __FILE__, __LINE__); else (void) 0 @@ -621,6 +605,9 @@ private: #define poco_debug_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).debug()) (logger).debug(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 + #define poco_debug_f(logger, fmt, ...) \ + if ((logger).debug()) (logger).debug(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 + #define poco_trace(logger, msg) \ if ((logger).trace()) (logger).trace(msg, __FILE__, __LINE__); else (void) 0 @@ -635,17 +622,22 @@ private: #define poco_trace_f4(logger, fmt, arg1, arg2, arg3, arg4) \ if ((logger).trace()) (logger).trace(Poco::format((fmt), (arg1), (arg2), (arg3), (arg4)), __FILE__, __LINE__); else (void) 0 + + #define poco_trace_f(logger, fmt, ...) \ + if ((logger).trace()) (logger).trace(Poco::format((fmt), __VA_ARGS__), __FILE__, __LINE__); else (void) 0 #else #define poco_debug(logger, msg) #define poco_debug_f1(logger, fmt, arg1) #define poco_debug_f2(logger, fmt, arg1, arg2) #define poco_debug_f3(logger, fmt, arg1, arg2, arg3) #define poco_debug_f4(logger, fmt, arg1, arg2, arg3, arg4) + #define poco_debug_f(logger, fmt, ...) #define poco_trace(logger, msg) #define poco_trace_f1(logger, fmt, arg1) #define poco_trace_f2(logger, fmt, arg1, arg2) #define poco_trace_f3(logger, fmt, arg1, arg2, arg3) #define poco_trace_f4(logger, fmt, arg1, arg2, arg3, arg4) + #define poco_trace_f(logger, fmt, ...) #endif @@ -694,65 +686,6 @@ inline void Logger::fatal(const std::string& msg, const char* file, int line) } -inline void Logger::fatal(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_FATAL); -} - - -inline void Logger::fatal(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_FATAL); -} - inline void Logger::critical(const std::string& msg) { @@ -766,66 +699,6 @@ inline void Logger::critical(const std::string& msg, const char* file, int line) } -inline void Logger::critical(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_CRITICAL); -} - - -inline void Logger::critical(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_CRITICAL); -} - - inline void Logger::error(const std::string& msg) { log(msg, Message::PRIO_ERROR); @@ -838,66 +711,6 @@ inline void Logger::error(const std::string& msg, const char* file, int line) } -inline void Logger::error(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_ERROR); -} - - -inline void Logger::error(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_ERROR); -} - - inline void Logger::warning(const std::string& msg) { log(msg, Message::PRIO_WARNING); @@ -910,66 +723,6 @@ inline void Logger::warning(const std::string& msg, const char* file, int line) } -inline void Logger::warning(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_WARNING); -} - - -inline void Logger::warning(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_WARNING); -} - - inline void Logger::notice(const std::string& msg) { log(msg, Message::PRIO_NOTICE); @@ -982,66 +735,6 @@ inline void Logger::notice(const std::string& msg, const char* file, int line) } -inline void Logger::notice(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_NOTICE); -} - - -inline void Logger::notice(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_NOTICE); -} - - inline void Logger::information(const std::string& msg) { log(msg, Message::PRIO_INFORMATION); @@ -1054,66 +747,6 @@ inline void Logger::information(const std::string& msg, const char* file, int li } -inline void Logger::information(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_INFORMATION); -} - - -inline void Logger::information(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_INFORMATION); -} - - inline void Logger::debug(const std::string& msg) { log(msg, Message::PRIO_DEBUG); @@ -1126,66 +759,6 @@ inline void Logger::debug(const std::string& msg, const char* file, int line) } -inline void Logger::debug(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_DEBUG); -} - - -inline void Logger::debug(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_DEBUG); -} - - inline void Logger::trace(const std::string& msg) { log(msg, Message::PRIO_TRACE); @@ -1198,66 +771,6 @@ inline void Logger::trace(const std::string& msg, const char* file, int line) } -inline void Logger::trace(const std::string& fmt, const Any& value1) -{ - log(Poco::format(fmt, value1), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2) -{ - log(Poco::format(fmt, value1, value2), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - log(Poco::format(fmt, value1, value2, value3), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - log(Poco::format(fmt, value1, value2, value3, value4), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9), Message::PRIO_TRACE); -} - - -inline void Logger::trace(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - log(Poco::format(fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10), Message::PRIO_TRACE); -} - - inline bool Logger::is(int level) const { return _level >= level; diff --git a/Foundation/include/Poco/LoggingFactory.h b/Foundation/include/Poco/LoggingFactory.h index c851c3f90..390b1b677 100644 --- a/Foundation/include/Poco/LoggingFactory.h +++ b/Foundation/include/Poco/LoggingFactory.h @@ -62,13 +62,13 @@ public: void registerFormatterClass(const std::string& className, FormatterFactory* pFactory); /// Registers a formatter class with the LoggingFactory. - Channel* createChannel(const std::string& className) const; + Channel::Ptr createChannel(const std::string& className) const; /// Creates a new Channel instance from specified class. /// /// Throws a NotFoundException if the specified channel class /// has not been registered. - Formatter* createFormatter(const std::string& className) const; + Formatter::Ptr createFormatter(const std::string& className) const; /// Creates a new Formatter instance from specified class. /// /// Throws a NotFoundException if the specified formatter class diff --git a/Foundation/include/Poco/LoggingRegistry.h b/Foundation/include/Poco/LoggingRegistry.h index 82bb2c858..2d4ca3647 100644 --- a/Foundation/include/Poco/LoggingRegistry.h +++ b/Foundation/include/Poco/LoggingRegistry.h @@ -42,24 +42,24 @@ public: ~LoggingRegistry(); /// Destroys the LoggingRegistry. - Channel* channelForName(const std::string& name) const; + Channel::Ptr channelForName(const std::string& name) const; /// Returns the Channel object which has been registered /// under the given name. /// /// Throws a NotFoundException if the name is unknown. - Formatter* formatterForName(const std::string& name) const; + Formatter::Ptr formatterForName(const std::string& name) const; /// Returns the Formatter object which has been registered /// under the given name. /// /// Throws a NotFoundException if the name is unknown. - void registerChannel(const std::string& name, Channel* pChannel); + void registerChannel(const std::string& name, Channel::Ptr pChannel); /// Registers a channel under a given name. /// It is okay to re-register a different channel under an /// already existing name. - void registerFormatter(const std::string& name, Formatter* pFormatter); + void registerFormatter(const std::string& name, Formatter::Ptr pFormatter); /// Registers a formatter under a given name. /// It is okay to re-register a different formatter under an /// already existing name. @@ -82,7 +82,7 @@ public: /// LoggingRegistry. private: - typedef AutoPtr ChannelPtr; + typedef Channel::Ptr ChannelPtr; typedef AutoPtr FormatterPtr; typedef std::map ChannelMap; typedef std::map FormatterMap; diff --git a/Foundation/include/Poco/MD4Engine.h b/Foundation/include/Poco/MD4Engine.h index 644575e06..c243e7851 100644 --- a/Foundation/include/Poco/MD4Engine.h +++ b/Foundation/include/Poco/MD4Engine.h @@ -49,7 +49,7 @@ namespace Poco { class Foundation_API MD4Engine: public DigestEngine - /// This class implementes the MD4 message digest algorithm, + /// This class implements the MD4 message digest algorithm, /// described in RFC 1320. { public: diff --git a/Foundation/include/Poco/MD5Engine.h b/Foundation/include/Poco/MD5Engine.h index 7835ff612..ec3e80df7 100644 --- a/Foundation/include/Poco/MD5Engine.h +++ b/Foundation/include/Poco/MD5Engine.h @@ -49,7 +49,7 @@ namespace Poco { class Foundation_API MD5Engine: public DigestEngine - /// This class implementes the MD5 message digest algorithm, + /// This class implements the MD5 message digest algorithm, /// described in RFC 1321. { public: diff --git a/Foundation/include/Poco/Manifest.h b/Foundation/include/Poco/Manifest.h index f2d36e76e..b3db242c6 100644 --- a/Foundation/include/Poco/Manifest.h +++ b/Foundation/include/Poco/Manifest.h @@ -145,9 +145,9 @@ public: void clear() /// Removes all MetaObjects from the manifest. { - for (typename MetaMap::iterator it = _metaMap.begin(); it != _metaMap.end(); ++it) + for (auto& p: _metaMap) { - delete it->second; + delete p.second; } _metaMap.clear(); } diff --git a/Foundation/include/Poco/MemoryStream.h b/Foundation/include/Poco/MemoryStream.h index 819f16094..e168c8a03 100644 --- a/Foundation/include/Poco/MemoryStream.h +++ b/Foundation/include/Poco/MemoryStream.h @@ -172,7 +172,7 @@ private: // // We provide an instantiation for char // -typedef BasicMemoryStreamBuf > MemoryStreamBuf; +typedef BasicMemoryStreamBuf> MemoryStreamBuf; class Foundation_API MemoryIOS: public virtual std::ios diff --git a/Foundation/include/Poco/Message.h b/Foundation/include/Poco/Message.h index 0086f2b37..7c42b748c 100644 --- a/Foundation/include/Poco/Message.h +++ b/Foundation/include/Poco/Message.h @@ -78,6 +78,9 @@ public: Message(const Message& msg); /// Creates a Message by copying another one. + Message(Message&& msg); + /// Creates a Message by copying another one. + Message(const Message& msg, const std::string& text); /// Creates a Message by copying all but the text from another message. @@ -87,6 +90,9 @@ public: Message& operator = (const Message& msg); /// Assignment operator. + Message& operator = (Message&& msg); + /// Assignment operator. + void swap(Message& msg); /// Swaps the message with another one. diff --git a/Foundation/include/Poco/MetaObject.h b/Foundation/include/Poco/MetaObject.h index b3b0d242e..a3e574da9 100644 --- a/Foundation/include/Poco/MetaObject.h +++ b/Foundation/include/Poco/MetaObject.h @@ -44,9 +44,9 @@ public: virtual ~AbstractMetaObject() { - for (typename ObjectSet::iterator it = _deleteSet.begin(); it != _deleteSet.end(); ++it) + for (auto p: _deleteSet) { - delete *it; + delete p; } } diff --git a/Foundation/include/Poco/Mutex.h b/Foundation/include/Poco/Mutex.h index 5eadb49eb..c10946846 100644 --- a/Foundation/include/Poco/Mutex.h +++ b/Foundation/include/Poco/Mutex.h @@ -61,7 +61,7 @@ class Foundation_API Mutex: private MutexImpl /// lock and unlock a mutex. { public: - typedef Poco::ScopedLock ScopedLock; + using ScopedLock = Poco::ScopedLock; Mutex(); /// creates the Mutex. @@ -116,7 +116,7 @@ class Foundation_API FastMutex: private FastMutexImpl /// lock and unlock a mutex. { public: - typedef Poco::ScopedLock ScopedLock; + using ScopedLock = Poco::ScopedLock; FastMutex(); /// creates the Mutex. @@ -175,7 +175,7 @@ class Foundation_API SpinlockMutex /// Works with the ScopedLock class. { public: - typedef Poco::ScopedLock ScopedLock; + using ScopedLock = Poco::ScopedLock; SpinlockMutex(); /// Creates the SpinlockMutex. @@ -221,7 +221,7 @@ class Foundation_API NullMutex /// Works with the ScopedLock class { public: - typedef Poco::ScopedLock ScopedLock; + using ScopedLock = Poco::ScopedLock; NullMutex() /// Creates the NullMutex. diff --git a/Foundation/include/Poco/NamedEvent.h b/Foundation/include/Poco/NamedEvent.h index b473be108..5ef42bb1e 100644 --- a/Foundation/include/Poco/NamedEvent.h +++ b/Foundation/include/Poco/NamedEvent.h @@ -21,10 +21,8 @@ #include "Poco/Foundation.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #include "Poco/NamedEvent_WIN32U.h" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Poco/NamedEvent_WIN32.h" #elif POCO_OS == POCO_OS_ANDROID #include "Poco/NamedEvent_Android.h" #elif defined(POCO_OS_FAMILY_UNIX) diff --git a/Foundation/include/Poco/NamedMutex.h b/Foundation/include/Poco/NamedMutex.h index 421f018e2..686ff5f06 100644 --- a/Foundation/include/Poco/NamedMutex.h +++ b/Foundation/include/Poco/NamedMutex.h @@ -22,10 +22,8 @@ #include "Poco/ScopedLock.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #include "Poco/NamedMutex_WIN32U.h" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Poco/NamedMutex_WIN32.h" #elif POCO_OS == POCO_OS_ANDROID #include "Poco/NamedMutex_Android.h" #elif defined(POCO_OS_FAMILY_UNIX) @@ -55,7 +53,7 @@ class Foundation_API NamedMutex: private NamedMutexImpl /// interfere with each other. { public: - typedef Poco::ScopedLock ScopedLock; + using ScopedLock = Poco::ScopedLock; NamedMutex(const std::string& name); /// creates the Mutex. diff --git a/Foundation/include/Poco/Notification.h b/Foundation/include/Poco/Notification.h index f5f20a1cc..2246c6b12 100644 --- a/Foundation/include/Poco/Notification.h +++ b/Foundation/include/Poco/Notification.h @@ -35,7 +35,7 @@ class Foundation_API Notification: public RefCountedObject /// template class. { public: - typedef AutoPtr Ptr; + using Ptr = AutoPtr; Notification(); /// Creates the notification. diff --git a/Foundation/include/Poco/NotificationQueue.h b/Foundation/include/Poco/NotificationQueue.h index 3194dddd4..f299ed336 100644 --- a/Foundation/include/Poco/NotificationQueue.h +++ b/Foundation/include/Poco/NotificationQueue.h @@ -123,6 +123,10 @@ public: void clear(); /// Removes all notifications from the queue. + bool remove(Notification::Ptr pNotification); + /// Removes a notification from the queue. + /// Returns true if remove succeeded, false otherwise + bool hasIdleThreads() const; /// Returns true if the queue has at least one thread waiting /// for a notification. diff --git a/Foundation/include/Poco/NotificationStrategy.h b/Foundation/include/Poco/NotificationStrategy.h index d36fbe28b..856507678 100644 --- a/Foundation/include/Poco/NotificationStrategy.h +++ b/Foundation/include/Poco/NotificationStrategy.h @@ -33,7 +33,7 @@ class NotificationStrategy /// but does not need to inherit from NotificationStrategy. { public: - typedef TDelegate* DelegateHandle; + using DelegateHandle = TDelegate*; NotificationStrategy() { @@ -74,7 +74,7 @@ class NotificationStrategy /// but does not need to inherit from NotificationStrategy. { public: - typedef TDelegate* DelegateHandle; + using DelegateHandle = TDelegate*; NotificationStrategy() { diff --git a/Foundation/include/Poco/NullChannel.h b/Foundation/include/Poco/NullChannel.h index 8384dcf4b..426107e71 100644 --- a/Foundation/include/Poco/NullChannel.h +++ b/Foundation/include/Poco/NullChannel.h @@ -35,6 +35,8 @@ class Foundation_API NullChannel: public Channel /// other channel class in a logging configuration. { public: + using Ptr = AutoPtr; + NullChannel(); /// Creates the NullChannel. diff --git a/Foundation/include/Poco/Nullable.h b/Foundation/include/Poco/Nullable.h index d113256cf..12a164a6f 100644 --- a/Foundation/include/Poco/Nullable.h +++ b/Foundation/include/Poco/Nullable.h @@ -90,6 +90,15 @@ public: { } + Nullable(Nullable&& other) noexcept: + /// Creates a Nullable by moving another one. + _value(std::move(other._value)), + _isNull(other._isNull), + _null() + { + other.isNull = true; + } + ~Nullable() /// Destroys the Nullable. { @@ -130,6 +139,15 @@ public: return assign(other); } + Nullable& operator = (Nullable&& other) noexcept + /// Moves another Nullable. + { + _isNull = other._isNull; + _value = std::move(other._value); + other._isNull = true; + return *this; + } + Nullable& operator = (NullType) /// Assigns another Nullable. { @@ -247,7 +265,6 @@ public: operator NullType& () /// Get reference to the value { - return _null; } diff --git a/Foundation/include/Poco/NumericString.h b/Foundation/include/Poco/NumericString.h index aa6369425..610714e6d 100644 --- a/Foundation/include/Poco/NumericString.h +++ b/Foundation/include/Poco/NumericString.h @@ -143,7 +143,7 @@ inline char decimalSeparator() /// default '.' for platforms where locale is unavailable. { #if !defined(POCO_NO_LOCALE) - return std::use_facet >(std::locale()).decimal_point(); + return std::use_facet>(std::locale()).decimal_point(); #else return '.'; #endif @@ -155,7 +155,7 @@ inline char thousandSeparator() /// default ',' for platforms where locale is unavailable. { #if !defined(POCO_NO_LOCALE) - return std::use_facet >(std::locale()).thousands_sep(); + return std::use_facet>(std::locale()).thousands_sep(); #else return ','; #endif diff --git a/Foundation/include/Poco/ObjectPool.h b/Foundation/include/Poco/ObjectPool.h index af3d7bab0..3933e13b3 100644 --- a/Foundation/include/Poco/ObjectPool.h +++ b/Foundation/include/Poco/ObjectPool.h @@ -90,7 +90,7 @@ public: template -class PoolableObjectFactory > +class PoolableObjectFactory > { public: Poco::AutoPtr createObject() @@ -118,7 +118,7 @@ public: template -class PoolableObjectFactory > +class PoolableObjectFactory > { public: Poco::SharedPtr createObject() @@ -145,7 +145,7 @@ public: }; -template > +template > class ObjectPool /// An ObjectPool manages a pool of objects of a certain class. /// @@ -195,9 +195,9 @@ public: { try { - for (typename std::vector

::iterator it = _pool.begin(); it != _pool.end(); ++it) + for (auto& p: _pool) { - _factory.destroyObject(*it); + _factory.destroyObject(p); } } catch (...) diff --git a/Foundation/include/Poco/Optional.h b/Foundation/include/Poco/Optional.h index 54593b16c..4f73d5e0a 100644 --- a/Foundation/include/Poco/Optional.h +++ b/Foundation/include/Poco/Optional.h @@ -74,6 +74,14 @@ public: { } + Optional(Optional&& other) noexcept: + /// Creates a Optional by moving another one. + _value(std::move(other._value)), + _isSpecified(other._isSpecified) + { + other._isSpecified = false; + } + ~Optional() /// Destroys the Optional. { @@ -105,6 +113,14 @@ public: return assign(other); } + Optional& operator = (Optional&& other) noexcept + { + _value = std::move(other._value); + _isSpecified = other._isSpecified; + other._isSpecified = false; + return *this; + } + void swap(Optional& other) { std::swap(_value, other._value); diff --git a/Foundation/include/Poco/OrderedMap.h b/Foundation/include/Poco/OrderedMap.h index 9a9065c0e..3d31cae46 100644 --- a/Foundation/include/Poco/OrderedMap.h +++ b/Foundation/include/Poco/OrderedMap.h @@ -20,7 +20,6 @@ #include "Poco/Foundation.h" -#ifdef POCO_ENABLE_CPP11 #ifdef min #undef min @@ -47,6 +46,5 @@ using OrderedMap = tsl::ordered_map class PBKDF2Engine: public DigestEngine - /// This class implementes the Password-Based Key Derivation Function 2, + /// This class implements the Password-Based Key Derivation Function 2, /// as specified in RFC 2898. The underlying DigestEngine (HMACEngine, etc.), /// which must accept the passphrase as constructor argument (std::string), /// must be given as template argument. @@ -56,7 +56,7 @@ class PBKDF2Engine: public DigestEngine /// by calling update(). /// /// Example (WPA2): - /// PBKDF2Engine > pbkdf2(ssid, 4096, 256); + /// PBKDF2Engine> pbkdf2(ssid, 4096, 256); /// pbkdf2.update(passphrase); /// DigestEngine::Digest d = pbkdf2.digest(); { diff --git a/Foundation/include/Poco/Path.h b/Foundation/include/Poco/Path.h index c50c1a1a8..30e465a5a 100644 --- a/Foundation/include/Poco/Path.h +++ b/Foundation/include/Poco/Path.h @@ -41,6 +41,7 @@ public: enum Style { PATH_UNIX, /// Unix-style path + PATH_URI = PATH_UNIX, /// URI-style path, same as Unix-style PATH_WINDOWS, /// Windows-style path PATH_VMS, /// VMS-style path PATH_NATIVE, /// The current platform's native style @@ -70,6 +71,9 @@ public: Path(const Path& path); /// Copy constructor + Path(Path&& path) noexcept; + /// Move constructor. + Path(const Path& parent, const std::string& fileName); /// Creates a path from a parent path and a filename. /// The parent path is expected to reference a directory. @@ -88,6 +92,9 @@ public: Path& operator = (const Path& path); /// Assignment operator. + + Path& operator = (Path&& path) noexcept; + /// Move assignment. Path& operator = (const std::string& path); /// Assigns a string containing a path in native format. @@ -168,7 +175,7 @@ public: /// Appends the given path. Path& resolve(const Path& path); - /// Resolves the given path agains the current one. + /// Resolves the given path against the current one. /// /// If the given path is absolute, it replaces the current one. /// Otherwise, the relative path is appended to the current path. @@ -353,8 +360,7 @@ public: /// Otherwise false is returned and the path argument remains unchanged. static std::string transcode(const std::string& path); - /// On Windows, if POCO has been compiled with Windows UTF-8 support - /// (POCO_WIN32_UTF8), this function converts a string (usually containing a path) + /// On Windows, this function converts a string (usually containing a path) /// encoded in UTF-8 into a string encoded in the current Windows code page. /// /// This function should be used for every string passed as a file name to diff --git a/Foundation/include/Poco/PatternFormatter.h b/Foundation/include/Poco/PatternFormatter.h index cdbb0f08d..a7a39c86c 100644 --- a/Foundation/include/Poco/PatternFormatter.h +++ b/Foundation/include/Poco/PatternFormatter.h @@ -21,9 +21,9 @@ #include "Poco/Foundation.h" #include "Poco/Formatter.h" #include "Poco/Message.h" - #include + namespace Poco { @@ -77,6 +77,8 @@ class Foundation_API PatternFormatter: public Formatter { public: + using Ptr = AutoPtr; + PatternFormatter(); /// Creates a PatternFormatter. /// The format pattern must be specified with @@ -102,6 +104,8 @@ public: /// for details. /// * times: Specifies whether times are adjusted for local time /// or taken as they are in UTC. Supported values are "local" and "UTC". + /// * priorityNames: Provide a comma-separated list of custom priority names, + /// e.g. "Fatal, Critical, Error, Warning, Notice, Information, Debug, Trace" /// /// If any other property name is given, a PropertyNotSupported /// exception is thrown. @@ -113,9 +117,10 @@ public: static const std::string PROP_PATTERN; static const std::string PROP_TIMES; + static const std::string PROP_PRIORITY_NAMES; protected: - static const std::string& getPriorityName(int); + const std::string& getPriorityName(int); /// Returns a string for the given priority value. private: @@ -134,11 +139,15 @@ private: void parsePattern(); /// Will parse the _pattern string into the vector of PatternActions, /// which contains the message key, any text that needs to be written first - /// a proprety in case of %[] and required length. + /// a property in case of %[] and required length. + + void parsePriorityNames(); std::vector _patternActions; bool _localTime; std::string _pattern; + std::string _priorityNames; + std::string _priorities[9]; }; diff --git a/Foundation/include/Poco/Platform_WIN32.h b/Foundation/include/Poco/Platform_WIN32.h index 4e61a17e4..77e448fca 100644 --- a/Foundation/include/Poco/Platform_WIN32.h +++ b/Foundation/include/Poco/Platform_WIN32.h @@ -67,17 +67,6 @@ #endif -// Unicode Support -#if defined(UNICODE) && !defined(POCO_WIN32_UTF8) - #define POCO_WIN32_UTF8 -#endif - - -#if !defined(POCO_WIN32_UTF8) - #pragma message("Compiling POCO on Windows without #define POCO_WIN32_UTF8 is deprecated.") -#endif - - // Turn off some annoying warnings #if defined(_MSC_VER) #pragma warning(disable:4018) // signed/unsigned comparison @@ -93,12 +82,6 @@ #endif -// Enable C++11 support for VS 2010 and newer -#if defined(_MSC_VER) && (_MSC_VER >= 1700) && !defined(POCO_ENABLE_CPP11) - #define POCO_ENABLE_CPP11 -#endif - - #if defined(__INTEL_COMPILER) #pragma warning(disable:1738) // base class dllexport/dllimport specification differs from that of the derived class #pragma warning(disable:1478) // function ... was declared "deprecated" diff --git a/Foundation/include/Poco/PriorityStrategy.h b/Foundation/include/Poco/PriorityStrategy.h index 65d67a449..418e5c04d 100644 --- a/Foundation/include/Poco/PriorityStrategy.h +++ b/Foundation/include/Poco/PriorityStrategy.h @@ -34,10 +34,10 @@ class PriorityStrategy: public NotificationStrategy /// by their priority. { public: - typedef TDelegate* DelegateHandle; - typedef SharedPtr DelegatePtr; - typedef std::vector Delegates; - typedef typename Delegates::iterator Iterator; + using DelegateHandle = TDelegate*; + using DelegatePtr = SharedPtr; + using Delegates = std::vector; + using Iterator = typename Delegates::iterator; public: PriorityStrategy() @@ -139,10 +139,10 @@ class PriorityStrategy /// by their priority. { public: - typedef TDelegate* DelegateHandle; - typedef SharedPtr DelegatePtr; - typedef std::vector Delegates; - typedef typename Delegates::iterator Iterator; + using DelegateHandle = TDelegate*; + using DelegatePtr = SharedPtr; + using Delegates = std::vector; + using Iterator = typename Delegates::iterator; public: diff --git a/Foundation/include/Poco/Process.h b/Foundation/include/Poco/Process.h index f9fefc524..9557fa031 100644 --- a/Foundation/include/Poco/Process.h +++ b/Foundation/include/Poco/Process.h @@ -21,14 +21,12 @@ #include "Poco/Foundation.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(_WIN32_WCE) #include "Process_WINCE.h" #else #include "Poco/Process_WIN32U.h" #endif -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Poco/Process_WIN32.h" #elif defined(POCO_VXWORKS) #include "Poco/Process_VX.h" #elif defined(POCO_OS_FAMILY_UNIX) diff --git a/Foundation/include/Poco/RWLock.h b/Foundation/include/Poco/RWLock.h index 23b3b16cb..b8cbe9937 100644 --- a/Foundation/include/Poco/RWLock.h +++ b/Foundation/include/Poco/RWLock.h @@ -50,9 +50,9 @@ class Foundation_API RWLock: private RWLockImpl /// readers or one exclusive writer. { public: - typedef ScopedRWLock ScopedLock; - typedef ScopedReadRWLock ScopedReadLock; - typedef ScopedWriteRWLock ScopedWriteLock; + using ScopedLock = ScopedRWLock; + using ScopedReadLock = ScopedReadRWLock; + using ScopedWriteLock = ScopedWriteRWLock; RWLock(); /// Creates the Reader/Writer lock. diff --git a/Foundation/include/Poco/RecursiveDirectoryIterator.h b/Foundation/include/Poco/RecursiveDirectoryIterator.h index c0ce2285e..869feb8f6 100644 --- a/Foundation/include/Poco/RecursiveDirectoryIterator.h +++ b/Foundation/include/Poco/RecursiveDirectoryIterator.h @@ -51,7 +51,7 @@ class RecursiveDirectoryIterator /// The class can follow different traversal strategies: /// * depth-first strategy; /// * siblings-first strategy. - /// The stategies are set by template parameter. + /// The strategies are set by template parameter. /// There are two corresponding typedefs: /// * SimpleRecursiveDirectoryIterator; /// * SiblingsFirstRecursiveDirectoryIterator. diff --git a/Foundation/include/Poco/RefCountedObject.h b/Foundation/include/Poco/RefCountedObject.h index 083cdfb2e..55ea76a16 100644 --- a/Foundation/include/Poco/RefCountedObject.h +++ b/Foundation/include/Poco/RefCountedObject.h @@ -40,7 +40,7 @@ public: void duplicate() const; /// Increments the object's reference count. - void release() const throw(); + void release() const noexcept; /// Decrements the object's reference count /// and deletes the object if the count /// reaches zero. @@ -75,7 +75,7 @@ inline void RefCountedObject::duplicate() const } -inline void RefCountedObject::release() const throw() +inline void RefCountedObject::release() const noexcept { try { diff --git a/Foundation/include/Poco/RegularExpression.h b/Foundation/include/Poco/RegularExpression.h index 638b99e11..5291aab6c 100644 --- a/Foundation/include/Poco/RegularExpression.h +++ b/Foundation/include/Poco/RegularExpression.h @@ -78,7 +78,7 @@ public: std::string::size_type offset; /// zero based offset (std::string::npos if subexpr does not match) std::string::size_type length; /// length of substring }; - typedef std::vector MatchVec; + using MatchVec = std::vector; RegularExpression(const std::string& pattern, int options = 0, bool study = true); /// Creates a regular expression and parses the given pattern. diff --git a/Foundation/include/Poco/SHA1Engine.h b/Foundation/include/Poco/SHA1Engine.h index 81c8a4d9e..9aa2b45e3 100644 --- a/Foundation/include/Poco/SHA1Engine.h +++ b/Foundation/include/Poco/SHA1Engine.h @@ -32,7 +32,7 @@ namespace Poco { class Foundation_API SHA1Engine: public DigestEngine - /// This class implementes the SHA-1 message digest algorithm. + /// This class implements the SHA-1 message digest algorithm. /// (FIPS 180-1, see http://www.itl.nist.gov/fipspubs/fip180-1.htm) { public: diff --git a/Foundation/include/Poco/SharedLibrary.h b/Foundation/include/Poco/SharedLibrary.h index 52292c741..b7e6acc7c 100644 --- a/Foundation/include/Poco/SharedLibrary.h +++ b/Foundation/include/Poco/SharedLibrary.h @@ -27,10 +27,8 @@ #include "Poco/SharedLibrary_VX.h" #elif defined(POCO_OS_FAMILY_UNIX) #include "Poco/SharedLibrary_UNIX.h" -#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#elif defined(POCO_OS_FAMILY_WINDOWS) #include "Poco/SharedLibrary_WIN32U.h" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Poco/SharedLibrary_WIN32.h" #endif diff --git a/Foundation/include/Poco/SharedMemory_WIN32.h b/Foundation/include/Poco/SharedMemory_WIN32.h index bd48b6932..c89130549 100644 --- a/Foundation/include/Poco/SharedMemory_WIN32.h +++ b/Foundation/include/Poco/SharedMemory_WIN32.h @@ -50,7 +50,7 @@ public: /// will generally ignore the hint. char* begin() const; - /// Returns the beginn address of the SharedMemory segment. Will be null for illegal segments. + /// Returns the begin address of the SharedMemory segment. Will be null for illegal segments. char* end() const; /// Points past the last byte of the end address of the SharedMemory segment. Will be null for illegal segments. diff --git a/Foundation/include/Poco/SharedPtr.h b/Foundation/include/Poco/SharedPtr.h index 44c790ea0..c09592599 100644 --- a/Foundation/include/Poco/SharedPtr.h +++ b/Foundation/include/Poco/SharedPtr.h @@ -63,7 +63,7 @@ class ReleasePolicy public: static void release(C* pObj) /// Delete the object. - /// Note that pObj can be 0. + /// Note that pObj can be nullptr. { delete pObj; } @@ -77,14 +77,14 @@ class ReleaseArrayPolicy public: static void release(C* pObj) /// Delete the object. - /// Note that pObj can be 0. + /// Note that pObj can be nullptr. { delete [] pObj; } }; -template > +template > class SharedPtr /// SharedPtr is a "smart" pointer for classes implementing /// reference counting based garbage collection. @@ -115,13 +115,13 @@ class SharedPtr public: typedef C Type; - SharedPtr(): _pCounter(new RC), _ptr(0) + SharedPtr(): _pCounter(nullptr), _ptr(nullptr) { } SharedPtr(C* ptr) try: - _pCounter(new RC), + _pCounter(ptr ? new RC : nullptr), _ptr(ptr) { } @@ -133,12 +133,18 @@ public: template SharedPtr(const SharedPtr& ptr): _pCounter(ptr._pCounter), _ptr(const_cast(ptr.get())) { - _pCounter->duplicate(); + if (_pCounter) _pCounter->duplicate(); } SharedPtr(const SharedPtr& ptr): _pCounter(ptr._pCounter), _ptr(ptr._ptr) { - _pCounter->duplicate(); + if (_pCounter) _pCounter->duplicate(); + } + + SharedPtr(SharedPtr&& ptr) noexcept: _pCounter(std::move(ptr._pCounter)), _ptr(std::move(ptr._ptr)) + { + ptr._pCounter = nullptr; + ptr._ptr = nullptr; } ~SharedPtr() @@ -186,7 +192,7 @@ public: void reset() { - assign(0); + assign(nullptr); } void reset(C* ptr) @@ -215,6 +221,15 @@ public: return assign(ptr); } + SharedPtr& operator = (SharedPtr&& ptr) noexcept + { + _ptr = std::move(ptr._ptr); + _pCounter = std::move(ptr._pCounter); + ptr._ptr = nullptr; + ptr._pCounter = nullptr; + return *this; + } + template SharedPtr& operator = (const SharedPtr& ptr) { @@ -296,12 +311,12 @@ public: bool operator ! () const { - return _ptr == 0; + return _ptr == nullptr; } bool isNull() const { - return _ptr == 0; + return _ptr == nullptr; } bool operator == (const SharedPtr& ptr) const @@ -396,7 +411,7 @@ public: int referenceCount() const { - return _pCounter->referenceCount(); + return _pCounter ? _pCounter->referenceCount() : 0; } private: @@ -410,15 +425,13 @@ private: void release() { - poco_assert_dbg (_pCounter); - int i = _pCounter->release(); - if (i == 0) + if (_pCounter && _pCounter->release() == 0) { RP::release(_ptr); - _ptr = 0; + _ptr = nullptr; delete _pCounter; - _pCounter = 0; + _pCounter = nullptr; } } @@ -444,6 +457,20 @@ inline void swap(SharedPtr& p1, SharedPtr& p2) } +template +SharedPtr makeShared(Args&&... args) +{ + return SharedPtr(new T(std::forward(args)...)); +} + + +template +SharedPtr> makeSharedArray(std::size_t size) +{ + return new SharedPtr>(new T[size]); +} + + } // namespace Poco diff --git a/Foundation/include/Poco/SimpleFileChannel.h b/Foundation/include/Poco/SimpleFileChannel.h index 29882f45b..844cacc51 100644 --- a/Foundation/include/Poco/SimpleFileChannel.h +++ b/Foundation/include/Poco/SimpleFileChannel.h @@ -73,11 +73,13 @@ class Foundation_API SimpleFileChannel: public Channel // or whether it's allowed to stay in the system's file buffer for some time. /// Valid values are: /// - /// * true: Every essages is immediately flushed to the log file (default). + /// * true: Every message is immediately flushed to the log file (default). /// * false: Messages are not immediately flushed to the log file. /// { public: + using Ptr = AutoPtr; + SimpleFileChannel(); /// Creates the FileChannel. diff --git a/Foundation/include/Poco/SimpleHashTable.h b/Foundation/include/Poco/SimpleHashTable.h index c149cd6b7..cc2e92fb3 100644 --- a/Foundation/include/Poco/SimpleHashTable.h +++ b/Foundation/include/Poco/SimpleHashTable.h @@ -32,11 +32,11 @@ namespace Poco { //@ deprecated -template > +template > class SimpleHashTable /// A SimpleHashTable stores a key value pair that can be looked up via a hashed key. /// - /// In comparision to a HashTable, this class handles collisions by sequentially searching the next + /// In comparison to a HashTable, this class handles collisions by sequentially searching the next /// free location. This also means that the maximum size of this table is limited, i.e. if the hash table /// is full, it will throw an exception and that this class does not support remove operations. /// On the plus side it is faster than the HashTable. @@ -66,10 +66,10 @@ public: _capacity(ht._capacity) { _entries.reserve(ht._capacity); - for (typename HashTableVector::iterator it = ht._entries.begin(); it != ht._entries.end(); ++it) + for (auto p: ht._entries.end()) { - if (*it) - _entries.push_back(new HashEntry(*it)); + if (p) + _entries.push_back(new HashEntry(p)); else _entries.push_back(0); } @@ -101,10 +101,10 @@ public: void clear() { - for (typename HashTableVector::iterator it = _entries.begin(); it != _entries.end(); ++it) + for (auto& p: _entries) { - delete *it; - *it = 0; + delete p; + p = 0; } _size = 0; } @@ -339,11 +339,11 @@ public: { SimpleHashTable tmp(newSize); swap(tmp); - for (typename HashTableVector::const_iterator it = tmp._entries.begin(); it != tmp._entries.end(); ++it) + for (const auto& p: tmp._entries) { - if (*it) + if (p) { - insertRaw((*it)->key, hash((*it)->key), (*it)->value); + insertRaw(p->key, hash(p->key), p->value); } } } diff --git a/Foundation/include/Poco/SplitterChannel.h b/Foundation/include/Poco/SplitterChannel.h index 75aa33b20..6f48eab3e 100644 --- a/Foundation/include/Poco/SplitterChannel.h +++ b/Foundation/include/Poco/SplitterChannel.h @@ -21,6 +21,7 @@ #include "Poco/Foundation.h" #include "Poco/Channel.h" #include "Poco/Mutex.h" +#include "Poco/AutoPtr.h" #include @@ -32,13 +33,15 @@ class Foundation_API SplitterChannel: public Channel /// channels simultaneously. { public: + using Ptr = AutoPtr; + SplitterChannel(); /// Creates the SplitterChannel. - void addChannel(Channel* pChannel); + void addChannel(Channel::Ptr pChannel); /// Attaches a channel, which may not be null. - void removeChannel(Channel* pChannel); + void removeChannel(Channel::Ptr pChannel); /// Removes a channel. void log(const Message& msg); @@ -64,7 +67,7 @@ protected: ~SplitterChannel(); private: - typedef std::vector ChannelVec; + typedef std::vector ChannelVec; ChannelVec _channels; mutable FastMutex _mutex; diff --git a/Foundation/include/Poco/StrategyCollection.h b/Foundation/include/Poco/StrategyCollection.h index 6372d4662..7994f5417 100644 --- a/Foundation/include/Poco/StrategyCollection.h +++ b/Foundation/include/Poco/StrategyCollection.h @@ -33,9 +33,9 @@ class StrategyCollection: public AbstractStrategy /// An StrategyCollection is a decorator masking n collections as a single one. { public: - typedef std::vector > > Strategies; - typedef typename Strategies::iterator Iterator; - typedef typename Strategies::const_iterator ConstIterator; + using Strategies = std::vector>>; + using Iterator = typename Strategies::iterator; + using ConstIterator = typename Strategies::const_iterator; public: StrategyCollection() @@ -49,7 +49,7 @@ public: void pushBack(AbstractStrategy* pStrat) /// Adds an AbstractStrategy to the collection. Class takes ownership of pointer { - _strategies.push_back(SharedPtr >(pStrat)); + _strategies.push_back(SharedPtr>(pStrat)); } void popBack() diff --git a/Foundation/include/Poco/StreamChannel.h b/Foundation/include/Poco/StreamChannel.h index 8ecf50a77..27ed0c7db 100644 --- a/Foundation/include/Poco/StreamChannel.h +++ b/Foundation/include/Poco/StreamChannel.h @@ -38,6 +38,8 @@ class Foundation_API StreamChannel: public Channel /// in the text. { public: + using Ptr = AutoPtr; + StreamChannel(std::ostream& str); /// Creates the channel. diff --git a/Foundation/include/Poco/String.h b/Foundation/include/Poco/String.h index 64c07e29b..1520e0a32 100644 --- a/Foundation/include/Poco/String.h +++ b/Foundation/include/Poco/String.h @@ -686,7 +686,7 @@ struct i_char_traits : public std::char_traits }; -typedef std::basic_string > istring; +typedef std::basic_string> istring; /// Case-insensitive std::string counterpart. diff --git a/Foundation/include/Poco/StringTokenizer.h b/Foundation/include/Poco/StringTokenizer.h index 91b771fe9..0690fb720 100644 --- a/Foundation/include/Poco/StringTokenizer.h +++ b/Foundation/include/Poco/StringTokenizer.h @@ -67,7 +67,7 @@ public: /// Returns true if token exists, false otherwise. std::string::size_type find(const std::string& token, std::string::size_type pos = 0) const; - /// Returns the index of the first occurence of the token + /// Returns the index of the first occurrence of the token /// starting at position pos. /// Throws a NotFoundException if the token is not found. diff --git a/Foundation/include/Poco/SynchronizedObject.h b/Foundation/include/Poco/SynchronizedObject.h index b697f48e6..a2cfd96fb 100644 --- a/Foundation/include/Poco/SynchronizedObject.h +++ b/Foundation/include/Poco/SynchronizedObject.h @@ -33,7 +33,7 @@ class Foundation_API SynchronizedObject /// scenario. { public: - typedef Poco::ScopedLock ScopedLock; + using ScopedLock = Poco::ScopedLock; SynchronizedObject(); /// Creates the object. diff --git a/Foundation/include/Poco/SyslogChannel.h b/Foundation/include/Poco/SyslogChannel.h index 4c304e8c0..843d4ce98 100644 --- a/Foundation/include/Poco/SyslogChannel.h +++ b/Foundation/include/Poco/SyslogChannel.h @@ -29,6 +29,8 @@ class Foundation_API SyslogChannel: public Channel /// This Unix-only channel works with the Unix syslog service. { public: + using Ptr = AutoPtr; + enum Option { SYSLOG_PID = 0x01, /// log the pid with each message diff --git a/Foundation/include/Poco/Task.h b/Foundation/include/Poco/Task.h index 01b52490f..6ae11d283 100644 --- a/Foundation/include/Poco/Task.h +++ b/Foundation/include/Poco/Task.h @@ -106,6 +106,16 @@ protected: /// /// A Task should use this method in favor of Thread::sleep(). + bool yield(); + /// Yields cpu to other threads + /// + /// If the task is cancelled while it is suspended, + /// yield() will return true. If the tasks resumes + /// without being cancelled, the + /// return value is false. + /// + /// A Task should use this method in favor of Thread::yield(). + void setProgress(float progress); /// Sets the task's progress. /// The value should be between 0.0 (just started) diff --git a/Foundation/include/Poco/TaskManager.h b/Foundation/include/Poco/TaskManager.h index 3d6e7f1cc..0a4ff86f2 100644 --- a/Foundation/include/Poco/TaskManager.h +++ b/Foundation/include/Poco/TaskManager.h @@ -47,8 +47,8 @@ class Foundation_API TaskManager /// will only be sent out once in 100 milliseconds. { public: - typedef AutoPtr TaskPtr; - typedef std::list TaskList; + using TaskPtr = AutoPtr; + using TaskList = std::list; TaskManager(); /// Creates the TaskManager, using the diff --git a/Foundation/include/Poco/TaskNotification.h b/Foundation/include/Poco/TaskNotification.h index 92d8a9582..88dab508d 100644 --- a/Foundation/include/Poco/TaskNotification.h +++ b/Foundation/include/Poco/TaskNotification.h @@ -120,7 +120,7 @@ class TaskCustomNotification: public TaskNotification /// This is a template for "custom" notification. /// Unlike other notifications, this notification /// is instantiated and posted by the task itself. - /// The purpose is to provide generic notifiation + /// The purpose is to provide generic notification /// mechanism between the task and its observer(s). { public: diff --git a/Foundation/include/Poco/TextEncoding.h b/Foundation/include/Poco/TextEncoding.h index 40d64b7c9..2a5db0f4d 100644 --- a/Foundation/include/Poco/TextEncoding.h +++ b/Foundation/include/Poco/TextEncoding.h @@ -41,7 +41,7 @@ class Foundation_API TextEncoding /// TextEncoding objects. { public: - typedef SharedPtr Ptr; + using Ptr = SharedPtr; enum { @@ -69,7 +69,7 @@ public: /// Returns true if the given name is one of the names of this encoding. /// For example, the "ISO-8859-1" encoding is also known as "Latin-1". /// - /// Encoding name comparisions are case insensitive. + /// Encoding name comparisons are case insensitive. virtual const CharacterMap& characterMap() const = 0; /// Returns the CharacterMap for the encoding. diff --git a/Foundation/include/Poco/Timer.h b/Foundation/include/Poco/Timer.h index d9f7fc256..56dbd2b5b 100644 --- a/Foundation/include/Poco/Timer.h +++ b/Foundation/include/Poco/Timer.h @@ -141,8 +141,8 @@ protected: void run(); private: - volatile long _startInterval; - volatile long _periodicInterval; + long _startInterval; + long _periodicInterval; Event _wakeUp; Event _done; long _skipped; diff --git a/Foundation/include/Poco/Timespan.h b/Foundation/include/Poco/Timespan.h index fcd742bbf..09f17428e 100644 --- a/Foundation/include/Poco/Timespan.h +++ b/Foundation/include/Poco/Timespan.h @@ -29,7 +29,7 @@ class Foundation_API Timespan /// A class that represents time spans up to microsecond resolution. { public: - typedef Timestamp::TimeDiff TimeDiff; + using TimeDiff = Timestamp::TimeDiff; Timespan(); /// Creates a zero Timespan. diff --git a/Foundation/include/Poco/Timestamp.h b/Foundation/include/Poco/Timestamp.h index 3fd5d9738..0f869e1bd 100644 --- a/Foundation/include/Poco/Timestamp.h +++ b/Foundation/include/Poco/Timestamp.h @@ -24,6 +24,7 @@ namespace Poco { + class Timespan; @@ -31,7 +32,7 @@ class Foundation_API Timestamp /// A Timestamp stores a monotonic* time value /// with (theoretical) microseconds resolution. /// Timestamps can be compared with each other - /// and simple arithmetics are supported. + /// and simple arithmetic is supported. /// /// [*] Note that Timestamp values are only monotonic as /// long as the systems's clock is monotonic as well @@ -46,15 +47,15 @@ class Foundation_API Timestamp /// midnight, January 1, 1970. { public: - typedef Int64 TimeVal; + using TimeVal = Int64; /// Monotonic UTC time value in microsecond resolution, /// with base time midnight, January 1, 1970. - typedef Int64 UtcTimeVal; + using UtcTimeVal = Int64; /// Monotonic UTC time value in 100 nanosecond resolution, /// with base time midnight, October 15, 1582. - typedef Int64 TimeDiff; + using TimeDiff = Int64; /// Difference between two TimeVal values in microseconds. static const TimeVal TIMEVAL_MIN; /// Minimum timestamp value. diff --git a/Foundation/include/Poco/TypeList.h b/Foundation/include/Poco/TypeList.h index 352696f8e..4a53737af 100644 --- a/Foundation/include/Poco/TypeList.h +++ b/Foundation/include/Poco/TypeList.h @@ -222,7 +222,7 @@ struct TypeGetter; template -struct TypeGetter > +struct TypeGetter> { typedef typename TypeGetter::HeadType HeadType; typedef typename TypeWrapper::CONSTTYPE ConstHeadType; @@ -230,7 +230,7 @@ struct TypeGetter > template -struct TypeGetter<0, TypeList > +struct TypeGetter<0, TypeList> { typedef typename TypeList::HeadType HeadType; typedef typename TypeWrapper::CONSTTYPE ConstHeadType; @@ -305,7 +305,7 @@ struct TypeAppender template -struct TypeAppender > +struct TypeAppender> { typedef TypeList HeadType; }; @@ -320,7 +320,7 @@ struct TypeAppender, T> template struct TypeOneEraser; - /// TypeOneEraser erases the first occurence of the type T in Head. + /// TypeOneEraser erases the first occurrence of the type T in Head. /// Usage: /// /// typedef TypeListType::HeadType Type3; @@ -352,7 +352,7 @@ struct TypeOneEraser, T> template struct TypeAllEraser; - /// TypeAllEraser erases all the occurences of the type T in Head. + /// TypeAllEraser erases all the occurrences of the type T in Head. /// Usage: /// /// typedef TypeListType::HeadType Type4; @@ -384,7 +384,7 @@ struct TypeAllEraser, T> template struct TypeDuplicateEraser; - /// TypeDuplicateEraser erases all but the first occurence of the type T in Head. + /// TypeDuplicateEraser erases all but the first occurrence of the type T in Head. /// Usage: /// /// typedef TypeListType::HeadType Type4; @@ -401,7 +401,7 @@ struct TypeDuplicateEraser template -struct TypeDuplicateEraser > +struct TypeDuplicateEraser> { private: typedef typename TypeDuplicateEraser::HeadType L1; @@ -413,7 +413,7 @@ public: template struct TypeOneReplacer; - /// TypeOneReplacer replaces the first occurence + /// TypeOneReplacer replaces the first occurrence /// of the type T in Head with type R. /// Usage: /// @@ -446,7 +446,7 @@ struct TypeOneReplacer, T, R> template struct TypeAllReplacer; - /// TypeAllReplacer replaces all the occurences + /// TypeAllReplacer replaces all the occurrences /// of the type T in Head with type R. /// Usage: /// diff --git a/Foundation/include/Poco/Types.h b/Foundation/include/Poco/Types.h index f3d2ebc00..ed7be1473 100644 --- a/Foundation/include/Poco/Types.h +++ b/Foundation/include/Poco/Types.h @@ -19,178 +19,62 @@ #include "Poco/Foundation.h" +#include namespace Poco { +using Int8 = std::int8_t; +using UInt8 = std::uint8_t; +using Int16 = std::int16_t; +using UInt16 = std::uint16_t; +using Int32 = std::int32_t; +using UInt32 = std::uint32_t; +using Int64 = std::int64_t; +using UInt64 = std::uint64_t; +using IntPtr = std::intptr_t; +using UIntPtr = std::uintptr_t; + + #if defined(_MSC_VER) - // - // Windows/Visual C++ - // - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; - typedef signed __int64 Int64; - typedef unsigned __int64 UInt64; #if defined(_WIN64) #define POCO_PTR_IS_64_BIT 1 - typedef signed __int64 IntPtr; - typedef unsigned __int64 UIntPtr; - #else - typedef signed long IntPtr; - typedef unsigned long UIntPtr; #endif #define POCO_HAVE_INT64 1 #elif defined(__GNUC__) || defined(__clang__) - // - // Unix/GCC/Clang - // - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; #if defined(_WIN64) #define POCO_PTR_IS_64_BIT 1 - typedef signed long long IntPtr; - typedef unsigned long long UIntPtr; - typedef signed long long Int64; - typedef unsigned long long UInt64; #else - typedef signed long IntPtr; - typedef unsigned long UIntPtr; #if defined(__LP64__) #define POCO_PTR_IS_64_BIT 1 #define POCO_LONG_IS_64_BIT 1 - typedef signed long Int64; - typedef unsigned long UInt64; - #else - typedef signed long long Int64; - typedef unsigned long long UInt64; #endif #endif #define POCO_HAVE_INT64 1 #elif defined(__DECCXX) - // - // Compaq C++ - // - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; - typedef signed __int64 Int64; - typedef unsigned __int64 UInt64; - typedef signed long IntPtr; - typedef unsigned long UIntPtr; #define POCO_PTR_IS_64_BIT 1 #define POCO_LONG_IS_64_BIT 1 #define POCO_HAVE_INT64 1 #elif defined(__HP_aCC) - // - // HP Ansi C++ - // - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; - typedef signed long IntPtr; - typedef unsigned long UIntPtr; #if defined(__LP64__) #define POCO_PTR_IS_64_BIT 1 #define POCO_LONG_IS_64_BIT 1 - typedef signed long Int64; - typedef unsigned long UInt64; - #else - typedef signed long long Int64; - typedef unsigned long long UInt64; #endif #define POCO_HAVE_INT64 1 #elif defined(__SUNPRO_CC) - // - // SUN Forte C++ - // - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; - typedef signed long IntPtr; - typedef unsigned long UIntPtr; #if defined(__sparcv9) #define POCO_PTR_IS_64_BIT 1 #define POCO_LONG_IS_64_BIT 1 - typedef signed long Int64; - typedef unsigned long UInt64; - #else - typedef signed long long Int64; - typedef unsigned long long UInt64; #endif #define POCO_HAVE_INT64 1 #elif defined(__IBMCPP__) - // - // IBM XL C++ - // - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; - typedef signed long IntPtr; - typedef unsigned long UIntPtr; #if defined(__64BIT__) #define POCO_PTR_IS_64_BIT 1 #define POCO_LONG_IS_64_BIT 1 - typedef signed long Int64; - typedef unsigned long UInt64; - #else - typedef signed long long Int64; - typedef unsigned long long UInt64; - #endif - #define POCO_HAVE_INT64 1 -#elif defined(__sgi) - // - // MIPSpro C++ - // - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; - typedef signed long IntPtr; - typedef unsigned long UIntPtr; - #if _MIPS_SZLONG == 64 - #define POCO_PTR_IS_64_BIT 1 - #define POCO_LONG_IS_64_BIT 1 - typedef signed long Int64; - typedef unsigned long UInt64; - #else - typedef signed long long Int64; - typedef unsigned long long UInt64; #endif #define POCO_HAVE_INT64 1 #elif defined(_DIAB_TOOL) - typedef signed char Int8; - typedef unsigned char UInt8; - typedef signed short Int16; - typedef unsigned short UInt16; - typedef signed int Int32; - typedef unsigned int UInt32; - typedef signed long IntPtr; - typedef unsigned long UIntPtr; - typedef signed long long Int64; - typedef unsigned long long UInt64; #define POCO_HAVE_INT64 1 #endif diff --git a/Foundation/include/Poco/URI.h b/Foundation/include/Poco/URI.h index b6d41de93..054d83539 100644 --- a/Foundation/include/Poco/URI.h +++ b/Foundation/include/Poco/URI.h @@ -51,7 +51,7 @@ class Foundation_API URI /// setQuery(), setRawQuery(), getQuery() and getRawQuery() for more information. { public: - typedef std::vector > QueryParameters; + using QueryParameters = std::vector>; URI(); /// Creates an empty URI. @@ -78,6 +78,9 @@ public: URI(const URI& uri); /// Copy constructor. Creates an URI from another one. + + URI(URI&& uri) noexcept; + /// Move constructor. URI(const URI& baseURI, const std::string& relativeURI); /// Creates an URI from a base URI and a relative URI, according to @@ -94,7 +97,10 @@ public: URI& operator = (const URI& uri); /// Assignment operator. - + + URI& operator = (URI&& uri) noexcept; + /// Move assignment. + URI& operator = (const std::string& uri); /// Parses and assigns an URI from the given string. Throws a /// SyntaxException if the uri is not valid. diff --git a/Foundation/include/Poco/UnWindows.h b/Foundation/include/Poco/UnWindows.h index 1949235e8..0c472ee10 100644 --- a/Foundation/include/Poco/UnWindows.h +++ b/Foundation/include/Poco/UnWindows.h @@ -13,8 +13,7 @@ // an Unicode variant (e.g., GetUserNameA) and an ASCII variant (GetUserNameW). // There is also a macro (GetUserName) that's either defined to be the Unicode // name or the ASCII name, depending on whether the UNICODE macro is #define'd -// or not. POCO always calls the Unicode or ASCII functions directly (depending -// on whether POCO_WIN32_UTF8 is #define'd or not), so the macros are not ignored. +// or not. POCO always calls the Unicode functions directly. // // These macro definitions are a frequent case of problems and naming conflicts, // especially for C++ programmers. Say, you define a class with a member function named diff --git a/Foundation/include/Poco/UnbufferedStreamBuf.h b/Foundation/include/Poco/UnbufferedStreamBuf.h index ed56cb83e..32bb38ab4 100644 --- a/Foundation/include/Poco/UnbufferedStreamBuf.h +++ b/Foundation/include/Poco/UnbufferedStreamBuf.h @@ -168,9 +168,9 @@ private: // instantiations in different libraries. // #if defined(_MSC_VER) && defined(POCO_DLL) && !defined(Foundation_EXPORTS) -template class Foundation_API BasicUnbufferedStreamBuf >; +template class Foundation_API BasicUnbufferedStreamBuf>; #endif -typedef BasicUnbufferedStreamBuf > UnbufferedStreamBuf; +typedef BasicUnbufferedStreamBuf> UnbufferedStreamBuf; } // namespace Poco diff --git a/Foundation/include/Poco/UniqueAccessExpireLRUCache.h b/Foundation/include/Poco/UniqueAccessExpireLRUCache.h index 6e7a36667..ce54a9905 100644 --- a/Foundation/include/Poco/UniqueAccessExpireLRUCache.h +++ b/Foundation/include/Poco/UniqueAccessExpireLRUCache.h @@ -35,7 +35,7 @@ template < > class UniqueAccessExpireLRUCache: public AbstractCache, TMutex, TEventMutex> /// A UniqueAccessExpireLRUCache combines LRU caching and time based per entry expire caching. - /// One can define for each cache entry a seperate timepoint + /// One can define for each cache entry a separate timepoint /// but also limit the size of the cache (per default: 1024). /// Each TValue object must thus offer the following method: /// @@ -48,7 +48,7 @@ class UniqueAccessExpireLRUCache: public AbstractCache, TMutex, TEventMutex>(StrategyCollection()) { this->_strategy.pushBack(new LRUStrategy(cacheSize)); diff --git a/Foundation/include/Poco/UniqueExpireLRUCache.h b/Foundation/include/Poco/UniqueExpireLRUCache.h index c59bf0f7a..e11935cf9 100644 --- a/Foundation/include/Poco/UniqueExpireLRUCache.h +++ b/Foundation/include/Poco/UniqueExpireLRUCache.h @@ -35,7 +35,7 @@ template < > class UniqueExpireLRUCache: public AbstractCache, TMutex, TEventMutex> /// A UniqueExpireLRUCache combines LRU caching and time based per entry expire caching. - /// One can define for each cache entry a seperate timepoint + /// One can define for each cache entry a separate timepoint /// but also limit the size of the cache (per default: 1024). /// Each TValue object must thus offer the following method: /// @@ -47,7 +47,7 @@ class UniqueExpireLRUCache: public AbstractCache, TMutex, TEventMutex>(StrategyCollection()) { this->_strategy.pushBack(new LRUStrategy(cacheSize)); diff --git a/Foundation/include/Poco/WindowsConsoleChannel.h b/Foundation/include/Poco/WindowsConsoleChannel.h index b395c26d0..4c7aef662 100644 --- a/Foundation/include/Poco/WindowsConsoleChannel.h +++ b/Foundation/include/Poco/WindowsConsoleChannel.h @@ -33,8 +33,7 @@ class Foundation_API WindowsConsoleChannel: public Channel /// Only the message's text is written, followed /// by a newline. /// - /// If POCO has been compiled with POCO_WIN32_UTF8, - /// log messages are assumed to be UTF-8 encoded, and + /// Log messages are assumed to be UTF-8 encoded, and /// are converted to UTF-16 prior to writing them to the /// console. This is the main difference to the ConsoleChannel /// class, which cannot handle UTF-8 encoded messages on Windows. @@ -46,6 +45,8 @@ class Foundation_API WindowsConsoleChannel: public Channel /// Only available on Windows platforms. { public: + using Ptr = AutoPtr; + WindowsConsoleChannel(); /// Creates the WindowsConsoleChannel. @@ -67,8 +68,7 @@ class Foundation_API WindowsColorConsoleChannel: public Channel /// Only the message's text is written, followed /// by a newline. /// - /// If POCO has been compiled with POCO_WIN32_UTF8, - /// log messages are assumed to be UTF-8 encoded, and + /// Log messages are assumed to be UTF-8 encoded, and /// are converted to UTF-16 prior to writing them to the /// console. This is the main difference to the ConsoleChannel /// class, which cannot handle UTF-8 encoded messages on Windows. @@ -116,6 +116,8 @@ class Foundation_API WindowsColorConsoleChannel: public Channel /// Only available on Windows platforms. { public: + using Ptr = AutoPtr; + WindowsColorConsoleChannel(); /// Creates the WindowsConsoleChannel. diff --git a/Foundation/src/ASCIIEncoding.cpp b/Foundation/src/ASCIIEncoding.cpp index cccd39062..66a1b3da9 100644 --- a/Foundation/src/ASCIIEncoding.cpp +++ b/Foundation/src/ASCIIEncoding.cpp @@ -21,6 +21,7 @@ namespace Poco { const char* ASCIIEncoding::_names[] = { + "US-ASCII", "ASCII", NULL }; @@ -107,7 +108,7 @@ int ASCIIEncoding::queryConvert(const unsigned char* bytes, int length) const } -int ASCIIEncoding::sequenceLength(const unsigned char* bytes, int length) const +int ASCIIEncoding::sequenceLength(const unsigned char* /*bytes*/, int /*length*/) const { return 1; } diff --git a/Foundation/src/AbstractObserver.cpp b/Foundation/src/AbstractObserver.cpp index f4baacbb7..a0fd89657 100644 --- a/Foundation/src/AbstractObserver.cpp +++ b/Foundation/src/AbstractObserver.cpp @@ -23,7 +23,7 @@ AbstractObserver::AbstractObserver() } -AbstractObserver::AbstractObserver(const AbstractObserver& observer) +AbstractObserver::AbstractObserver(const AbstractObserver& /*observer*/) { } @@ -33,7 +33,7 @@ AbstractObserver::~AbstractObserver() } -AbstractObserver& AbstractObserver::operator = (const AbstractObserver& observer) +AbstractObserver& AbstractObserver::operator = (const AbstractObserver& /*observer*/) { return *this; } diff --git a/Foundation/src/ArchiveStrategy.cpp b/Foundation/src/ArchiveStrategy.cpp index dc3ef8c51..08cacacbb 100644 --- a/Foundation/src/ArchiveStrategy.cpp +++ b/Foundation/src/ArchiveStrategy.cpp @@ -45,7 +45,7 @@ public: { } - ActiveMethod > compress; + ActiveMethod> compress; protected: void compressImpl(const std::string& path) diff --git a/Foundation/src/AsyncChannel.cpp b/Foundation/src/AsyncChannel.cpp index adfadf4d0..b9be051bc 100644 --- a/Foundation/src/AsyncChannel.cpp +++ b/Foundation/src/AsyncChannel.cpp @@ -46,11 +46,10 @@ private: }; -AsyncChannel::AsyncChannel(Channel* pChannel, Thread::Priority prio): +AsyncChannel::AsyncChannel(Channel::Ptr pChannel, Thread::Priority prio): _pChannel(pChannel), _thread("AsyncChannel") { - if (_pChannel) _pChannel->duplicate(); _thread.setPriority(prio); } @@ -60,7 +59,6 @@ AsyncChannel::~AsyncChannel() try { close(); - if (_pChannel) _pChannel->release(); } catch (...) { @@ -69,17 +67,15 @@ AsyncChannel::~AsyncChannel() } -void AsyncChannel::setChannel(Channel* pChannel) +void AsyncChannel::setChannel(Channel::Ptr pChannel) { FastMutex::ScopedLock lock(_channelMutex); - if (_pChannel) _pChannel->release(); _pChannel = pChannel; - if (_pChannel) _pChannel->duplicate(); } -Channel* AsyncChannel::getChannel() const +Channel::Ptr AsyncChannel::getChannel() const { return _pChannel; } @@ -89,8 +85,7 @@ void AsyncChannel::open() { FastMutex::ScopedLock lock(_threadMutex); - if (!_thread.isRunning()) - _thread.start(*this); + if (!_thread.isRunning()) _thread.start(*this); } diff --git a/Foundation/src/AtomicCounter.cpp b/Foundation/src/AtomicCounter.cpp index ef94e02d1..b1172976a 100644 --- a/Foundation/src/AtomicCounter.cpp +++ b/Foundation/src/AtomicCounter.cpp @@ -18,10 +18,6 @@ namespace Poco { -#if defined(POCO_HAVE_STD_ATOMICS) -// -// C++11 atomics -// AtomicCounter::AtomicCounter(): _counter(0) { @@ -59,173 +55,4 @@ AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value) } -#elif POCO_OS == POCO_OS_WINDOWS_NT -// -// Windows -// -AtomicCounter::AtomicCounter(): - _counter(0) -{ -} - - -AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue): - _counter(initialValue) -{ -} - - -AtomicCounter::AtomicCounter(const AtomicCounter& counter): - _counter(counter.value()) -{ -} - - -AtomicCounter::~AtomicCounter() -{ -} - - -AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter) -{ - InterlockedExchange(&_counter, counter.value()); - return *this; -} - - -AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value) -{ - InterlockedExchange(&_counter, value); - return *this; -} - - -#elif POCO_OS == POCO_OS_MAC_OS_X -// -// Mac OS X -// -AtomicCounter::AtomicCounter(): - _counter(0) -{ -} - - -AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue): - _counter(initialValue) -{ -} - - -AtomicCounter::AtomicCounter(const AtomicCounter& counter): - _counter(counter.value()) -{ -} - - -AtomicCounter::~AtomicCounter() -{ -} - - -AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter) -{ - _counter = counter.value(); - return *this; -} - - -AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value) -{ - _counter = value; - return *this; -} - - -#elif defined(POCO_HAVE_GCC_ATOMICS) -// -// GCC 4.1+ atomic builtins. -// -AtomicCounter::AtomicCounter(): - _counter(0) -{ -} - - -AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue): - _counter(initialValue) -{ -} - - -AtomicCounter::AtomicCounter(const AtomicCounter& counter): - _counter(counter.value()) -{ -} - - -AtomicCounter::~AtomicCounter() -{ -} - - -AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter) -{ - __sync_lock_test_and_set(&_counter, counter.value()); - return *this; -} - - -AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value) -{ - __sync_lock_test_and_set(&_counter, value); - return *this; -} - - -#else -// -// Generic implementation based on FastMutex -// -AtomicCounter::AtomicCounter() -{ - _counter.value = 0; -} - - -AtomicCounter::AtomicCounter(AtomicCounter::ValueType initialValue) -{ - _counter.value = initialValue; -} - - -AtomicCounter::AtomicCounter(const AtomicCounter& counter) -{ - _counter.value = counter.value(); -} - - -AtomicCounter::~AtomicCounter() -{ -} - - -AtomicCounter& AtomicCounter::operator = (const AtomicCounter& counter) -{ - FastMutex::ScopedLock lock(_counter.mutex); - _counter.value = counter.value(); - return *this; -} - - -AtomicCounter& AtomicCounter::operator = (AtomicCounter::ValueType value) -{ - FastMutex::ScopedLock lock(_counter.mutex); - _counter.value = value; - return *this; -} - - -#endif // POCO_OS - - } // namespace Poco diff --git a/Foundation/src/AtomicFlag.cpp b/Foundation/src/AtomicFlag.cpp index bcefc6057..a7b54eb13 100644 --- a/Foundation/src/AtomicFlag.cpp +++ b/Foundation/src/AtomicFlag.cpp @@ -1,9 +1,9 @@ // -// AtomicCounter.cpp +// AtomicFlag.cpp // // Library: Foundation // Package: Core -// Module: AtomicCounter +// Module: AtomicFlag // // Copyright (c) 2009, Applied Informatics Software Engineering GmbH. // and Contributors. @@ -12,26 +12,5 @@ // -#if defined(POCO_HAVE_STD_ATOMICS) - - #include "Poco/AtomicCounter.h" - -namespace Poco { - - -AtomicFlag::AtomicFlag() -{ -} - - -AtomicFlag::~AtomicFlag() -{ -} - - -} // namespace Poco - - -#endif // POCO_HAVE_STD_ATOMICS diff --git a/Foundation/src/Base32Decoder.cpp b/Foundation/src/Base32Decoder.cpp index ba9f9db59..8e5cf0e04 100644 --- a/Foundation/src/Base32Decoder.cpp +++ b/Foundation/src/Base32Decoder.cpp @@ -46,7 +46,7 @@ Base32DecoderBuf::Base32DecoderBuf(std::istream& istr): } for (unsigned i = 0; i < sizeof(Base32EncoderBuf::OUT_ENCODING); i++) { - IN_ENCODING[Base32EncoderBuf::OUT_ENCODING[i]] = i; + IN_ENCODING[Base32EncoderBuf::OUT_ENCODING[i]] = static_cast(i); } IN_ENCODING[static_cast('=')] = '\0'; IN_ENCODING_INIT = true; diff --git a/Foundation/src/Base64Decoder.cpp b/Foundation/src/Base64Decoder.cpp index d433e51b8..6f826d6bf 100644 --- a/Foundation/src/Base64Decoder.cpp +++ b/Foundation/src/Base64Decoder.cpp @@ -51,7 +51,7 @@ Base64DecoderBuf::Base64DecoderBuf(std::istream& istr, int options): } for (unsigned i = 0; i < sizeof(Base64EncoderBuf::OUT_ENCODING_URL); i++) { - IN_ENCODING_URL[Base64EncoderBuf::OUT_ENCODING_URL[i]] = i; + IN_ENCODING_URL[Base64EncoderBuf::OUT_ENCODING_URL[i]] = static_cast(i); } IN_ENCODING_URL[static_cast('=')] = '\0'; IN_ENCODING_URL_INIT = true; @@ -67,7 +67,7 @@ Base64DecoderBuf::Base64DecoderBuf(std::istream& istr, int options): } for (unsigned i = 0; i < sizeof(Base64EncoderBuf::OUT_ENCODING); i++) { - IN_ENCODING[Base64EncoderBuf::OUT_ENCODING[i]] = i; + IN_ENCODING[Base64EncoderBuf::OUT_ENCODING[i]] = static_cast(i); } IN_ENCODING[static_cast('=')] = '\0'; IN_ENCODING_INIT = true; @@ -92,20 +92,20 @@ int Base64DecoderBuf::readFromDevice() unsigned char buffer[4]; int c; if ((c = readOne()) == -1) return -1; - buffer[0] = (unsigned char) c; + buffer[0] = static_cast(c); if (_pInEncoding[buffer[0]] == 0xFF) throw DataFormatException(); if ((c = readOne()) == -1) return -1; - buffer[1] = (unsigned char) c; + buffer[1] = static_cast(c); if (_pInEncoding[buffer[1]] == 0xFF) throw DataFormatException(); if (_options & BASE64_NO_PADDING) { if ((c = readOne()) != -1) - buffer[2] = c; + buffer[2] = static_cast(c); else buffer[2] = '='; if (_pInEncoding[buffer[2]] == 0xFF) throw DataFormatException(); if ((c = readOne()) != -1) - buffer[3] = c; + buffer[3] = static_cast(c); else buffer[3] = '='; if (_pInEncoding[buffer[3]] == 0xFF) throw DataFormatException(); @@ -113,10 +113,10 @@ int Base64DecoderBuf::readFromDevice() else { if ((c = readOne()) == -1) throw DataFormatException(); - buffer[2] = c; + buffer[2] = static_cast(c); if (_pInEncoding[buffer[2]] == 0xFF) throw DataFormatException(); if ((c = readOne()) == -1) throw DataFormatException(); - buffer[3] = c; + buffer[3] = static_cast(c); if (_pInEncoding[buffer[3]] == 0xFF) throw DataFormatException(); } diff --git a/Foundation/src/Channel.cpp b/Foundation/src/Channel.cpp index 02b163083..aa225b5eb 100644 --- a/Foundation/src/Channel.cpp +++ b/Foundation/src/Channel.cpp @@ -38,7 +38,7 @@ void Channel::close() } -void Channel::setProperty(const std::string& name, const std::string& value) +void Channel::setProperty(const std::string& name, const std::string& /*value*/) { throw PropertyNotSupportedException(name); } diff --git a/Foundation/src/Condition.cpp b/Foundation/src/Condition.cpp index 0acb9d1bb..0d237d69b 100644 --- a/Foundation/src/Condition.cpp +++ b/Foundation/src/Condition.cpp @@ -43,9 +43,9 @@ void Condition::broadcast() { FastMutex::ScopedLock lock(_mutex); - for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it) + for (auto p: _waitQueue) { - (*it)->set(); + p->set(); } _waitQueue.clear(); } diff --git a/Foundation/src/CountingStream.cpp b/Foundation/src/CountingStream.cpp index b6e8e9909..a2ecf907d 100644 --- a/Foundation/src/CountingStream.cpp +++ b/Foundation/src/CountingStream.cpp @@ -88,27 +88,27 @@ void CountingStreamBuf::reset() } -void CountingStreamBuf::setCurrentLineNumber(int line) +void CountingStreamBuf::setCurrentLineNumber(std::streamsize line) { _lines = line; } -void CountingStreamBuf::addChars(int chars) +void CountingStreamBuf::addChars(std::streamsize charsToAdd) { - _chars += chars; + _chars += charsToAdd; } -void CountingStreamBuf::addLines(int lines) +void CountingStreamBuf::addLines(std::streamsize linesToAdd) { - _lines += lines; + _lines += linesToAdd; } -void CountingStreamBuf::addPos(int pos) +void CountingStreamBuf::addPos(std::streamsize posToAdd) { - _pos += pos; + _pos += posToAdd; } @@ -141,27 +141,27 @@ void CountingIOS::reset() } -void CountingIOS::setCurrentLineNumber(int line) +void CountingIOS::setCurrentLineNumber(std::streamsize line) { _buf.setCurrentLineNumber(line); } -void CountingIOS::addChars(int chars) +void CountingIOS::addChars(std::streamsize charsToAdd) { - _buf.addChars(chars); + _buf.addChars(charsToAdd); } -void CountingIOS::addLines(int lines) +void CountingIOS::addLines(std::streamsize linesToAdd) { - _buf.addLines(lines); + _buf.addLines(linesToAdd); } -void CountingIOS::addPos(int pos) +void CountingIOS::addPos(std::streamsize posToAdd) { - _buf.addPos(pos); + _buf.addPos(posToAdd); } diff --git a/Foundation/src/DateTime.cpp b/Foundation/src/DateTime.cpp index dda9169d5..185aa0844 100644 --- a/Foundation/src/DateTime.cpp +++ b/Foundation/src/DateTime.cpp @@ -22,19 +22,6 @@ namespace Poco { -inline double DateTime::toJulianDay(Timestamp::UtcTimeVal utcTime) -{ - double utcDays = double(utcTime)/864000000000.0; - return utcDays + 2299160.5; // first day of Gregorian reform (Oct 15 1582) -} - - -inline Timestamp::UtcTimeVal DateTime::toUtcTime(double julianDay) -{ - return Timestamp::UtcTimeVal((julianDay - 2299160.5)*864000000000.0); -} - - DateTime::DateTime() { Timestamp now; diff --git a/Foundation/src/Debugger.cpp b/Foundation/src/Debugger.cpp index c9efe5eac..f50a7f75b 100644 --- a/Foundation/src/Debugger.cpp +++ b/Foundation/src/Debugger.cpp @@ -22,9 +22,7 @@ #include #include #endif -#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING) #include "Poco/UnicodeConverter.h" -#endif // NOTE: In this module, we use the C library functions (fputs) for, @@ -73,15 +71,10 @@ void Debugger::message(const std::string& msg) #if defined(POCO_OS_FAMILY_WINDOWS) if (isAvailable()) { - #if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING) std::wstring umsg; UnicodeConverter::toUTF16(msg, umsg); umsg += '\n'; OutputDebugStringW(umsg.c_str()); - #else - OutputDebugStringA(msg.c_str()); - OutputDebugStringA("\n"); - #endif } #endif #endif diff --git a/Foundation/src/DigestEngine.cpp b/Foundation/src/DigestEngine.cpp index 2c01eb6b8..bbdc34142 100644 --- a/Foundation/src/DigestEngine.cpp +++ b/Foundation/src/DigestEngine.cpp @@ -34,11 +34,10 @@ std::string DigestEngine::digestToHex(const Digest& bytes) static const char digits[] = "0123456789abcdef"; std::string result; result.reserve(bytes.size() * 2); - for (Digest::const_iterator it = bytes.begin(); it != bytes.end(); ++it) + for (auto b: bytes) { - unsigned char c = *it; - result += digits[(c >> 4) & 0xF]; - result += digits[c & 0xF]; + result += digits[(b >> 4) & 0xF]; + result += digits[b & 0xF]; } return result; } diff --git a/Foundation/src/DirectoryIterator.cpp b/Foundation/src/DirectoryIterator.cpp index 28d29e0d2..bc5f53452 100644 --- a/Foundation/src/DirectoryIterator.cpp +++ b/Foundation/src/DirectoryIterator.cpp @@ -15,10 +15,8 @@ #include "Poco/DirectoryIterator.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #include "DirectoryIterator_WIN32U.cpp" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "DirectoryIterator_WIN32.cpp" #elif defined(POCO_OS_FAMILY_UNIX) #include "DirectoryIterator_UNIX.cpp" #endif diff --git a/Foundation/src/DirectoryWatcher.cpp b/Foundation/src/DirectoryWatcher.cpp index 8c8dc4674..4d9d3613d 100644 --- a/Foundation/src/DirectoryWatcher.cpp +++ b/Foundation/src/DirectoryWatcher.cpp @@ -107,16 +107,16 @@ protected: void compare(ItemInfoMap& oldEntries, ItemInfoMap& newEntries) { - for (ItemInfoMap::iterator itn = newEntries.begin(); itn != newEntries.end(); ++itn) + for (auto& np: newEntries) { - ItemInfoMap::iterator ito = oldEntries.find(itn->first); + ItemInfoMap::iterator ito = oldEntries.find(np.first); if (ito != oldEntries.end()) { if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_MODIFIED) && !owner().eventsSuspended()) { - if (itn->second.size != ito->second.size || itn->second.lastModified != ito->second.lastModified) + if (np.second.size != ito->second.size || np.second.lastModified != ito->second.lastModified) { - Poco::File f(itn->second.path); + Poco::File f(np.second.path); DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_MODIFIED); owner().itemModified(&owner(), ev); } @@ -125,16 +125,16 @@ protected: } else if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_ADDED) && !owner().eventsSuspended()) { - Poco::File f(itn->second.path); + Poco::File f(np.second.path); DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_ADDED); owner().itemAdded(&owner(), ev); } } if ((owner().eventMask() & DirectoryWatcher::DW_ITEM_REMOVED) && !owner().eventsSuspended()) { - for (ItemInfoMap::iterator it = oldEntries.begin(); it != oldEntries.end(); ++it) + for (const auto& i: oldEntries) { - Poco::File f(it->second.path); + Poco::File f(i.second.path); DirectoryWatcher::DirectoryEvent ev(f, DirectoryWatcher::DW_ITEM_REMOVED); owner().itemRemoved(&owner(), ev); } @@ -179,13 +179,9 @@ public: filter |= FILE_NOTIFY_CHANGE_SIZE | FILE_NOTIFY_CHANGE_LAST_WRITE; std::string path(owner().directory().path()); -#if defined(POCO_WIN32_UTF8) std::wstring upath; FileImpl::convertPath(path.c_str(), upath); HANDLE hChange = FindFirstChangeNotificationW(upath.c_str(), FALSE, filter); -#else - HANDLE hChange = FindFirstChangeNotificationA(path.c_str(), FALSE, filter); -#endif if (hChange == INVALID_HANDLE_VALUE) { diff --git a/Foundation/src/Error.cpp b/Foundation/src/Error.cpp index fbd3673f6..721b96ff3 100644 --- a/Foundation/src/Error.cpp +++ b/Foundation/src/Error.cpp @@ -36,15 +36,9 @@ namespace Poco { { std::string errMsg; DWORD dwFlg = FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS; - #if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING) LPWSTR lpMsgBuf = 0; if (FormatMessageW(dwFlg, 0, errorCode, 0, (LPWSTR) & lpMsgBuf, 0, NULL)) UnicodeConverter::toUTF8(lpMsgBuf, errMsg); - #else - LPTSTR lpMsgBuf = 0; - if (FormatMessageA(dwFlg, 0, errorCode, 0, (LPTSTR) & lpMsgBuf, 0, NULL)) - errMsg = lpMsgBuf; - #endif LocalFree(lpMsgBuf); return errMsg; } diff --git a/Foundation/src/Event.cpp b/Foundation/src/Event.cpp index c8e8fa0b9..2d8f327e1 100644 --- a/Foundation/src/Event.cpp +++ b/Foundation/src/Event.cpp @@ -27,6 +27,11 @@ namespace Poco { +Event::Event(EventType type): EventImpl(type == EVENT_AUTORESET) +{ +} + + Event::Event(bool autoReset): EventImpl(autoReset) { } diff --git a/Foundation/src/EventLogChannel.cpp b/Foundation/src/EventLogChannel.cpp index ed4e25a6d..1f51296bb 100644 --- a/Foundation/src/EventLogChannel.cpp +++ b/Foundation/src/EventLogChannel.cpp @@ -16,9 +16,7 @@ #include "Poco/Message.h" #include "Poco/String.h" #include "pocomsg.h" -#if defined(POCO_WIN32_UTF8) #include "Poco/UnicodeConverter.h" -#endif namespace Poco { @@ -35,7 +33,6 @@ EventLogChannel::EventLogChannel(): _h(0) { const DWORD maxPathLen = MAX_PATH + 1; -#if defined(POCO_WIN32_UTF8) wchar_t name[maxPathLen]; int n = GetModuleFileNameW(NULL, name, maxPathLen); if (n > 0) @@ -46,17 +43,6 @@ EventLogChannel::EventLogChannel(): std::wstring uname(end); UnicodeConverter::toUTF8(uname, _name); } -#else - char name[maxPathLen]; - int n = GetModuleFileNameA(NULL, name, maxPathLen); - if (n > 0) - { - char* end = name + n - 1; - while (end > name && *end != '\\') --end; - if (*end == '\\') ++end; - _name = end; - } -#endif } @@ -93,15 +79,11 @@ EventLogChannel::~EventLogChannel() void EventLogChannel::open() { setUpRegistry(); -#if defined(POCO_WIN32_UTF8) std::wstring uhost; UnicodeConverter::toUTF16(_host, uhost); std::wstring uname; UnicodeConverter::toUTF16(_name, uname); _h = RegisterEventSourceW(uhost.empty() ? NULL : uhost.c_str(), uname.c_str()); -#else - _h = RegisterEventSource(_host.empty() ? NULL : _host.c_str(), _name.c_str()); -#endif if (!_h) throw SystemException("cannot register event source"); } @@ -116,15 +98,10 @@ void EventLogChannel::close() void EventLogChannel::log(const Message& msg) { if (!_h) open(); -#if defined(POCO_WIN32_UTF8) std::wstring utext; UnicodeConverter::toUTF16(msg.getText(), utext); const wchar_t* pMsg = utext.c_str(); ReportEventW(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL); -#else - const char* pMsg = msg.getText().c_str(); - ReportEvent(_h, getType(msg), getCategory(msg), POCO_MSG_LOG, NULL, 1, 0, &pMsg, NULL); -#endif } @@ -209,18 +186,13 @@ void EventLogChannel::setUpRegistry() const key.append(_name); HKEY hKey; DWORD disp; -#if defined(POCO_WIN32_UTF8) std::wstring ukey; UnicodeConverter::toUTF16(key, ukey); DWORD rc = RegCreateKeyExW(HKEY_LOCAL_MACHINE, ukey.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp); -#else - DWORD rc = RegCreateKeyEx(HKEY_LOCAL_MACHINE, key.c_str(), 0, NULL, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL, &hKey, &disp); -#endif if (rc != ERROR_SUCCESS) return; if (disp == REG_CREATED_NEW_KEY) { -#if defined(POCO_WIN32_UTF8) std::wstring path; #if defined(POCO_DLL) #if defined(_DEBUG) @@ -240,50 +212,21 @@ void EventLogChannel::setUpRegistry() const if (path.empty()) path = findLibrary(L"PocoMsg.dll"); -#else - std::string path; - #if defined(POCO_DLL) - #if defined(_DEBUG) - #if defined(_WIN64) - path = findLibrary("PocoFoundation64d.dll"); - #else - path = findLibrary("PocoFoundationd.dll"); - #endif - #else - #if defined(_WIN64) - path = findLibrary("PocoFoundation64.dll"); - #else - path = findLibrary("PocoFoundation.dll"); - #endif - #endif - #endif - - if (path.empty()) - path = findLibrary("PocoMsg.dll"); -#endif if (!path.empty()) { DWORD count = 8; DWORD types = 7; -#if defined(POCO_WIN32_UTF8) RegSetValueExW(hKey, L"CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast(sizeof(wchar_t)*(path.size() + 1))); RegSetValueExW(hKey, L"EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast(sizeof(wchar_t)*(path.size() + 1))); RegSetValueExW(hKey, L"CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast(sizeof(count))); RegSetValueExW(hKey, L"TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast(sizeof(types))); -#else - RegSetValueEx(hKey, "CategoryMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast(path.size() + 1)); - RegSetValueEx(hKey, "EventMessageFile", 0, REG_SZ, (const BYTE*) path.c_str(), static_cast(path.size() + 1)); - RegSetValueEx(hKey, "CategoryCount", 0, REG_DWORD, (const BYTE*) &count, static_cast(sizeof(count))); - RegSetValueEx(hKey, "TypesSupported", 0, REG_DWORD, (const BYTE*) &types, static_cast(sizeof(types))); -#endif } } RegCloseKey(hKey); } -#if defined(POCO_WIN32_UTF8) std::wstring EventLogChannel::findLibrary(const wchar_t* name) { std::wstring path; @@ -298,22 +241,6 @@ std::wstring EventLogChannel::findLibrary(const wchar_t* name) } return path; } -#else -std::string EventLogChannel::findLibrary(const char* name) -{ - std::string path; - HMODULE dll = LoadLibraryA(name); - if (dll) - { - const DWORD maxPathLen = MAX_PATH + 1; - char name[maxPathLen]; - int n = GetModuleFileNameA(dll, name, maxPathLen); - if (n > 0) path = name; - FreeLibrary(dll); - } - return path; -} -#endif } // namespace Poco diff --git a/Foundation/src/Exception.cpp b/Foundation/src/Exception.cpp index 4a505d645..b8e5bacde 100644 --- a/Foundation/src/Exception.cpp +++ b/Foundation/src/Exception.cpp @@ -53,7 +53,7 @@ Exception::Exception(const Exception& exc): } -Exception::~Exception() throw() +Exception::~Exception() noexcept { delete _pNested; } @@ -73,19 +73,19 @@ Exception& Exception::operator = (const Exception& exc) } -const char* Exception::name() const throw() +const char* Exception::name() const noexcept { return "Exception"; } -const char* Exception::className() const throw() +const char* Exception::className() const noexcept { return typeid(*this).name(); } -const char* Exception::what() const throw() +const char* Exception::what() const noexcept { return name(); } diff --git a/Foundation/src/File.cpp b/Foundation/src/File.cpp index 07571c5a5..0765fd489 100644 --- a/Foundation/src/File.cpp +++ b/Foundation/src/File.cpp @@ -17,14 +17,12 @@ #include "Poco/DirectoryIterator.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(_WIN32_WCE) #include "File_WINCE.cpp" #else #include "File_WIN32U.cpp" #endif -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "File_WIN32.cpp" #elif defined(POCO_VXWORKS) #include "File_VX.cpp" #elif defined(POCO_OS_FAMILY_UNIX) @@ -268,9 +266,9 @@ void File::remove(bool recursive) { std::vector files; list(files); - for (std::vector::iterator it = files.begin(); it != files.end(); ++it) + for (auto& f: files) { - it->remove(true); + f.remove(true); } // Note: On Windows, removing a directory may not succeed at first diff --git a/Foundation/src/FileStream_WIN32.cpp b/Foundation/src/FileStream_WIN32.cpp index 28f53c9d4..fb934e2a4 100644 --- a/Foundation/src/FileStream_WIN32.cpp +++ b/Foundation/src/FileStream_WIN32.cpp @@ -15,9 +15,7 @@ #include "Poco/FileStream.h" #include "Poco/File.h" #include "Poco/Exception.h" -#if defined (POCO_WIN32_UTF8) #include "Poco/UnicodeConverter.h" -#endif namespace Poco { @@ -64,13 +62,9 @@ void FileStreamBuf::open(const std::string& path, std::ios::openmode mode) DWORD flags = FILE_ATTRIBUTE_NORMAL; -#if defined (POCO_WIN32_UTF8) std::wstring utf16Path; FileImpl::convertPath(path, utf16Path); _handle = CreateFileW(utf16Path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL); -#else - _handle = CreateFileA(path.c_str(), access, shareMode, NULL, creationDisp, flags, NULL); -#endif if (_handle == INVALID_HANDLE_VALUE) File::handleLastError(_path); diff --git a/Foundation/src/Format.cpp b/Foundation/src/Format.cpp index ed5db5c21..46d20f0b4 100644 --- a/Foundation/src/Format.cpp +++ b/Foundation/src/Format.cpp @@ -44,28 +44,44 @@ namespace } - void parseWidth(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt) + void parseWidth(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector::const_iterator& itVal) { int width = 0; + if (itFmt != endFmt && *itFmt == '*') + { + ++itFmt; + width = AnyCast(*itVal++); + } + else + { while (itFmt != endFmt && Ascii::isDigit(*itFmt)) { width = 10*width + *itFmt - '0'; ++itFmt; } - if (width != 0) str.width(width); + } + if (width > 0) str.width(width); } - void parsePrec(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt) + void parsePrec(std::ostream& str, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector::const_iterator& itVal) { if (itFmt != endFmt && *itFmt == '.') { ++itFmt; int prec = 0; - while (itFmt != endFmt && Ascii::isDigit(*itFmt)) + if (itFmt != endFmt && *itFmt == '*') { - prec = 10*prec + *itFmt - '0'; ++itFmt; + prec = AnyCast(*itVal++); + } + else + { + while (itFmt != endFmt && Ascii::isDigit(*itFmt)) + { + prec = 10*prec + *itFmt - '0'; + ++itFmt; + } } if (prec >= 0) str.precision(prec); } @@ -153,8 +169,8 @@ namespace try { parseFlags(str, itFmt, endFmt); - parseWidth(str, itFmt, endFmt); - parsePrec(str, itFmt, endFmt); + parseWidth(str, itFmt, endFmt, itVal); + parsePrec(str, itFmt, endFmt, itVal); char mod = parseMod(itFmt, endFmt); if (itFmt != endFmt) { @@ -225,7 +241,7 @@ namespace } -std::string format(const std::string& fmt, const Any& value) +std::string format(const std::string& fmt, const Any& value) { std::string result; format(result, fmt, value); @@ -233,200 +249,9 @@ std::string format(const std::string& fmt, const Any& value) } -std::string format(const std::string& fmt, const Any& value1, const Any& value2) +void format(std::string& result, const char *fmt, const std::vector& values) { - std::string result; - format(result, fmt, value1, value2); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - std::string result; - format(result, fmt, value1, value2, value3); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - std::string result; - format(result, fmt, value1, value2, value3, value4); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - std::string result; - format(result, fmt, value1, value2, value3, value4, value5); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - std::string result; - format(result, fmt, value1, value2, value3, value4, value5, value6); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - std::string result; - format(result, fmt, value1, value2, value3, value4, value5, value6, value7); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - std::string result; - format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - std::string result; - format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9); - return result; -} - - -std::string format(const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - std::string result; - format(result, fmt, value1, value2, value3, value4, value5, value6, value7, value8, value9, value10); - return result; -} - - -void format(std::string& result, const std::string& fmt, const Any& value) -{ - std::vector args; - args.push_back(value); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - args.push_back(value4); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - args.push_back(value4); - args.push_back(value5); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - args.push_back(value4); - args.push_back(value5); - args.push_back(value6); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - args.push_back(value4); - args.push_back(value5); - args.push_back(value6); - args.push_back(value7); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - args.push_back(value4); - args.push_back(value5); - args.push_back(value6); - args.push_back(value7); - args.push_back(value8); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - args.push_back(value4); - args.push_back(value5); - args.push_back(value6); - args.push_back(value7); - args.push_back(value8); - args.push_back(value9); - format(result, fmt, args); -} - - -void format(std::string& result, const std::string& fmt, const Any& value1, const Any& value2, const Any& value3, const Any& value4, const Any& value5, const Any& value6, const Any& value7, const Any& value8, const Any& value9, const Any& value10) -{ - std::vector args; - args.push_back(value1); - args.push_back(value2); - args.push_back(value3); - args.push_back(value4); - args.push_back(value5); - args.push_back(value6); - args.push_back(value7); - args.push_back(value8); - args.push_back(value9); - args.push_back(value10); - format(result, fmt, args); + format(result, std::string(fmt), values); } diff --git a/Foundation/src/Formatter.cpp b/Foundation/src/Formatter.cpp index 2a1ac5f45..e14e46e87 100644 --- a/Foundation/src/Formatter.cpp +++ b/Foundation/src/Formatter.cpp @@ -29,13 +29,13 @@ Formatter::~Formatter() } -void Formatter::setProperty(const std::string& name, const std::string& value) +void Formatter::setProperty(const std::string& /*name*/, const std::string& /*value*/) { throw PropertyNotSupportedException(); } -std::string Formatter::getProperty(const std::string& name) const +std::string Formatter::getProperty(const std::string& /*name*/) const { throw PropertyNotSupportedException(); } diff --git a/Foundation/src/FormattingChannel.cpp b/Foundation/src/FormattingChannel.cpp index be6c0ae18..bdaef07b9 100644 --- a/Foundation/src/FormattingChannel.cpp +++ b/Foundation/src/FormattingChannel.cpp @@ -13,7 +13,6 @@ #include "Poco/FormattingChannel.h" -#include "Poco/Formatter.h" #include "Poco/Message.h" #include "Poco/LoggingRegistry.h" @@ -28,53 +27,44 @@ FormattingChannel::FormattingChannel(): } -FormattingChannel::FormattingChannel(Formatter* pFormatter): +FormattingChannel::FormattingChannel(Formatter::Ptr pFormatter): _pFormatter(pFormatter), _pChannel(0) { - if (_pFormatter) _pFormatter->duplicate(); } -FormattingChannel::FormattingChannel(Formatter* pFormatter, Channel* pChannel): +FormattingChannel::FormattingChannel(Formatter::Ptr pFormatter, Channel::Ptr pChannel): _pFormatter(pFormatter), _pChannel(pChannel) { - if (_pFormatter) _pFormatter->duplicate(); - if (_pChannel) _pChannel->duplicate(); } FormattingChannel::~FormattingChannel() { - if (_pChannel) _pChannel->release(); - if (_pFormatter) _pFormatter->release(); } -void FormattingChannel::setFormatter(Formatter* pFormatter) +void FormattingChannel::setFormatter(Formatter::Ptr pFormatter) { - if (_pFormatter) _pFormatter->release(); _pFormatter = pFormatter; - if (_pFormatter) _pFormatter->duplicate(); } -Formatter* FormattingChannel::getFormatter() const +Formatter::Ptr FormattingChannel::getFormatter() const { return _pFormatter; } -void FormattingChannel::setChannel(Channel* pChannel) +void FormattingChannel::setChannel(Channel::Ptr pChannel) { - if (_pChannel) _pChannel->release(); _pChannel = pChannel; - if (_pChannel) _pChannel->duplicate(); } -Channel* FormattingChannel::getChannel() const +Channel::Ptr FormattingChannel::getChannel() const { return _pChannel; } diff --git a/Foundation/src/LogFile.cpp b/Foundation/src/LogFile.cpp index 2aaaf8c56..5380110fd 100644 --- a/Foundation/src/LogFile.cpp +++ b/Foundation/src/LogFile.cpp @@ -15,10 +15,8 @@ #include "Poco/LogFile.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #include "LogFile_WIN32U.cpp" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "LogFile_WIN32.cpp" #else #include "LogFile_STD.cpp" #endif diff --git a/Foundation/src/Logger.cpp b/Foundation/src/Logger.cpp index 7c3f51ac2..1b3446444 100644 --- a/Foundation/src/Logger.cpp +++ b/Foundation/src/Logger.cpp @@ -24,32 +24,28 @@ namespace Poco { -Logger::LoggerMap* Logger::_pLoggerMap = 0; -Mutex Logger::_mapMtx; -const std::string Logger::ROOT; +Logger::LoggerMapPtr Logger::_pLoggerMap; +Mutex Logger::_mapMtx; +const std::string Logger::ROOT; -Logger::Logger(const std::string& name, Channel* pChannel, int level): _name(name), _pChannel(pChannel), _level(level) +Logger::Logger(const std::string& name, Channel::Ptr pChannel, int level): _name(name), _pChannel(pChannel), _level(level) { - if (pChannel) pChannel->duplicate(); } Logger::~Logger() { - if (_pChannel) _pChannel->release(); } -void Logger::setChannel(Channel* pChannel) +void Logger::setChannel(Channel::Ptr pChannel) { - if (_pChannel) _pChannel->release(); _pChannel = pChannel; - if (_pChannel) _pChannel->duplicate(); } -Channel* Logger::getChannel() const +Channel::Ptr Logger::getChannel() const { return _pChannel; } @@ -117,31 +113,29 @@ void Logger::setLevel(const std::string& name, int level) if (_pLoggerMap) { std::string::size_type len = name.length(); - for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it) + for (auto& p: *_pLoggerMap) { - if (len == 0 || - (it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.'))) + if (len == 0 || (p.first.compare(0, len, name) == 0 && (p.first.length() == len || p.first[len] == '.'))) { - it->second->setLevel(level); + p.second->setLevel(level); } } } } -void Logger::setChannel(const std::string& name, Channel* pChannel) +void Logger::setChannel(const std::string& name, Channel::Ptr pChannel) { Mutex::ScopedLock lock(_mapMtx); if (_pLoggerMap) { std::string::size_type len = name.length(); - for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it) + for (auto& p: *_pLoggerMap) { - if (len == 0 || - (it->first.compare(0, len, name) == 0 && (it->first.length() == len || it->first[len] == '.'))) + if (len == 0 || (p.first.compare(0, len, name) == 0 && (p.first.length() == len || p.first[len] == '.'))) { - it->second->setChannel(pChannel); + p.second->setChannel(pChannel); } } } @@ -155,12 +149,11 @@ void Logger::setProperty(const std::string& loggerName, const std::string& prope if (_pLoggerMap) { std::string::size_type len = loggerName.length(); - for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it) + for (auto& p: *_pLoggerMap) { - if (len == 0 || - (it->first.compare(0, len, loggerName) == 0 && (it->first.length() == len || it->first[len] == '.'))) + if (len == 0 || (p.first.compare(0, len, loggerName) == 0 && (p.first.length() == len || p.first[len] == '.'))) { - it->second->setProperty(propertyName, value); + p.second->setProperty(propertyName, value); } } } @@ -290,7 +283,7 @@ Logger& Logger::get(const std::string& name) Logger& Logger::unsafeGet(const std::string& name) { - Logger* pLogger = find(name); + Ptr pLogger = find(name); if (!pLogger) { if (name == ROOT) @@ -308,12 +301,12 @@ Logger& Logger::unsafeGet(const std::string& name) } -Logger& Logger::create(const std::string& name, Channel* pChannel, int level) +Logger& Logger::create(const std::string& name, Channel::Ptr pChannel, int level) { Mutex::ScopedLock lock(_mapMtx); if (find(name)) throw ExistsException(); - Logger* pLogger = new Logger(name, pChannel, level); + Ptr pLogger = new Logger(name, pChannel, level); add(pLogger); return *pLogger; } @@ -327,7 +320,7 @@ Logger& Logger::root() } -Logger* Logger::has(const std::string& name) +Logger::Ptr Logger::has(const std::string& name) { Mutex::ScopedLock lock(_mapMtx); @@ -339,25 +332,16 @@ void Logger::shutdown() { Mutex::ScopedLock lock(_mapMtx); - if (_pLoggerMap) - { - for (LoggerMap::iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it) - { - it->second->release(); - } - delete _pLoggerMap; - _pLoggerMap = 0; - } + _pLoggerMap.reset(); } -Logger* Logger::find(const std::string& name) +Logger::Ptr Logger::find(const std::string& name) { if (_pLoggerMap) { LoggerMap::iterator it = _pLoggerMap->find(name); - if (it != _pLoggerMap->end()) - return it->second; + if (it != _pLoggerMap->end()) return it->second; } return 0; } @@ -370,11 +354,7 @@ void Logger::destroy(const std::string& name) if (_pLoggerMap) { LoggerMap::iterator it = _pLoggerMap->find(name); - if (it != _pLoggerMap->end()) - { - it->second->release(); - _pLoggerMap->erase(it); - } + if (it != _pLoggerMap->end()) _pLoggerMap->erase(it); } } @@ -386,9 +366,9 @@ void Logger::names(std::vector& names) names.clear(); if (_pLoggerMap) { - for (LoggerMap::const_iterator it = _pLoggerMap->begin(); it != _pLoggerMap->end(); ++it) + for (const auto& p: *_pLoggerMap) { - names.push_back(it->first); + names.push_back(p.first); } } } @@ -400,7 +380,7 @@ Logger& Logger::parent(const std::string& name) if (pos != std::string::npos) { std::string pname = name.substr(0, pos); - Logger* pParent = find(pname); + Ptr pParent = find(pname); if (pParent) return *pParent; else @@ -446,36 +426,9 @@ int Logger::parseLevel(const std::string& level) } -class AutoLoggerShutdown +void Logger::add(Ptr pLogger) { -public: - AutoLoggerShutdown() - { - } - ~AutoLoggerShutdown() - { - try - { - Logger::shutdown(); - } - catch (...) - { - poco_unexpected(); - } - } -}; - - -namespace -{ - static AutoLoggerShutdown als; -} - - -void Logger::add(Logger* pLogger) -{ - if (!_pLoggerMap) - _pLoggerMap = new LoggerMap; + if (!_pLoggerMap) _pLoggerMap.reset(new LoggerMap); _pLoggerMap->insert(LoggerMap::value_type(pLogger->name(), pLogger)); } diff --git a/Foundation/src/LoggingFactory.cpp b/Foundation/src/LoggingFactory.cpp index f3e067a61..267e4dd4d 100644 --- a/Foundation/src/LoggingFactory.cpp +++ b/Foundation/src/LoggingFactory.cpp @@ -17,6 +17,7 @@ #include "Poco/AsyncChannel.h" #include "Poco/ConsoleChannel.h" #include "Poco/FileChannel.h" +#include "Poco/SimpleFileChannel.h" #include "Poco/FormattingChannel.h" #include "Poco/SplitterChannel.h" #include "Poco/NullChannel.h" @@ -57,13 +58,13 @@ void LoggingFactory::registerFormatterClass(const std::string& className, Format } -Channel* LoggingFactory::createChannel(const std::string& className) const +Channel::Ptr LoggingFactory::createChannel(const std::string& className) const { return _channelFactory.createInstance(className); } -Formatter* LoggingFactory::createFormatter(const std::string& className) const +Formatter::Ptr LoggingFactory::createFormatter(const std::string& className) const { return _formatterFactory.createInstance(className); } @@ -91,8 +92,10 @@ void LoggingFactory::registerBuiltins() _channelFactory.registerClass("ConsoleChannel", new Instantiator); _channelFactory.registerClass("ColorConsoleChannel", new Instantiator); #endif + #ifndef POCO_NO_FILECHANNEL _channelFactory.registerClass("FileChannel", new Instantiator); + _channelFactory.registerClass("SimpleFileChannel", new Instantiator); #endif _channelFactory.registerClass("FormattingChannel", new Instantiator); #ifndef POCO_NO_SPLITTERCHANNEL @@ -106,6 +109,7 @@ void LoggingFactory::registerBuiltins() _channelFactory.registerClass("SyslogChannel", new Instantiator); #endif #endif + #if defined(POCO_OS_FAMILY_WINDOWS) && !defined(_WIN32_WCE) _channelFactory.registerClass("EventLogChannel", new Instantiator); #endif diff --git a/Foundation/src/LoggingRegistry.cpp b/Foundation/src/LoggingRegistry.cpp index 9d7edfef4..da8feda24 100644 --- a/Foundation/src/LoggingRegistry.cpp +++ b/Foundation/src/LoggingRegistry.cpp @@ -29,31 +29,31 @@ LoggingRegistry::~LoggingRegistry() } -Channel* LoggingRegistry::channelForName(const std::string& name) const +Channel::Ptr LoggingRegistry::channelForName(const std::string& name) const { FastMutex::ScopedLock lock(_mutex); ChannelMap::const_iterator it = _channelMap.find(name); if (it != _channelMap.end()) - return const_cast(it->second.get()); + return it->second; else throw NotFoundException("logging channel", name); } -Formatter* LoggingRegistry::formatterForName(const std::string& name) const +Formatter::Ptr LoggingRegistry::formatterForName(const std::string& name) const { FastMutex::ScopedLock lock(_mutex); FormatterMap::const_iterator it = _formatterMap.find(name); if (it != _formatterMap.end()) - return const_cast(it->second.get()); + return it->second; else throw NotFoundException("logging formatter", name); } -void LoggingRegistry::registerChannel(const std::string& name, Channel* pChannel) +void LoggingRegistry::registerChannel(const std::string& name, Channel::Ptr pChannel) { FastMutex::ScopedLock lock(_mutex); @@ -61,7 +61,7 @@ void LoggingRegistry::registerChannel(const std::string& name, Channel* pChannel } -void LoggingRegistry::registerFormatter(const std::string& name, Formatter* pFormatter) +void LoggingRegistry::registerFormatter(const std::string& name, Formatter::Ptr pFormatter) { FastMutex::ScopedLock lock(_mutex); diff --git a/Foundation/src/MemoryPool.cpp b/Foundation/src/MemoryPool.cpp index 01c477be5..5b6e79cfa 100644 --- a/Foundation/src/MemoryPool.cpp +++ b/Foundation/src/MemoryPool.cpp @@ -57,9 +57,9 @@ MemoryPool::~MemoryPool() void MemoryPool::clear() { - for (BlockVec::iterator it = _blocks.begin(); it != _blocks.end(); ++it) + for (auto p: _blocks) { - delete [] *it; + delete [] p; } _blocks.clear(); } diff --git a/Foundation/src/Message.cpp b/Foundation/src/Message.cpp index a93943571..7a26c9253 100644 --- a/Foundation/src/Message.cpp +++ b/Foundation/src/Message.cpp @@ -82,6 +82,22 @@ Message::Message(const Message& msg): } +Message::Message(Message&& msg) : + _source(std::move(msg._source)), + _text(std::move(msg._text)), + _prio(std::move(msg._prio)), + _time(std::move(msg._time)), + _tid(std::move(msg._tid)), + _thread(std::move(msg._thread)), + _pid(std::move(msg._pid)), + _file(std::move(msg._file)), + _line(std::move(msg._line)) +{ + _pMap = msg._pMap; + msg._pMap = nullptr; +} + + Message::Message(const Message& msg, const std::string& text): _source(msg._source), _text(text), @@ -131,6 +147,27 @@ Message& Message::operator = (const Message& msg) } +Message& Message::operator = (Message&& msg) +{ + if (&msg != this) + { + _source = std::move(msg._source); + _text = std::move(msg._text); + _prio = std::move(msg._prio); + _time = std::move(msg._time); + _tid = std::move(msg._tid); + _thread = std::move(msg._thread); + _pid = std::move(msg._pid); + _file = std::move(msg._file); + _line = std::move(msg._line); + delete _pMap; + _pMap = msg._pMap; + msg._pMap = nullptr; + } + return *this; +} + + void Message::swap(Message& msg) { using std::swap; diff --git a/Foundation/src/NamedEvent.cpp b/Foundation/src/NamedEvent.cpp index 6615ca8f0..0cdeddbdc 100644 --- a/Foundation/src/NamedEvent.cpp +++ b/Foundation/src/NamedEvent.cpp @@ -15,10 +15,8 @@ #include "Poco/NamedEvent.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #include "NamedEvent_WIN32U.cpp" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "NamedEvent_WIN32.cpp" #elif POCO_OS == POCO_OS_ANDROID #include "NamedEvent_Android.cpp" #elif defined(POCO_OS_FAMILY_UNIX) diff --git a/Foundation/src/NamedMutex.cpp b/Foundation/src/NamedMutex.cpp index 77fd672c6..98c2f8714 100644 --- a/Foundation/src/NamedMutex.cpp +++ b/Foundation/src/NamedMutex.cpp @@ -15,10 +15,8 @@ #include "Poco/NamedMutex.h" -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #include "NamedMutex_WIN32U.cpp" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "NamedMutex_WIN32.cpp" #elif POCO_OS == POCO_OS_ANDROID #include "NamedMutex_Android.cpp" #elif defined(POCO_OS_FAMILY_UNIX) diff --git a/Foundation/src/NestedDiagnosticContext.cpp b/Foundation/src/NestedDiagnosticContext.cpp index dcbae13a0..fda6e921d 100644 --- a/Foundation/src/NestedDiagnosticContext.cpp +++ b/Foundation/src/NestedDiagnosticContext.cpp @@ -80,11 +80,11 @@ int NestedDiagnosticContext::depth() const std::string NestedDiagnosticContext::toString() const { std::string result; - for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it) + for (const auto& i: _stack) { if (!result.empty()) result.append(":"); - result.append(it->info); + result.append(i.info); } return result; } @@ -98,11 +98,11 @@ void NestedDiagnosticContext::dump(std::ostream& ostr) const void NestedDiagnosticContext::dump(std::ostream& ostr, const std::string& delimiter) const { - for (Stack::const_iterator it = _stack.begin(); it != _stack.end(); ++it) + for (const auto& i: _stack) { - ostr << it->info; - if (it->file) - ostr << " (in \"" << it->file << "\", line " << it->line << ")"; + ostr << i.info; + if (i.file) + ostr << " (in \"" << i.file << "\", line " << i.line << ")"; ostr << delimiter; } } diff --git a/Foundation/src/NotificationCenter.cpp b/Foundation/src/NotificationCenter.cpp index 3b024fa73..9da92f349 100644 --- a/Foundation/src/NotificationCenter.cpp +++ b/Foundation/src/NotificationCenter.cpp @@ -57,8 +57,8 @@ void NotificationCenter::removeObserver(const AbstractObserver& observer) bool NotificationCenter::hasObserver(const AbstractObserver& observer) const { Mutex::ScopedLock lock(_mutex); - for (ObserverList::const_iterator it = _observers.begin(); it != _observers.end(); ++it) - if (observer.equals(**it)) return true; + for (const auto& p: _observers) + if (observer.equals(*p)) return true; return false; } @@ -71,9 +71,9 @@ void NotificationCenter::postNotification(Notification::Ptr pNotification) ScopedLockWithUnlock lock(_mutex); ObserverList observersToNotify(_observers); lock.unlock(); - for (ObserverList::iterator it = observersToNotify.begin(); it != observersToNotify.end(); ++it) + for (auto& p: observersToNotify) { - (*it)->notify(pNotification); + p->notify(pNotification); } } diff --git a/Foundation/src/NotificationQueue.cpp b/Foundation/src/NotificationQueue.cpp index 670d11ec3..7b5969c9a 100644 --- a/Foundation/src/NotificationQueue.cpp +++ b/Foundation/src/NotificationQueue.cpp @@ -148,9 +148,9 @@ void NotificationQueue::dispatch(NotificationCenter& notificationCenter) void NotificationQueue::wakeUpAll() { FastMutex::ScopedLock lock(_mutex); - for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it) + for (auto p: _waitQueue) { - (*it)->nfAvailable.set(); + p->nfAvailable.set(); } _waitQueue.clear(); } @@ -177,6 +177,19 @@ void NotificationQueue::clear() } +bool NotificationQueue::remove(Notification::Ptr pNotification) +{ + FastMutex::ScopedLock lock(_mutex); + NfQueue::iterator it = std::find(_nfQueue.begin(), _nfQueue.end(), pNotification); + if (it == _nfQueue.end()) + { + return false; + } + _nfQueue.erase(it); + return true; +} + + bool NotificationQueue::hasIdleThreads() const { FastMutex::ScopedLock lock(_mutex); diff --git a/Foundation/src/Path.cpp b/Foundation/src/Path.cpp index 6b26ca046..bf3e6a854 100644 --- a/Foundation/src/Path.cpp +++ b/Foundation/src/Path.cpp @@ -16,7 +16,7 @@ #include "Poco/File.h" #include "Poco/Exception.h" #include "Poco/StringTokenizer.h" -#if defined(_WIN32) && defined(POCO_WIN32_UTF8) +#if defined(_WIN32) #include "Poco/UnicodeConverter.h" #include "Poco/Buffer.h" #endif @@ -25,14 +25,12 @@ #if defined(POCO_OS_FAMILY_UNIX) #include "Path_UNIX.cpp" -#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#elif defined(POCO_OS_FAMILY_WINDOWS) #if defined(_WIN32_WCE) #include "Path_WINCE.cpp" #else #include "Path_WIN32U.cpp" #endif -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Path_WIN32.cpp" #endif @@ -86,6 +84,17 @@ Path::Path(const Path& path): } +Path::Path(Path&& path) noexcept: + _node(std::move(path._node)), + _device(std::move(path._device)), + _name(std::move(path._name)), + _version(std::move(path._version)), + _dirs(std::move(path._dirs)), + _absolute(std::move(path._absolute)) +{ +} + + Path::Path(const Path& parent, const std::string& fileName): _node(parent._node), _device(parent._device), @@ -135,6 +144,18 @@ Path& Path::operator = (const Path& path) } +Path& Path::operator = (Path&& path) noexcept +{ + _node = std::move(path._node); + _device = std::move(path._device); + _name = std::move(path._name); + _version = std::move(path._version); + _dirs = std::move(path._dirs); + _absolute = std::move(path._absolute); + return *this; +} + + Path& Path::operator = (const std::string& path) { return assign(path); @@ -325,9 +346,9 @@ Path& Path::makeAbsolute(const Path& base) { Path tmp = base; tmp.makeDirectory(); - for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it) + for (const auto& d: _dirs) { - tmp.pushDirectory(*it); + tmp.pushDirectory(d); } _node = tmp._node; _device = tmp._device; @@ -964,9 +985,9 @@ std::string Path::buildUnix() const { result.append("/"); } - for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it) + for (const auto& d: _dirs) { - result.append(*it); + result.append(d); result.append("/"); } result.append(_name); @@ -992,9 +1013,9 @@ std::string Path::buildWindows() const { result.append("\\"); } - for (StringVec::const_iterator it = _dirs.begin(); it != _dirs.end(); ++it) + for (const auto& d: _dirs) { - result.append(*it); + result.append(d); result.append("\\"); } result.append(_name); @@ -1043,7 +1064,7 @@ std::string Path::buildVMS() const std::string Path::transcode(const std::string& path) { -#if defined(_WIN32) && defined(POCO_WIN32_UTF8) +#if defined(_WIN32) std::wstring uniPath; UnicodeConverter::toUTF16(path, uniPath); DWORD len = WideCharToMultiByte(CP_ACP, WC_NO_BEST_FIT_CHARS, uniPath.c_str(), static_cast(uniPath.length()), NULL, 0, NULL, NULL); @@ -1056,8 +1077,8 @@ std::string Path::transcode(const std::string& path) return std::string(buffer.begin(), buffer.size()); } } -#endif return path; +#endif } diff --git a/Foundation/src/PatternFormatter.cpp b/Foundation/src/PatternFormatter.cpp index b287b942e..3ae8ccf79 100644 --- a/Foundation/src/PatternFormatter.cpp +++ b/Foundation/src/PatternFormatter.cpp @@ -22,6 +22,7 @@ #include "Poco/Timezone.h" #include "Poco/Environment.h" #include "Poco/NumberParser.h" +#include "Poco/StringTokenizer.h" namespace Poco { @@ -29,11 +30,13 @@ namespace Poco { const std::string PatternFormatter::PROP_PATTERN = "pattern"; const std::string PatternFormatter::PROP_TIMES = "times"; +const std::string PatternFormatter::PROP_PRIORITY_NAMES = "priorityNames"; PatternFormatter::PatternFormatter(): _localTime(false) { + parsePriorityNames(); } @@ -41,6 +44,7 @@ PatternFormatter::PatternFormatter(const std::string& format): _localTime(false), _pattern(format) { + parsePriorityNames(); parsePattern(); } @@ -60,10 +64,10 @@ void PatternFormatter::format(const Message& msg, std::string& text) timestamp += Timezone::dst()*Timestamp::resolution(); } DateTime dateTime = timestamp; - for (std::vector::iterator ip = _patternActions.begin(); ip != _patternActions.end(); ++ip) + for (auto& pa:_patternActions) { - text.append(ip->prepend); - switch (ip->key) + text.append(pa.prepend); + switch (pa.key) { case 's': text.append(msg.getSource()); break; case 't': text.append(msg.getText()); break; @@ -101,17 +105,17 @@ void PatternFormatter::format(const Message& msg, std::string& text) case 'Z': text.append(DateTimeFormatter::tzdRFC(localTime ? Timezone::tzd() : DateTimeFormatter::UTC)); break; case 'E': NumberFormatter::append(text, msg.getTime().epochTime()); break; case 'v': - if (ip->length > msg.getSource().length()) //append spaces - text.append(msg.getSource()).append(ip->length - msg.getSource().length(), ' '); - else if (ip->length && ip->length < msg.getSource().length()) // crop - text.append(msg.getSource(), msg.getSource().length()-ip->length, ip->length); + if (pa.length > msg.getSource().length()) //append spaces + text.append(msg.getSource()).append(pa.length - msg.getSource().length(), ' '); + else if (pa.length && pa.length < msg.getSource().length()) // crop + text.append(msg.getSource(), msg.getSource().length()-pa.length, pa.length); else text.append(msg.getSource()); break; case 'x': try { - text.append(msg[ip->property]); + text.append(msg[pa.property]); } catch (...) { @@ -201,6 +205,11 @@ void PatternFormatter::setProperty(const std::string& name, const std::string& v { _localTime = (value == "local"); } + else if (name == PROP_PRIORITY_NAMES) + { + _priorityNames = value; + parsePriorityNames(); + } else { Formatter::setProperty(name, value); @@ -214,6 +223,8 @@ std::string PatternFormatter::getProperty(const std::string& name) const return _pattern; else if (name == PROP_TIMES) return _localTime ? "local" : "UTC"; + else if (name == PROP_PRIORITY_NAMES) + return _priorityNames; else return Formatter::getProperty(name); } @@ -236,6 +247,27 @@ namespace } +void PatternFormatter::parsePriorityNames() +{ + for (int i = 0; i <= 8; i++) + { + _priorities[i] = priorities[i]; + } + if (!_priorityNames.empty()) + { + StringTokenizer st(_priorityNames, ",;", StringTokenizer::TOK_TRIM); + if (st.count() == 8) + { + for (int i = 1; i <= 8; i++) + { + _priorities[i] = st[i - 1]; + } + } + else throw Poco::SyntaxException("priorityNames property must specify a comma-separated list of 8 property names"); + } +} + + const std::string& PatternFormatter::getPriorityName(int prio) { poco_assert (1 <= prio && prio <= 8); diff --git a/Foundation/src/PriorityNotificationQueue.cpp b/Foundation/src/PriorityNotificationQueue.cpp index b0e5523ce..d0121160b 100644 --- a/Foundation/src/PriorityNotificationQueue.cpp +++ b/Foundation/src/PriorityNotificationQueue.cpp @@ -131,9 +131,9 @@ void PriorityNotificationQueue::dispatch(NotificationCenter& notificationCenter) void PriorityNotificationQueue::wakeUpAll() { FastMutex::ScopedLock lock(_mutex); - for (WaitQueue::iterator it = _waitQueue.begin(); it != _waitQueue.end(); ++it) + for (auto p: _waitQueue) { - (*it)->nfAvailable.set(); + p->nfAvailable.set(); } _waitQueue.clear(); } diff --git a/Foundation/src/Process.cpp b/Foundation/src/Process.cpp index 7d5112b50..be542a8aa 100644 --- a/Foundation/src/Process.cpp +++ b/Foundation/src/Process.cpp @@ -23,17 +23,17 @@ namespace std::vector envbuf; std::size_t pos = 0; - for (Poco::Process::Env::const_iterator it = env.begin(); it != env.end(); ++it) + for (const auto& p: env) { - std::size_t envlen = it->first.length() + it->second.length() + 1; + std::size_t envlen = p.first.length() + p.second.length() + 1; envbuf.resize(pos + envlen + 1); - std::copy(it->first.begin(), it->first.end(), &envbuf[pos]); - pos += it->first.length(); + std::copy(p.first.begin(), p.first.end(), &envbuf[pos]); + pos += p.first.length(); envbuf[pos] = '='; ++pos; - std::copy(it->second.begin(), it->second.end(), &envbuf[pos]); - pos += it->second.length(); + std::copy(p.second.begin(), p.second.end(), &envbuf[pos]); + pos += p.second.length(); envbuf[pos] = '\0'; ++pos; @@ -47,14 +47,12 @@ namespace } -#if defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#if defined(POCO_OS_FAMILY_WINDOWS) #if defined(_WIN32_WCE) #include "Process_WINCE.cpp" #else #include "Process_WIN32U.cpp" #endif -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "Process_WIN32.cpp" #elif defined(POCO_VXWORKS) #include "Process_VX.cpp" #elif defined(POCO_OS_FAMILY_UNIX) diff --git a/Foundation/src/Process_UNIX.cpp b/Foundation/src/Process_UNIX.cpp index 4671278e1..4cb21fffb 100644 --- a/Foundation/src/Process_UNIX.cpp +++ b/Foundation/src/Process_UNIX.cpp @@ -97,8 +97,8 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg char** argv = new char*[args.size() + 2]; int i = 0; argv[i++] = const_cast(command.c_str()); - for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it) - argv[i++] = const_cast(it->c_str()); + for (const auto& a: args) + argv[i++] = const_cast(a.c_str()); argv[i] = NULL; struct inheritance inherit; std::memset(&inherit, 0, sizeof(inherit)); @@ -155,9 +155,9 @@ ProcessHandleImpl* ProcessImpl::launchByForkExecImpl(const std::string& command, std::vector argv(args.size() + 2); int i = 0; argv[i++] = const_cast(command.c_str()); - for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it) + for (const auto& a: args) { - argv[i++] = const_cast(it->c_str()); + argv[i++] = const_cast(a.c_str()); } argv[i] = NULL; diff --git a/Foundation/src/Process_WIN32.cpp b/Foundation/src/Process_WIN32.cpp index d698a9726..51a99d2d6 100644 --- a/Foundation/src/Process_WIN32.cpp +++ b/Foundation/src/Process_WIN32.cpp @@ -162,10 +162,10 @@ static std::string escapeArg(const std::string& arg) ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env) { std::string commandLine = command; - for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it) + for (const auto& a: args) { commandLine.append(" "); - commandLine.append(escapeArg(*it)); + commandLine.append(escapeArg(a)); } STARTUPINFOA startupInfo; diff --git a/Foundation/src/Process_WIN32U.cpp b/Foundation/src/Process_WIN32U.cpp index 2a81a8dd4..42da63ab4 100644 --- a/Foundation/src/Process_WIN32U.cpp +++ b/Foundation/src/Process_WIN32U.cpp @@ -166,10 +166,10 @@ static std::string escapeArg(const std::string& arg) ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const ArgsImpl& args, const std::string& initialDirectory, Pipe* inPipe, Pipe* outPipe, Pipe* errPipe, const EnvImpl& env) { std::string commandLine = escapeArg(command); - for (ArgsImpl::const_iterator it = args.begin(); it != args.end(); ++it) + for (const auto& a: args) { commandLine.append(" "); - commandLine.append(escapeArg(*it)); + commandLine.append(escapeArg(a)); } std::wstring ucommandLine; diff --git a/Foundation/src/PurgeStrategy.cpp b/Foundation/src/PurgeStrategy.cpp index 5be4e62be..8a3a25866 100644 --- a/Foundation/src/PurgeStrategy.cpp +++ b/Foundation/src/PurgeStrategy.cpp @@ -76,11 +76,11 @@ void PurgeByAgeStrategy::purge(const std::string& path) { std::vector files; list(path, files); - for (std::vector::iterator it = files.begin(); it != files.end(); ++it) + for (auto& f: files) { - if (it->getLastModified().isElapsed(_age.totalMicroseconds())) + if (f.getLastModified().isElapsed(_age.totalMicroseconds())) { - it->remove(); + f.remove(); } } } diff --git a/Foundation/src/RandomStream.cpp b/Foundation/src/RandomStream.cpp index 7a490eb60..89137fe71 100644 --- a/Foundation/src/RandomStream.cpp +++ b/Foundation/src/RandomStream.cpp @@ -88,7 +88,7 @@ int RandomBuf::readFromDevice(char* buffer, std::streamsize length) for (DigestEngine::Digest::const_iterator it = d.begin(); it != d.end() && n < length; ++it, ++n) { engine.update(*it); - *buffer++ = *it++; + *buffer++ = *it; } } } diff --git a/Foundation/src/RegularExpression.cpp b/Foundation/src/RegularExpression.cpp index 0ab62b654..90f22b9f5 100644 --- a/Foundation/src/RegularExpression.cpp +++ b/Foundation/src/RegularExpression.cpp @@ -168,10 +168,10 @@ int RegularExpression::split(const std::string& subject, std::string::size_type strings.clear(); int rc = match(subject, offset, matches, options); strings.reserve(matches.size()); - for (MatchVec::const_iterator it = matches.begin(); it != matches.end(); ++it) + for (const auto& m: matches) { - if (it->offset != std::string::npos) - strings.push_back(subject.substr(it->offset, it->length)); + if (m.offset != std::string::npos) + strings.push_back(subject.substr(m.offset, m.length)); else strings.push_back(std::string()); } diff --git a/Foundation/src/RotateStrategy.cpp b/Foundation/src/RotateStrategy.cpp index 0019ff911..d3939b70f 100644 --- a/Foundation/src/RotateStrategy.cpp +++ b/Foundation/src/RotateStrategy.cpp @@ -17,6 +17,7 @@ #include "Poco/DateTimeParser.h" #include "Poco/DateTimeFormatter.h" #include "Poco/DateTimeFormat.h" +#include "Poco/LineEndingConverter.h" namespace Poco { @@ -65,8 +66,9 @@ bool RotateByIntervalStrategy::mustRotate(LogFile* pFile) if (pFile->size() != 0) { Poco::FileInputStream istr(pFile->path()); + Poco::InputLineEndingConverter converter(istr, Poco::LineEnding::NEWLINE_LF); std::string tag; - std::getline(istr, tag); + std::getline(converter, tag); if (tag.compare(0, ROTATE_TEXT.size(), ROTATE_TEXT) == 0) { std::string timestamp(tag, ROTATE_TEXT.size()); diff --git a/Foundation/src/SharedLibrary.cpp b/Foundation/src/SharedLibrary.cpp index 542f9e810..bad305fef 100644 --- a/Foundation/src/SharedLibrary.cpp +++ b/Foundation/src/SharedLibrary.cpp @@ -22,10 +22,8 @@ #include "SharedLibrary_VX.cpp" #elif defined(POCO_OS_FAMILY_UNIX) #include "SharedLibrary_UNIX.cpp" -#elif defined(POCO_OS_FAMILY_WINDOWS) && defined(POCO_WIN32_UTF8) +#elif defined(POCO_OS_FAMILY_WINDOWS) #include "SharedLibrary_WIN32U.cpp" -#elif defined(POCO_OS_FAMILY_WINDOWS) -#include "SharedLibrary_WIN32.cpp" #endif diff --git a/Foundation/src/SharedMemory_WIN32.cpp b/Foundation/src/SharedMemory_WIN32.cpp index 1e86d7d10..65959bf85 100644 --- a/Foundation/src/SharedMemory_WIN32.cpp +++ b/Foundation/src/SharedMemory_WIN32.cpp @@ -17,9 +17,7 @@ #include "Poco/Exception.h" #include "Poco/File.h" #include "Poco/Format.h" -#if defined (POCO_WIN32_UTF8) #include "Poco/UnicodeConverter.h" -#endif #include "Poco/UnWindows.h" @@ -37,13 +35,9 @@ SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, Sh if (mode == SharedMemory::AM_WRITE) _mode = PAGE_READWRITE; -#if defined (POCO_WIN32_UTF8) std::wstring utf16name; UnicodeConverter::toUTF16(_name, utf16name); _memHandle = CreateFileMappingW(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, utf16name.c_str()); -#else - _memHandle = CreateFileMappingA(INVALID_HANDLE_VALUE, NULL, _mode, 0, _size, _name.c_str()); -#endif if (!_memHandle) { @@ -54,11 +48,7 @@ SharedMemoryImpl::SharedMemoryImpl(const std::string& name, std::size_t size, Sh if (_mode != PAGE_READONLY || dwRetVal != 5) throw SystemException(format("Cannot create shared memory object %s [Error %d: %s]", _name, static_cast(dwRetVal), Error::getMessage(dwRetVal))); -#if defined (POCO_WIN32_UTF8) _memHandle = OpenFileMappingW(PAGE_READONLY, FALSE, utf16name.c_str()); -#else - _memHandle = OpenFileMappingA(PAGE_READONLY, FALSE, _name.c_str()); -#endif if (!_memHandle) { dwRetVal = GetLastError(); @@ -92,13 +82,9 @@ SharedMemoryImpl::SharedMemoryImpl(const Poco::File& file, SharedMemory::AccessM fileMode |= GENERIC_WRITE; } -#if defined (POCO_WIN32_UTF8) std::wstring utf16name; UnicodeConverter::toUTF16(_name, utf16name); _fileHandle = CreateFileW(utf16name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#else - _fileHandle = CreateFileA(_name.c_str(), fileMode, shareMode, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL); -#endif if (_fileHandle == INVALID_HANDLE_VALUE) throw OpenFileException("Cannot open memory mapped file", _name); diff --git a/Foundation/src/SortedDirectoryIterator.cpp b/Foundation/src/SortedDirectoryIterator.cpp index 3d2a84ef8..9cc572401 100644 --- a/Foundation/src/SortedDirectoryIterator.cpp +++ b/Foundation/src/SortedDirectoryIterator.cpp @@ -81,7 +81,9 @@ void SortedDirectoryIterator::scan() { isDir = (*this)->isDirectory(); } - catch (...) {} + catch (...) + { + } if (isDir) _directories.push_back(_path.toString()); else diff --git a/Foundation/src/SplitterChannel.cpp b/Foundation/src/SplitterChannel.cpp index 69ba36a24..488297524 100644 --- a/Foundation/src/SplitterChannel.cpp +++ b/Foundation/src/SplitterChannel.cpp @@ -38,18 +38,16 @@ SplitterChannel::~SplitterChannel() } -void SplitterChannel::addChannel(Channel* pChannel) +void SplitterChannel::addChannel(Channel::Ptr pChannel) { poco_check_ptr (pChannel); FastMutex::ScopedLock lock(_mutex); - - pChannel->duplicate(); _channels.push_back(pChannel); } -void SplitterChannel::removeChannel(Channel* pChannel) +void SplitterChannel::removeChannel(Channel::Ptr pChannel) { FastMutex::ScopedLock lock(_mutex); @@ -57,7 +55,6 @@ void SplitterChannel::removeChannel(Channel* pChannel) { if (*it == pChannel) { - pChannel->release(); _channels.erase(it); break; } @@ -83,9 +80,9 @@ void SplitterChannel::log(const Message& msg) { FastMutex::ScopedLock lock(_mutex); - for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it) + for (auto& p: _channels) { - (*it)->log(msg); + p->log(msg); } } @@ -93,11 +90,6 @@ void SplitterChannel::log(const Message& msg) void SplitterChannel::close() { FastMutex::ScopedLock lock(_mutex); - - for (ChannelVec::iterator it = _channels.begin(); it != _channels.end(); ++it) - { - (*it)->release(); - } _channels.clear(); } diff --git a/Foundation/src/StreamTokenizer.cpp b/Foundation/src/StreamTokenizer.cpp index 1b6e93627..99dc4482d 100644 --- a/Foundation/src/StreamTokenizer.cpp +++ b/Foundation/src/StreamTokenizer.cpp @@ -32,9 +32,9 @@ StreamTokenizer::StreamTokenizer(std::istream& istr): StreamTokenizer::~StreamTokenizer() { - for (TokenVec::iterator it = _tokens.begin(); it != _tokens.end(); ++it) + for (auto& t: _tokens) { - delete it->pToken; + delete t.pToken; } } diff --git a/Foundation/src/Task.cpp b/Foundation/src/Task.cpp index 550b01c38..a512c36d9 100644 --- a/Foundation/src/Task.cpp +++ b/Foundation/src/Task.cpp @@ -14,6 +14,7 @@ #include "Poco/Task.h" #include "Poco/TaskManager.h" +#include "Poco/Thread.h" #include "Poco/Exception.h" @@ -25,7 +26,7 @@ Task::Task(const std::string& name): _pOwner(0), _progress(0), _state(TASK_IDLE), - _cancelEvent(false) + _cancelEvent(Event::EVENT_MANUALRESET) { } @@ -89,6 +90,13 @@ bool Task::sleep(long milliseconds) } +bool Task::yield() +{ + Thread::yield(); + return isCancelled(); +} + + void Task::setProgress(float progress) { FastMutex::ScopedLock lock(_mutex); diff --git a/Foundation/src/TaskManager.cpp b/Foundation/src/TaskManager.cpp index 8bf1cb340..67a3c91fe 100644 --- a/Foundation/src/TaskManager.cpp +++ b/Foundation/src/TaskManager.cpp @@ -67,9 +67,9 @@ void TaskManager::cancelAll() { FastMutex::ScopedLock lock(_mutex); - for (TaskList::iterator it = _taskList.begin(); it != _taskList.end(); ++it) + for (auto& pTask: _taskList) { - (*it)->cancel(); + pTask->cancel(); } } diff --git a/Foundation/src/TeeStream.cpp b/Foundation/src/TeeStream.cpp index 12ae7d0da..b3ef72b70 100644 --- a/Foundation/src/TeeStream.cpp +++ b/Foundation/src/TeeStream.cpp @@ -62,9 +62,9 @@ int TeeStreamBuf::readFromDevice() int TeeStreamBuf::writeToDevice(char c) { - for (StreamVec::iterator it = _streams.begin(); it != _streams.end(); ++it) + for (auto& pStream: _streams) { - (*it)->put(c); + pStream->put(c); } return charToInt(c); } diff --git a/Foundation/src/TemporaryFile.cpp b/Foundation/src/TemporaryFile.cpp index e89c970f3..c341256a5 100644 --- a/Foundation/src/TemporaryFile.cpp +++ b/Foundation/src/TemporaryFile.cpp @@ -37,13 +37,13 @@ public: { try { - for (std::set::iterator it = _files.begin(); it != _files.end(); ++it) + for (auto& f: _files) { try { - File f(*it); - if (f.exists()) - f.remove(true); + File file(f); + if (file.exists()) + file.remove(true); } catch (Exception&) { diff --git a/Foundation/src/ThreadLocal.cpp b/Foundation/src/ThreadLocal.cpp index 3cc03f696..64060a083 100644 --- a/Foundation/src/ThreadLocal.cpp +++ b/Foundation/src/ThreadLocal.cpp @@ -37,9 +37,9 @@ ThreadLocalStorage::ThreadLocalStorage() ThreadLocalStorage::~ThreadLocalStorage() { - for (TLSMap::iterator it = _map.begin(); it != _map.end(); ++it) + for (auto& p: _map) { - delete it->second; + delete p.second; } } diff --git a/Foundation/src/ThreadPool.cpp b/Foundation/src/ThreadPool.cpp index 398469450..4665b0045 100644 --- a/Foundation/src/ThreadPool.cpp +++ b/Foundation/src/ThreadPool.cpp @@ -313,9 +313,9 @@ int ThreadPool::available() const FastMutex::ScopedLock lock(_mutex); int count = 0; - for (ThreadVec::const_iterator it = _threads.begin(); it != _threads.end(); ++it) + for (auto pThread: _threads) { - if ((*it)->idle()) ++count; + if (pThread->idle()) ++count; } return (int) (count + _maxCapacity - _threads.size()); } @@ -326,9 +326,9 @@ int ThreadPool::used() const FastMutex::ScopedLock lock(_mutex); int count = 0; - for (ThreadVec::const_iterator it = _threads.begin(); it != _threads.end(); ++it) + for (auto pThread: _threads) { - if (!(*it)->idle()) ++count; + if (!pThread->idle()) ++count; } return count; } @@ -370,9 +370,9 @@ void ThreadPool::stopAll() { FastMutex::ScopedLock lock(_mutex); - for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it) + for (auto pThread: _threads) { - (*it)->release(); + pThread->release(); } _threads.clear(); } @@ -382,9 +382,9 @@ void ThreadPool::joinAll() { FastMutex::ScopedLock lock(_mutex); - for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it) + for (auto pThread: _threads) { - (*it)->join(); + pThread->join(); } housekeep(); } @@ -409,30 +409,30 @@ void ThreadPool::housekeep() idleThreads.reserve(_threads.size()); activeThreads.reserve(_threads.size()); - for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it) + for (auto pThread: _threads) { - if ((*it)->idle()) + if (pThread->idle()) { - if ((*it)->idleTime() < _idleTime) - idleThreads.push_back(*it); + if (pThread->idleTime() < _idleTime) + idleThreads.push_back(pThread); else - expiredThreads.push_back(*it); + expiredThreads.push_back(pThread); } - else activeThreads.push_back(*it); + else activeThreads.push_back(pThread); } int n = (int) activeThreads.size(); int limit = (int) idleThreads.size() + n; if (limit < _minCapacity) limit = _minCapacity; idleThreads.insert(idleThreads.end(), expiredThreads.begin(), expiredThreads.end()); _threads.clear(); - for (ThreadVec::iterator it = idleThreads.begin(); it != idleThreads.end(); ++it) + for (auto pIdle: idleThreads) { if (n < limit) { - _threads.push_back(*it); + _threads.push_back(pIdle); ++n; } - else (*it)->release(); + else pIdle->release(); } _threads.insert(_threads.end(), activeThreads.begin(), activeThreads.end()); } diff --git a/Foundation/src/Timezone_WIN32.cpp b/Foundation/src/Timezone_WIN32.cpp index 45be02e0a..8fdc77e8f 100644 --- a/Foundation/src/Timezone_WIN32.cpp +++ b/Foundation/src/Timezone_WIN32.cpp @@ -53,13 +53,7 @@ std::string Timezone::name() TIME_ZONE_INFORMATION tzInfo; DWORD dstFlag = GetTimeZoneInformation(&tzInfo); WCHAR* ptr = dstFlag == TIME_ZONE_ID_DAYLIGHT ? tzInfo.DaylightName : tzInfo.StandardName; -#if defined(POCO_WIN32_UTF8) UnicodeConverter::toUTF8(ptr, result); -#else - char buffer[256]; - DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL); - if (rc) result = buffer; -#endif return result; } @@ -70,13 +64,7 @@ std::string Timezone::standardName() TIME_ZONE_INFORMATION tzInfo; DWORD dstFlag = GetTimeZoneInformation(&tzInfo); WCHAR* ptr = tzInfo.StandardName; -#if defined(POCO_WIN32_UTF8) UnicodeConverter::toUTF8(ptr, result); -#else - char buffer[256]; - DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL); - if (rc) result = buffer; -#endif return result; } @@ -87,13 +75,7 @@ std::string Timezone::dstName() TIME_ZONE_INFORMATION tzInfo; DWORD dstFlag = GetTimeZoneInformation(&tzInfo); WCHAR* ptr = tzInfo.DaylightName; -#if defined(POCO_WIN32_UTF8) UnicodeConverter::toUTF8(ptr, result); -#else - char buffer[256]; - DWORD rc = WideCharToMultiByte(CP_ACP, 0, ptr, -1, buffer, sizeof(buffer), NULL, NULL); - if (rc) result = buffer; -#endif return result; } diff --git a/Foundation/src/URI.cpp b/Foundation/src/URI.cpp index d0d5bb1a4..eb4fbf584 100644 --- a/Foundation/src/URI.cpp +++ b/Foundation/src/URI.cpp @@ -111,7 +111,19 @@ URI::URI(const URI& uri): { } - + +URI::URI(URI&& uri) noexcept: + _scheme(std::move(uri._scheme)), + _userInfo(std::move(uri._userInfo)), + _host(std::move(uri._host)), + _port(std::move(uri._port)), + _path(std::move(uri._path)), + _query(std::move(uri._query)), + _fragment(std::move(uri._fragment)) +{ +} + + URI::URI(const URI& baseURI, const std::string& relativeURI): _scheme(baseURI._scheme), _userInfo(baseURI._userInfo), @@ -155,6 +167,20 @@ URI& URI::operator = (const URI& uri) return *this; } + +URI& URI::operator = (URI&& uri) noexcept +{ + _scheme = std::move(uri._scheme); + _userInfo = std::move(uri._userInfo); + _host = std::move(uri._host); + _port = std::move(uri._port); + _path = std::move(uri._path); + _query = std::move(uri._query); + _fragment = std::move(uri._fragment); + + return *this; +} + URI& URI::operator = (const std::string& uri) { @@ -390,9 +416,9 @@ URI::QueryParameters URI::getQueryParameters() const void URI::setQueryParameters(const QueryParameters& params) { _query.clear(); - for (QueryParameters::const_iterator it = params.begin(); it != params.end(); ++it) + for (const auto& p: params) { - addQueryParameter(it->first, it->second); + addQueryParameter(p.first, p.second); } } @@ -567,25 +593,25 @@ void URI::removeDotSegments(bool removeLeading) std::vector segments; std::vector normalizedSegments; getPathSegments(segments); - for (std::vector::const_iterator it = segments.begin(); it != segments.end(); ++it) + for (const auto& s: segments) { - if (*it == "..") + if (s == "..") { if (!normalizedSegments.empty()) { if (normalizedSegments.back() == "..") - normalizedSegments.push_back(*it); + normalizedSegments.push_back(s); else normalizedSegments.pop_back(); } else if (!removeLeading) { - normalizedSegments.push_back(*it); + normalizedSegments.push_back(s); } } - else if (*it != ".") + else if (s != ".") { - normalizedSegments.push_back(*it); + normalizedSegments.push_back(s); } } buildPath(normalizedSegments, leadingSlash, trailingSlash); @@ -623,9 +649,8 @@ void URI::getPathSegments(const std::string& path, std::vector& seg void URI::encode(const std::string& str, const std::string& reserved, std::string& encodedStr) { - for (std::string::const_iterator it = str.begin(); it != str.end(); ++it) + for (auto c: str) { - char c = *it; if ((c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z') || (c >= '0' && c <= '9') || @@ -883,18 +908,18 @@ void URI::mergePath(const std::string& path) addLeadingSlash = addLeadingSlash || (!path.empty() && path[0] == '/'); bool hasTrailingSlash = (!path.empty() && *(path.rbegin()) == '/'); bool addTrailingSlash = false; - for (std::vector::const_iterator it = segments.begin(); it != segments.end(); ++it) + for (const auto& s: segments) { - if (*it == "..") + if (s == "..") { addTrailingSlash = true; if (!normalizedSegments.empty()) normalizedSegments.pop_back(); } - else if (*it != ".") + else if (s != ".") { addTrailingSlash = false; - normalizedSegments.push_back(*it); + normalizedSegments.push_back(s); } else addTrailingSlash = true; } @@ -906,18 +931,18 @@ void URI::buildPath(const std::vector& segments, bool leadingSlash, { _path.clear(); bool first = true; - for (std::vector::const_iterator it = segments.begin(); it != segments.end(); ++it) + for (const auto& s: segments) { if (first) { first = false; if (leadingSlash) _path += '/'; - else if (_scheme.empty() && (*it).find(':') != std::string::npos) + else if (_scheme.empty() && s.find(':') != std::string::npos) _path.append("./"); } else _path += '/'; - _path.append(*it); + _path.append(s); } if (trailingSlash) _path += '/'; diff --git a/Foundation/src/URIStreamOpener.cpp b/Foundation/src/URIStreamOpener.cpp index 1f9631853..18d30c3bb 100644 --- a/Foundation/src/URIStreamOpener.cpp +++ b/Foundation/src/URIStreamOpener.cpp @@ -32,8 +32,7 @@ URIStreamOpener::URIStreamOpener() URIStreamOpener::~URIStreamOpener() { - for (FactoryMap::iterator it = _map.begin(); it != _map.end(); ++it) - delete it->second; + for (auto& p: _map) delete p.second; } diff --git a/Foundation/src/Var.cpp b/Foundation/src/Var.cpp index c99e86cb3..ed95c0696 100644 --- a/Foundation/src/Var.cpp +++ b/Foundation/src/Var.cpp @@ -363,13 +363,11 @@ Var& Var::getAt(std::size_t n) InvalidAccessException>("Not a deque.")->operator[](n); else if (isStruct()) { -#ifdef POCO_ENABLE_CPP11 if (isOrdered()) - return structIndexOperator(holderImpl, OrderedSet >, + return structIndexOperator(holderImpl, OrderedSet>, InvalidAccessException>("Not a struct."), static_cast(n)); else -#endif // POCO_ENABLE_CPP11 - return structIndexOperator(holderImpl, std::set >, + return structIndexOperator(holderImpl, std::set>, InvalidAccessException>("Not a struct."), static_cast(n)); } else if (!isString() && !isEmpty() && (n == 0)) @@ -395,11 +393,9 @@ Var& Var::getAt(const std::string& name) { if (isStruct()) { -#ifdef POCO_ENABLE_CPP11 if (isOrdered()) return structIndexOperator(holderImpl("Not a struct."), name); else -#endif // POCO_ENABLE_CPP11 return structIndexOperator(holderImpl("Not a struct."), name); } @@ -644,7 +640,7 @@ std::string Var::toString(const Var& any) } /* -Var& Var::structIndexOperator(VarHolderImpl >* pStr, int n) const +Var& Var::structIndexOperator(VarHolderImpl>* pStr, int n) const { return pStr->operator[](n); } diff --git a/Foundation/src/WindowsConsoleChannel.cpp b/Foundation/src/WindowsConsoleChannel.cpp index 07e352935..358b007ee 100644 --- a/Foundation/src/WindowsConsoleChannel.cpp +++ b/Foundation/src/WindowsConsoleChannel.cpp @@ -14,9 +14,7 @@ #include "Poco/WindowsConsoleChannel.h" #include "Poco/Message.h" -#if defined(POCO_WIN32_UTF8) #include "Poco/UnicodeConverter.h" -#endif #include "Poco/String.h" #include "Poco/Exception.h" @@ -45,7 +43,6 @@ void WindowsConsoleChannel::log(const Message& msg) std::string text = msg.getText(); text += "\r\n"; -#if defined(POCO_WIN32_UTF8) if (_isFile) { DWORD written; @@ -58,10 +55,6 @@ void WindowsConsoleChannel::log(const Message& msg) DWORD written; WriteConsoleW(_hConsole, utext.data(), static_cast(utext.size()), &written, NULL); } -#else - DWORD written; - WriteFile(_hConsole, text.data(), text.size(), &written, NULL); -#endif } @@ -96,7 +89,6 @@ void WindowsColorConsoleChannel::log(const Message& msg) SetConsoleTextAttribute(_hConsole, attr); } -#if defined(POCO_WIN32_UTF8) if (_isFile) { DWORD written; @@ -109,10 +101,6 @@ void WindowsColorConsoleChannel::log(const Message& msg) DWORD written; WriteConsoleW(_hConsole, utext.data(), static_cast(utext.size()), &written, NULL); } -#else - DWORD written; - WriteFile(_hConsole, text.data(), text.size(), &written, NULL); -#endif if (_enableColors && !_isFile) { diff --git a/Foundation/testsuite/src/AutoPtrTest.cpp b/Foundation/testsuite/src/AutoPtrTest.cpp index 90f5bcaf6..23aa2c8cb 100644 --- a/Foundation/testsuite/src/AutoPtrTest.cpp +++ b/Foundation/testsuite/src/AutoPtrTest.cpp @@ -16,6 +16,7 @@ using Poco::AutoPtr; +using Poco::makeAuto; using Poco::NullPointerException; @@ -28,6 +29,14 @@ namespace { ++_count; } + + explicit TestObj(int value): _rc(1) + { + } + + TestObj(int value1, const std::string& value2): _rc(1) + { + } void duplicate() { @@ -92,6 +101,14 @@ void AutoPtrTest::testAutoPtr() ptr3 = ptr2; assertTrue (ptr2->rc() == 2); assertTrue (TestObj::count() > 0); + + AutoPtr ptr4 = std::move(ptr); + assertTrue (ptr4->rc() == 1); + assertTrue (ptr.isNull()); + + ptr3 = std::move(ptr4); + assertTrue (ptr4.isNull()); + assertTrue (ptr3->rc() == 1); } assertTrue (TestObj::count() == 0); } @@ -165,6 +182,19 @@ void AutoPtrTest::testOps() } +void AutoPtrTest::testMakeAuto() +{ + AutoPtr ptr = makeAuto(); + assertTrue (ptr->rc() == 1); + + ptr = makeAuto(42); + assertTrue (ptr->rc() == 1); + + ptr = makeAuto(42, "fortytwo"); + assertTrue (ptr->rc() == 1); +} + + void AutoPtrTest::setUp() { } @@ -181,6 +211,7 @@ CppUnit::Test* AutoPtrTest::suite() CppUnit_addTest(pSuite, AutoPtrTest, testAutoPtr); CppUnit_addTest(pSuite, AutoPtrTest, testOps); + CppUnit_addTest(pSuite, AutoPtrTest, testMakeAuto); return pSuite; } diff --git a/Foundation/testsuite/src/AutoPtrTest.h b/Foundation/testsuite/src/AutoPtrTest.h index 1ea03c1f3..4365ff66c 100644 --- a/Foundation/testsuite/src/AutoPtrTest.h +++ b/Foundation/testsuite/src/AutoPtrTest.h @@ -26,6 +26,7 @@ public: void testAutoPtr(); void testOps(); + void testMakeAuto(); void setUp(); void tearDown(); diff --git a/Foundation/testsuite/src/CoreTestSuite.cpp b/Foundation/testsuite/src/CoreTestSuite.cpp index b7e85a4f4..3be42ba4f 100644 --- a/Foundation/testsuite/src/CoreTestSuite.cpp +++ b/Foundation/testsuite/src/CoreTestSuite.cpp @@ -70,9 +70,7 @@ CppUnit::Test* CoreTestSuite::suite() pSuite->addTest(TypeListTest::suite()); pSuite->addTest(ObjectPoolTest::suite()); pSuite->addTest(ListMapTest::suite()); -#ifdef POCO_ENABLE_CPP11 pSuite->addTest(OrderedContainersTest::suite()); -#endif return pSuite; } diff --git a/Foundation/testsuite/src/FormatTest.cpp b/Foundation/testsuite/src/FormatTest.cpp index 4b121038a..0fb5e14ce 100644 --- a/Foundation/testsuite/src/FormatTest.cpp +++ b/Foundation/testsuite/src/FormatTest.cpp @@ -42,6 +42,11 @@ void FormatTest::testChar() s = format("%-2c", c); assertTrue (s == "a "); + s = format("%*c", 2, c); + assertTrue (s == " a"); + s = format("%-*c", 2, c); + assertTrue (s == "a "); + s = format("%c", std::string("foo")); assertTrue (s == "[ERRFMT]"); } @@ -57,6 +62,11 @@ void FormatTest::testInt() s = format("%04d", i); assertTrue (s == "0042"); + s = format("%*d", 4, i); + assertTrue (s == " 42"); + s = format("%0*d", 4, i); + assertTrue (s == "0042"); + short h = 42; s = format("%hd", h); assertTrue (s == "42"); @@ -65,6 +75,11 @@ void FormatTest::testInt() s = format("%04hd", h); assertTrue (s == "0042"); + s = format("%*hd", 4, h); + assertTrue (s == " 42"); + s = format("%0*hd", 4, h); + assertTrue (s == "0042"); + unsigned short hu = 42; s = format("%hu", hu); assertTrue (s == "42"); @@ -73,6 +88,11 @@ void FormatTest::testInt() s = format("%04hu", hu); assertTrue (s == "0042"); + s = format("%*hu", 4, hu); + assertTrue (s == " 42"); + s = format("%0*hu", 4, hu); + assertTrue (s == "0042"); + unsigned x = 0x42; s = format("%x", x); assertTrue (s == "42"); @@ -81,6 +101,11 @@ void FormatTest::testInt() s = format("%04x", x); assertTrue (s == "0042"); + s = format("%*x", 4, x); + assertTrue (s == " 42"); + s = format("%0*x", 4, x); + assertTrue (s == "0042"); + unsigned o = 042; s = format("%o", o); assertTrue (s == "42"); @@ -89,6 +114,11 @@ void FormatTest::testInt() s = format("%04o", o); assertTrue (s == "0042"); + s = format("%*o", 4, o); + assertTrue (s == " 42"); + s = format("%0*o", 4, o); + assertTrue (s == "0042"); + unsigned u = 42; s = format("%u", u); assertTrue (s == "42"); @@ -97,6 +127,11 @@ void FormatTest::testInt() s = format("%04u", u); assertTrue (s == "0042"); + s = format("%*u", 4, u); + assertTrue (s == " 42"); + s = format("%0*u", 4, u); + assertTrue (s == "0042"); + long l = 42; s = format("%ld", l); assertTrue (s == "42"); @@ -105,6 +140,11 @@ void FormatTest::testInt() s = format("%04ld", l); assertTrue (s == "0042"); + s = format("%*ld", 4, l); + assertTrue (s == " 42"); + s = format("%0*ld", 4, l); + assertTrue (s == "0042"); + unsigned long ul = 42; s = format("%lu", ul); assertTrue (s == "42"); @@ -113,6 +153,11 @@ void FormatTest::testInt() s = format("%04lu", ul); assertTrue (s == "0042"); + s = format("%*lu", 4, ul); + assertTrue (s == " 42"); + s = format("%0*lu", 4, ul); + assertTrue (s == "0042"); + unsigned long xl = 0x42; s = format("%lx", xl); assertTrue (s == "42"); @@ -121,6 +166,11 @@ void FormatTest::testInt() s = format("%04lx", xl); assertTrue (s == "0042"); + s = format("%*lx", 4, xl); + assertTrue (s == " 42"); + s = format("%0*lx", 4, xl); + assertTrue (s == "0042"); + Int64 i64 = 42; s = format("%Ld", i64); assertTrue (s == "42"); @@ -129,6 +179,11 @@ void FormatTest::testInt() s = format("%04Ld", i64); assertTrue (s == "0042"); + s = format("%*Ld", 4, i64); + assertTrue (s == " 42"); + s = format("%0*Ld", 4, i64); + assertTrue (s == "0042"); + UInt64 ui64 = 42; s = format("%Lu", ui64); assertTrue (s == "42"); @@ -137,6 +192,11 @@ void FormatTest::testInt() s = format("%04Lu", ui64); assertTrue (s == "0042"); + s = format("%*Lu", 4, ui64); + assertTrue (s == " 42"); + s = format("%0*Lu", 4, ui64); + assertTrue (s == "0042"); + x = 0xaa; s = format("%x", x); assertTrue (s == "aa"); @@ -152,6 +212,10 @@ void FormatTest::testInt() assertTrue (s == "-42"); s = format("%+04d", i); assertTrue (s == "-042"); + + s = format("%+0*d", 4, i); + assertTrue (s == "-042"); + s = format("%d", i); assertTrue (s == "-42"); @@ -201,6 +265,11 @@ void FormatTest::testAnyInt() std::string s(format("%?i", c)); assertTrue (s == "42"); + c = 43; + s.clear(); + format(s, "%?i", c); + assertTrue (s == "43"); + bool b = true; s = format("%?i", b); assertTrue (s == "1"); @@ -264,17 +333,28 @@ void FormatTest::testFloatFix() s = format("%10f", d); assertTrue (s.find(" 1.50") != std::string::npos); + s = format("%*f", 10, d); + assertTrue (s.find(" 1.50") != std::string::npos); + s = format("%6.2f", d); assertTrue (s == " 1.50"); s = format("%-6.2f", d); assertTrue (s == "1.50 "); + s = format("%*.*f", 6, 2, d); + assertTrue (s == " 1.50"); + s = format("%-*.*f", 6,2, d); + assertTrue (s == "1.50 "); + float f = 1.5; s = format("%hf", f); assertTrue (s.find("1.50") == 0); s = format("%.0f", 1.0); assertTrue (s == "1"); + + s = format("%.*f", 0, 1.0); + assertTrue (s == "1"); } @@ -289,12 +369,23 @@ void FormatTest::testFloatSci() assertTrue (s.find(" 1.50") != std::string::npos); assertTrue (s.find("0e+0") != std::string::npos); + s = format("%*e", 20, d); + assertTrue (s.find(" 1.50") != std::string::npos); + assertTrue (s.find("0e+0") != std::string::npos); + s = format("%10.2e", d); assertTrue (s == " 1.50e+000" || s == " 1.50e+00"); s = format("%-10.2e", d); assertTrue (s == "1.50e+000 " || s == "1.50e+00 "); s = format("%-10.2E", d); assertTrue (s == "1.50E+000 " || s == "1.50E+00 "); + + s = format("%*.*e", 10, 2, d); + assertTrue (s == " 1.50e+000" || s == " 1.50e+00"); + s = format("%-*.*e", 10, 2, d); + assertTrue (s == "1.50e+000 " || s == "1.50e+00 "); + s = format("%-*.*E", 10, 2, d); + assertTrue (s == "1.50E+000 " || s == "1.50E+00 "); } @@ -310,6 +401,12 @@ void FormatTest::testString() s = format("%-5s", foo); assertTrue (s == "foo "); + s = format("%*s", 5, foo); + assertTrue (s == " foo"); + + s = format("%-*s", 5, foo); + assertTrue (s == "foo "); + s = format("%s%%a", foo); assertTrue (s == "foo%a"); @@ -334,6 +431,9 @@ void FormatTest::testMultiple() s = format("%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6); assertTrue (s == "123456"); + + s = format("%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 0); + assertTrue (s == "1234567890"); } diff --git a/Foundation/testsuite/src/LoggerTest.cpp b/Foundation/testsuite/src/LoggerTest.cpp index dd47d01b9..cf6ba6563 100644 --- a/Foundation/testsuite/src/LoggerTest.cpp +++ b/Foundation/testsuite/src/LoggerTest.cpp @@ -36,7 +36,8 @@ void LoggerTest::testLogger() { AutoPtr pChannel = new TestChannel; Logger& root = Logger::root(); - root.setChannel(pChannel.get()); + root.setChannel(pChannel); + assertTrue (root.getLevel() == Message::PRIO_INFORMATION); assertTrue (root.is(Message::PRIO_INFORMATION)); assertTrue (root.fatal()); @@ -106,14 +107,14 @@ void LoggerTest::testLogger() assertTrue (logger22.getLevel() == Message::PRIO_WARNING); AutoPtr pChannel2 = new TestChannel; - Logger::setChannel("Logger2", pChannel2.get()); - assertTrue (pChannel == root.getChannel()); - assertTrue (pChannel == logger1.getChannel()); - assertTrue (pChannel == logger11.getChannel()); - assertTrue (pChannel == logger12.getChannel()); - assertTrue (pChannel2 == logger2.getChannel()); - assertTrue (pChannel2 == logger21.getChannel()); - assertTrue (pChannel2 == logger22.getChannel()); + Logger::setChannel("Logger2", pChannel2); + assertTrue (pChannel.get() == root.getChannel().get()); + assertTrue (pChannel.get() == logger1.getChannel().get()); + assertTrue (pChannel.get() == logger11.getChannel().get()); + assertTrue (pChannel.get() == logger12.getChannel().get()); + assertTrue (pChannel2.get() == logger2.getChannel().get()); + assertTrue (pChannel2.get() == logger21.getChannel().get()); + assertTrue (pChannel2.get() == logger22.getChannel().get()); root.setLevel(Message::PRIO_TRACE); pChannel->list().clear(); @@ -191,7 +192,7 @@ void LoggerTest::testFormatAny() { AutoPtr pChannel = new TestChannel; Logger& root = Logger::root(); - root.setChannel(pChannel.get()); + root.setChannel(pChannel); root.error("%s%s", std::string("foo"), std::string("bar")); assertTrue (pChannel->getLastMessage().getText() == "foobar"); @@ -231,6 +232,21 @@ void LoggerTest::testFormatAny() root.error("%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10); assertTrue (pChannel->getLastMessage().getText() == "12345678910"); + + root.error("%d%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); + assertTrue (pChannel->getLastMessage().getText() == "1234567891011"); + + root.error("%d%d%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12); + assertTrue (pChannel->getLastMessage().getText() == "123456789101112"); + + root.error("%d%d%d%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13); + assertTrue (pChannel->getLastMessage().getText() == "12345678910111213"); + + root.error("%d%d%d%d%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14); + assertTrue (pChannel->getLastMessage().getText() == "1234567891011121314"); + + root.error("%d%d%d%d%d%d%d%d%d%d%d%d%d%d%d", 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15); + assertTrue (pChannel->getLastMessage().getText() == "123456789101112131415"); } @@ -238,7 +254,7 @@ void LoggerTest::testDump() { AutoPtr pChannel = new TestChannel; Logger& root = Logger::root(); - root.setChannel(pChannel.get()); + root.setChannel(pChannel); root.setLevel(Message::PRIO_INFORMATION); char buffer1[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05}; diff --git a/Foundation/testsuite/src/LoggingFactoryTest.cpp b/Foundation/testsuite/src/LoggingFactoryTest.cpp index 056f4943a..2cb53b87b 100644 --- a/Foundation/testsuite/src/LoggingFactoryTest.cpp +++ b/Foundation/testsuite/src/LoggingFactoryTest.cpp @@ -18,7 +18,10 @@ #if defined(_WIN32) #include "Poco/WindowsConsoleChannel.h" #endif +#ifndef POCO_NO_FILECHANNEL #include "Poco/FileChannel.h" +#include "Poco/SimpleFileChannel.h" +#endif #include "Poco/SplitterChannel.h" #include "Poco/Formatter.h" #include "Poco/PatternFormatter.h" @@ -31,7 +34,10 @@ using Poco::LoggingFactory; using Poco::Channel; using Poco::ConsoleChannel; +#ifndef POCO_NO_FILECHANNEL using Poco::FileChannel; +using Poco::SimpleFileChannel; +#endif using Poco::SplitterChannel; using Poco::Formatter; using Poco::PatternFormatter; @@ -73,34 +79,39 @@ void LoggingFactoryTest::testBuiltins() { LoggingFactory& fact = LoggingFactory::defaultFactory(); - AutoPtr pConsoleChannel = fact.createChannel("ConsoleChannel"); + Channel::Ptr pConsoleChannel = fact.createChannel("ConsoleChannel"); #if defined(_WIN32) && !defined(_WIN32_WCE) - assertTrue (dynamic_cast(pConsoleChannel.get()) != 0); + assertTrue (!pConsoleChannel.cast().isNull()); #else - assertTrue (dynamic_cast(pConsoleChannel.get()) != 0); + assertTrue (!pConsoleChannel.cast().isNull()); #endif - AutoPtr pFileChannel = fact.createChannel("FileChannel"); - assertTrue (dynamic_cast(pFileChannel.get()) != 0); +#ifndef POCO_NO_FILECHANNEL + Channel::Ptr pFileChannel = fact.createChannel("FileChannel"); + assertTrue (!pFileChannel.cast().isNull()); - AutoPtr pSplitterChannel = fact.createChannel("SplitterChannel"); - assertTrue (dynamic_cast(pSplitterChannel.get()) != 0); + Channel::Ptr pSimpleFileChannel = fact.createChannel("SimpleFileChannel"); + assertTrue(!pSimpleFileChannel.cast().isNull()); +#endif + + Channel::Ptr pSplitterChannel = fact.createChannel("SplitterChannel"); + assertTrue (!pSplitterChannel.cast().isNull()); try { - AutoPtr pUnknownChannel = fact.createChannel("UnknownChannel"); + Channel::Ptr pUnknownChannel = fact.createChannel("UnknownChannel"); fail("unknown class - must throw"); } catch (Poco::NotFoundException&) { } - AutoPtr pPatternFormatter = fact.createFormatter("PatternFormatter"); - assertTrue (dynamic_cast(pPatternFormatter.get()) != 0); + Formatter::Ptr pPatternFormatter = fact.createFormatter("PatternFormatter"); + assertTrue (!pPatternFormatter.isNull()); try { - AutoPtr pUnknownFormatter = fact.createFormatter("UnknownFormatter"); + Formatter::Ptr pUnknownFormatter = fact.createFormatter("UnknownFormatter"); fail("unknown class - must throw"); } catch (Poco::NotFoundException&) @@ -116,11 +127,11 @@ void LoggingFactoryTest::testCustom() fact->registerChannelClass("CustomChannel", new Instantiator); fact->registerFormatterClass("CustomFormatter", new Instantiator); - AutoPtr pCustomChannel = fact->createChannel("CustomChannel"); + Channel::Ptr pCustomChannel = fact->createChannel("CustomChannel"); assertTrue (dynamic_cast(pCustomChannel.get()) != 0); - AutoPtr pCustomFormatter = fact->createFormatter("CustomFormatter"); - assertTrue (dynamic_cast(pCustomFormatter.get()) != 0); + Formatter::Ptr pCustomFormatter = fact->createFormatter("CustomFormatter"); + assertTrue (!pCustomFormatter.isNull()); } diff --git a/Foundation/testsuite/src/LoggingRegistryTest.cpp b/Foundation/testsuite/src/LoggingRegistryTest.cpp index e32bdf1e9..5356901b1 100644 --- a/Foundation/testsuite/src/LoggingRegistryTest.cpp +++ b/Foundation/testsuite/src/LoggingRegistryTest.cpp @@ -41,17 +41,17 @@ void LoggingRegistryTest::testRegister() reg.clear(); - AutoPtr pC1 = new ConsoleChannel(); - AutoPtr pC2 = new ConsoleChannel(); - AutoPtr pF1 = new PatternFormatter(""); - AutoPtr pF2 = new PatternFormatter(""); + Channel::Ptr pC1 = new ConsoleChannel(); + Channel::Ptr pC2 = new ConsoleChannel(); + Formatter::Ptr pF1 = new PatternFormatter(""); + Formatter::Ptr pF2 = new PatternFormatter(""); reg.registerChannel("c1", pC1); reg.registerChannel("c2", pC2); reg.registerFormatter("f1", pF1); reg.registerFormatter("f2", pF2); - Channel* pC = reg.channelForName("c1"); + Channel::Ptr pC = reg.channelForName("c1"); assertTrue (pC1 == pC); pC = reg.channelForName("c2"); assertTrue (pC2 == pC); @@ -78,9 +78,9 @@ void LoggingRegistryTest::testReregister() reg.clear(); - AutoPtr pC1 = new ConsoleChannel(); - AutoPtr pC2 = new ConsoleChannel(); - AutoPtr pC1b = new ConsoleChannel(); + Channel::Ptr pC1 = new ConsoleChannel(); + Channel::Ptr pC2 = new ConsoleChannel(); + Channel::Ptr pC1b = new ConsoleChannel(); AutoPtr pF1 = new PatternFormatter(""); AutoPtr pF2 = new PatternFormatter(""); AutoPtr pF1b = new PatternFormatter(""); @@ -91,17 +91,19 @@ void LoggingRegistryTest::testReregister() reg.registerFormatter("f2", pF2); reg.registerChannel("c1", pC1b); - Channel* pC = reg.channelForName("c1"); + + Channel::Ptr pC = reg.channelForName("c1"); assertTrue (pC1b == pC); + pC = reg.channelForName("c2"); assertTrue (pC2 == pC); reg.registerFormatter("f1", pF1b); - Formatter* pF = reg.formatterForName("f1"); + + Formatter::Ptr pF = reg.formatterForName("f1"); assertTrue (pF1b == pF); pF = reg.formatterForName("f2"); assertTrue (pF2 == pF); - } @@ -111,8 +113,8 @@ void LoggingRegistryTest::testUnregister() reg.clear(); - AutoPtr pC1 = new ConsoleChannel(); - AutoPtr pC2 = new ConsoleChannel(); + Channel::Ptr pC1 = new ConsoleChannel(); + Channel::Ptr pC2 = new ConsoleChannel(); AutoPtr pF1 = new PatternFormatter(""); AutoPtr pF2 = new PatternFormatter(""); @@ -126,7 +128,7 @@ void LoggingRegistryTest::testUnregister() try { - Channel* POCO_UNUSED pC = reg.channelForName("c1"); + Channel::Ptr pC = reg.channelForName("c1"); fail("unregistered - must throw"); } catch (Poco::NotFoundException&) @@ -135,7 +137,7 @@ void LoggingRegistryTest::testUnregister() try { - Formatter* POCO_UNUSED pF = reg.formatterForName("f2"); + Formatter::Ptr pF = reg.formatterForName("f2"); fail("unregistered - must throw"); } catch (Poco::NotFoundException&) diff --git a/Foundation/testsuite/src/OrderedContainersTest.cpp b/Foundation/testsuite/src/OrderedContainersTest.cpp index 271b438ea..9f0fdf449 100644 --- a/Foundation/testsuite/src/OrderedContainersTest.cpp +++ b/Foundation/testsuite/src/OrderedContainersTest.cpp @@ -9,9 +9,6 @@ #include "OrderedContainersTest.h" - -#ifdef POCO_ENABLE_CPP11 - #include "Poco/CppUnit/TestCaller.h" #include "Poco/CppUnit/TestSuite.h" #include "Poco/Exception.h" @@ -22,6 +19,7 @@ #pragma warning(disable : 4267) #endif // POCO_COMPILER_MSVC + using Poco::OrderedMap; using Poco::OrderedSet; using Poco::Exception; @@ -1120,5 +1118,3 @@ CppUnit::Test* OrderedContainersTest::suite() #ifdef POCO_COMPILER_MSVC #pragma warning(pop) #endif // POCO_COMPILER_MSVC - -#endif // POCO_ENABLE_CPP11 diff --git a/Foundation/testsuite/src/OrderedContainersTest.h b/Foundation/testsuite/src/OrderedContainersTest.h index ea89bfd3e..5fb2ac6fe 100644 --- a/Foundation/testsuite/src/OrderedContainersTest.h +++ b/Foundation/testsuite/src/OrderedContainersTest.h @@ -12,9 +12,6 @@ #include "Poco/Foundation.h" - -#ifdef POCO_ENABLE_CPP11 - #include "Poco/CppUnit/TestCase.h" #include "Poco/OrderedMap.h" #include "Poco/OrderedSet.h" @@ -335,6 +332,5 @@ private: #pragma warning(pop) #endif // POCO_COMPILER_MSVC -#endif // POCO_ENABLE_CPP11 #endif // OrderedContainersTest_INCLUDED diff --git a/Foundation/testsuite/src/StringTest.cpp b/Foundation/testsuite/src/StringTest.cpp index ff3986fbb..603a89192 100644 --- a/Foundation/testsuite/src/StringTest.cpp +++ b/Foundation/testsuite/src/StringTest.cpp @@ -1265,7 +1265,6 @@ void StringTest::testNumericStringLimit() numericStringLowerLimit(); } -#ifdef POCO_ENABLE_CPP11 assertTrue(!isIntOverflow(0)); assertTrue(isIntOverflow(std::numeric_limits::max())); assertTrue(isIntOverflow(std::numeric_limits::min())); @@ -1295,7 +1294,6 @@ void StringTest::testNumericStringLimit() numericStringLowerLimit(); numericStringLowerLimit(); numericStringLowerLimit(); -#endif } diff --git a/Foundation/testsuite/src/VarTest.cpp b/Foundation/testsuite/src/VarTest.cpp index 2124dd257..f54989e5d 100644 --- a/Foundation/testsuite/src/VarTest.cpp +++ b/Foundation/testsuite/src/VarTest.cpp @@ -2257,7 +2257,6 @@ void VarTest::testDynamicStructBasics() void VarTest::testOrderedDynamicStructBasics() { -#ifdef POCO_ENABLE_CPP11 OrderedDynamicStruct aStruct; assertTrue(aStruct.empty()); assertTrue(aStruct.size() == 0); @@ -2279,7 +2278,6 @@ void VarTest::testOrderedDynamicStructBasics() assertTrue(*(aStruct.members().begin()) == "Last Name"); aStruct.clear(); assertTrue(aStruct.size() == 0); -#endif // POCO_ENABLE_CPP11 } @@ -2319,7 +2317,6 @@ void VarTest::testDynamicStructString() void VarTest::testOrderedDynamicStructString() { -#ifdef POCO_ENABLE_CPP11 OrderedDynamicStruct aStruct; aStruct["First Name"] = "Junior"; aStruct["Last Name"] = "POCO"; @@ -2352,7 +2349,6 @@ void VarTest::testOrderedDynamicStructString() assertTrue(m2["1"] == 1); assertTrue(m2["2"] == 2); assertTrue(m2["3"] == 3); -#endif // POCO_ENABLE_CPP11 } @@ -2393,7 +2389,6 @@ void VarTest::testDynamicStructInt() void VarTest::testOrderedDynamicStructInt() { -#ifdef POCO_ENABLE_CPP11 typedef Struct, OrderedSet > OrderedStruct; OrderedStruct aStruct; aStruct[0] = "POCO"; @@ -2428,7 +2423,6 @@ void VarTest::testOrderedDynamicStructInt() assertTrue(m2[1] == "2"); assertTrue(m2[2] == "1"); assertTrue(m2[3] == "3"); -#endif // POCO_ENABLE_CPP11 } @@ -2523,7 +2517,6 @@ void VarTest::testStructToString() void VarTest::testOrderedStructToString() { -#ifdef POCO_ENABLE_CPP11 OrderedDynamicStruct aStruct; aStruct["First Name"] = "Junior"; aStruct["Last Name"] = "POCO"; @@ -2533,7 +2526,6 @@ void VarTest::testOrderedStructToString() std::string expected = "{ \"First Name\" : \"Junior\", \"Last Name\" : \"POCO\", \"Age\" : 1 }"; assertTrue(res == expected); assertTrue(aStruct.toString() == res); -#endif // POCO_ENABLE_CPP11 } diff --git a/JSON/include/Poco/JSON/Array.h b/JSON/include/Poco/JSON/Array.h index 0c42fe985..507f2ead4 100644 --- a/JSON/include/Poco/JSON/Array.h +++ b/JSON/include/Poco/JSON/Array.h @@ -58,10 +58,10 @@ class JSON_API Array /// ---- { public: - typedef std::vector ValueVec; - typedef std::vector::iterator Iterator; - typedef std::vector::const_iterator ConstIterator; - typedef SharedPtr Ptr; + using ValueVec = std::vector; + using Iterator = std::vector::iterator; + using ConstIterator = std::vector::const_iterator; + using Ptr = SharedPtr; Array(int options = 0); /// Creates an empty Array. @@ -73,16 +73,12 @@ public: Array(const Array& copy); /// Creates an Array by copying another one. -#ifdef POCO_ENABLE_CPP11 - Array(Array&& other); /// Move constructor Array& operator=(Array&& other); /// Move assignment operator. -#endif // POCO_ENABLE_CPP11 - Array& operator=(const Array& other); /// Assignment operator. diff --git a/JSON/include/Poco/JSON/Handler.h b/JSON/include/Poco/JSON/Handler.h index 8c64f34ff..327060fe6 100644 --- a/JSON/include/Poco/JSON/Handler.h +++ b/JSON/include/Poco/JSON/Handler.h @@ -36,7 +36,7 @@ class JSON_API Handler /// parser would handle XML. { public: - typedef SharedPtr Ptr; + using Ptr = SharedPtr; Handler(); /// Creates an empty Handler. diff --git a/JSON/include/Poco/JSON/Object.h b/JSON/include/Poco/JSON/Object.h index 925d45d56..60837cf05 100644 --- a/JSON/include/Poco/JSON/Object.h +++ b/JSON/include/Poco/JSON/Object.h @@ -60,12 +60,12 @@ class JSON_API Object /// { public: - typedef SharedPtr Ptr; - typedef std::map ValueMap; - typedef ValueMap::value_type ValueType; - typedef ValueMap::iterator Iterator; - typedef ValueMap::const_iterator ConstIterator; - typedef std::vector NameList; + using Ptr = SharedPtr; + using ValueMap = std::map; + using ValueType = ValueMap::value_type; + using Iterator = ValueMap::iterator; + using ConstIterator = ValueMap::const_iterator; + using NameList = std::vector; explicit Object(int options = 0); /// Creates an empty Object. @@ -84,16 +84,12 @@ public: /// Struct is not copied to keep the operation as /// efficient as possible (when needed, it will be generated upon request). -#ifdef POCO_ENABLE_CPP11 - Object(Object&& other); /// Move constructor Object &operator =(Object &&other); // Move asignment operator -#endif // POCO_ENABLE_CPP11 - virtual ~Object(); /// Destroys the Object. @@ -224,16 +220,12 @@ public: static Poco::DynamicStruct makeStruct(const Object::Ptr& obj); /// Utility function for creation of struct. -#ifdef POCO_ENABLE_CPP11 - static Poco::OrderedDynamicStruct makeOrderedStruct(const Object::Ptr& obj); /// Utility function for creation of ordered struct. operator const Poco::OrderedDynamicStruct& () const; /// Cast operator to Poco::OrderedDynamiStruct. -#endif // POCO_ENABLE_CPP11 - operator const Poco::DynamicStruct& () const; /// Cast operator to Poco::DynamiStruct. @@ -245,9 +237,7 @@ public: private: typedef std::deque KeyList; typedef Poco::DynamicStruct::Ptr StructPtr; -#ifdef POCO_ENABLE_CPP11 typedef Poco::OrderedDynamicStruct::Ptr OrdStructPtr; -#endif // POCO_ENABLE_CPP11 void syncKeys(const KeyList& keys); @@ -360,9 +350,7 @@ private: // so it must know whether to escape unicode or not. bool _escapeUnicode; mutable StructPtr _pStruct; -#ifdef POCO_ENABLE_CPP11 mutable OrdStructPtr _pOrdStruct; -#endif // POCO_ENABLE_CPP11 mutable bool _modified; }; diff --git a/JSON/include/Poco/JSON/PrintHandler.h b/JSON/include/Poco/JSON/PrintHandler.h index 620dc52a9..291c8979a 100644 --- a/JSON/include/Poco/JSON/PrintHandler.h +++ b/JSON/include/Poco/JSON/PrintHandler.h @@ -34,7 +34,7 @@ class JSON_API PrintHandler: public Handler /// otherwise, the proper indentation is applied to elements. { public: - typedef SharedPtr Ptr; + using Ptr = SharedPtr; static const unsigned JSON_PRINT_FLAT = 0; diff --git a/JSON/include/Poco/JSON/Template.h b/JSON/include/Poco/JSON/Template.h index 7e8ac51e0..37f0ef0d0 100644 --- a/JSON/include/Poco/JSON/Template.h +++ b/JSON/include/Poco/JSON/Template.h @@ -87,7 +87,7 @@ class JSON_API Template /// A query is passed to Poco::JSON::Query to get the value. { public: - typedef SharedPtr