From dcabc2befc0e392b2a3e217a1e9481d613f4e5ad Mon Sep 17 00:00:00 2001 From: Guenter Obiltschnig Date: Fri, 4 May 2007 11:04:40 +0000 Subject: [PATCH] latest changes from main rep --- Foundation/Foundation_vs71.vcproj | 12 + Foundation/Foundation_vs80.vcproj | 16 ++ Foundation/Makefile | 4 +- Foundation/include/Poco/ExpireStrategy.h | 4 +- Foundation/include/Poco/Format.h | 4 +- Foundation/include/Poco/HMACEngine.h | 16 +- Foundation/include/Poco/NamedTuple.h | 2 +- Foundation/include/Poco/NumberFormatter.h | 8 +- Foundation/include/Poco/Platform_WIN32.h | 6 +- Foundation/include/Poco/String.h | 48 ++-- Foundation/include/Poco/TextConverter.h | 23 +- Foundation/include/Poco/Timestamp.h | 14 +- Foundation/include/Poco/UTF8String.h | 80 +++++++ Foundation/include/Poco/Unicode.h | 216 ++++++++++++++++++ Foundation/src/BinaryWriter.cpp | 5 +- Foundation/src/DateTime.cpp | 38 +-- Foundation/src/DateTimeParser.cpp | 48 ++-- Foundation/src/Debugger.cpp | 14 +- Foundation/src/DirectoryIterator_WIN32U.cpp | 4 +- Foundation/src/DynamicAny.cpp | 3 +- Foundation/src/Environment_WIN32U.cpp | 4 +- Foundation/src/File.cpp | 2 +- Foundation/src/FileChannel.cpp | 26 +-- Foundation/src/File_UNIX.cpp | 5 +- Foundation/src/MD2Engine.cpp | 20 +- Foundation/src/MD4Engine.cpp | 14 +- Foundation/src/MD5Engine.cpp | 14 +- Foundation/src/NumberFormatter.cpp | 78 +++---- Foundation/src/NumberParser.cpp | 20 +- Foundation/src/Path_UNIX.cpp | 10 +- Foundation/src/Process_UNIX.cpp | 6 +- Foundation/src/Random.cpp | 6 +- Foundation/src/RandomStream.cpp | 6 +- Foundation/src/SHA1Engine.cpp | 12 +- Foundation/src/SimpleFileChannel.cpp | 12 +- Foundation/src/String.cpp | 14 +- Foundation/src/StringTokenizer.cpp | 11 +- Foundation/src/TextConverter.cpp | 28 ++- Foundation/src/ThreadPool.cpp | 8 +- Foundation/src/Timestamp.cpp | 5 +- Foundation/src/Timezone.cpp | 4 +- Foundation/src/Timezone_UNIX.cpp | 18 +- Foundation/src/Timezone_WIN32.cpp | 8 +- Foundation/src/Token.cpp | 8 +- Foundation/src/UTF8String.cpp | 203 ++++++++++++++++ Foundation/src/UUID.cpp | 44 ++-- Foundation/src/UUIDGenerator.cpp | 16 +- Foundation/src/Unicode.cpp | 94 ++++++++ Foundation/src/UnicodeConverter.cpp | 6 +- Foundation/testsuite/Makefile-Driver | 4 +- Foundation/testsuite/TestSuite_vs71.vcproj | 6 + Foundation/testsuite/TestSuite_vs80.vcproj | 8 + .../testsuite/src/LoggingFactoryTest.cpp | 11 +- Foundation/testsuite/src/NamedTuplesTest.cpp | 2 +- Foundation/testsuite/src/RandomStreamTest.cpp | 6 +- Foundation/testsuite/src/RandomTest.cpp | 8 +- .../testsuite/src/StreamTokenizerTest.cpp | 12 +- Foundation/testsuite/src/TextTestSuite.cpp | 4 +- Foundation/testsuite/src/UTF8StringTest.cpp | 122 ++++++++++ Foundation/testsuite/src/UTF8StringTest.h | 61 +++++ 60 files changed, 1183 insertions(+), 328 deletions(-) create mode 100644 Foundation/include/Poco/UTF8String.h create mode 100644 Foundation/include/Poco/Unicode.h create mode 100644 Foundation/src/UTF8String.cpp create mode 100644 Foundation/src/Unicode.cpp create mode 100644 Foundation/testsuite/src/UTF8StringTest.cpp create mode 100644 Foundation/testsuite/src/UTF8StringTest.h diff --git a/Foundation/Foundation_vs71.vcproj b/Foundation/Foundation_vs71.vcproj index 396a3481d..9f71f930d 100644 --- a/Foundation/Foundation_vs71.vcproj +++ b/Foundation/Foundation_vs71.vcproj @@ -3326,6 +3326,9 @@ + + @@ -3335,6 +3338,9 @@ + + @@ -3363,6 +3369,9 @@ + + @@ -3372,6 +3381,9 @@ + + diff --git a/Foundation/Foundation_vs80.vcproj b/Foundation/Foundation_vs80.vcproj index d05309c7b..2993a27fc 100644 --- a/Foundation/Foundation_vs80.vcproj +++ b/Foundation/Foundation_vs80.vcproj @@ -4335,6 +4335,10 @@ RelativePath=".\src\TextIterator.cpp" > + + @@ -4347,6 +4351,10 @@ RelativePath=".\src\UTF8Encoding.cpp" > + + @@ -4383,6 +4391,10 @@ RelativePath=".\include\Poco\TextIterator.h" > + + @@ -4395,6 +4407,10 @@ RelativePath=".\include\Poco\UTF8Encoding.h" > + + diff --git a/Foundation/Makefile b/Foundation/Makefile index 70938afa9..0a8f15168 100644 --- a/Foundation/Makefile +++ b/Foundation/Makefile @@ -1,7 +1,7 @@ # # Makefile # -# $Id: //poco/Main/Foundation/Makefile#42 $ +# $Id: //poco/Main/Foundation/Makefile#43 $ # # Makefile for Poco Foundation # @@ -30,7 +30,7 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder FileStreamFactory URIStreamFactory URIStreamOpener UTF16Encoding Windows1252Encoding \ UTF8Encoding UnicodeConverter UUID UUIDGenerator Void Format \ Pipe PipeImpl PipeStream DynamicAny DynamicAnyHolder SharedMemory \ - FileStream \ + FileStream Unicode UTF8String \ adler32 compress crc32 deflate gzio infback inffast inflate inftrees \ trees zutil \ pcre_chartables pcre_compile pcre_globals pcre_maketables pcre_study \ diff --git a/Foundation/include/Poco/ExpireStrategy.h b/Foundation/include/Poco/ExpireStrategy.h index b330389f1..bdb4803b6 100644 --- a/Foundation/include/Poco/ExpireStrategy.h +++ b/Foundation/include/Poco/ExpireStrategy.h @@ -1,7 +1,7 @@ // // ExpireStrategy.h // -// $Id: //poco/Main/Foundation/include/Poco/ExpireStrategy.h#5 $ +// $Id: //poco/Main/Foundation/include/Poco/ExpireStrategy.h#6 $ // // Library: Foundation // Package: Cache @@ -82,7 +82,7 @@ public: void onAdd(const void*, const KeyValueArgs & args) { Timestamp now; - IndexIterator it = _keyIndex.insert(std::make_pair(now, args.key())); + IndexIterator it = _keyIndex.insert(TimeIndex::value_type(now, args.key())); std::pair stat = _keys.insert(std::make_pair(args.key(), it)); if (!stat.second) { diff --git a/Foundation/include/Poco/Format.h b/Foundation/include/Poco/Format.h index 690e11a2f..ec9755772 100644 --- a/Foundation/include/Poco/Format.h +++ b/Foundation/include/Poco/Format.h @@ -1,7 +1,7 @@ // // Format.h // -// $Id: //poco/Main/Foundation/include/Poco/Format.h#4 $ +// $Id: //poco/Main/Foundation/include/Poco/Format.h#5 $ // // Library: Foundation // Package: Core @@ -67,7 +67,7 @@ std::string Foundation_API format(const std::string& fmt, const Any& value); /// different number of arguments (up to six). /// /// The formatting is controlled by the format string in fmt. - /// Format strings are quite similar to those of the printf() function, but + /// Format strings are quite similar to those of the std::printf() function, but /// there are some minor differences. /// /// The format string can consist of any sequence of characters; certain diff --git a/Foundation/include/Poco/HMACEngine.h b/Foundation/include/Poco/HMACEngine.h index ca7e0882b..f9e043fd4 100644 --- a/Foundation/include/Poco/HMACEngine.h +++ b/Foundation/include/Poco/HMACEngine.h @@ -1,7 +1,7 @@ // // HMACEngine.h // -// $Id: //poco/Main/Foundation/include/Poco/HMACEngine.h#2 $ +// $Id: //poco/Main/Foundation/include/Poco/HMACEngine.h#3 $ // // Library: Foundation // Package: Crypt @@ -42,7 +42,7 @@ #include "Poco/Foundation.h" #include "Poco/DigestEngine.h" -#include +#include namespace Poco { @@ -80,8 +80,8 @@ public: ~HMACEngine() { - memset(_ipad, 0, BLOCK_SIZE); - memset(_opad, 0, BLOCK_SIZE); + std::memset(_ipad, 0, BLOCK_SIZE); + std::memset(_opad, 0, BLOCK_SIZE); delete [] _ipad; delete [] _opad; } @@ -117,8 +117,8 @@ protected: { _ipad = new char[BLOCK_SIZE]; _opad = new char[BLOCK_SIZE]; - memset(_ipad, 0, BLOCK_SIZE); - memset(_opad, 0, BLOCK_SIZE); + std::memset(_ipad, 0, BLOCK_SIZE); + std::memset(_opad, 0, BLOCK_SIZE); if (length > BLOCK_SIZE) { _engine.reset(); @@ -135,8 +135,8 @@ protected: } else { - memcpy(_ipad, passphrase, length); - memcpy(_opad, passphrase, length); + std::memcpy(_ipad, passphrase, length); + std::memcpy(_opad, passphrase, length); } for (int i = 0; i < BLOCK_SIZE; ++i) { diff --git a/Foundation/include/Poco/NamedTuple.h b/Foundation/include/Poco/NamedTuple.h index 6ca562d0e..17fea7dec 100644 --- a/Foundation/include/Poco/NamedTuple.h +++ b/Foundation/include/Poco/NamedTuple.h @@ -1,7 +1,7 @@ // // NamedTuple.h // -// $Id: //poco/Main/Foundation/include/Poco/NamedTuple.h#1 $ +// $Id: //poco/Main/Foundation/include/Poco/NamedTuple.h#2 $ // // Library: Foundation // Package: Core diff --git a/Foundation/include/Poco/NumberFormatter.h b/Foundation/include/Poco/NumberFormatter.h index 0d918b11d..1c80bb861 100644 --- a/Foundation/include/Poco/NumberFormatter.h +++ b/Foundation/include/Poco/NumberFormatter.h @@ -1,7 +1,7 @@ // // NumberFormatter.h // -// $Id: //poco/Main/Foundation/include/Poco/NumberFormatter.h#2 $ +// $Id: //poco/Main/Foundation/include/Poco/NumberFormatter.h#3 $ // // Library: Foundation // Package: Core @@ -187,15 +187,15 @@ public: static std::string format(float value); /// Formats a float value in decimal floating-point notation, - /// according to printf's %g format with a precision of 8 fractional digits. + /// according to std::printf's %g format with a precision of 8 fractional digits. static std::string format(double value); /// Formats a double value in decimal floating-point notation, - /// according to printf's %g format with a precision of 16 fractional digits. + /// according to std::printf's %g format with a precision of 16 fractional digits. static std::string format(double value, int precision); /// Formats a double value in decimal floating-point notation, - /// according to printf's %f format with the given precision. + /// according to std::printf's %f format with the given precision. static std::string format(double value, int width, int precision); /// Formats a double value in decimal floating-point notation, diff --git a/Foundation/include/Poco/Platform_WIN32.h b/Foundation/include/Poco/Platform_WIN32.h index 7c9e7a6c7..67de8b2d2 100644 --- a/Foundation/include/Poco/Platform_WIN32.h +++ b/Foundation/include/Poco/Platform_WIN32.h @@ -1,7 +1,7 @@ // // Platform_WIN32.h // -// $Id: //poco/Main/Foundation/include/Poco/Platform_WIN32.h#4 $ +// $Id: //poco/Main/Foundation/include/Poco/Platform_WIN32.h#6 $ // // Library: Foundation // Package: Core @@ -10,7 +10,7 @@ // Platform and architecture identification macros // and platform-specific definitions for Windows. // -// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. +// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH. // and Contributors. // // Permission is hereby granted, free of charge, to any person or organization @@ -77,6 +77,8 @@ #pragma warning(disable:4251) // ... needs to have dll-interface warning #pragma warning(disable:4355) // 'this' : used in base member initializer list #pragma warning(disable:4996) // VC++ 8.0 deprecation warnings + #pragma warning(disable:4351) // new behavior: elements of array '...' will be default initialized + #pragma warning(disable:4675) // resolved overload was found by argument-dependent lookup #endif diff --git a/Foundation/include/Poco/String.h b/Foundation/include/Poco/String.h index a23eda7fa..53b130752 100644 --- a/Foundation/include/Poco/String.h +++ b/Foundation/include/Poco/String.h @@ -1,7 +1,7 @@ // // String.h // -// $Id: //poco/Main/Foundation/include/Poco/String.h#6 $ +// $Id: //poco/Main/Foundation/include/Poco/String.h#7 $ // // Library: Foundation // Package: Core @@ -42,7 +42,7 @@ #include "Poco/Foundation.h" #include -#include +#include namespace Poco { @@ -53,11 +53,10 @@ S trimLeft(const S& str) /// Returns a copy of str with all leading /// whitespace removed. { - std::locale loc; typename S::const_iterator it = str.begin(); typename S::const_iterator end = str.end(); - while (it != end && isspace(*it, loc)) ++it; + while (it != end && std::isspace(*it)) ++it; return S(it, end); } @@ -66,11 +65,10 @@ template S& trimLeftInPlace(S& str) /// Removes all leading whitespace in str. { - std::locale loc; typename S::iterator it = str.begin(); typename S::iterator end = str.end(); - while (it != end && isspace(*it, loc)) ++it; + while (it != end && std::isspace(*it)) ++it; str.erase(str.begin(), it); return str; } @@ -81,10 +79,9 @@ S trimRight(const S& str) /// Returns a copy of str with all trailing /// whitespace removed. { - std::locale loc; int pos = int(str.size()) - 1; - while (pos >= 0 && isspace(str[pos], loc)) --pos; + while (pos >= 0 && std::isspace(str[pos])) --pos; return S(str, 0, pos + 1); } @@ -93,10 +90,9 @@ template S& trimRightInPlace(S& str) /// Removes all trailing whitespace in str. { - std::locale loc; int pos = int(str.size()) - 1; - while (pos >= 0 && isspace(str[pos], loc)) --pos; + while (pos >= 0 && std::isspace(str[pos])) --pos; str.resize(pos + 1); return str; @@ -108,12 +104,11 @@ S trim(const S& str) /// Returns a copy of str with all leading and /// trailing whitespace removed. { - std::locale loc; int first = 0; int last = int(str.size()) - 1; - while (first <= last && isspace(str[first], loc)) ++first; - while (last >= first && isspace(str[last], loc)) --last; + while (first <= last && std::isspace(str[first])) ++first; + while (last >= first && std::isspace(str[last])) --last; return S(str, first, last - first + 1); } @@ -123,12 +118,11 @@ template S& trimInPlace(S& str) /// Removes all leading and trailing whitespace in str. { - std::locale loc; int first = 0; int last = int(str.size()) - 1; - while (first <= last && isspace(str[first], loc)) ++first; - while (last >= first && isspace(str[last], loc)) --last; + while (first <= last && std::isspace(str[first])) ++first; + while (last >= first && std::isspace(str[last])) --last; str.resize(last + 1); str.erase(0, first); @@ -141,13 +135,12 @@ template S toUpper(const S& str) /// Returns a copy of str containing all upper-case characters. { - std::locale loc; typename S::const_iterator it = str.begin(); typename S::const_iterator end = str.end(); S result; result.reserve(str.size()); - while (it != end) result += toupper(*it++, loc); + while (it != end) result += std::toupper(*it++); return result; } @@ -156,11 +149,10 @@ template S& toUpperInPlace(S& str) /// Replaces all characters in str with their upper-case counterparts. { - std::locale loc; typename S::iterator it = str.begin(); typename S::iterator end = str.end(); - while (it != end) { *it = toupper(*it, loc); ++it; } + while (it != end) { *it = std::toupper(*it); ++it; } return str; } @@ -169,13 +161,12 @@ template S toLower(const S& str) /// Returns a copy of str containing all lower-case characters. { - std::locale loc; typename S::const_iterator it = str.begin(); typename S::const_iterator end = str.end(); S result; result.reserve(str.size()); - while (it != end) result += tolower(*it++, loc); + while (it != end) result += std::tolower(*it++); return result; } @@ -184,11 +175,10 @@ template S& toLowerInPlace(S& str) /// Replaces all characters in str with their lower-case counterparts. { - std::locale loc; typename S::iterator it = str.begin(); typename S::iterator end = str.end(); - while (it != end) { *it = tolower(*it, loc); ++it; } + while (it != end) { *it = std::tolower(*it); ++it; } return str; } @@ -210,11 +200,10 @@ int icompare( if (pos + n > sz) n = sz - pos; It it1 = str.begin() + pos; It end1 = str.begin() + pos + n; - std::locale loc; while (it1 != end1 && it2 != end2) { - typename S::value_type c1 = tolower(*it1, loc); - typename S::value_type c2 = tolower(*it2, loc); + typename S::value_type c1 = std::tolower(*it1); + typename S::value_type c2 = std::tolower(*it2); if (c1 < c2) return -1; else if (c1 > c2) @@ -303,11 +292,10 @@ int icompare( if (pos + n > sz) n = sz - pos; typename S::const_iterator it = str.begin() + pos; typename S::const_iterator end = str.begin() + pos + n; - std::locale loc; while (it != end && *ptr) { - typename S::value_type c1 = tolower(*it, loc); - typename S::value_type c2 = tolower(*ptr, loc); + typename S::value_type c1 = std::tolower(*it); + typename S::value_type c2 = std::tolower(*ptr); if (c1 < c2) return -1; else if (c1 > c2) diff --git a/Foundation/include/Poco/TextConverter.h b/Foundation/include/Poco/TextConverter.h index bd1c49866..97c5b6932 100644 --- a/Foundation/include/Poco/TextConverter.h +++ b/Foundation/include/Poco/TextConverter.h @@ -1,7 +1,7 @@ // // TextConverter.h // -// $Id: //poco/Main/Foundation/include/Poco/TextConverter.h#2 $ +// $Id: //poco/Main/Foundation/include/Poco/TextConverter.h#3 $ // // Library: Foundation // Package: Text @@ -54,6 +54,9 @@ class Foundation_API TextConverter /// into another. { public: + typedef int (*Transform)(int); + /// Transform function for convert. + TextConverter(const TextEncoding& inEncoding, const TextEncoding& outEncoding, int defaultChar = '?'); /// Creates the TextConverter. The encoding objects must not be deleted while the /// TextConverter is in use. @@ -61,6 +64,24 @@ public: ~TextConverter(); /// Destroys the TextConverter. + int convert(const std::string& source, std::string& destination, Transform trans); + /// Converts the source string from inEncoding to outEncoding + /// and appends the result to destination. Every character is + /// passed to the transform function. + /// If a character cannot be represented in outEncoding, defaultChar + /// is used instead. + /// Returns the number of encoding errors (invalid byte sequences + /// in source). + + int convert(const void* source, int length, std::string& destination, Transform trans); + /// Converts the source buffer from inEncoding to outEncoding + /// and appends the result to destination. Every character is + /// passed to the transform function. + /// If a character cannot be represented in outEncoding, defaultChar + /// is used instead. + /// Returns the number of encoding errors (invalid byte sequences + /// in source). + int convert(const std::string& source, std::string& destination); /// Converts the source string from inEncoding to outEncoding /// and appends the result to destination. diff --git a/Foundation/include/Poco/Timestamp.h b/Foundation/include/Poco/Timestamp.h index bee2d95e4..ad6c646a8 100644 --- a/Foundation/include/Poco/Timestamp.h +++ b/Foundation/include/Poco/Timestamp.h @@ -1,7 +1,7 @@ // // Timestamp.h // -// $Id: //poco/Main/Foundation/include/Poco/Timestamp.h#3 $ +// $Id: //poco/Main/Foundation/include/Poco/Timestamp.h#4 $ // // Library: Foundation // Package: DateTime @@ -41,7 +41,7 @@ #include "Poco/Foundation.h" -#include +#include namespace Poco { @@ -95,7 +95,7 @@ public: Timestamp& operator += (TimeDiff d); Timestamp& operator -= (TimeDiff d); - time_t epochTime() const; + std::time_t epochTime() const; /// Returns the timestamp expressed in time_t. /// time_t base time is midnight, January 1, 1970. /// Resolution is one second. @@ -117,8 +117,8 @@ public: /// Returns true iff the given interval has passed /// since the time denoted by the timestamp. - static Timestamp fromEpochTime(time_t t); - /// Creates a timestamp from a time_t. + static Timestamp fromEpochTime(std::time_t t); + /// Creates a timestamp from a std::time_t. static Timestamp fromUtcTime(UtcTimeVal val); /// Creates a timestamp from a UTC time value. @@ -209,9 +209,9 @@ inline Timestamp& Timestamp::operator -= (Timestamp::TimeDiff d) } -inline time_t Timestamp::epochTime() const +inline std::time_t Timestamp::epochTime() const { - return time_t(_ts/resolution()); + return std::time_t(_ts/resolution()); } diff --git a/Foundation/include/Poco/UTF8String.h b/Foundation/include/Poco/UTF8String.h new file mode 100644 index 000000000..df55597cf --- /dev/null +++ b/Foundation/include/Poco/UTF8String.h @@ -0,0 +1,80 @@ +// +// UTF8String.h +// +// $Id: //poco/Main/Foundation/include/Poco/UTF8String.h#1 $ +// +// Library: Foundation +// Package: Text +// Module: UTF8String +// +// Definition of the UTF8 string functions. +// +// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// + + +#ifndef Foundation_UTF8String_INCLUDED +#define Foundation_UTF8String_INCLUDED + + +#include "Poco/Foundation.h" + + +namespace Poco { + + +struct Foundation_API UTF8 + /// This class provides static methods that are UTF-8 capable variants + /// of the same functions in Poco/String.h. + /// + /// The various variants of icompare() provide case insensitive comparison + /// for UTF-8 encoded strings. + /// + /// toUppwer(), toUpperInPlace(), toLower() and toLowerInPlace() provide + /// Unicode-based character case transformation for UTF-8 encoded strings. +{ + static int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, std::string::const_iterator it2, std::string::const_iterator end2); + static int icompare(const std::string& str1, const std::string& str2); + static int icompare(const std::string& str1, std::string::size_type n1, const std::string& str2, std::string::size_type n2); + static int icompare(const std::string& str1, std::string::size_type n, const std::string& str2); + static int icompare(const std::string& str1, std::string::size_type pos, std::string::size_type n, const std::string& str2); + static int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2); + static int icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2); + static int icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr); + static int icompare(const std::string& str, std::string::size_type pos, const std::string::value_type* ptr); + static int icompare(const std::string& str, const std::string::value_type* ptr); + + static std::string toUpper(const std::string& str); + static std::string& toUpperInPlace(std::string& str); + static std::string toLower(const std::string& str); + static std::string& toLowerInPlace(std::string& str); +}; + + +} // namespace Poco + + +#endif // Foundation_UTF8String_INCLUDED diff --git a/Foundation/include/Poco/Unicode.h b/Foundation/include/Poco/Unicode.h new file mode 100644 index 000000000..7ee60cb44 --- /dev/null +++ b/Foundation/include/Poco/Unicode.h @@ -0,0 +1,216 @@ +// +// Unicode.h +// +// $Id: //poco/Main/Foundation/include/Poco/Unicode.h#1 $ +// +// Library: Foundation +// Package: Text +// Module: Unicode +// +// Definition of the Unicode class. +// +// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// + + +#ifndef Foundation_Unicode_INCLUDED +#define Foundation_Unicode_INCLUDED + + +#include "Poco/Foundation.h" + + +namespace Poco { + + +class Foundation_API Unicode + /// This class contains enumerations and static + /// utility functions for dealing with Unicode characters + /// and their properties. + /// + /// For more information on Unicode, see . + /// + /// The implementation is based on the Unicode support + /// functions in PCRE. +{ +public: + // Implementation note: the following definitions must be kept + // in sync with those from ucp.h (PCRE). + enum CharacterCategory + /// Unicode 5.0 character categories. + { + UCP_OTHER, + UCP_LETTER, + UCP_MARK, + UCP_NUMBER, + UCP_PUNCTUATION, + UCP_SYMBOL, + UCP_SEPARATOR + }; + + enum CharacterType + /// Unicode 5.0 character types. + { + UCP_CONTROL, + UCP_FORMAT, + UCP_UNASSIGNED, + UCP_PRIVATE_USE, + UCP_SURROGATE, + UCP_LOWER_CASE_LETTER, + UCP_MODIFIER_LETTER, + UCP_OTHER_LETTER, + UCP_TITLE_CASE_LETTER, + UCP_UPPER_CASE_LETTER, + UCP_SPACING_MARK, + UCP_ENCLOSING_MARK, + UCP_NON_SPACING_MARK, + UCP_DECIMAL_NUMBER, + UCP_LETTER_NUMBER, + UCP_OTHER_NUMBER, + UCP_CONNECTOR_PUNCTUATION, + UCP_DASH_PUNCTUATION, + UCP_CLOSE_PUNCTUATION, + UCP_FINAL_PUNCTUATION, + UCP_INITIAL_PUNCTUATION, + UCP_OTHER_PUNCTUATION, + UCP_OPEN_PUNCTUATION, + UCP_CURRENCY_SYMBOL, + UCP_MODIFIER_SYMBOL, + UCP_MATHEMATICAL_SYMBOL, + UCP_OTHER_SYMBOL, + UCP_LINE_SEPARATOR, + UCP_PARAGRAPH_SEPARATOR, + UCP_SPACE_SEPARATOR + }; + + enum Script + /// Unicode 5.0 scripts. + { + UCP_ARABIC, + UCP_ARMENIAN, + UCP_BENGALI, + UCP_BOPOMOFO, + UCP_BRAILLE, + UCP_BUGINESE, + UCP_BUHID, + UCP_CANADIAN_ABORIGINAL, + UCP_CHEROKEE, + UCP_COMMON, + UCP_COPTIC, + UCP_CYPRIOT, + UCP_CYRILLIC, + UCP_DESERET, + UCP_DEVANAGARI, + UCP_ETHIOPIC, + UCP_GEORGIAN, + UCP_GLAGOLITIC, + UCP_GOTHIC, + UCP_GREEK, + UCP_GUJARATI, + UCP_GURMUKHI, + UCP_HAN, + UCP_HANGUL, + UCP_HANUNOO, + UCP_HEBREW, + UCP_HIRAGANA, + UCP_INHERITED, + UCP_KANNADA, + UCP_KATAKANA, + UCP_KHAROSHTHI, + UCP_KHMER, + UCP_LAO, + UCP_LATIN, + UCP_LIMBU, + UCP_LINEAR_B, + UCP_MALAYALAM, + UCP_MONGOLIAN, + UCP_MYANMAR, + UCP_NEW_TAI_LUE, + UCP_OGHAM, + UCP_OLD_ITALIC, + UCP_OLD_PERSIAN, + UCP_ORIYA, + UCP_OSMANYA, + UCP_RUNIC, + UCP_SHAVIAN, + UCP_SINHALA, + UCP_SYLOTI_NAGRI, + UCP_SYRIAC, + UCP_TAGALOG, + UCP_TAGBANWA, + UCP_TAI_LE, + UCP_TAMIL, + UCP_TELUGU, + UCP_THAANA, + UCP_THAI, + UCP_TIBETAN, + UCP_TIFINAGH, + UCP_UGARITIC, + UCP_YI, + UCP_BALINESE, + UCP_CUNEIFORM, + UCP_NKO, + UCP_PHAGS_PA, + UCP_PHOENICIAN + }; + + struct CharacterProperties + /// This structure holds the character properties + /// of an Unicode character. + { + CharacterCategory category; + CharacterType type; + Script script; + }; + + static void properties(int ch, CharacterProperties& props); + /// Return the Unicode character properties for the + /// character with the given Unicode value. + + static bool isLower(int ch); + /// Returns true iff the given character is a lowercase + /// character. + + static bool isUpper(int ch); + /// Returns true iff the given character is an uppercase + /// character. + + static int toLower(int ch); + /// If the given character is an uppercase character, + /// return its lowercase counterpart, otherwise return + /// the character. + + static int toUpper(int ch); + /// If the given character is a lowercase character, + /// return its uppercase counterpart, otherwise return + /// the character. +}; + + +} // namespace Poco + + +#endif // Foundation_Unicode_INCLUDED diff --git a/Foundation/src/BinaryWriter.cpp b/Foundation/src/BinaryWriter.cpp index 5cc6a64cf..27afbec20 100644 --- a/Foundation/src/BinaryWriter.cpp +++ b/Foundation/src/BinaryWriter.cpp @@ -1,7 +1,7 @@ // // BinaryWriter.cpp // -// $Id: //poco/Main/Foundation/src/BinaryWriter.cpp#12 $ +// $Id: //poco/Main/Foundation/src/BinaryWriter.cpp#13 $ // // Library: Foundation // Package: Streams @@ -36,7 +36,6 @@ #include "Poco/BinaryWriter.h" #include "Poco/ByteOrder.h" -#include namespace Poco { @@ -266,7 +265,7 @@ BinaryWriter& BinaryWriter::operator << (const std::string& value) BinaryWriter& BinaryWriter::operator << (const char* value) { poco_check_ptr (value); - UInt32 length = (UInt32) strlen(value); + UInt32 length = (UInt32) std::strlen(value); write7BitEncoded(length); _ostr.write(value, length); return *this; diff --git a/Foundation/src/DateTime.cpp b/Foundation/src/DateTime.cpp index ce0e6101d..d0d66c107 100644 --- a/Foundation/src/DateTime.cpp +++ b/Foundation/src/DateTime.cpp @@ -1,7 +1,7 @@ // // DateTime.cpp // -// $Id: //poco/Main/Foundation/src/DateTime.cpp#16 $ +// $Id: //poco/Main/Foundation/src/DateTime.cpp#18 $ // // Library: Foundation // Package: DateTime @@ -37,7 +37,7 @@ #include "Poco/DateTime.h" #include "Poco/Timespan.h" #include -#include +#include namespace Poco { @@ -206,7 +206,7 @@ void DateTime::swap(DateTime& dateTime) int DateTime::dayOfWeek() const { - return int((floor(julianDay() + 1.5))) % 7; + return int((std::floor(julianDay() + 1.5))) % 7; } @@ -331,7 +331,7 @@ double DateTime::toJulianDay(int year, int month, int day, int hour, int minute, --year; } double dyear = double(year); - return dday + lookup[month] + 365*year + floor(dyear/4) - floor(dyear/100) + floor(dyear/400) + 1721118.5; + return dday + lookup[month] + 365*year + std::floor(dyear/4) - std::floor(dyear/100) + std::floor(dyear/400) + 1721118.5; } @@ -367,15 +367,15 @@ void DateTime::normalize() void DateTime::computeGregorian(double julianDay) { - double z = floor(julianDay - 1721118.5); + double z = std::floor(julianDay - 1721118.5); double r = julianDay - 1721118.5 - z; double g = z - 0.25; - double a = floor(g / 36524.25); - double b = a - floor(a/4); - _year = short(floor((b + g)/365.25)); - double c = b + z - floor(365.25*_year); - _month = short(floor((5*c + 456)/153)); - double dday = c - floor((153.0*_month - 457)/5) + r; + double a = std::floor(g / 36524.25); + double b = a - std::floor(a/4); + _year = short(std::floor((b + g)/365.25)); + double c = b + z - std::floor(365.25*_year); + _month = short(std::floor((5*c + 456)/153)); + double dday = c - std::floor((153.0*_month - 457)/5) + r; _day = short(dday); if (_month > 12) { @@ -383,17 +383,17 @@ void DateTime::computeGregorian(double julianDay) _month -= 12; } r *= 24; - _hour = short(floor(r)); - r -= floor(r); + _hour = short(std::floor(r)); + r -= std::floor(r); r *= 60; - _minute = short(floor(r)); - r -= floor(r); + _minute = short(std::floor(r)); + r -= std::floor(r); r *= 60; - _second = short(floor(r)); - r -= floor(r); + _second = short(std::floor(r)); + r -= std::floor(r); r *= 1000; - _millisecond = short(floor(r)); - r -= floor(r); + _millisecond = short(std::floor(r)); + r -= std::floor(r); r *= 1000; _microsecond = short(r + 0.5); diff --git a/Foundation/src/DateTimeParser.cpp b/Foundation/src/DateTimeParser.cpp index 1bbdbf289..ab7a7f8e3 100644 --- a/Foundation/src/DateTimeParser.cpp +++ b/Foundation/src/DateTimeParser.cpp @@ -1,7 +1,7 @@ // // DateTimeParser.cpp // -// $Id: //poco/Main/Foundation/src/DateTimeParser.cpp#14 $ +// $Id: //poco/Main/Foundation/src/DateTimeParser.cpp#16 $ // // Library: Foundation // Package: DateTime @@ -38,22 +38,22 @@ #include "Poco/DateTimeFormat.h" #include "Poco/DateTime.h" #include "Poco/Exception.h" -#include +#include namespace Poco { #define SKIP_JUNK() \ - while (it != end && !isdigit(*it)) ++it + while (it != end && !std::isdigit(*it)) ++it #define PARSE_NUMBER(var) \ - while (it != end && isdigit(*it)) var = var*10 + ((*it++) - '0') + while (it != end && std::isdigit(*it)) var = var*10 + ((*it++) - '0') #define PARSE_NUMBER_N(var, n) \ - { int i = 0; while (i++ < n && it != end && isdigit(*it)) var = var*10 + ((*it++) - '0'); } + { int i = 0; while (i++ < n && it != end && std::isdigit(*it)) var = var*10 + ((*it++) - '0'); } void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateTime& dateTime, int& timeZoneDifferential) @@ -82,8 +82,8 @@ void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateT { case 'w': case 'W': - while (it != end && isspace(*it)) ++it; - while (it != end && isalpha(*it)) ++it; + while (it != end && std::isspace(*it)) ++it; + while (it != end && std::isalpha(*it)) ++it; break; case 'b': case 'B': @@ -208,7 +208,7 @@ bool DateTimeParser::tryParse(const std::string& str, DateTime& dateTime, int& t return tryParse(DateTimeFormat::ASCTIME_FORMAT, str, dateTime, timeZoneDifferential); else if (str.find(',') != std::string::npos) return tryParse(DateTimeFormat::RFC850_FORMAT, str, dateTime, timeZoneDifferential); - else if (isdigit(str[0])) + else if (std::isdigit(str[0])) { if (str.find(' ') != std::string::npos || str.length() == 10) return tryParse(DateTimeFormat::SORTABLE_FORMAT, str, dateTime, timeZoneDifferential); @@ -265,16 +265,16 @@ int DateTimeParser::parseTZD(std::string::const_iterator& it, const std::string: {"AWDT", 9*3600} }; - while (it != end && isspace(*it)) ++it; + while (it != end && std::isspace(*it)) ++it; if (it != end) { - if (isalpha(*it)) + if (std::isalpha(*it)) { std::string designator; designator += *it++; - if (it != end && isalpha(*it)) designator += *it++; - if (it != end && isalpha(*it)) designator += *it++; - if (it != end && isalpha(*it)) designator += *it++; + if (it != end && std::isalpha(*it)) designator += *it++; + if (it != end && std::isalpha(*it)) designator += *it++; + if (it != end && std::isalpha(*it)) designator += *it++; for (unsigned i = 0; i < sizeof(zones)/sizeof(Zone); ++i) { if (designator == zones[i].designator) @@ -300,13 +300,13 @@ int DateTimeParser::parseTZD(std::string::const_iterator& it, const std::string: int DateTimeParser::parseMonth(std::string::const_iterator& it, const std::string::const_iterator& end) { std::string month; - while (it != end && isspace(*it) || ispunct(*it)) ++it; + while (it != end && std::isspace(*it) || std::ispunct(*it)) ++it; bool isFirst = true; - while (it != end && isalpha(*it)) + while (it != end && std::isalpha(*it)) { char ch = (*it++); - if (isFirst) { month += toupper(ch); isFirst = false; } - else month += tolower(ch); + if (isFirst) { month += std::toupper(ch); isFirst = false; } + else month += std::tolower(ch); } if (month.length() < 3) throw SyntaxException("Month name must be at least three characters long", month); for (int i = 0; i < 12; ++i) @@ -321,13 +321,13 @@ int DateTimeParser::parseMonth(std::string::const_iterator& it, const std::strin int DateTimeParser::parseDayOfWeek(std::string::const_iterator& it, const std::string::const_iterator& end) { std::string dow; - while (it != end && isspace(*it) || ispunct(*it)) ++it; + while (it != end && std::isspace(*it) || std::ispunct(*it)) ++it; bool isFirst = true; - while (it != end && isalpha(*it)) + while (it != end && std::isalpha(*it)) { char ch = (*it++); - if (isFirst) { dow += toupper(ch); isFirst = false; } - else dow += tolower(ch); + if (isFirst) { dow += std::toupper(ch); isFirst = false; } + else dow += std::tolower(ch); } if (dow.length() < 3) throw SyntaxException("Weekday name must be at least three characters long", dow); for (int i = 0; i < 7; ++i) @@ -342,11 +342,11 @@ int DateTimeParser::parseDayOfWeek(std::string::const_iterator& it, const std::s int DateTimeParser::parseAMPM(std::string::const_iterator& it, const std::string::const_iterator& end, int hour) { std::string ampm; - while (it != end && isspace(*it) || ispunct(*it)) ++it; - while (it != end && isalpha(*it)) + while (it != end && std::isspace(*it) || std::ispunct(*it)) ++it; + while (it != end && std::isalpha(*it)) { char ch = (*it++); - ampm += toupper(ch); + ampm += std::toupper(ch); } if (ampm == "AM") { diff --git a/Foundation/src/Debugger.cpp b/Foundation/src/Debugger.cpp index 2314194e4..b44467e93 100644 --- a/Foundation/src/Debugger.cpp +++ b/Foundation/src/Debugger.cpp @@ -1,7 +1,7 @@ // // Debugger.cpp // -// $Id: //poco/Main/Foundation/src/Debugger.cpp#11 $ +// $Id: //poco/Main/Foundation/src/Debugger.cpp#13 $ // // Library: Foundation // Package: Core @@ -36,8 +36,8 @@ #include "Poco/Debugger.h" #include -#include -#include +#include +#include #if defined(POCO_OS_FAMILY_WINDOWS) #include #elif defined(POCO_OS_FAMILY_UNIX) @@ -66,7 +66,7 @@ bool Debugger::isAvailable() #if defined(POCO_OS_FAMILY_WINDOWS) return IsDebuggerPresent() ? true : false; #elif defined(POCO_OS_FAMILY_UNIX) - return getenv("POCO_ENABLE_DEBUGGER") ? true : false; + return std::getenv("POCO_ENABLE_DEBUGGER") ? true : false; #elif defined(POCO_OS_FAMILY_VMS) return true; #endif @@ -79,9 +79,9 @@ bool Debugger::isAvailable() void Debugger::message(const std::string& msg) { #if defined(_DEBUG) - fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr); - fputs(msg.c_str(), stderr); - fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr); + std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr); + std::fputs(msg.c_str(), stderr); + std::fputs("\n%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n", stderr); #if defined(POCO_OS_FAMILY_WINDOWS) if (IsDebuggerPresent()) { diff --git a/Foundation/src/DirectoryIterator_WIN32U.cpp b/Foundation/src/DirectoryIterator_WIN32U.cpp index a0fa6fa42..bf7985d01 100644 --- a/Foundation/src/DirectoryIterator_WIN32U.cpp +++ b/Foundation/src/DirectoryIterator_WIN32U.cpp @@ -1,7 +1,7 @@ // // DirectoryIterator_WIN32U.cpp // -// $Id: //poco/Main/Foundation/src/DirectoryIterator_WIN32U.cpp#7 $ +// $Id: //poco/Main/Foundation/src/DirectoryIterator_WIN32U.cpp#8 $ // // Library: Foundation // Package: Filesystem @@ -38,7 +38,7 @@ #include "Poco/File_WIN32U.h" #include "Poco/Path.h" #include "Poco/UnicodeConverter.h" -#include +#include namespace Poco { diff --git a/Foundation/src/DynamicAny.cpp b/Foundation/src/DynamicAny.cpp index bcdf2ff65..507c209d3 100644 --- a/Foundation/src/DynamicAny.cpp +++ b/Foundation/src/DynamicAny.cpp @@ -1,7 +1,7 @@ // // DynamicAny.cpp // -// $Id: //poco/Main/Foundation/src/DynamicAny.cpp#3 $ +// $Id: //poco/Main/Foundation/src/DynamicAny.cpp#4 $ // // Library: Foundation // Package: Core @@ -35,6 +35,7 @@ #include "Poco/DynamicAny.h" +#include namespace Poco { diff --git a/Foundation/src/Environment_WIN32U.cpp b/Foundation/src/Environment_WIN32U.cpp index 3a1d7ea11..c74f6a1a7 100644 --- a/Foundation/src/Environment_WIN32U.cpp +++ b/Foundation/src/Environment_WIN32U.cpp @@ -1,7 +1,7 @@ // // Environment_WIN32U.cpp // -// $Id: //poco/Main/Foundation/src/Environment_WIN32U.cpp#7 $ +// $Id: //poco/Main/Foundation/src/Environment_WIN32U.cpp#8 $ // // Library: Foundation // Package: Core @@ -39,7 +39,7 @@ #include "Poco/UnicodeConverter.h" #include "Poco/Buffer.h" #include -#include +#include #include diff --git a/Foundation/src/File.cpp b/Foundation/src/File.cpp index 7e329292a..237d58b66 100644 --- a/Foundation/src/File.cpp +++ b/Foundation/src/File.cpp @@ -1,7 +1,7 @@ // // File.cpp // -// $Id: //poco/Main/Foundation/src/File.cpp#19 $ +// $Id: //poco/Main/Foundation/src/File.cpp#20 $ // // Library: Foundation // Package: Filesystem diff --git a/Foundation/src/FileChannel.cpp b/Foundation/src/FileChannel.cpp index f7c724e59..29b474c87 100644 --- a/Foundation/src/FileChannel.cpp +++ b/Foundation/src/FileChannel.cpp @@ -1,7 +1,7 @@ // // FileChannel.cpp // -// $Id: //poco/Main/Foundation/src/FileChannel.cpp#18 $ +// $Id: //poco/Main/Foundation/src/FileChannel.cpp#19 $ // // Library: Foundation // Package: Logging @@ -46,7 +46,7 @@ #include "Poco/String.h" #include "Poco/Timespan.h" #include "Poco/Exception.h" -#include +#include namespace Poco { @@ -216,11 +216,11 @@ void FileChannel::setRotation(const std::string& rotation) std::string::const_iterator it = rotation.begin(); std::string::const_iterator end = rotation.end(); int n = 0; - while (it != end && isspace(*it)) ++it; - while (it != end && isdigit(*it)) { n *= 10; n += *it++ - '0'; } - while (it != end && isspace(*it)) ++it; + while (it != end && std::isspace(*it)) ++it; + while (it != end && std::isdigit(*it)) { n *= 10; n += *it++ - '0'; } + while (it != end && std::isspace(*it)) ++it; std::string unit; - while (it != end && isalpha(*it)) unit += *it++; + while (it != end && std::isalpha(*it)) unit += *it++; RotateStrategy* pStrategy = 0; if ((rotation.find(',') != std::string::npos) || (rotation.find(':') != std::string::npos)) @@ -299,11 +299,11 @@ void FileChannel::setPurgeAge(const std::string& age) std::string::const_iterator it = age.begin(); std::string::const_iterator end = age.end(); int n = 0; - while (it != end && isspace(*it)) ++it; - while (it != end && isdigit(*it)) { n *= 10; n += *it++ - '0'; } - while (it != end && isspace(*it)) ++it; + while (it != end && std::isspace(*it)) ++it; + while (it != end && std::isdigit(*it)) { n *= 10; n += *it++ - '0'; } + while (it != end && std::isspace(*it)) ++it; std::string unit; - while (it != end && isalpha(*it)) unit += *it++; + while (it != end && std::isalpha(*it)) unit += *it++; Timespan::TimeDiff factor = Timespan::SECONDS; if (unit == "minutes") @@ -330,9 +330,9 @@ void FileChannel::setPurgeCount(const std::string& count) std::string::const_iterator it = count.begin(); std::string::const_iterator end = count.end(); int n = 0; - while (it != end && isspace(*it)) ++it; - while (it != end && isdigit(*it)) { n *= 10; n += *it++ - '0'; } - while (it != end && isspace(*it)) ++it; + while (it != end && std::isspace(*it)) ++it; + while (it != end && std::isdigit(*it)) { n *= 10; n += *it++ - '0'; } + while (it != end && std::isspace(*it)) ++it; delete _pPurgeStrategy; _pPurgeStrategy = new PurgeByCountStrategy(n); diff --git a/Foundation/src/File_UNIX.cpp b/Foundation/src/File_UNIX.cpp index 77c7eacc9..c2d6d9080 100644 --- a/Foundation/src/File_UNIX.cpp +++ b/Foundation/src/File_UNIX.cpp @@ -1,7 +1,7 @@ // // File_UNIX.cpp // -// $Id: //poco/Main/Foundation/src/File_UNIX.cpp#19 $ +// $Id: //poco/Main/Foundation/src/File_UNIX.cpp#21 $ // // Library: Foundation // Package: Filesystem @@ -45,7 +45,6 @@ #include #include #include -#include namespace Poco { @@ -427,7 +426,7 @@ void FileImpl::handleLastErrorImpl(const std::string& path) case EMFILE: throw FileException("too many open files", path); default: - throw FileException(strerror(errno), path); + throw FileException(std::strerror(errno), path); } } diff --git a/Foundation/src/MD2Engine.cpp b/Foundation/src/MD2Engine.cpp index 37d81c6c9..ab982e7b6 100644 --- a/Foundation/src/MD2Engine.cpp +++ b/Foundation/src/MD2Engine.cpp @@ -1,7 +1,7 @@ // // MD2Engine.cpp // -// $Id: //poco/Main/Foundation/src/MD2Engine.cpp#11 $ +// $Id: //poco/Main/Foundation/src/MD2Engine.cpp#12 $ // // Library: Foundation // Package: Crypt @@ -54,7 +54,7 @@ #include "Poco/MD2Engine.h" -#include +#include namespace Poco { @@ -87,7 +87,7 @@ void MD2Engine::updateImpl(const void* input_, unsigned inputLen) /* Transform as many times as possible. */ if (inputLen >= partLen) { - memcpy(&_context.buffer[index], input, partLen); + std::memcpy(&_context.buffer[index], input, partLen); transform(_context.state, _context.checksum, _context.buffer); for (i = partLen; i + 15 < inputLen; i += 16) @@ -98,7 +98,7 @@ void MD2Engine::updateImpl(const void* input_, unsigned inputLen) else i = 0; /* Buffer remaining input */ - memcpy(&_context.buffer[index], &input[i], inputLen-i); + std::memcpy(&_context.buffer[index], &input[i], inputLen-i); } @@ -110,7 +110,7 @@ unsigned MD2Engine::digestLength() const void MD2Engine::reset() { - memset(&_context, 0, sizeof(_context)); + std::memset(&_context, 0, sizeof(_context)); } @@ -151,7 +151,7 @@ const DigestEngine::Digest& MD2Engine::digest() _digest.insert(_digest.begin(), _context.state, _context.state + 16); /* Zeroize sensitive information. */ - memset(&_context, 0, sizeof(_context)); + std::memset(&_context, 0, sizeof(_context)); reset(); return _digest; } @@ -186,8 +186,8 @@ void MD2Engine::transform(unsigned char state[16], unsigned char checksum[16], c unsigned char x[48]; /* Form encryption block from state, block, state ^ block. */ - memcpy(x, state, 16); - memcpy(x+16, block, 16); + std::memcpy(x, state, 16); + std::memcpy(x+16, block, 16); for (i = 0; i < 16; i++) x[i+32] = state[i] ^ block[i]; @@ -201,7 +201,7 @@ void MD2Engine::transform(unsigned char state[16], unsigned char checksum[16], c } /* Save new state */ - memcpy(state, x, 16); + std::memcpy(state, x, 16); /* Update checksum. */ t = checksum[15]; @@ -209,7 +209,7 @@ void MD2Engine::transform(unsigned char state[16], unsigned char checksum[16], c t = checksum[i] ^= PI_SUBST[block[i] ^ t]; /* Zeroize sensitive information. */ - memset(x, 0, sizeof(x)); + std::memset(x, 0, sizeof(x)); } diff --git a/Foundation/src/MD4Engine.cpp b/Foundation/src/MD4Engine.cpp index 90adbeaeb..f26fe6399 100644 --- a/Foundation/src/MD4Engine.cpp +++ b/Foundation/src/MD4Engine.cpp @@ -1,7 +1,7 @@ // // MD4Engine.cpp // -// $Id: //poco/Main/Foundation/src/MD4Engine.cpp#11 $ +// $Id: //poco/Main/Foundation/src/MD4Engine.cpp#13 $ // // Library: Foundation // Package: Crypt @@ -58,7 +58,7 @@ #include "Poco/MD4Engine.h" -#include +#include namespace Poco { @@ -95,7 +95,7 @@ void MD4Engine::updateImpl(const void* input_, unsigned inputLen) /* Transform as many times as possible. */ if (inputLen >= partLen) { - memcpy(&_context.buffer[index], input, partLen); + std::memcpy(&_context.buffer[index], input, partLen); transform(_context.state, _context.buffer); for (i = partLen; i + 63 < inputLen; i += 64) @@ -106,7 +106,7 @@ void MD4Engine::updateImpl(const void* input_, unsigned inputLen) else i = 0; /* Buffer remaining input */ - memcpy(&_context.buffer[index], &input[i], inputLen-i); + std::memcpy(&_context.buffer[index], &input[i], inputLen-i); } @@ -118,7 +118,7 @@ unsigned MD4Engine::digestLength() const void MD4Engine::reset() { - memset(&_context, 0, sizeof(_context)); + std::memset(&_context, 0, sizeof(_context)); _context.count[0] = _context.count[1] = 0; _context.state[0] = 0x67452301; _context.state[1] = 0xefcdab89; @@ -156,7 +156,7 @@ const DigestEngine::Digest& MD4Engine::digest() _digest.insert(_digest.begin(), digest, digest + sizeof(digest)); /* Zeroize sensitive information. */ - memset(&_context, 0, sizeof (_context)); + std::memset(&_context, 0, sizeof (_context)); reset(); return _digest; } @@ -269,7 +269,7 @@ void MD4Engine::transform (UInt32 state[4], const unsigned char block[64]) state[3] += d; /* Zeroize sensitive information. */ - memset(x, 0, sizeof(x)); + std::memset(x, 0, sizeof(x)); } diff --git a/Foundation/src/MD5Engine.cpp b/Foundation/src/MD5Engine.cpp index 9f91a02d3..6d8ec0e5d 100644 --- a/Foundation/src/MD5Engine.cpp +++ b/Foundation/src/MD5Engine.cpp @@ -1,7 +1,7 @@ // // MD5Engine.cpp // -// $Id: //poco/Main/Foundation/src/MD5Engine.cpp#11 $ +// $Id: //poco/Main/Foundation/src/MD5Engine.cpp#13 $ // // Library: Foundation // Package: Crypt @@ -58,7 +58,7 @@ #include "Poco/MD5Engine.h" -#include +#include namespace Poco { @@ -95,7 +95,7 @@ void MD5Engine::updateImpl(const void* input_, unsigned inputLen) /* Transform as many times as possible. */ if (inputLen >= partLen) { - memcpy(&_context.buffer[index], input, partLen); + std::memcpy(&_context.buffer[index], input, partLen); transform(_context.state, _context.buffer); for (i = partLen; i + 63 < inputLen; i += 64) @@ -106,7 +106,7 @@ void MD5Engine::updateImpl(const void* input_, unsigned inputLen) else i = 0; /* Buffer remaining input */ - memcpy(&_context.buffer[index], &input[i],inputLen-i); + std::memcpy(&_context.buffer[index], &input[i],inputLen-i); } @@ -118,7 +118,7 @@ unsigned MD5Engine::digestLength() const void MD5Engine::reset() { - memset(&_context, 0, sizeof(_context)); + std::memset(&_context, 0, sizeof(_context)); _context.count[0] = _context.count[1] = 0; _context.state[0] = 0x67452301; _context.state[1] = 0xefcdab89; @@ -156,7 +156,7 @@ const DigestEngine::Digest& MD5Engine::digest() _digest.insert(_digest.begin(), digest, digest + sizeof(digest)); /* Zeroize sensitive information. */ - memset(&_context, 0, sizeof (_context)); + std::memset(&_context, 0, sizeof (_context)); reset(); return _digest; } @@ -300,7 +300,7 @@ void MD5Engine::transform (UInt32 state[4], const unsigned char block[64]) state[3] += d; /* Zeroize sensitive information. */ - memset(x, 0, sizeof(x)); + std::memset(x, 0, sizeof(x)); } diff --git a/Foundation/src/NumberFormatter.cpp b/Foundation/src/NumberFormatter.cpp index 46a61fc96..7aa3aac5a 100644 --- a/Foundation/src/NumberFormatter.cpp +++ b/Foundation/src/NumberFormatter.cpp @@ -1,7 +1,7 @@ // // NumberFormatter.cpp // -// $Id: //poco/Main/Foundation/src/NumberFormatter.cpp#10 $ +// $Id: //poco/Main/Foundation/src/NumberFormatter.cpp#12 $ // // Library: Foundation // Package: Core @@ -35,8 +35,8 @@ #include "Poco/NumberFormatter.h" -#include -#include +#include +#include #if defined(_MSC_VER) @@ -54,7 +54,7 @@ namespace Poco { std::string NumberFormatter::format(int value) { char buffer[64]; - sprintf(buffer, "%d", value); + std::sprintf(buffer, "%d", value); return std::string(buffer); } @@ -64,7 +64,7 @@ std::string NumberFormatter::format(int value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%*d", width, value); + std::sprintf(buffer, "%*d", width, value); return std::string(buffer); } @@ -74,7 +74,7 @@ std::string NumberFormatter::format0(int value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*d", width, value); + std::sprintf(buffer, "%0*d", width, value); return std::string(buffer); } @@ -82,7 +82,7 @@ std::string NumberFormatter::format0(int value, int width) std::string NumberFormatter::formatHex(int value) { char buffer[64]; - sprintf(buffer, "%X", value); + std::sprintf(buffer, "%X", value); return std::string(buffer); } @@ -92,7 +92,7 @@ std::string NumberFormatter::formatHex(int value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*X", width, value); + std::sprintf(buffer, "%0*X", width, value); return std::string(buffer); } @@ -100,7 +100,7 @@ std::string NumberFormatter::formatHex(int value, int width) std::string NumberFormatter::format(unsigned value) { char buffer[64]; - sprintf(buffer, "%u", value); + std::sprintf(buffer, "%u", value); return std::string(buffer); } @@ -110,7 +110,7 @@ std::string NumberFormatter::format(unsigned value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%*u", width, value); + std::sprintf(buffer, "%*u", width, value); return std::string(buffer); } @@ -120,7 +120,7 @@ std::string NumberFormatter::format0(unsigned int value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*u", width, value); + std::sprintf(buffer, "%0*u", width, value); return std::string(buffer); } @@ -128,7 +128,7 @@ std::string NumberFormatter::format0(unsigned int value, int width) std::string NumberFormatter::formatHex(unsigned value) { char buffer[64]; - sprintf(buffer, "%X", value); + std::sprintf(buffer, "%X", value); return std::string(buffer); } @@ -138,7 +138,7 @@ std::string NumberFormatter::formatHex(unsigned value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*X", width, value); + std::sprintf(buffer, "%0*X", width, value); return std::string(buffer); } @@ -146,7 +146,7 @@ std::string NumberFormatter::formatHex(unsigned value, int width) std::string NumberFormatter::format(long value) { char buffer[64]; - sprintf(buffer, "%ld", value); + std::sprintf(buffer, "%ld", value); return std::string(buffer); } @@ -156,7 +156,7 @@ std::string NumberFormatter::format(long value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%*ld", width, value); + std::sprintf(buffer, "%*ld", width, value); return std::string(buffer); } @@ -166,7 +166,7 @@ std::string NumberFormatter::format0(long value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*ld", width, value); + std::sprintf(buffer, "%0*ld", width, value); return std::string(buffer); } @@ -174,7 +174,7 @@ std::string NumberFormatter::format0(long value, int width) std::string NumberFormatter::formatHex(long value) { char buffer[64]; - sprintf(buffer, "%lX", value); + std::sprintf(buffer, "%lX", value); return std::string(buffer); } @@ -184,7 +184,7 @@ std::string NumberFormatter::formatHex(long value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*lX", width, value); + std::sprintf(buffer, "%0*lX", width, value); return std::string(buffer); } @@ -192,7 +192,7 @@ std::string NumberFormatter::formatHex(long value, int width) std::string NumberFormatter::format(unsigned long value) { char buffer[64]; - sprintf(buffer, "%lu", value); + std::sprintf(buffer, "%lu", value); return std::string(buffer); } @@ -202,7 +202,7 @@ std::string NumberFormatter::format(unsigned long value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%*lu", width, value); + std::sprintf(buffer, "%*lu", width, value); return std::string(buffer); } @@ -212,7 +212,7 @@ std::string NumberFormatter::format0(unsigned long value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*lu", width, value); + std::sprintf(buffer, "%0*lu", width, value); return std::string(buffer); } @@ -220,7 +220,7 @@ std::string NumberFormatter::format0(unsigned long value, int width) std::string NumberFormatter::formatHex(unsigned long value) { char buffer[64]; - sprintf(buffer, "%lX", value); + std::sprintf(buffer, "%lX", value); return std::string(buffer); } @@ -230,7 +230,7 @@ std::string NumberFormatter::formatHex(unsigned long value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*lX", width, value); + std::sprintf(buffer, "%0*lX", width, value); return std::string(buffer); } @@ -241,7 +241,7 @@ std::string NumberFormatter::formatHex(unsigned long value, int width) std::string NumberFormatter::format(Int64 value) { char buffer[64]; - sprintf(buffer, "%"I64_FMT"d", value); + std::sprintf(buffer, "%"I64_FMT"d", value); return std::string(buffer); } @@ -251,7 +251,7 @@ std::string NumberFormatter::format(Int64 value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%*"I64_FMT"d", width, value); + std::sprintf(buffer, "%*"I64_FMT"d", width, value); return std::string(buffer); } @@ -261,7 +261,7 @@ std::string NumberFormatter::format0(Int64 value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*"I64_FMT"d", width, value); + std::sprintf(buffer, "%0*"I64_FMT"d", width, value); return std::string(buffer); } @@ -269,7 +269,7 @@ std::string NumberFormatter::format0(Int64 value, int width) std::string NumberFormatter::formatHex(Int64 value) { char buffer[64]; - sprintf(buffer, "%"I64_FMT"X", value); + std::sprintf(buffer, "%"I64_FMT"X", value); return std::string(buffer); } @@ -279,7 +279,7 @@ std::string NumberFormatter::formatHex(Int64 value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*"I64_FMT"X", width, value); + std::sprintf(buffer, "%0*"I64_FMT"X", width, value); return std::string(buffer); } @@ -287,7 +287,7 @@ std::string NumberFormatter::formatHex(Int64 value, int width) std::string NumberFormatter::format(UInt64 value) { char buffer[64]; - sprintf(buffer, "%"I64_FMT"u", value); + std::sprintf(buffer, "%"I64_FMT"u", value); return std::string(buffer); } @@ -297,7 +297,7 @@ std::string NumberFormatter::format(UInt64 value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%*"I64_FMT"u", width, value); + std::sprintf(buffer, "%*"I64_FMT"u", width, value); return std::string(buffer); } @@ -307,7 +307,7 @@ std::string NumberFormatter::format0(UInt64 value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*"I64_FMT"u", width, value); + std::sprintf(buffer, "%0*"I64_FMT"u", width, value); return std::string(buffer); } @@ -315,7 +315,7 @@ std::string NumberFormatter::format0(UInt64 value, int width) std::string NumberFormatter::formatHex(UInt64 value) { char buffer[64]; - sprintf(buffer, "%"I64_FMT"X", value); + std::sprintf(buffer, "%"I64_FMT"X", value); return std::string(buffer); } @@ -325,7 +325,7 @@ std::string NumberFormatter::formatHex(UInt64 value, int width) poco_assert (width > 0 && width < 64); char buffer[64]; - sprintf(buffer, "%0*"I64_FMT"X", width, value); + std::sprintf(buffer, "%0*"I64_FMT"X", width, value); return std::string(buffer); } @@ -336,7 +336,7 @@ std::string NumberFormatter::formatHex(UInt64 value, int width) std::string NumberFormatter::format(float value) { char buffer[64]; - sprintf(buffer, "%.*g", 10, (double) value); + std::sprintf(buffer, "%.*g", 10, (double) value); return std::string(buffer); } @@ -344,7 +344,7 @@ std::string NumberFormatter::format(float value) std::string NumberFormatter::format(double value) { char buffer[64]; - sprintf(buffer, "%.*g", 20, value); + std::sprintf(buffer, "%.*g", 20, value); return std::string(buffer); } @@ -354,7 +354,7 @@ std::string NumberFormatter::format(double value, int precision) poco_assert (precision >= 0 && precision < 32); char buffer[64]; - sprintf(buffer, "%.*f", precision, value); + std::sprintf(buffer, "%.*f", precision, value); return std::string(buffer); } @@ -364,7 +364,7 @@ std::string NumberFormatter::format(double value, int width, int precision) poco_assert (width > 0 && width < 64 && precision >= 0 && precision < width); char buffer[64]; - sprintf(buffer, "%*.*f", width, precision, value); + std::sprintf(buffer, "%*.*f", width, precision, value); return std::string(buffer); } @@ -373,9 +373,9 @@ std::string NumberFormatter::format(const void* ptr) { char buffer[24]; #if defined(POCO_PTR_IS_64_BIT) - sprintf(buffer, "%016"I64_FMT"X", (UIntPtr) ptr); + std::sprintf(buffer, "%016"I64_FMT"X", (UIntPtr) ptr); #else - sprintf(buffer, "%08lX", (UIntPtr) ptr); + std::sprintf(buffer, "%08lX", (UIntPtr) ptr); #endif return std::string(buffer); } diff --git a/Foundation/src/NumberParser.cpp b/Foundation/src/NumberParser.cpp index 8eab40950..487be7146 100644 --- a/Foundation/src/NumberParser.cpp +++ b/Foundation/src/NumberParser.cpp @@ -1,7 +1,7 @@ // // NumberParser.cpp // -// $Id: //poco/Main/Foundation/src/NumberParser.cpp#11 $ +// $Id: //poco/Main/Foundation/src/NumberParser.cpp#13 $ // // Library: Foundation // Package: Core @@ -36,8 +36,8 @@ #include "Poco/NumberParser.h" #include "Poco/Exception.h" -#include -#include +#include +#include #if defined(_MSC_VER) @@ -65,7 +65,7 @@ int NumberParser::parse(const std::string& s) bool NumberParser::tryParse(const std::string& s, int& value) { char temp; - return sscanf(s.c_str(), "%d%c", &value, &temp) == 1; + return std::sscanf(s.c_str(), "%d%c", &value, &temp) == 1; } @@ -82,7 +82,7 @@ unsigned NumberParser::parseUnsigned(const std::string& s) bool NumberParser::tryParseUnsigned(const std::string& s, unsigned& value) { char temp; - return sscanf(s.c_str(), "%u%c", &value, &temp) == 1; + return std::sscanf(s.c_str(), "%u%c", &value, &temp) == 1; } @@ -99,7 +99,7 @@ unsigned NumberParser::parseHex(const std::string& s) bool NumberParser::tryParseHex(const std::string& s, unsigned& value) { char temp; - return sscanf(s.c_str(), "%x%c", &value, &temp) == 1; + return std::sscanf(s.c_str(), "%x%c", &value, &temp) == 1; } @@ -119,7 +119,7 @@ Int64 NumberParser::parse64(const std::string& s) bool NumberParser::tryParse64(const std::string& s, Int64& value) { char temp; - return sscanf(s.c_str(), "%"I64_FMT"d%c", &value, &temp) == 1; + return std::sscanf(s.c_str(), "%"I64_FMT"d%c", &value, &temp) == 1; } @@ -136,7 +136,7 @@ UInt64 NumberParser::parseUnsigned64(const std::string& s) bool NumberParser::tryParseUnsigned64(const std::string& s, UInt64& value) { char temp; - return sscanf(s.c_str(), "%"I64_FMT"u%c", &value, &temp) == 1; + return std::sscanf(s.c_str(), "%"I64_FMT"u%c", &value, &temp) == 1; } @@ -153,7 +153,7 @@ UInt64 NumberParser::parseHex64(const std::string& s) bool NumberParser::tryParseHex64(const std::string& s, UInt64& value) { char temp; - return sscanf(s.c_str(), "%"I64_FMT"x%c", &value, &temp) == 1; + return std::sscanf(s.c_str(), "%"I64_FMT"x%c", &value, &temp) == 1; } @@ -173,7 +173,7 @@ double NumberParser::parseFloat(const std::string& s) bool NumberParser::tryParseFloat(const std::string& s, double& value) { char temp; - return sscanf(s.c_str(), "%lf%c", &value, &temp) == 1; + return std::sscanf(s.c_str(), "%lf%c", &value, &temp) == 1; } diff --git a/Foundation/src/Path_UNIX.cpp b/Foundation/src/Path_UNIX.cpp index 7699559d5..67b001be1 100644 --- a/Foundation/src/Path_UNIX.cpp +++ b/Foundation/src/Path_UNIX.cpp @@ -1,7 +1,7 @@ // // Path_UNIX.cpp // -// $Id: //poco/Main/Foundation/src/Path_UNIX.cpp#11 $ +// $Id: //poco/Main/Foundation/src/Path_UNIX.cpp#12 $ // // Library: Foundation // Package: Filesystem @@ -41,9 +41,8 @@ #include #include #include -#include -#include -#include +#include +#include #ifndef PATH_MAX @@ -114,7 +113,6 @@ std::string PathImpl::nullImpl() std::string PathImpl::expandImpl(const std::string& path) { - std::locale loc; std::string result; std::string::const_iterator it = path.begin(); std::string::const_iterator end = path.end(); @@ -141,7 +139,7 @@ std::string PathImpl::expandImpl(const std::string& path) } else { - while (it != end && (isalnum(*it, loc) || *it == '_')) var += *it++; + while (it != end && (std::isalnum(*it) || *it == '_')) var += *it++; } char* val = getenv(var.c_str()); if (val) result += val; diff --git a/Foundation/src/Process_UNIX.cpp b/Foundation/src/Process_UNIX.cpp index bd1e22309..caaf0d035 100644 --- a/Foundation/src/Process_UNIX.cpp +++ b/Foundation/src/Process_UNIX.cpp @@ -1,7 +1,7 @@ // // Process_UNIX.cpp // -// $Id: //poco/Main/Foundation/src/Process_UNIX.cpp#28 $ +// $Id: //poco/Main/Foundation/src/Process_UNIX.cpp#29 $ // // Library: Foundation // Package: Processes @@ -49,7 +49,7 @@ #if defined(__QNX__) #include #include -#include +#include #endif @@ -120,7 +120,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg argv[i++] = const_cast(it->c_str()); argv[i] = NULL; struct inheritance inherit; - memset(&inherit, 0, sizeof(inherit)); + std::memset(&inherit, 0, sizeof(inherit)); inherit.flags = SPAWN_ALIGN_DEFAULT | SPAWN_CHECK_SCRIPT | SPAWN_SEARCH_PATH; int fdmap[3]; fdmap[0] = inPipe ? inPipe->readHandle() : 0; diff --git a/Foundation/src/Random.cpp b/Foundation/src/Random.cpp index 35c417a67..0256295a7 100644 --- a/Foundation/src/Random.cpp +++ b/Foundation/src/Random.cpp @@ -1,7 +1,7 @@ // // Random.cpp // -// $Id: //poco/Main/Foundation/src/Random.cpp#13 $ +// $Id: //poco/Main/Foundation/src/Random.cpp#14 $ // // Library: Foundation // Package: Crypt @@ -68,7 +68,7 @@ #include "Poco/Random.h" #include "Poco/RandomStream.h" -#include "time.h" +#include /* @@ -172,7 +172,7 @@ Random::Random(int stateSize) poco_assert (BREAK_0 <= stateSize && stateSize <= BREAK_4); _pBuffer = new char[stateSize]; - initState((UInt32) time(NULL), _pBuffer, stateSize); + initState((UInt32) std::time(NULL), _pBuffer, stateSize); } diff --git a/Foundation/src/RandomStream.cpp b/Foundation/src/RandomStream.cpp index 23c852382..7b64ff3a6 100644 --- a/Foundation/src/RandomStream.cpp +++ b/Foundation/src/RandomStream.cpp @@ -1,7 +1,7 @@ // // RandomStream.cpp // -// $Id: //poco/Main/Foundation/src/RandomStream.cpp#12 $ +// $Id: //poco/Main/Foundation/src/RandomStream.cpp#13 $ // // Library: Foundation // Package: Crypt @@ -44,7 +44,7 @@ #include #include #endif -#include +#include namespace Poco { @@ -90,7 +90,7 @@ int RandomBuf::readFromDevice(char* buffer, std::streamsize length) n = 0; SHA1Engine engine; - UInt32 t = (UInt32) time(NULL); + UInt32 t = (UInt32) std::time(NULL); engine.update(&t, sizeof(t)); void* p = this; engine.update(&p, sizeof(p)); diff --git a/Foundation/src/SHA1Engine.cpp b/Foundation/src/SHA1Engine.cpp index 84dba0af3..dc110067e 100644 --- a/Foundation/src/SHA1Engine.cpp +++ b/Foundation/src/SHA1Engine.cpp @@ -1,7 +1,7 @@ // // SHA1Engine.cpp // -// $Id: //poco/Main/Foundation/src/SHA1Engine.cpp#12 $ +// $Id: //poco/Main/Foundation/src/SHA1Engine.cpp#14 $ // // Library: Foundation // Package: Crypt @@ -38,7 +38,7 @@ #include "Poco/SHA1Engine.h" -#include +#include #ifdef POCO_ARCH_LITTLE_ENDIAN @@ -119,7 +119,7 @@ void SHA1Engine::reset() _context.countLo = 0; _context.countHi = 0; _context.slop = 0; - memset(_context.data, 0, sizeof(_context.data)); + std::memset(_context.data, 0, sizeof(_context.data)); } @@ -140,17 +140,17 @@ const DigestEngine::Digest& SHA1Engine::digest() if (count > 56) { /* Two lots of padding: Pad the first block to 64 bytes */ - memset((BYTE*) &_context.data + count, 0, 64 - count); + std::memset((BYTE*) &_context.data + count, 0, 64 - count); SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE); transform(); /* Now fill the next block with 56 bytes */ - memset(&_context.data, 0, 56); + std::memset(&_context.data, 0, 56); } else { /* Pad block to 56 bytes */ - memset((BYTE*) &_context.data + count, 0, 56 - count); + std::memset((BYTE*) &_context.data + count, 0, 56 - count); } SHA1_BYTE_REVERSE(_context.data, BLOCK_SIZE); diff --git a/Foundation/src/SimpleFileChannel.cpp b/Foundation/src/SimpleFileChannel.cpp index 41b2b7c22..cac5e3ff6 100644 --- a/Foundation/src/SimpleFileChannel.cpp +++ b/Foundation/src/SimpleFileChannel.cpp @@ -1,7 +1,7 @@ // // SimpleFileChannel.cpp // -// $Id: //poco/Main/Foundation/src/SimpleFileChannel.cpp#6 $ +// $Id: //poco/Main/Foundation/src/SimpleFileChannel.cpp#7 $ // // Library: Foundation // Package: Logging @@ -39,7 +39,7 @@ #include "Poco/File.h" #include "Poco/Message.h" #include "Poco/Exception.h" -#include +#include namespace Poco { @@ -182,11 +182,11 @@ void SimpleFileChannel::setRotation(const std::string& rotation) std::string::const_iterator it = rotation.begin(); std::string::const_iterator end = rotation.end(); UInt64 n = 0; - while (it != end && isspace(*it)) ++it; - while (it != end && isdigit(*it)) { n *= 10; n += *it++ - '0'; } - while (it != end && isspace(*it)) ++it; + while (it != end && std::isspace(*it)) ++it; + while (it != end && std::isdigit(*it)) { n *= 10; n += *it++ - '0'; } + while (it != end && std::isspace(*it)) ++it; std::string unit; - while (it != end && isalpha(*it)) unit += *it++; + while (it != end && std::isalpha(*it)) unit += *it++; if (unit == "K") _limit = n*1024; diff --git a/Foundation/src/String.cpp b/Foundation/src/String.cpp index a885e8024..21e63a5b3 100644 --- a/Foundation/src/String.cpp +++ b/Foundation/src/String.cpp @@ -1,7 +1,7 @@ // // String.h // -// $Id: //poco/Main/Foundation/src/String.cpp#11 $ +// $Id: //poco/Main/Foundation/src/String.cpp#12 $ // // Library: Foundation // Package: Core @@ -50,11 +50,10 @@ int icompare(const std::string& str, std::string::size_type pos, std::string::si if (pos + n > sz) n = sz - pos; std::string::const_iterator it1 = str.begin() + pos; std::string::const_iterator end1 = str.begin() + pos + n; - std::locale loc; while (it1 != end1 && it2 != end2) { - std::string::value_type c1 = tolower(*it1, loc); - std::string::value_type c2 = tolower(*it2, loc); + std::string::value_type c1 = std::tolower(*it1); + std::string::value_type c2 = std::tolower(*it2); if (c1 < c2) return -1; else if (c1 > c2) @@ -121,11 +120,10 @@ int icompare(const std::string& str, std::string::size_type pos, std::string::si if (pos + n > sz) n = sz - pos; std::string::const_iterator it = str.begin() + pos; std::string::const_iterator end = str.begin() + pos + n; - std::locale loc; while (it != end && *ptr) { - std::string::value_type c1 = tolower(*it, loc); - std::string::value_type c2 = tolower(*ptr, loc); + std::string::value_type c1 = std::tolower(*it); + std::string::value_type c2 = std::tolower(*ptr); if (c1 < c2) return -1; else if (c1 > c2) @@ -198,7 +196,7 @@ std::string& replaceInPlace(std::string& str, const std::string::value_type* fro std::string result; std::string::size_type pos = 0; - std::string::size_type fromLen = strlen(from); + std::string::size_type fromLen = std::strlen(from); result.append(str, 0, start); do { diff --git a/Foundation/src/StringTokenizer.cpp b/Foundation/src/StringTokenizer.cpp index 6ebd8d07c..efb888ff9 100644 --- a/Foundation/src/StringTokenizer.cpp +++ b/Foundation/src/StringTokenizer.cpp @@ -1,7 +1,7 @@ // // StringTokenizer.cpp // -// $Id: //poco/Main/Foundation/src/StringTokenizer.cpp#11 $ +// $Id: //poco/Main/Foundation/src/StringTokenizer.cpp#12 $ // // Library: Foundation // Package: Core @@ -35,7 +35,7 @@ #include "Poco/StringTokenizer.h" -#include +#include namespace Poco { @@ -43,7 +43,6 @@ namespace Poco { StringTokenizer::StringTokenizer(const std::string& str, const std::string& separators, int options) { - std::locale loc; std::string::const_iterator it1 = str.begin(); std::string::const_iterator it2; std::string::const_iterator it3; @@ -53,7 +52,7 @@ StringTokenizer::StringTokenizer(const std::string& str, const std::string& sepa { if (options & TOK_TRIM) { - while (it1 != end && std::isspace(*it1, loc)) ++it1; + while (it1 != end && std::isspace(*it1)) ++it1; } it2 = it1; while (it2 != end && separators.find(*it2) == std::string::npos) ++it2; @@ -61,8 +60,8 @@ StringTokenizer::StringTokenizer(const std::string& str, const std::string& sepa if (it3 != it1 && (options & TOK_TRIM)) { --it3; - while (it3 != it1 && std::isspace(*it3, loc)) --it3; - if (!std::isspace(*it3, loc)) ++it3; + while (it3 != it1 && std::isspace(*it3)) --it3; + if (!std::isspace(*it3)) ++it3; } if (options & TOK_IGNORE_EMPTY) { diff --git a/Foundation/src/TextConverter.cpp b/Foundation/src/TextConverter.cpp index 663fb3c7d..4114d594d 100644 --- a/Foundation/src/TextConverter.cpp +++ b/Foundation/src/TextConverter.cpp @@ -1,7 +1,7 @@ // // TextConverter.cpp // -// $Id: //poco/Main/Foundation/src/TextConverter.cpp#10 $ +// $Id: //poco/Main/Foundation/src/TextConverter.cpp#11 $ // // Library: Foundation // Package: Text @@ -39,6 +39,14 @@ #include "Poco/TextEncoding.h" +namespace { + int nullTransform(int ch) + { + return ch; + } +} + + namespace Poco { @@ -55,7 +63,7 @@ TextConverter::~TextConverter() } -int TextConverter::convert(const std::string& source, std::string& destination) +int TextConverter::convert(const std::string& source, std::string& destination, Transform trans) { int errors = 0; TextIterator it(source, _inEncoding); @@ -66,6 +74,7 @@ int TextConverter::convert(const std::string& source, std::string& destination) { int c = *it; if (c == -1) { ++errors; c = _defaultChar; } + c = trans(c); int n = _outEncoding.convert(c, buffer, sizeof(buffer)); if (n == 0) n = _outEncoding.convert(_defaultChar, buffer, sizeof(buffer)); poco_assert (n <= sizeof(buffer)); @@ -76,7 +85,7 @@ int TextConverter::convert(const std::string& source, std::string& destination) } -int TextConverter::convert(const void* source, int length, std::string& destination) +int TextConverter::convert(const void* source, int length, std::string& destination, Transform trans) { poco_check_ptr (source); @@ -115,6 +124,7 @@ int TextConverter::convert(const void* source, int length, std::string& destinat } it -= n; } + uc = trans(uc); n = _outEncoding.convert(uc, buffer, sizeof(buffer)); if (n == 0) n = _outEncoding.convert(_defaultChar, buffer, sizeof(buffer)); poco_assert (n <= sizeof(buffer)); @@ -124,4 +134,16 @@ int TextConverter::convert(const void* source, int length, std::string& destinat } +int TextConverter::convert(const std::string& source, std::string& destination) +{ + return convert(source, destination, nullTransform); +} + + +int TextConverter::convert(const void* source, int length, std::string& destination) +{ + return convert(source, length, destination, nullTransform); +} + + } // namespace Poco diff --git a/Foundation/src/ThreadPool.cpp b/Foundation/src/ThreadPool.cpp index d0d5a3d2b..acd477b73 100644 --- a/Foundation/src/ThreadPool.cpp +++ b/Foundation/src/ThreadPool.cpp @@ -1,7 +1,7 @@ // // ThreadPool.cpp // -// $Id: //poco/Main/Foundation/src/ThreadPool.cpp#19 $ +// $Id: //poco/Main/Foundation/src/ThreadPool.cpp#20 $ // // Library: Foundation // Package: Threading @@ -41,7 +41,7 @@ #include "Poco/ThreadLocal.h" #include "Poco/ErrorHandler.h" #include -#include +#include namespace Poco { @@ -64,8 +64,8 @@ public: void run(); private: - volatile bool _idle; - volatile time_t _idleTime; + volatile bool _idle; + volatile std::time_t _idleTime; Runnable* _pTarget; std::string _name; Thread _thread; diff --git a/Foundation/src/Timestamp.cpp b/Foundation/src/Timestamp.cpp index c239b6a23..4b4bc8898 100644 --- a/Foundation/src/Timestamp.cpp +++ b/Foundation/src/Timestamp.cpp @@ -1,7 +1,7 @@ // // Timestamp.cpp // -// $Id: //poco/Main/Foundation/src/Timestamp.cpp#11 $ +// $Id: //poco/Main/Foundation/src/Timestamp.cpp#13 $ // // Library: Foundation // Package: DateTime @@ -38,6 +38,7 @@ #include "Poco/Exception.h" #include #if defined(POCO_OS_FAMILY_UNIX) +#include #include #include #include @@ -92,7 +93,7 @@ void Timestamp::swap(Timestamp& timestamp) } -Timestamp Timestamp::fromEpochTime(time_t t) +Timestamp Timestamp::fromEpochTime(std::time_t t) { return Timestamp(TimeVal(t)*resolution()); } diff --git a/Foundation/src/Timezone.cpp b/Foundation/src/Timezone.cpp index 98e66096e..e59b4a2ba 100644 --- a/Foundation/src/Timezone.cpp +++ b/Foundation/src/Timezone.cpp @@ -1,7 +1,7 @@ // // Timezone.cpp // -// $Id: //poco/Main/Foundation/src/Timezone.cpp#11 $ +// $Id: //poco/Main/Foundation/src/Timezone.cpp#12 $ // // Library: Foundation // Package: DateTime @@ -35,7 +35,7 @@ #include "Poco/Timezone.h" -#include +#include #if defined(POCO_OS_FAMILY_WINDOWS) diff --git a/Foundation/src/Timezone_UNIX.cpp b/Foundation/src/Timezone_UNIX.cpp index 56468f7b5..5b61cdb5d 100644 --- a/Foundation/src/Timezone_UNIX.cpp +++ b/Foundation/src/Timezone_UNIX.cpp @@ -1,7 +1,7 @@ // // Timezone_UNIX.cpp // -// $Id: //poco/Main/Foundation/src/Timezone_UNIX.cpp#13 $ +// $Id: //poco/Main/Foundation/src/Timezone_UNIX.cpp#14 $ // // Library: Foundation // Package: DateTime @@ -35,7 +35,7 @@ #include "Poco/Timezone.h" -#include +#include namespace Poco { @@ -52,10 +52,10 @@ public: int timeZone() { #if defined(__APPLE__) || defined(__FreeBSD__) // no timezone global var - time_t now = time(NULL); - struct tm t; + std::time_t now = std::time(NULL); + struct std::tm t; gmtime_r(&now, &t); - time_t utc = mktime(&t); + std::time_t utc = std::mktime(&t); return now - utc; #elif defined(__CYGWIN__) return -_timezone; @@ -82,8 +82,8 @@ int Timezone::utcOffset() int Timezone::dst() { - time_t now = time(NULL); - struct tm t; + std::time_t now = std::time(NULL); + struct std::tm t; localtime_r(&now, &t); return t.tm_isdst == 1 ? 3600 : 0; } @@ -91,8 +91,8 @@ int Timezone::dst() bool Timezone::isDst(const Timestamp& timestamp) { - time_t time = timestamp.epochTime(); - struct tm* tms = localtime(&time); + std::time_t time = timestamp.epochTime(); + struct std::tm* tms = std::localtime(&time); return tms->tm_isdst > 0; } diff --git a/Foundation/src/Timezone_WIN32.cpp b/Foundation/src/Timezone_WIN32.cpp index f73190c63..151b6a8b2 100644 --- a/Foundation/src/Timezone_WIN32.cpp +++ b/Foundation/src/Timezone_WIN32.cpp @@ -1,7 +1,7 @@ // // Timezone_WIN32.cpp // -// $Id: //poco/Main/Foundation/src/Timezone_WIN32.cpp#11 $ +// $Id: //poco/Main/Foundation/src/Timezone_WIN32.cpp#12 $ // // Library: Foundation // Package: DateTime @@ -37,7 +37,7 @@ #include "Poco/Timezone.h" #include "Poco/UnicodeConverter.h" #include -#include +#include namespace Poco { @@ -61,8 +61,8 @@ int Timezone::dst() bool Timezone::isDst(const Timestamp& timestamp) { - time_t time = timestamp.epochTime(); - struct tm* tms = localtime(&time); + std::time_t time = timestamp.epochTime(); + struct std::tm* tms = std::localtime(&time); return tms->tm_isdst > 0; } diff --git a/Foundation/src/Token.cpp b/Foundation/src/Token.cpp index 4491a12da..db3a3874d 100644 --- a/Foundation/src/Token.cpp +++ b/Foundation/src/Token.cpp @@ -1,7 +1,7 @@ // // Token.cpp // -// $Id: //poco/Main/Foundation/src/Token.cpp#11 $ +// $Id: //poco/Main/Foundation/src/Token.cpp#12 $ // // Library: Foundation // Package: Streams @@ -36,7 +36,7 @@ #include "Poco/Token.h" #include "Poco/NumberParser.h" -#include +#include namespace Poco { @@ -144,7 +144,7 @@ Token::Class WhitespaceToken::tokenClass() const bool WhitespaceToken::start(char c, std::istream& istr) { - if (isspace(c)) + if (std::isspace(c)) { _value = c; return true; @@ -156,7 +156,7 @@ bool WhitespaceToken::start(char c, std::istream& istr) void WhitespaceToken::finish(std::istream& istr) { int c = istr.peek(); - while (isspace(c)) + while (std::isspace(c)) { istr.get(); _value += (char) c; diff --git a/Foundation/src/UTF8String.cpp b/Foundation/src/UTF8String.cpp new file mode 100644 index 000000000..a8fab91af --- /dev/null +++ b/Foundation/src/UTF8String.cpp @@ -0,0 +1,203 @@ +// +// UTF8String.cpp +// +// $Id: //poco/Main/Foundation/src/UTF8String.cpp#1 $ +// +// Library: Foundation +// Package: Text +// Module: UTF8String +// +// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// + + +#include "Poco/UTF8String.h" +#include "Poco/Unicode.h" +#include "Poco/TextIterator.h" +#include "Poco/TextConverter.h" +#include "Poco/UTF8Encoding.h" +#include + + +namespace Poco { + + +int UTF8::icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, std::string::const_iterator it2, std::string::const_iterator end2) +{ + static UTF8Encoding utf8; + + std::string::size_type sz = str.size(); + if (pos > sz) pos = sz; + if (pos + n > sz) n = sz - pos; + TextIterator uit1(str.begin() + pos, str.begin() + pos + n, utf8); + TextIterator uend1(str.begin() + pos + n); + TextIterator uit2(it2, end2, utf8); + TextIterator uend2(end2); + while (uit1 != uend1 && uit2 != uend2) + { + int c1 = Unicode::toLower(*uit1); + int c2 = Unicode::toLower(*uit2); + if (c1 < c2) + return -1; + else if (c1 > c2) + return 1; + ++uit1; ++uit2; + } + + if (uit1 == uend1) + return uit2 == uend2 ? 0 : -1; + else + return 1; +} + + +int UTF8::icompare(const std::string& str1, const std::string& str2) +{ + return icompare(str1, 0, str1.size(), str2.begin(), str2.end()); +} + + +int UTF8::icompare(const std::string& str1, std::string::size_type n1, const std::string& str2, std::string::size_type n2) +{ + if (n2 > str2.size()) n2 = str2.size(); + return icompare(str1, 0, n1, str2.begin(), str2.begin() + n2); +} + + +int UTF8::icompare(const std::string& str1, std::string::size_type n, const std::string& str2) +{ + if (n > str2.size()) n = str2.size(); + return icompare(str1, 0, n, str2.begin(), str2.begin() + n); +} + + +int UTF8::icompare(const std::string& str1, std::string::size_type pos, std::string::size_type n, const std::string& str2) +{ + return icompare(str1, pos, n, str2.begin(), str2.end()); +} + + +int UTF8::icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n1, const std::string& str2, std::string::size_type pos2, std::string::size_type n2) +{ + std::string::size_type sz2 = str2.size(); + if (pos2 > sz2) pos2 = sz2; + if (pos2 + n2 > sz2) n2 = sz2 - pos2; + return icompare(str1, pos1, n1, str2.begin() + pos2, str2.begin() + pos2 + n2); +} + + +int UTF8::icompare(const std::string& str1, std::string::size_type pos1, std::string::size_type n, const std::string& str2, std::string::size_type pos2) +{ + std::string::size_type sz2 = str2.size(); + if (pos2 > sz2) pos2 = sz2; + if (pos2 + n > sz2) n = sz2 - pos2; + return icompare(str1, pos1, n, str2.begin() + pos2, str2.begin() + pos2 + n); +} + + +int UTF8::icompare(const std::string& str, std::string::size_type pos, std::string::size_type n, const std::string::value_type* ptr) +{ + static UTF8Encoding utf8; + + poco_check_ptr (ptr); + std::string::size_type sz = str.size(); + if (pos > sz) pos = sz; + if (pos + n > sz) n = sz - pos; + TextIterator uit(str.begin() + pos, str.begin() + pos + n, utf8); + TextIterator uend(str.begin() + pos + n); + while (uit != uend && *ptr) + { + int c1 = Unicode::toLower(*uit); + int c2 = Unicode::toLower(*ptr); + if (c1 < c2) + return -1; + else if (c1 > c2) + return 1; + ++uit; ++ptr; + } + + if (uit == uend) + return *ptr == 0 ? 0 : -1; + else + return 1; +} + + +int UTF8::icompare(const std::string& str, std::string::size_type pos, const std::string::value_type* ptr) +{ + return icompare(str, pos, str.size() - pos, ptr); +} + + +int UTF8::icompare(const std::string& str, const std::string::value_type* ptr) +{ + return icompare(str, 0, str.size(), ptr); +} + + +std::string UTF8::toUpper(const std::string& str) +{ + static UTF8Encoding utf8; + std::string result; + TextConverter converter(utf8, utf8); + converter.convert(str, result, Unicode::toUpper); + return result; +} + + +std::string& UTF8::toUpperInPlace(std::string& str) +{ + static UTF8Encoding utf8; + std::string result; + TextConverter converter(utf8, utf8); + converter.convert(str, result, Unicode::toUpper); + std::swap(str, result); + return str; +} + + +std::string UTF8::toLower(const std::string& str) +{ + static UTF8Encoding utf8; + std::string result; + TextConverter converter(utf8, utf8); + converter.convert(str, result, Unicode::toLower); + return result; +} + + +std::string& UTF8::toLowerInPlace(std::string& str) +{ + static UTF8Encoding utf8; + std::string result; + TextConverter converter(utf8, utf8); + converter.convert(str, result, Unicode::toLower); + std::swap(str, result); + return str; +} + + +} // namespace Poco diff --git a/Foundation/src/UUID.cpp b/Foundation/src/UUID.cpp index 3e789c36f..7cdaff980 100644 --- a/Foundation/src/UUID.cpp +++ b/Foundation/src/UUID.cpp @@ -1,7 +1,7 @@ // // UUID.cpp // -// $Id: //poco/Main/Foundation/src/UUID.cpp#12 $ +// $Id: //poco/Main/Foundation/src/UUID.cpp#13 $ // // Library: Foundation // Package: UUID @@ -38,7 +38,7 @@ #include "Poco/ByteOrder.h" #include "Poco/Exception.h" #include -#include +#include namespace Poco { @@ -50,7 +50,7 @@ UUID::UUID(): _timeHiAndVersion(0), _clockSeq(0) { - memset(_node, 0, sizeof(_node)); + std::memset(_node, 0, sizeof(_node)); } @@ -60,7 +60,7 @@ UUID::UUID(const UUID& uuid): _timeHiAndVersion(uuid._timeHiAndVersion), _clockSeq(uuid._clockSeq) { - memcpy(_node, uuid._node, sizeof(_node)); + std::memcpy(_node, uuid._node, sizeof(_node)); } @@ -83,7 +83,7 @@ UUID::UUID(UInt32 timeLow, UInt32 timeMid, UInt32 timeHiAndVersion, UInt16 clock _timeHiAndVersion(timeHiAndVersion), _clockSeq(clockSeq) { - memcpy(_node, node, sizeof(_node)); + std::memcpy(_node, node, sizeof(_node)); } @@ -91,19 +91,19 @@ UUID::UUID(const char* bytes, Version version) { UInt32 i32; UInt16 i16; - memcpy(&i32, bytes, sizeof(i32)); + std::memcpy(&i32, bytes, sizeof(i32)); _timeLow = ByteOrder::fromNetwork(i32); bytes += sizeof(i32); - memcpy(&i16, bytes, sizeof(i16)); + std::memcpy(&i16, bytes, sizeof(i16)); _timeMid = ByteOrder::fromNetwork(i16); bytes += sizeof(i16); - memcpy(&i16, bytes, sizeof(i16)); + std::memcpy(&i16, bytes, sizeof(i16)); _timeHiAndVersion = ByteOrder::fromNetwork(i16); bytes += sizeof(i16); - memcpy(&i16, bytes, sizeof(i16)); + std::memcpy(&i16, bytes, sizeof(i16)); _clockSeq = ByteOrder::fromNetwork(i16); bytes += sizeof(i16); - memcpy(_node, bytes, sizeof(_node)); + std::memcpy(_node, bytes, sizeof(_node)); _timeHiAndVersion &= 0x0FFF; _timeHiAndVersion |= (version << 12); @@ -125,7 +125,7 @@ UUID& UUID::operator = (const UUID& uuid) _timeMid = uuid._timeMid; _timeHiAndVersion = uuid._timeHiAndVersion; _clockSeq = uuid._clockSeq; - memcpy(_node, uuid._node, sizeof(_node)); + std::memcpy(_node, uuid._node, sizeof(_node)); } return *this; } @@ -191,7 +191,7 @@ void UUID::parse(const std::string& uuid) _timeMid = timeMid; _timeHiAndVersion = timeHiAndVersion; _clockSeq = clockSeq; - memcpy(_node, node, sizeof(_node)); + std::memcpy(_node, node, sizeof(_node)); } } @@ -218,37 +218,37 @@ void UUID::copyFrom(const char* buffer) { UInt32 i32; UInt16 i16; - memcpy(&i32, buffer, sizeof(i32)); + std::memcpy(&i32, buffer, sizeof(i32)); _timeLow = ByteOrder::fromNetwork(i32); buffer += sizeof(i32); - memcpy(&i16, buffer, sizeof(i16)); + std::memcpy(&i16, buffer, sizeof(i16)); _timeMid = ByteOrder::fromNetwork(i16); buffer += sizeof(i16); - memcpy(&i16, buffer, sizeof(i16)); + std::memcpy(&i16, buffer, sizeof(i16)); _timeHiAndVersion = ByteOrder::fromNetwork(i16); buffer += sizeof(i16); - memcpy(&i16, buffer, sizeof(i16)); + std::memcpy(&i16, buffer, sizeof(i16)); _clockSeq = ByteOrder::fromNetwork(i16); buffer += sizeof(i16); - memcpy(_node, buffer, sizeof(_node)); + std::memcpy(_node, buffer, sizeof(_node)); } void UUID::copyTo(char* buffer) const { UInt32 i32 = ByteOrder::toNetwork(_timeLow); - memcpy(buffer, &i32, sizeof(i32)); + std::memcpy(buffer, &i32, sizeof(i32)); buffer += sizeof(i32); UInt16 i16 = ByteOrder::toNetwork(_timeMid); - memcpy(buffer, &i16, sizeof(i16)); + std::memcpy(buffer, &i16, sizeof(i16)); buffer += sizeof(i16); i16 = ByteOrder::toNetwork(_timeHiAndVersion); - memcpy(buffer, &i16, sizeof(i16)); + std::memcpy(buffer, &i16, sizeof(i16)); buffer += sizeof(i16); i16 = ByteOrder::toNetwork(_clockSeq); - memcpy(buffer, &i16, sizeof(i16)); + std::memcpy(buffer, &i16, sizeof(i16)); buffer += sizeof(i16); - memcpy(buffer, _node, sizeof(_node)); + std::memcpy(buffer, _node, sizeof(_node)); } diff --git a/Foundation/src/UUIDGenerator.cpp b/Foundation/src/UUIDGenerator.cpp index 7bde311ab..bda8bcb32 100644 --- a/Foundation/src/UUIDGenerator.cpp +++ b/Foundation/src/UUIDGenerator.cpp @@ -1,7 +1,7 @@ // // UUIDGenerator.cpp // -// $Id: //poco/Main/Foundation/src/UUIDGenerator.cpp#15 $ +// $Id: //poco/Main/Foundation/src/UUIDGenerator.cpp#17 $ // // Library: Foundation // Package: UUID @@ -40,7 +40,7 @@ #include "Poco/DigestEngine.h" #include "Poco/MD5Engine.h" #include "Poco/SingletonHolder.h" -#include +#include namespace Poco { @@ -199,7 +199,7 @@ void UUIDGenerator::getNode() { if (pAdapter->Type == MIB_IF_TYPE_ETHERNET && pAdapter->AddressLength == sizeof(_node)) { - memcpy(_node, pAdapter->Address, pAdapter->AddressLength); + std::memcpy(_node, pAdapter->Address, pAdapter->AddressLength); found = true; } } @@ -248,7 +248,7 @@ void UUIDGenerator::getNode() int alen = sdl->sdl_alen; if (ap && alen > 0) { - memcpy(_node, ap, sizeof(_node)); + std::memcpy(_node, ap, sizeof(_node)); foundAdapter = true; break; } @@ -289,7 +289,7 @@ void UUIDGenerator::getNode() close(s); if (rc < 0) throw SystemException("cannot get MAC address"); struct sockaddr* sa = reinterpret_cast(&ifr.ifr_addr); - memcpy(_node, sa->sa_data, sizeof(_node)); + std::memcpy(_node, sa->sa_data, sizeof(_node)); } @@ -344,14 +344,14 @@ void UUIDGenerator::getNode() if (s == -1) throw SystemException("cannot open socket"); struct arpreq ar; - memset(&ar, 0, sizeof(ar)); + std::memset(&ar, 0, sizeof(ar)); struct sockaddr_in* pAddr = reinterpret_cast(&ar.arp_pa); pAddr->sin_family = AF_INET; - memcpy(&pAddr->sin_addr, *pHost->h_addr_list, sizeof(struct in_addr)); + std::memcpy(&pAddr->sin_addr, *pHost->h_addr_list, sizeof(struct in_addr)); int rc = ioctl(s, SIOCGARP, &ar); close(s); if (rc < 0) throw SystemException("cannot get MAC address"); - memcpy(_node, ar.arp_ha.sa_data, sizeof(_node)); + std::memcpy(_node, ar.arp_ha.sa_data, sizeof(_node)); } diff --git a/Foundation/src/Unicode.cpp b/Foundation/src/Unicode.cpp new file mode 100644 index 000000000..1326658ef --- /dev/null +++ b/Foundation/src/Unicode.cpp @@ -0,0 +1,94 @@ +// +// Unicode.cpp +// +// $Id: //poco/Main/Foundation/src/Unicode.cpp#1 $ +// +// Library: Foundation +// Package: Text +// Module: Unicode +// +// Copyright (c) 2007, Applied Informatics Software Engineering GmbH. +// and Contributors. +// +// Permission is hereby granted, free of charge, to any person or organization +// obtaining a copy of the software and accompanying documentation covered by +// this license (the "Software") to use, reproduce, display, distribute, +// execute, and transmit the Software, and to prepare derivative works of the +// Software, and to permit third-parties to whom the Software is furnished to +// do so, all subject to the following: +// +// The copyright notices in the Software and this entire statement, including +// the above license grant, this restriction and the following disclaimer, +// must be included in all copies of the Software, in whole or in part, and +// all derivative works of the Software, unless such copies or derivative +// works are solely in the form of machine-executable object code generated by +// a source language processor. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT +// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE +// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, +// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +// DEALINGS IN THE SOFTWARE. +// + + +#include "Poco/Unicode.h" + + +extern "C" +{ +#include "pcre_internal.h" +} + + +namespace Poco { + + +void Unicode::properties(int ch, CharacterProperties& props) +{ + int type; + int script; + int category = _pcre_ucp_findprop(static_cast(ch), &type, &script); + props.category = static_cast(category); + props.type = static_cast(type); + props.script = static_cast