mirror of
https://github.com/pocoproject/poco.git
synced 2024-12-13 10:32:57 +01:00
integrated changes from main repository
This commit is contained in:
parent
13f73441e2
commit
d9d531350d
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Format.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Format.h#1 $
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/Format.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -93,6 +93,7 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
|
||||
/// * E signed floating-point value in the form [-]d.ddddE[<sign>]dd[d]
|
||||
/// * f signed floating-point value in the form [-]dddd.dddd
|
||||
/// * s std::string
|
||||
/// * z std::size_t
|
||||
///
|
||||
/// The following flags are supported:
|
||||
///
|
||||
@ -108,6 +109,7 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
|
||||
/// * l argument is long (d, i), unsigned long (o, u, x, X) or long double (e, E, f, g, G)
|
||||
/// * L argument is long long (d, i), unsigned long long (o, u, x, X)
|
||||
/// * h argument is short (d, i), unsigned short (o, u, x, X) or float (e, E, f, g, G)
|
||||
/// * * argument is any signed or unsigned integer (d, i, o, x, X)
|
||||
///
|
||||
/// The width argument is a nonnegative decimal integer controlling the minimum number of characters printed.
|
||||
/// If the number of characters in the output value is less than the specified width, blanks or
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// TaskNotification.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/TaskNotification.h#1 $
|
||||
// $Id: //poco/1.3/Foundation/include/Poco/TaskNotification.h#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Tasks
|
||||
@ -146,7 +146,7 @@ class TaskCustomNotification: public TaskNotification
|
||||
/// mechanism between the task and its observer(s).
|
||||
{
|
||||
public:
|
||||
TaskCustomNotification(Task* pTask, C& custom):
|
||||
TaskCustomNotification(Task* pTask, const C& custom):
|
||||
TaskNotification(pTask),
|
||||
_custom(custom)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// Format.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/src/Format.cpp#1 $
|
||||
// $Id: //poco/1.3/Foundation/src/Format.cpp#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@ -50,7 +50,8 @@
|
||||
#include "Poco/Format.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <sstream>
|
||||
#include <ctype.h>
|
||||
#include <cctype>
|
||||
#include <cstddef>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
@ -111,7 +112,8 @@ namespace
|
||||
{
|
||||
case 'l':
|
||||
case 'h':
|
||||
case 'L': mod = *itFmt++; break;
|
||||
case 'L':
|
||||
case '*': mod = *itFmt++; break;
|
||||
}
|
||||
}
|
||||
return mod;
|
||||
@ -132,6 +134,33 @@ namespace
|
||||
case 'f': str << std::fixed; break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void writeAnyInt(std::ostream& str, const Any& any)
|
||||
{
|
||||
if (any.type() == typeid(char))
|
||||
str << static_cast<int>(AnyCast<char>(any));
|
||||
else if (any.type() == typeid(signed char))
|
||||
str << static_cast<int>(AnyCast<signed char>(any));
|
||||
else if (any.type() == typeid(unsigned char))
|
||||
str << static_cast<unsigned>(AnyCast<unsigned char>(any));
|
||||
else if (any.type() == typeid(short))
|
||||
str << AnyCast<short>(any);
|
||||
else if (any.type() == typeid(unsigned short))
|
||||
str << AnyCast<unsigned short>(any);
|
||||
else if (any.type() == typeid(int))
|
||||
str << AnyCast<int>(any);
|
||||
else if (any.type() == typeid(unsigned int))
|
||||
str << AnyCast<unsigned int>(any);
|
||||
else if (any.type() == typeid(long))
|
||||
str << AnyCast<long>(any);
|
||||
else if (any.type() == typeid(unsigned long))
|
||||
str << AnyCast<unsigned long>(any);
|
||||
else if (any.type() == typeid(Int64))
|
||||
str << AnyCast<Int64>(any);
|
||||
else if (any.type() == typeid(UInt64))
|
||||
str << AnyCast<UInt64>(any);
|
||||
}
|
||||
|
||||
|
||||
void formatOne(std::string& result, std::string::const_iterator& itFmt, const std::string::const_iterator& endFmt, std::vector<Any>::const_iterator& itVal)
|
||||
@ -157,6 +186,7 @@ namespace
|
||||
case 'l': str << AnyCast<long>(*itVal++); break;
|
||||
case 'L': str << AnyCast<Int64>(*itVal++); break;
|
||||
case 'h': str << AnyCast<short>(*itVal++); break;
|
||||
case '*': writeAnyInt(str, *itVal++); break;
|
||||
default: str << AnyCast<int>(*itVal++); break;
|
||||
}
|
||||
break;
|
||||
@ -169,6 +199,7 @@ namespace
|
||||
case 'l': str << AnyCast<unsigned long>(*itVal++); break;
|
||||
case 'L': str << AnyCast<UInt64>(*itVal++); break;
|
||||
case 'h': str << AnyCast<unsigned short>(*itVal++); break;
|
||||
case '*': writeAnyInt(str, *itVal++); break;
|
||||
default: str << AnyCast<unsigned>(*itVal++); break;
|
||||
}
|
||||
break;
|
||||
@ -186,6 +217,11 @@ namespace
|
||||
case 's':
|
||||
str << RefAnyCast<std::string>(*itVal++);
|
||||
break;
|
||||
case 'z':
|
||||
str << AnyCast<std::size_t>(*itVal++);
|
||||
break;
|
||||
case 'I':
|
||||
case 'D':
|
||||
default:
|
||||
str << type;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// PurgeStrategy.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/src/PurgeStrategy.cpp#1 $
|
||||
// $Id: //poco/1.3/Foundation/src/PurgeStrategy.cpp#2 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Logging
|
||||
@ -66,7 +66,7 @@ void PurgeStrategy::list(const std::string& path, std::vector<File>& files)
|
||||
std::string baseName = p.getFileName();
|
||||
baseName.append(".");
|
||||
|
||||
DirectoryIterator it(Path::current());
|
||||
DirectoryIterator it(parent);
|
||||
DirectoryIterator end;
|
||||
while (it != end)
|
||||
{
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FormatTest.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.cpp#1 $
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.cpp#2 $
|
||||
//
|
||||
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
|
||||
// All rights reserved.
|
||||
@ -208,7 +208,62 @@ void FormatTest::testInt()
|
||||
catch (BadCastException&)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void FormatTest::testAnyInt()
|
||||
{
|
||||
char c = 42;
|
||||
std::string s(format("%*i", c));
|
||||
assert (s == "42");
|
||||
|
||||
signed char sc = -42;
|
||||
s = format("%*i", sc);
|
||||
assert (s == "-42");
|
||||
|
||||
unsigned char uc = 65;
|
||||
s = format("%*i", uc);
|
||||
assert (s == "65");
|
||||
|
||||
short ss = -134;
|
||||
s = format("%*i", ss);
|
||||
assert (s == "-134");
|
||||
|
||||
unsigned short us = 200;
|
||||
s = format("%*i", us);
|
||||
assert (s == "200");
|
||||
|
||||
int i = -12345;
|
||||
s = format("%*i", i);
|
||||
assert (s == "-12345");
|
||||
|
||||
unsigned ui = 12345;
|
||||
s = format("%*i", ui);
|
||||
assert (s == "12345");
|
||||
|
||||
long l = -54321;
|
||||
s = format("%*i", l);
|
||||
assert (s == "-54321");
|
||||
|
||||
unsigned long ul = 54321;
|
||||
s = format("%*i", ul);
|
||||
assert (s == "54321");
|
||||
|
||||
Int64 i64 = -12345678;
|
||||
s = format("%*i", i64);
|
||||
assert (s == "-12345678");
|
||||
|
||||
UInt64 ui64 = 12345678;
|
||||
s = format("%*i", ui64);
|
||||
assert (s == "12345678");
|
||||
|
||||
ss = 0x42;
|
||||
s = format("%*x", ss);
|
||||
assert (s == "42");
|
||||
|
||||
ss = 042;
|
||||
s = format("%*o", ss);
|
||||
assert (s == "42");
|
||||
}
|
||||
|
||||
|
||||
@ -301,6 +356,7 @@ CppUnit::Test* FormatTest::suite()
|
||||
|
||||
CppUnit_addTest(pSuite, FormatTest, testChar);
|
||||
CppUnit_addTest(pSuite, FormatTest, testInt);
|
||||
CppUnit_addTest(pSuite, FormatTest, testAnyInt);
|
||||
CppUnit_addTest(pSuite, FormatTest, testFloatFix);
|
||||
CppUnit_addTest(pSuite, FormatTest, testFloatSci);
|
||||
CppUnit_addTest(pSuite, FormatTest, testString);
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// FormatTest.h
|
||||
//
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.h#1 $
|
||||
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.h#2 $
|
||||
//
|
||||
// Definition of the FormatTest class.
|
||||
//
|
||||
@ -61,6 +61,7 @@ public:
|
||||
|
||||
void testChar();
|
||||
void testInt();
|
||||
void testAnyInt();
|
||||
void testFloatFix();
|
||||
void testFloatSci();
|
||||
void testString();
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPRequest.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Net/src/HTTPRequest.cpp#1 $
|
||||
// $Id: //poco/1.3/Net/src/HTTPRequest.cpp#2 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTP
|
||||
@ -211,10 +211,10 @@ void HTTPRequest::read(std::istream& istr)
|
||||
while (isspace(ch)) ch = istr.get();
|
||||
if (ch == eof) throw MessageException("No HTTP request header");
|
||||
while (!isspace(ch) && ch != eof && method.length() < MAX_METHOD_LENGTH) { method += (char) ch; ch = istr.get(); }
|
||||
if (!isspace(ch)) throw MessageException("HTTP request method too long");
|
||||
if (!isspace(ch)) throw MessageException("HTTP request method invalid or too long");
|
||||
while (isspace(ch)) ch = istr.get();
|
||||
while (!isspace(ch) && ch != eof && uri.length() < MAX_URI_LENGTH) { uri += (char) ch; ch = istr.get(); }
|
||||
if (!isspace(ch)) throw MessageException("HTTP request URI too long");
|
||||
if (!isspace(ch)) throw MessageException("HTTP request URI invalid or too long");
|
||||
while (isspace(ch)) ch = istr.get();
|
||||
while (!isspace(ch) && ch != eof && version.length() < MAX_VERSION_LENGTH) { version += (char) ch; ch = istr.get(); }
|
||||
if (!isspace(ch)) throw MessageException("Invalid HTTP version string");
|
||||
|
@ -1,7 +1,7 @@
|
||||
//
|
||||
// HTTPServerSession.cpp
|
||||
//
|
||||
// $Id: //poco/1.3/Net/src/HTTPServerSession.cpp#1 $
|
||||
// $Id: //poco/1.3/Net/src/HTTPServerSession.cpp#2 $
|
||||
//
|
||||
// Library: Net
|
||||
// Package: HTTPServer
|
||||
@ -64,9 +64,10 @@ bool HTTPServerSession::hasMoreRequests()
|
||||
--_maxKeepAliveRequests;
|
||||
return socket().poll(getTimeout(), Socket::SELECT_READ);
|
||||
}
|
||||
else if (_maxKeepAliveRequests > 0 && getKeepAlive())
|
||||
else if (_maxKeepAliveRequests != 0 && getKeepAlive())
|
||||
{
|
||||
--_maxKeepAliveRequests;
|
||||
if (_maxKeepAliveRequests > 0)
|
||||
--_maxKeepAliveRequests;
|
||||
return socket().poll(_keepAliveTimeout, Socket::SELECT_READ);
|
||||
}
|
||||
else return false;
|
||||
|
Loading…
Reference in New Issue
Block a user