latest changes from main rep

This commit is contained in:
Guenter Obiltschnig
2007-05-04 11:04:40 +00:00
parent 3580ad72cb
commit dcabc2befc
60 changed files with 1183 additions and 328 deletions

View File

@@ -3326,6 +3326,9 @@
<File
RelativePath=".\src\TextIterator.cpp">
</File>
<File
RelativePath=".\src\Unicode.cpp">
</File>
<File
RelativePath=".\src\UnicodeConverter.cpp">
</File>
@@ -3335,6 +3338,9 @@
<File
RelativePath=".\src\UTF8Encoding.cpp">
</File>
<File
RelativePath=".\src\UTF8String.cpp">
</File>
<File
RelativePath=".\src\Windows1252Encoding.cpp">
</File>
@@ -3363,6 +3369,9 @@
<File
RelativePath=".\include\Poco\TextIterator.h">
</File>
<File
RelativePath=".\include\Poco\Unicode.h">
</File>
<File
RelativePath=".\include\Poco\UnicodeConverter.h">
</File>
@@ -3372,6 +3381,9 @@
<File
RelativePath=".\include\Poco\UTF8Encoding.h">
</File>
<File
RelativePath=".\include\Poco\UTF8String.h">
</File>
<File
RelativePath=".\include\Poco\Windows1252Encoding.h">
</File>

View File

@@ -4335,6 +4335,10 @@
RelativePath=".\src\TextIterator.cpp"
>
</File>
<File
RelativePath=".\src\Unicode.cpp"
>
</File>
<File
RelativePath=".\src\UnicodeConverter.cpp"
>
@@ -4347,6 +4351,10 @@
RelativePath=".\src\UTF8Encoding.cpp"
>
</File>
<File
RelativePath=".\src\UTF8String.cpp"
>
</File>
<File
RelativePath=".\src\Windows1252Encoding.cpp"
>
@@ -4383,6 +4391,10 @@
RelativePath=".\include\Poco\TextIterator.h"
>
</File>
<File
RelativePath=".\include\Poco\Unicode.h"
>
</File>
<File
RelativePath=".\include\Poco\UnicodeConverter.h"
>
@@ -4395,6 +4407,10 @@
RelativePath=".\include\Poco\UTF8Encoding.h"
>
</File>
<File
RelativePath=".\include\Poco\UTF8String.h"
>
</File>
<File
RelativePath=".\include\Poco\Windows1252Encoding.h"
>

View File

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

View File

@@ -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 <TKey, TValue>& 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<Iterator, bool> stat = _keys.insert(std::make_pair(args.key(), it));
if (!stat.second)
{

View File

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

View File

@@ -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 <string.h>
#include <cstring>
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)
{

View File

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

View File

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

View File

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

View File

@@ -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 <cstring>
#include <locale>
#include <cctype>
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 <class S>
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 <class S>
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 <class S>
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 <class S>
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 <class S>
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 <class S>
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 <class S>
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)

View File

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

View File

@@ -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 <time.h>
#include <ctime>
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());
}

View File

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

View File

@@ -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 <http://www.unicode.org>.
///
/// 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

View File

@@ -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 <string.h>
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;

View File

@@ -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 <algorithm>
#include <math.h>
#include <cmath>
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);

View File

@@ -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 <ctype.h>
#include <cctype>
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")
{

View File

@@ -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 <sstream>
#include <stdlib.h>
#include <stdio.h>
#include <cstdlib>
#include <cstdio>
#if defined(POCO_OS_FAMILY_WINDOWS)
#include <windows.h>
#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())
{

View File

@@ -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 <string.h>
#include <cstring>
namespace Poco {

View File

@@ -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 <algorithm>
namespace Poco {

View File

@@ -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 <sstream>
#include <string.h>
#include <cstring>
#include <windows.h>

View File

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

View File

@@ -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 <ctype.h>
#include <cctype>
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);

View File

@@ -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 <unistd.h>
#include <stdio.h>
#include <utime.h>
#include <string.h>
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);
}
}

View File

@@ -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 <string.h>
#include <cstring>
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));
}

View File

@@ -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 <string.h>
#include <cstring>
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));
}

View File

@@ -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 <string.h>
#include <cstring>
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));
}

View File

@@ -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 <stdio.h>
#include <ctype.h>
#include <cstdio>
#include <cctype>
#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);
}

View File

@@ -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 <stdio.h>
#include <ctype.h>
#include <cstdio>
#include <cctype>
#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;
}

View File

@@ -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 <stdlib.h>
#include <sys/types.h>
#include <pwd.h>
#include <ctype.h>
#include <limits.h>
#include <locale>
#include <cctype>
#include <climits>
#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;

View File

@@ -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 <process.h>
#include <spawn.h>
#include <string.h>
#include <cstring>
#endif
@@ -120,7 +120,7 @@ ProcessHandleImpl* ProcessImpl::launchImpl(const std::string& command, const Arg
argv[i++] = const_cast<char*>(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;

View File

@@ -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 <ctime>
/*
@@ -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);
}

View File

@@ -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 <fcntl.h>
#include <unistd.h>
#endif
#include <time.h>
#include <ctime>
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));

View File

@@ -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 <string.h>
#include <cstring>
#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);

View File

@@ -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 <ctype.h>
#include <cctype>
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;

View File

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

View File

@@ -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 <locale>
#include <cctype>
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)
{

View File

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

View File

@@ -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 <sstream>
#include <time.h>
#include <ctime>
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;

View File

@@ -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 <algorithm>
#if defined(POCO_OS_FAMILY_UNIX)
#include <time.h>
#include <unistd.h>
#include <sys/time.h>
#include <sys/times.h>
@@ -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());
}

View File

@@ -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 <time.h>
#include <ctime>
#if defined(POCO_OS_FAMILY_WINDOWS)

View File

@@ -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 <time.h>
#include <ctime>
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;
}

View File

@@ -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 <windows.h>
#include <time.h>
#include <ctime>
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;
}

View File

@@ -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 <ctype.h>
#include <cctype>
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;

View File

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

View File

@@ -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 <algorithm>
#include <string.h>
#include <cstring>
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));
}

View File

@@ -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 <string.h>
#include <cstring>
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<struct sockaddr*>(&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<struct sockaddr_in*>(&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));
}

View File

@@ -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<unsigned>(ch), &type, &script);
props.category = static_cast<CharacterCategory>(category);
props.type = static_cast<CharacterType>(type);
props.script = static_cast<Script>(script);
}
bool Unicode::isLower(int ch)
{
CharacterProperties props;
properties(ch, props);
return props.category == UCP_LETTER && props.type == UCP_LOWER_CASE_LETTER;
}
bool Unicode::isUpper(int ch)
{
CharacterProperties props;
properties(ch, props);
return props.category == UCP_LETTER && props.type == UCP_UPPER_CASE_LETTER;
}
int Unicode::toLower(int ch)
{
if (isUpper(ch))
return static_cast<int>(_pcre_ucp_othercase(static_cast<unsigned>(ch)));
else
return ch;
}
int Unicode::toUpper(int ch)
{
if (isLower(ch))
return static_cast<int>(_pcre_ucp_othercase(static_cast<unsigned>(ch)));
else
return ch;
}
} // namespace Poco

View File

@@ -1,7 +1,7 @@
//
// UnicodeConverter.cpp
//
// $Id: //poco/Main/Foundation/src/UnicodeConverter.cpp#8 $
// $Id: //poco/Main/Foundation/src/UnicodeConverter.cpp#9 $
//
// Library: Foundation
// Package: Text
@@ -42,7 +42,7 @@
#include "Poco/TextIterator.h"
#include "Poco/UTF8Encoding.h"
#include "Poco/UTF16Encoding.h"
#include <string.h>
#include <cstring>
#include <wchar.h>
@@ -100,7 +100,7 @@ void UnicodeConverter::toUTF16(const char* utf8String, int length, std::wstring&
void UnicodeConverter::toUTF16(const char* utf8String, std::wstring& utf16String)
{
toUTF16(utf8String, (int) strlen(utf8String), utf16String);
toUTF16(utf8String, (int) std::strlen(utf8String), utf16String);
}

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/Main/Foundation/testsuite/Makefile-Driver#34 $
# $Id: //poco/Main/Foundation/testsuite/Makefile-Driver#35 $
#
# Makefile for Poco Foundation testsuite
#
@@ -27,7 +27,7 @@ objects = ActiveMethodTest ActivityTest ActiveDispatcherTest \
SimpleFileChannelTest StopwatchTest \
StreamConverterTest StreamCopierTest StreamTokenizerTest \
StreamsTestSuite StringTest StringTokenizerTest TaskTestSuite TaskTest \
TaskManagerTest TestChannel TeeStreamTest \
TaskManagerTest TestChannel TeeStreamTest UTF8StringTest \
TextConverterTest TextIteratorTest TextTestSuite TextEncodingTest \
ThreadLocalTest ThreadPoolTest ThreadTest ThreadingTestSuite TimerTest \
TimespanTest TimestampTest TimezoneTest URIStreamOpenerTest URITest \

View File

@@ -913,6 +913,9 @@
<File
RelativePath=".\src\TextTestSuite.cpp">
</File>
<File
RelativePath=".\src\UTF8StringTest.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
@@ -932,6 +935,9 @@
<File
RelativePath=".\src\TextTestSuite.h">
</File>
<File
RelativePath=".\src\UTF8StringTest.h">
</File>
</Filter>
</Filter>
<Filter

View File

@@ -1214,6 +1214,10 @@
RelativePath=".\src\TextTestSuite.cpp"
>
</File>
<File
RelativePath=".\src\UTF8StringTest.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
@@ -1238,6 +1242,10 @@
RelativePath=".\src\TextTestSuite.h"
>
</File>
<File
RelativePath=".\src\UTF8StringTest.h"
>
</File>
</Filter>
</Filter>
<Filter

View File

@@ -1,7 +1,7 @@
//
// LoggingFactoryTest.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/LoggingFactoryTest.cpp#6 $
// $Id: //poco/Main/Foundation/testsuite/src/LoggingFactoryTest.cpp#7 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -37,6 +37,9 @@
#include "Poco/Instantiator.h"
#include "Poco/Channel.h"
#include "Poco/ConsoleChannel.h"
#if defined(_WIN32)
#include "Poco/WindowsConsoleChannel.h"
#endif
#include "Poco/FileChannel.h"
#include "Poco/SplitterChannel.h"
#include "Poco/Formatter.h"
@@ -93,8 +96,12 @@ void LoggingFactoryTest::testBuiltins()
LoggingFactory& fact = LoggingFactory::defaultFactory();
AutoPtr<Channel> pConsoleChannel = fact.createChannel("ConsoleChannel");
#if defined(_WIN32)
assert (dynamic_cast<Poco::WindowsConsoleChannel*>(pConsoleChannel.get()) != 0);
#else
assert (dynamic_cast<ConsoleChannel*>(pConsoleChannel.get()) != 0);
#endif
AutoPtr<Channel> pFileChannel = fact.createChannel("FileChannel");
assert (dynamic_cast<FileChannel*>(pFileChannel.get()) != 0);

View File

@@ -1,7 +1,7 @@
//
// NamedTuplesTest.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/NamedTuplesTest.cpp#1 $
// $Id: //poco/Main/Foundation/testsuite/src/NamedTuplesTest.cpp#2 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.

View File

@@ -1,7 +1,7 @@
//
// RandomStreamTest.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/RandomStreamTest.cpp#9 $
// $Id: //poco/Main/Foundation/testsuite/src/RandomStreamTest.cpp#10 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -35,7 +35,7 @@
#include "CppUnit/TestSuite.h"
#include "Poco/RandomStream.h"
#include <vector>
#include <math.h>
#include <cmath>
using Poco::RandomInputStream;
@@ -70,7 +70,7 @@ void RandomStreamTest::testStream()
int var = 0;
for (int k = 0; k < n; ++k) var += (d[k] - avg)*(d[k] - avg);
var /= n;
int sd = int(sqrt((double) var));
int sd = int(std::sqrt((double) var));
assert (110 < avg && avg < 140);
assert (sd < 20);

View File

@@ -1,7 +1,7 @@
//
// RandomTest.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/RandomTest.cpp#9 $
// $Id: //poco/Main/Foundation/testsuite/src/RandomTest.cpp#10 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -35,7 +35,7 @@
#include "CppUnit/TestSuite.h"
#include "Poco/Random.h"
#include <vector>
#include <math.h>
#include <cmath>
using Poco::Random;
@@ -118,7 +118,7 @@ void RandomTest::testDistribution2()
int var = 0;
for (int k = 0; k < n; ++k) var += (d[k] - avg)*(d[k] - avg);
var /= n;
int sd = int(sqrt((double) var));
int sd = int(std::sqrt((double) var));
assert (95 < avg && avg < 105);
assert (sd < 15);
@@ -141,7 +141,7 @@ void RandomTest::testDistribution3()
int var = 0;
for (int k = 0; k < n; ++k) var += (d[k] - avg)*(d[k] - avg);
var /= n;
int sd = int(sqrt((double) var));
int sd = int(std::sqrt((double) var));
assert (95 < avg && avg < 105);
assert (sd < 15);

View File

@@ -1,7 +1,7 @@
//
// StreamTokenizerTest.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/StreamTokenizerTest.cpp#9 $
// $Id: //poco/Main/Foundation/testsuite/src/StreamTokenizerTest.cpp#10 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -35,7 +35,7 @@
#include "CppUnit/TestSuite.h"
#include "Poco/StreamTokenizer.h"
#include "Poco/Token.h"
#include <ctype.h>
#include <cctype>
#include <sstream>
@@ -64,7 +64,7 @@ public:
bool start(char c, std::istream& istr)
{
if (isalpha(c))
if (std::isalpha(c))
{
_value = c;
return true;
@@ -75,7 +75,7 @@ public:
void finish(std::istream& istr)
{
int c = istr.peek();
while (isalnum(c))
while (std::isalnum(c))
{
istr.get();
_value += c;
@@ -103,7 +103,7 @@ public:
bool start(char c, std::istream& istr)
{
if (isdigit(c))
if (std::isdigit(c))
{
_value = c;
return true;
@@ -114,7 +114,7 @@ public:
void finish(std::istream& istr)
{
int c = istr.peek();
while (isdigit(c))
while (std::isdigit(c))
{
istr.get();
_value += c;

View File

@@ -1,7 +1,7 @@
//
// TextTestSuite.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/TextTestSuite.cpp#9 $
// $Id: //poco/Main/Foundation/testsuite/src/TextTestSuite.cpp#10 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -35,6 +35,7 @@
#include "TextConverterTest.h"
#include "StreamConverterTest.h"
#include "TextEncodingTest.h"
#include "UTF8StringTest.h"
CppUnit::Test* TextTestSuite::suite()
@@ -45,6 +46,7 @@ CppUnit::Test* TextTestSuite::suite()
pSuite->addTest(TextConverterTest::suite());
pSuite->addTest(StreamConverterTest::suite());
pSuite->addTest(TextEncodingTest::suite());
pSuite->addTest(UTF8StringTest::suite());
return pSuite;
}

View File

@@ -0,0 +1,122 @@
//
// UTF8StringTest.cpp
//
// $Id: //poco/Main/Foundation/testsuite/src/UTF8StringTest.cpp#1 $
//
// Copyright (c) 2004-2006, 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 "UTF8StringTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/UTF8String.h"
using Poco::UTF8;
UTF8StringTest::UTF8StringTest(const std::string& name): CppUnit::TestCase(name)
{
}
UTF8StringTest::~UTF8StringTest()
{
}
void UTF8StringTest::testCompare()
{
std::string a1("aaaaa");
std::string b1("bbbbb");
assert (UTF8::icompare(a1, b1) < 0);
std::string a2("aaaaa");
std::string b2("BBBBB");
assert (UTF8::icompare(a2, b2) < 0);
std::string a3("AAAAA");
std::string b3("bbbbb");
assert (UTF8::icompare(a3, b3) < 0);
std::string a4("aaaaa");
std::string b4("AAAAA");
assert (UTF8::icompare(a4, b4) == 0);
std::string a5("AAAAA");
std::string b5("bbbbb");
assert (UTF8::icompare(a5, b5) < 0);
std::string a6("\303\274\303\266\303\244"); // "u"a"o
std::string b6("\303\234\303\226\303\204"); // "U"A"O
assert (UTF8::icompare(a6, b6) == 0);
}
void UTF8StringTest::testTransform()
{
std::string s1("abcde");
UTF8::toUpperInPlace(s1);
assert (s1 == "ABCDE");
std::string s2("aBcDe123");
UTF8::toUpperInPlace(s2);
assert (s2 == "ABCDE123");
std::string s3("\303\274\303\266\303\244"); // "u"a"o
UTF8::toUpperInPlace(s3);
assert (s3 == "\303\234\303\226\303\204"); // "U"A"O
UTF8::toLowerInPlace(s3);
assert (s3 == "\303\274\303\266\303\244"); // "U"A"O
}
void UTF8StringTest::setUp()
{
}
void UTF8StringTest::tearDown()
{
}
CppUnit::Test* UTF8StringTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("UTF8StringTest");
CppUnit_addTest(pSuite, UTF8StringTest, testCompare);
CppUnit_addTest(pSuite, UTF8StringTest, testTransform);
return pSuite;
}

View File

@@ -0,0 +1,61 @@
//
// UTF8StringTest.h
//
// $Id: //poco/Main/Foundation/testsuite/src/UTF8StringTest.h#1 $
//
// Definition of the UTF8StringTest 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 UTF8StringTest_INCLUDED
#define UTF8StringTest_INCLUDED
#include "Poco/Foundation.h"
#include "CppUnit/TestCase.h"
class UTF8StringTest: public CppUnit::TestCase
{
public:
UTF8StringTest(const std::string& name);
~UTF8StringTest();
void testCompare();
void testTransform();
void setUp();
void tearDown();
static CppUnit::Test* suite();
private:
};
#endif // UTF8StringTest_INCLUDED