changes for 1.3.2

This commit is contained in:
Guenter Obiltschnig 2008-01-28 17:54:26 +00:00
parent 4f5b88bc3d
commit 112149e736
131 changed files with 2477 additions and 1087 deletions

View File

@ -1,5 +1,48 @@
This is the changelog file for the POCO C++ Libraries.
Release 1.3.2 (2008-01-30)
==========================
Foundation, XML, Net, Util:
- added POCO_NO_SHAREDMEMORY to Config.h
- POCO_NO_WSTRING now really disables all wide string related calls
- added template specialization for string hashfunction (performance)
- XML parser performance improvements (SAX parser is now up to 40 % faster
- added parseMemoryNP() to XMLReader and friends
- URIStreamOpener improvement: redirect logic is now in URIStreamOpener.
this enables support for redirects from http to https.
- added support for temporary redirects and useproxy return code
- added getBlocking() to Socket
- added File::isHidden()
- better WIN64 support (AMD64 and IA64 platforms are recognized)
- added support for timed lock operations to [Fast]Mutex
- SharedLibrary: dlopen() is called with RTLD_GLOBAL instead of RTLD_LOCAL
(see http://gcc.gnu.org/faq.html#dso)
- Poco::Timer threads can now run with a specified priority
- added testcase for SF# 1774351
- fixed SF# 1784772: Message::swap omits _tid mem
- fixed SF# 1790894: IPAddress(addr,family) doesn't fail on invalid address
- fixed SF# 1804395: Constructor argument name wrong
- fixed SF# 1806807: XMLWriter::characters should ignore empty strings
- fixed SF# 1806994: property application.runAsService set too late
- fixed SF# 1828908: HTMLForm does not encode '+'
- fixed SF# 1831871: Windows configuration file line endings not correct.
- fixed SF# 1845545: TCP server hangs on shutdown
- fixed SF# 1846734: Option::validator() does not behave according to doc
- fixed SF# 1856567: Assertion in DateTimeParser::tryParse()
- fixed SF# 1864832: HTTP server sendFile() uses incorrect date
- HTTPServerResponseImpl now always sets the Date header automatically
in the constructor.
- fixed SF# 1787667: DateTimeFormatter and time related classes
(also SF# 1800031: The wrong behavior of time related classes)
- fixed SF# 1829700: TaskManager::_taskList contains tasks that never started
- fixed SF# 1834127: Anonymous enums in Tuple.h result in invalid C++
- fixed SF# 1834130: RunnableAdapter::operator= not returning a value
- fixed SF# 1873924: Add exception code to NetException
- fixed SF# 1873929: SMTPClientSession support for name in sender field
- logging performance improvements (PatternFormatter)
Release 1.3.1 (2007-08-08)
==========================
@ -775,4 +818,4 @@ building the libraries.
--
$Id: //poco/1.3/dist/CHANGELOG#12 $
$Id: //poco/1.3/dist/CHANGELOG#15 $

View File

@ -8,6 +8,10 @@ Andrew J. P. Maclean <a.maclean@optusnet.com.au>
Paschal Mushubi <mushubi@sympatico.ca>
Sergey N. Yatskevich <snc@begun.ru>
Krzysztof Burghardt <burghardt@users.sourceforge.net>
David Shawley <boredc0der@users.sourceforge.net>
Larry Lewis <lewislp@users.sourceforge.net>
Ryan Kraay <rkraay@users.sourceforge.net>
Eran Hammer-Lahav <therazorblade@users.sourceforge.net>
--
$Id: //poco/1.3/dist/CONTRIBUTORS#3 $
$Id: //poco/1.3/dist/CONTRIBUTORS#4 $

View File

@ -1,7 +1,7 @@
//
// ActiveMethod.h
//
// $Id: //poco/1.3/Foundation/include/Poco/ActiveMethod.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/ActiveMethod.h#3 $
//
// Library: Foundation
// Package: Threading
@ -115,10 +115,119 @@ public:
return result;
}
ActiveMethod(const ActiveMethod& other):
_pOwner(other._pOwner),
_method(other._method)
{
}
ActiveMethod& operator = (const ActiveMethod& other)
{
ActiveMethod tmp(other);
swap(tmp);
return *this;
}
void swap(ActiveMethod& other)
{
std::swap(_pOwner, other._pOwner);
std::swap(_method, other._method);
}
private:
ActiveMethod();
OwnerType* _pOwner;
Callback _method;
};
template <class ResultType, class OwnerType, class StarterType>
class ActiveMethod <ResultType, void, OwnerType, StarterType>
/// An active method is a method that, when called, executes
/// in its own thread. ActiveMethod's take exactly one
/// argument and can return a value. To pass more than one
/// argument to the method, use a struct.
/// The following example shows how to add an ActiveMethod
/// to a class:
///
/// class ActiveObject
/// {
/// public:
/// ActiveObject():
/// exampleActiveMethod(this, &ActiveObject::exampleActiveMethodImpl)
/// {
/// }
///
/// ActiveMethod<std::string, std::string, ActiveObject> exampleActiveMethod;
///
/// protected:
/// std::string exampleActiveMethodImpl(const std::string& arg)
/// {
/// ...
/// }
/// };
///
/// And following is an example that shows how to invoke an ActiveMethod.
///
/// ActiveObject myActiveObject;
/// ActiveResult<std::string> result = myActiveObject.exampleActiveMethod("foo");
/// ...
/// result.wait();
/// std::cout << result.data() << std::endl;
///
/// The way an ActiveMethod is started can be changed by passing a StarterType
/// template argument with a corresponding class. The default ActiveStarter
/// starts the method in its own thread, obtained from a thread pool.
///
/// For an alternative implementation of StarterType, see ActiveDispatcher.
///
/// For methods that do not require an argument or a return value, simply use void.
{
public:
typedef ResultType (OwnerType::*Callback)(void);
typedef ActiveResult<ResultType> ActiveResultType;
typedef ActiveRunnable<ResultType, void, OwnerType> ActiveRunnableType;
ActiveMethod(OwnerType* pOwner, Callback method):
_pOwner(pOwner),
_method(method)
/// Creates an ActiveMethod object.
{
poco_check_ptr (pOwner);
}
ActiveResultType operator () (void)
/// Invokes the ActiveMethod.
{
ActiveResultType result(new ActiveResultHolder<ResultType>());
ActiveRunnableBase::Ptr pRunnable(new ActiveRunnableType(_pOwner, _method, result));
StarterType::start(_pOwner, pRunnable);
return result;
}
ActiveMethod(const ActiveMethod& other):
_pOwner(other._pOwner),
_method(other._method)
{
}
ActiveMethod& operator = (const ActiveMethod& other)
{
ActiveMethod tmp(other);
swap(tmp);
return *this;
}
void swap(ActiveMethod& other)
{
std::swap(_pOwner, other._pOwner);
std::swap(_method, other._method);
}
private:
ActiveMethod();
ActiveMethod(const ActiveMethod&);
ActiveMethod& operator = (const ActiveMethod&);
OwnerType* _pOwner;
Callback _method;

View File

@ -1,7 +1,7 @@
//
// ActiveResult.h
//
// $Id: //poco/1.3/Foundation/include/Poco/ActiveResult.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/ActiveResult.h#3 $
//
// Library: Foundation
// Package: Threading
@ -162,6 +162,97 @@ private:
};
template <>
class ActiveResultHolder<void>: public RefCountedObject
{
public:
ActiveResultHolder():
_pExc(0),
_event(false)
/// Creates an ActiveResultHolder.
{
}
void wait()
/// Pauses the caller until the result becomes available.
{
_event.wait();
}
bool tryWait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Returns true if the result became
/// available, false otherwise.
{
return _event.tryWait(milliseconds);
}
void wait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Throws a TimeoutException if the
/// result did not became available.
{
_event.wait(milliseconds);
}
void notify()
/// Notifies the invoking thread that the result became available.
{
_event.set();
}
bool failed() const
/// Returns true if the active method failed (and threw an exception).
/// Information about the exception can be obtained by calling error().
{
return _pExc != 0;
}
std::string error() const
/// If the active method threw an exception, a textual representation
/// of the exception is returned. An empty string is returned if the
/// active method completed successfully.
{
if (_pExc)
return _pExc->message();
else
return std::string();
}
Exception* exception() const
/// If the active method threw an exception, a clone of the exception
/// object is returned, otherwise null.
{
return _pExc;
}
void error(const Exception& exc)
/// Sets the exception.
{
delete _pExc;
_pExc = exc.clone();
}
void error(const std::string& msg)
/// Sets the exception.
{
delete _pExc;
_pExc = new UnhandledException(msg);
}
protected:
~ActiveResultHolder()
{
delete _pExc;
}
private:
Exception* _pExc;
Event _event;
};
template <class RT>
class ActiveResult
/// This class holds the result of an asynchronous method
@ -300,6 +391,126 @@ private:
};
template <>
class ActiveResult<void>
/// This class holds the result of an asynchronous method
/// invocation (see class ActiveMethod). It is used to pass the
/// result from the execution thread back to the invocation thread.
{
public:
typedef ActiveResultHolder<void> ActiveResultHolderType;
ActiveResult(ActiveResultHolderType* pHolder):
_pHolder(pHolder)
/// Creates the active result. For internal use only.
{
poco_check_ptr (pHolder);
}
ActiveResult(const ActiveResult& result)
/// Copy constructor.
{
_pHolder = result._pHolder;
_pHolder->duplicate();
}
~ActiveResult()
/// Destroys the result.
{
_pHolder->release();
}
ActiveResult& operator = (const ActiveResult& result)
/// Assignment operator.
{
ActiveResult tmp(result);
swap(tmp);
return *this;
}
void swap(ActiveResult& result)
{
using std::swap;
swap(_pHolder, result._pHolder);
}
void wait()
/// Pauses the caller until the result becomes available.
{
_pHolder->wait();
}
bool tryWait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Returns true if the result became
/// available, false otherwise.
{
return _pHolder->tryWait(milliseconds);
}
void wait(long milliseconds)
/// Waits up to the specified interval for the result to
/// become available. Throws a TimeoutException if the
/// result did not became available.
{
_pHolder->wait(milliseconds);
}
bool available() const
/// Returns true if a result is available.
{
return _pHolder->tryWait(0);
}
bool failed() const
/// Returns true if the active method failed (and threw an exception).
/// Information about the exception can be obtained by calling error().
{
return _pHolder->failed();
}
std::string error() const
/// If the active method threw an exception, a textual representation
/// of the exception is returned. An empty string is returned if the
/// active method completed successfully.
{
return _pHolder->error();
}
Exception* exception() const
/// If the active method threw an exception, a clone of the exception
/// object is returned, otherwise null.
{
return _pHolder->exception();
}
void notify()
/// Notifies the invoking thread that the result became available.
/// For internal use only.
{
_pHolder->notify();
}
void error(const std::string& msg)
/// Sets the failed flag and the exception message.
{
_pHolder->error(msg);
}
void error(const Exception& exc)
/// Sets the failed flag and the exception message.
{
_pHolder->error(exc);
}
private:
ActiveResult();
ActiveResultHolderType* _pHolder;
};
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// ActiveRunnable.h
//
// $Id: //poco/1.3/Foundation/include/Poco/ActiveRunnable.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/ActiveRunnable.h#3 $
//
// Library: Foundation
// Package: Threading
@ -107,6 +107,146 @@ private:
};
template <class ArgType, class OwnerType>
class ActiveRunnable<void, ArgType, OwnerType>: public ActiveRunnableBase
/// This class is used by ActiveMethod.
/// See the ActiveMethod class for more information.
{
public:
typedef void (OwnerType::*Callback)(const ArgType&);
typedef ActiveResult<void> ActiveResultType;
ActiveRunnable(OwnerType* pOwner, Callback method, const ArgType& arg, const ActiveResultType& result):
_pOwner(pOwner),
_method(method),
_arg(arg),
_result(result)
{
poco_check_ptr (pOwner);
}
void run()
{
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
try
{
(_pOwner->*_method)(_arg);
}
catch (Exception& e)
{
_result.error(e);
}
catch (std::exception& e)
{
_result.error(e.what());
}
catch (...)
{
_result.error("unknown exception");
}
_result.notify();
}
private:
OwnerType* _pOwner;
Callback _method;
ArgType _arg;
ActiveResultType _result;
};
template <class ResultType, class OwnerType>
class ActiveRunnable<ResultType, void, OwnerType>: public ActiveRunnableBase
/// This class is used by ActiveMethod.
/// See the ActiveMethod class for more information.
{
public:
typedef ResultType (OwnerType::*Callback)();
typedef ActiveResult<ResultType> ActiveResultType;
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
_pOwner(pOwner),
_method(method),
_result(result)
{
poco_check_ptr (pOwner);
}
void run()
{
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
try
{
_result.data(new ResultType((_pOwner->*_method)()));
}
catch (Exception& e)
{
_result.error(e);
}
catch (std::exception& e)
{
_result.error(e.what());
}
catch (...)
{
_result.error("unknown exception");
}
_result.notify();
}
private:
OwnerType* _pOwner;
Callback _method;
ActiveResultType _result;
};
template <class OwnerType>
class ActiveRunnable<void, void, OwnerType>: public ActiveRunnableBase
/// This class is used by ActiveMethod.
/// See the ActiveMethod class for more information.
{
public:
typedef void (OwnerType::*Callback)();
typedef ActiveResult<void> ActiveResultType;
ActiveRunnable(OwnerType* pOwner, Callback method, const ActiveResultType& result):
_pOwner(pOwner),
_method(method),
_result(result)
{
poco_check_ptr (pOwner);
}
void run()
{
ActiveRunnableBase::Ptr guard(this, false); // ensure automatic release when done
try
{
(_pOwner->*_method)();
}
catch (Exception& e)
{
_result.error(e);
}
catch (std::exception& e)
{
_result.error(e.what());
}
catch (...)
{
_result.error("unknown exception");
}
_result.notify();
}
private:
OwnerType* _pOwner;
Callback _method;
ActiveResultType _result;
};
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// Config.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Config.h#3 $
// $Id: //poco/1.3/Foundation/include/Poco/Config.h#6 $
//
// Library: Foundation
// Package: Core
@ -56,4 +56,8 @@
// #define POCO_NO_WSTRING
// Define to disable shared memory
// #define POCO_NO_SHAREDMEMORY
#endif // Foundation_Config_INCLUDED

View File

@ -1,7 +1,7 @@
//
// Exception.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Exception.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/Exception.h#2 $
//
// Library: Foundation
// Package: Core
@ -52,13 +52,13 @@ class Foundation_API Exception: public std::exception
/// in the Poco class library.
{
public:
Exception(const std::string& msg);
Exception(const std::string& msg, int code = 0);
/// Creates an exception.
Exception(const std::string& msg, const std::string& arg);
Exception(const std::string& msg, const std::string& arg, int code = 0);
/// Creates an exception.
Exception(const std::string& msg, const Exception& nested);
Exception(const std::string& msg, const Exception& nested, int code = 0);
/// Creates an exception and stores a clone
/// of the nested exception.
@ -88,6 +88,9 @@ public:
const std::string& message() const;
/// Returns the message text.
int code() const;
/// Returns the exception code if defined.
std::string displayText() const;
/// Returns a string consisting of the
@ -107,12 +110,13 @@ public:
/// throwing it again.
protected:
Exception();
Exception(int code = 0);
/// Standard constructor.
private:
std::string _msg;
Exception* _pNested;
int _code;
};
@ -131,6 +135,12 @@ inline const std::string& Exception::message() const
}
inline int Exception::code() const
{
return _code;
}
//
// Macros for quickly declaring and implementing exception classes.
// Unfortunately, we cannot use a template here because character
@ -138,62 +148,62 @@ inline const std::string& Exception::message() const
// are not allowed as template arguments.
//
#define POCO_DECLARE_EXCEPTION(API, CLS, BASE) \
class API CLS: public BASE \
{ \
public: \
CLS(); \
CLS(const std::string& msg); \
CLS(const std::string& msg, const std::string& arg); \
CLS(const std::string& msg, const Poco::Exception& exc); \
CLS(const CLS& exc); \
~CLS() throw(); \
CLS& operator = (const CLS& exc); \
const char* name() const throw(); \
const char* className() const throw(); \
Poco::Exception* clone() const; \
void rethrow() const; \
class API CLS: public BASE \
{ \
public: \
CLS(int code = 0); \
CLS(const std::string& msg, int code = 0); \
CLS(const std::string& msg, const std::string& arg, int code = 0); \
CLS(const std::string& msg, const Poco::Exception& exc, int code = 0); \
CLS(const CLS& exc); \
~CLS() throw(); \
CLS& operator = (const CLS& exc); \
const char* name() const throw(); \
const char* className() const throw(); \
Poco::Exception* clone() const; \
void rethrow() const; \
};
#define POCO_IMPLEMENT_EXCEPTION(CLS, BASE, NAME) \
CLS::CLS() \
{ \
} \
CLS::CLS(const std::string& msg): BASE(msg) \
{ \
} \
CLS::CLS(const std::string& msg, const std::string& arg): BASE(msg, arg) \
{ \
} \
CLS::CLS(const std::string& msg, const Poco::Exception& exc): BASE(msg, exc) \
{ \
} \
CLS::CLS(const CLS& exc): BASE(exc) \
{ \
} \
CLS::~CLS() throw() \
{ \
} \
CLS& CLS::operator = (const CLS& exc) \
{ \
BASE::operator = (exc); \
return *this; \
} \
const char* CLS::name() const throw() \
{ \
return NAME; \
} \
const char* CLS::className() const throw() \
{ \
return typeid(*this).name(); \
} \
Poco::Exception* CLS::clone() const \
{ \
return new CLS(*this); \
} \
void CLS::rethrow() const \
{ \
throw *this; \
#define POCO_IMPLEMENT_EXCEPTION(CLS, BASE, NAME) \
CLS::CLS(int code): BASE(code) \
{ \
} \
CLS::CLS(const std::string& msg, int code): BASE(msg, code) \
{ \
} \
CLS::CLS(const std::string& msg, const std::string& arg, int code): BASE(msg, arg, code) \
{ \
} \
CLS::CLS(const std::string& msg, const Poco::Exception& exc, int code): BASE(msg, exc, code) \
{ \
} \
CLS::CLS(const CLS& exc): BASE(exc) \
{ \
} \
CLS::~CLS() throw() \
{ \
} \
CLS& CLS::operator = (const CLS& exc) \
{ \
BASE::operator = (exc); \
return *this; \
} \
const char* CLS::name() const throw() \
{ \
return NAME; \
} \
const char* CLS::className() const throw() \
{ \
return typeid(*this).name(); \
} \
Poco::Exception* CLS::clone() const \
{ \
return new CLS(*this); \
} \
void CLS::rethrow() const \
{ \
throw *this; \
}

View File

@ -1,7 +1,7 @@
//
// File.h
//
// $Id: //poco/1.3/Foundation/include/Poco/File.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/File.h#4 $
//
// Library: Foundation
// Package: Filesystem
@ -129,7 +129,16 @@ public:
bool isDirectory() const;
/// Returns true iff the file is a directory.
bool isHidden() const;
/// Returns true if the file is hidden.
///
/// On Windows platforms, the file's hidden
/// attribute is set for this to be true.
///
/// On Unix platforms, the file name must
/// begin with a period for this to be true.
Timestamp created() const;
/// Returns the creation date of the file.

View File

@ -1,7 +1,7 @@
//
// File_UNIX.h
//
// $Id: //poco/1.3/Foundation/include/Poco/File_UNIX.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/File_UNIX.h#3 $
//
// Library: Foundation
// Package: Filesystem
@ -64,6 +64,7 @@ protected:
bool isFileImpl() const;
bool isDirectoryImpl() const;
bool isLinkImpl() const;
bool isHiddenImpl() const;
Timestamp createdImpl() const;
Timestamp getLastModifiedImpl() const;
void setLastModifiedImpl(const Timestamp& ts);

View File

@ -1,7 +1,7 @@
//
// File_VMS.h
//
// $Id: //poco/1.3/Foundation/include/Poco/File_VMS.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/File_VMS.h#3 $
//
// Library: Foundation
// Package: Filesystem
@ -65,6 +65,7 @@ protected:
bool isFileImpl() const;
bool isDirectoryImpl() const;
bool isLinkImpl() const;
bool isHiddenImpl() const;
Timestamp createdImpl() const;
Timestamp getLastModifiedImpl() const;
void setLastModifiedImpl(const Timestamp& ts);

View File

@ -1,7 +1,7 @@
//
// File_WIN32.h
//
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32.h#3 $
//
// Library: Foundation
// Package: Filesystem
@ -65,6 +65,7 @@ protected:
bool isFileImpl() const;
bool isDirectoryImpl() const;
bool isLinkImpl() const;
bool isHiddenImpl() const;
Timestamp createdImpl() const;
Timestamp getLastModifiedImpl() const;
void setLastModifiedImpl(const Timestamp& ts);

View File

@ -1,7 +1,7 @@
//
// File_WIN32U.h
//
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32U.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/File_WIN32U.h#3 $
//
// Library: Foundation
// Package: Filesystem
@ -65,6 +65,7 @@ protected:
bool isFileImpl() const;
bool isDirectoryImpl() const;
bool isLinkImpl() const;
bool isHiddenImpl() const;
Timestamp createdImpl() const;
Timestamp getLastModifiedImpl() const;
void setLastModifiedImpl(const Timestamp& ts);

View File

@ -1,7 +1,7 @@
//
// Format.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Format.h#4 $
// $Id: //poco/1.3/Foundation/include/Poco/Format.h#5 $
//
// Library: Foundation
// Package: Core
@ -82,6 +82,7 @@ std::string Foundation_API format(const std::string& fmt, const Any& value);
///
/// Following are valid type specifications and their meaning:
///
/// * b boolean (true = 1, false = 0)
/// * c character
/// * d signed decimal integer
/// * i signed decimal integer

View File

@ -1,7 +1,7 @@
//
// HashFunction.h
//
// $Id: //poco/1.3/Foundation/include/Poco/HashFunction.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/HashFunction.h#2 $
//
// Library: Foundation
// Package: Hashing
@ -60,6 +60,19 @@ struct HashFunction
};
//@ deprecated
template <>
struct HashFunction<std::string>
/// A generic hash function.
{
UInt32 operator () (const std::string& key, UInt32 maxValue) const
/// Returns the hash value for the given key.
{
return ((UInt32) hash(key)) % maxValue;
}
};
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// LocalDateTime.h
//
// $Id: //poco/1.3/Foundation/include/Poco/LocalDateTime.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/LocalDateTime.h#3 $
//
// Library: Foundation
// Package: DateTime
@ -64,6 +64,14 @@ class Foundation_API LocalDateTime
/// class for better performance. The relational operators
/// normalize the dates/times involved to UTC before carrying out
/// the comparison.
///
/// The time zone differential is based on the input date and
/// time and current time zone. A number of constructors accept
/// an explicit time zone differential parameter. These should
/// not be used since daylight savings time processing is impossible
/// since the time zone is unknown. Each of the constructors
/// accepting a tzd parameter have been marked as deprecated and
/// may be removed in a future revision.
{
public:
LocalDateTime();
@ -81,6 +89,7 @@ public:
/// * millisecond is from 0 to 999.
/// * microsecond is from 0 to 999.
//@ deprecated
LocalDateTime(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond);
/// Creates a DateTime for the given Gregorian date and time in the
/// time zone denoted by the time zone differential in tzd.
@ -98,11 +107,13 @@ public:
/// Creates a LocalDateTime from the UTC time given in dateTime,
/// using the time zone differential of the current time zone.
//@ deprecated
LocalDateTime(int tzd, const DateTime& dateTime);
/// Creates a LocalDateTime from the UTC time given in dateTime,
/// using the given time zone differential. Adjusts dateTime
/// for the given time zone differential.
//@ deprecated
LocalDateTime(int tzd, const DateTime& dateTime, bool adjust);
/// Creates a LocalDateTime from the UTC time given in dateTime,
/// using the given time zone differential. If adjust is true,
@ -111,6 +122,7 @@ public:
LocalDateTime(double julianDay);
/// Creates a LocalDateTime for the given Julian day in the local time zone.
//@ deprecated
LocalDateTime(int tzd, double julianDay);
/// Creates a LocalDateTime for the given Julian day in the time zone
/// denoted by the time zone differential in tzd.
@ -141,6 +153,7 @@ public:
/// * millisecond is from 0 to 999.
/// * microsecond is from 0 to 999.
//@ deprecated
LocalDateTime& assign(int tzd, int year, int month, int day, int hour, int minute, int second, int millisecond, int microseconds);
/// Assigns a Gregorian local date and time in the time zone denoted by
/// the time zone differential in tzd.
@ -154,6 +167,7 @@ public:
/// * millisecond is from 0 to 999.
/// * microsecond is from 0 to 999.
//@ deprecated
LocalDateTime& assign(int tzd, double julianDay);
/// Assigns a Julian day in the time zone denoted by the
/// time zone differential in tzd.
@ -245,6 +259,15 @@ public:
protected:
LocalDateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff diff, int tzd);
void determineTzd(bool adjust = false);
/// Recalculate the tzd based on the _dateTime member based
/// on the current timezone using the Standard C runtime functions.
/// If adjust is true, then adjustForTzd() is called after the
/// differential is calculated.
void adjustForTzd();
/// Adjust the _dateTime member based on the _tzd member.
private:
DateTime _dateTime;
@ -364,6 +387,12 @@ inline Timestamp::UtcTimeVal LocalDateTime::utcTime() const
}
inline void LocalDateTime::adjustForTzd()
{
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
}
inline void swap(LocalDateTime& d1, LocalDateTime& d2)
{
d1.swap(d2);

View File

@ -1,7 +1,7 @@
//
// Message.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Message.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/Message.h#3 $
//
// Library: Foundation
// Package: Logging
@ -187,6 +187,12 @@ inline Message::Priority Message::getPriority() const
}
inline const Timestamp& Message::getTime() const
{
return _time;
}
inline const std::string& Message::getThread() const
{
return _thread;

View File

@ -1,7 +1,7 @@
//
// Mutex.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Mutex.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/Mutex.h#2 $
//
// Library: Foundation
// Package: Threading
@ -9,7 +9,7 @@
//
// Definition of the Mutex and FastMutex classes.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@ -41,6 +41,7 @@
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include "Poco/ScopedLock.h"
@ -76,12 +77,30 @@ public:
void lock();
/// Locks the mutex. Blocks if the mutex
/// is held by another thread.
void lock(long milliseconds);
/// Locks the mutex. Blocks up to the given number of milliseconds
/// if the mutex is held by another thread. Throws a TimeoutException
/// if the mutex can not be locked within the given timeout.
///
/// Performance Note: On most platforms (including Windows), this member function is
/// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
/// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
bool tryLock();
/// Tries to lock the mutex. Returns false immediately
/// if the mutex is already held by another thread.
/// Returns true if the mutex was successfully locked.
bool tryLock(long milliseconds);
/// Locks the mutex. Blocks up to the given number of milliseconds
/// if the mutex is held by another thread.
/// Returns true if the mutex was successfully locked.
///
/// Performance Note: On most platforms (including Windows), this member function is
/// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
/// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
void unlock();
/// Unlocks the mutex so that it can be acquired by
/// other threads.
@ -114,11 +133,29 @@ public:
/// Locks the mutex. Blocks if the mutex
/// is held by another thread.
void lock(long milliseconds);
/// Locks the mutex. Blocks up to the given number of milliseconds
/// if the mutex is held by another thread. Throws a TimeoutException
/// if the mutex can not be locked within the given timeout.
///
/// Performance Note: On most platforms (including Windows), this member function is
/// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
/// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
bool tryLock();
/// Tries to lock the mutex. Returns false immediately
/// if the mutex is already held by another thread.
/// Returns true if the mutex was successfully locked.
bool tryLock(long milliseconds);
/// Locks the mutex. Blocks up to the given number of milliseconds
/// if the mutex is held by another thread.
/// Returns true if the mutex was successfully locked.
///
/// Performance Note: On most platforms (including Windows), this member function is
/// implemented using a loop calling (the equivalent of) tryLock() and Thread::sleep().
/// On POSIX platforms that support pthread_mutex_timedlock(), this is used.
void unlock();
/// Unlocks the mutex so that it can be acquired by
/// other threads.
@ -138,12 +175,25 @@ inline void Mutex::lock()
}
inline void Mutex::lock(long milliseconds)
{
if (!tryLockImpl(milliseconds))
throw TimeoutException();
}
inline bool Mutex::tryLock()
{
return tryLockImpl();
}
inline bool Mutex::tryLock(long milliseconds)
{
return tryLockImpl(milliseconds);
}
inline void Mutex::unlock()
{
unlockImpl();
@ -156,12 +206,25 @@ inline void FastMutex::lock()
}
inline void FastMutex::lock(long milliseconds)
{
if (!tryLockImpl(milliseconds))
throw TimeoutException();
}
inline bool FastMutex::tryLock()
{
return tryLockImpl();
}
inline bool FastMutex::tryLock(long milliseconds)
{
return tryLockImpl(milliseconds);
}
inline void FastMutex::unlock()
{
unlockImpl();

View File

@ -1,7 +1,7 @@
//
// Mutex_POSIX.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Mutex_POSIX.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/Mutex_POSIX.h#2 $
//
// Library: Foundation
// Package: Threading
@ -9,7 +9,7 @@
//
// Definition of the MutexImpl and FastMutexImpl classes for POSIX Threads.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@ -57,6 +57,7 @@ protected:
~MutexImpl();
void lockImpl();
bool tryLockImpl();
bool tryLockImpl(long milliseconds);
void unlockImpl();
private:

View File

@ -1,7 +1,7 @@
//
// Mutex_WIN32.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Mutex_WIN32.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/Mutex_WIN32.h#3 $
//
// Library: Foundation
// Package: Threading
@ -9,7 +9,7 @@
//
// Definition of the MutexImpl and FastMutexImpl classes for WIN32.
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@ -55,6 +55,7 @@ protected:
~MutexImpl();
void lockImpl();
bool tryLockImpl();
bool tryLockImpl(long milliseconds);
void unlockImpl();
private:

View File

@ -1,7 +1,7 @@
//
// PatternFormatter.h
//
// $Id: //poco/1.3/Foundation/include/Poco/PatternFormatter.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/PatternFormatter.h#2 $
//
// Library: Foundation
// Package: Logging
@ -132,7 +132,11 @@ public:
protected:
static const std::string& getPriorityName(int);
/// Returns a string for the given priority value.
static void fmt(std::string& str, int value);
static void fmt(std::string& str, int value, int width);
static void fmt0(std::string& str, int value, int width);
private:
bool _localTime;
std::string _pattern;

View File

@ -1,7 +1,7 @@
//
// Platform.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Platform.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/Platform.h#2 $
//
// Library: Foundation
// Package: Core
@ -148,7 +148,7 @@
#else
#define POCO_ARCH_LITTLE_ENDIAN 1
#endif
#elif defined(__x86_64__)
#elif defined(__x86_64__) || defined(_M_X64)
#define POCO_ARCH POCO_ARCH_AMD64
#define POCO_ARCH_LITTLE_ENDIAN 1
#elif defined(__mips__) || defined(__mips) || defined(__MIPS__) || defined(_M_MRX000)

View File

@ -1,7 +1,7 @@
//
// Platform_WIN32.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Platform_WIN32.h#4 $
// $Id: //poco/1.3/Foundation/include/Poco/Platform_WIN32.h#5 $
//
// Library: Foundation
// Package: Core
@ -82,4 +82,11 @@
#endif
#if defined(__INTEL_COMPILER)
#pragma warning(disable:1738) // base class dllexport/dllimport specification differs from that of the derived class
#pragma warning(disable:1478) // function ... was declared "deprecated"
#pragma warning(disable:1744) // field of class type without a DLL interface used in a class with a DLL interface
#endif
#endif // Foundation_Platform_WIN32_INCLUDED

View File

@ -1,7 +1,7 @@
//
// RunnableAdapter.h
//
// $Id: //poco/1.3/Foundation/include/Poco/RunnableAdapter.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/RunnableAdapter.h#2 $
//
// Library: Foundation
// Package: Threading
@ -75,6 +75,7 @@ public:
{
_pObject = ra._pObject;
_method = ra._method;
return *this;
}
void run()

View File

@ -1,7 +1,7 @@
//
// Timer.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Timer.h#2 $
// $Id: //poco/1.3/Foundation/include/Poco/Timer.h#3 $
//
// Library: Foundation
// Package: Threading
@ -44,6 +44,7 @@
#include "Poco/Runnable.h"
#include "Poco/Mutex.h"
#include "Poco/Event.h"
#include "Poco/Thread.h"
namespace Poco {
@ -92,11 +93,25 @@ public:
///
/// The timer thread is taken from the global default thread pool.
void start(const AbstractTimerCallback& method, Thread::Priority priority);
/// Starts the timer in a thread with the given priority.
/// Create the TimerCallback as follows:
/// TimerCallback<MyClass> callback(*this, &MyClass::onTimer);
/// timer.start(callback);
///
/// The timer thread is taken from the global default thread pool.
void start(const AbstractTimerCallback& method, ThreadPool& threadPool);
/// Starts the timer.
/// Create the TimerCallback as follows:
/// TimerCallback<MyClass> callback(*this, &MyClass::onTimer);
/// timer.start(callback);
void start(const AbstractTimerCallback& method, Thread::Priority priority, ThreadPool& threadPool);
/// Starts the timer in a thread with the given priority.
/// Create the TimerCallback as follows:
/// TimerCallback<MyClass> callback(*this, &MyClass::onTimer);
/// timer.start(callback);
void stop();
/// Stops the timer. If the callback method is currently running

View File

@ -1,7 +1,7 @@
//
// Tuple.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Tuple.h#4 $
// $Id: //poco/1.3/Foundation/include/Poco/Tuple.h#5 $
//
// Library: Foundation
// Package: Core
@ -78,7 +78,7 @@ struct Tuple
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,T19>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -191,7 +191,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18,N
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,T18>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -301,7 +301,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17,NullT
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,T17>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -408,7 +408,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16,NullTypeL
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,T16>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -512,7 +512,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15,NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,T15>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -613,7 +613,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14,NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,T14>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -711,7 +711,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13,NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12,T13>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -806,7 +806,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,T12>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -898,7 +898,7 @@ struct Tuple<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11,NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10,T11>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -987,7 +987,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9,T10, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9,T10>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1073,7 +1073,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9, NullTypeList>
{
typedef typename TypeListType<T0, T1,T2,T3,T4,T5,T6,T7,T8,T9>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1156,7 +1156,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7,T8, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7,T8>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1236,7 +1236,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6,T7, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6,T7>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1313,7 +1313,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5,T6, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5,T6>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1387,7 +1387,7 @@ struct Tuple<T0, T1,T2,T3,T4,T5, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4,T5>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1458,7 +1458,7 @@ struct Tuple<T0, T1,T2,T3,T4, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3,T4>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1526,7 +1526,7 @@ struct Tuple<T0, T1,T2,T3, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2,T3>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1591,7 +1591,7 @@ struct Tuple<T0, T1,T2, NullTypeList>
{
typedef typename TypeListType<T0,T1,T2>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1653,7 +1653,7 @@ struct Tuple<T0, T1, NullTypeList>
{
typedef typename TypeListType<T0,T1>::HeadType Type;
enum
enum TupleLengthType
{
length = Type::length
};
@ -1711,7 +1711,7 @@ struct Tuple<T0, NullTypeList>
{
typedef TypeList<T0, NullTypeList> Type;
enum
enum TupleLengthType
{
length = Type::length
};

View File

@ -1,7 +1,7 @@
//
// TypeList.h
//
// $Id: //poco/1.3/Foundation/include/Poco/TypeList.h#4 $
// $Id: //poco/1.3/Foundation/include/Poco/TypeList.h#5 $
//
// Library: Foundation
// Package: Core
@ -143,39 +143,6 @@ struct TypeList
};
#define POCO_TYPELIST_1(T0) TypeList<T0, NullTypeList>
#define POCO_TYPELIST_2(T0, T1) TypeList<T0, POCO_TYPELIST_1(T1) >
#define POCO_TYPELIST_3(T0, T1, T2) TypeList<T0, POCO_TYPELIST_2(T1, T2) >
#define POCO_TYPELIST_4(T0, T1, T2, T3) TypeList<T0, POCO_TYPELIST_3(T1, T2, T3) >
#define POCO_TYPELIST_5(T0, T1, T2, T3, T4) TypeList<T0, POCO_TYPELIST_4(T1, T2, T3, T4) >
#define POCO_TYPELIST_6(T0, T1, T2, T3, T4, T5) TypeList<T0, POCO_TYPELIST_5(T1, T2, T3, T4, T5) >
#define POCO_TYPELIST_7(T0, T1, T2, T3, T4, T5, T6) TypeList<T0, POCO_TYPELIST_6(T1, T2, T3, T4, T5, T6) >
#define POCO_TYPELIST_8(T0, T1, T2, T3, T4, T5, T6, T7) TypeList<T0, POCO_TYPELIST_7(T1, T2, T3, T4, T5, T6, T7) >
#define POCO_TYPELIST_9(T0, T1, T2, T3, T4, T5, T6, T7, T8) TypeList<T0, POCO_TYPELIST_8(T1, T2, T3, T4, T5, T6, T7, T8) >
#define POCO_TYPELIST_10(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9) \
TypeList<T0, POCO_TYPELIST_9(T1, T2, T3, T4, T5, T6, T7, T8, T9) >
#define POCO_TYPELIST_11(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) \
TypeList<T0, POCO_TYPELIST_10(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10) >
#define POCO_TYPELIST_12(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) \
TypeList<T0, POCO_TYPELIST_11(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11) >
#define POCO_TYPELIST_13(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) \
TypeList<T0, POCO_TYPELIST_12(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12) >
#define POCO_TYPELIST_14(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) \
TypeList<T0, POCO_TYPELIST_13(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13) >
#define POCO_TYPELIST_15(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) \
TypeList<T0, POCO_TYPELIST_14(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14) >
#define POCO_TYPELIST_16(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) \
TypeList<T0, POCO_TYPELIST_15(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15) >
#define POCO_TYPELIST_17(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) \
TypeList<T0, POCO_TYPELIST_16(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16) >
#define POCO_TYPELIST_18(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) \
TypeList<T0, POCO_TYPELIST_17(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17) >
#define POCO_TYPELIST_19(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) \
TypeList<T0, POCO_TYPELIST_18(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18) >
#define POCO_TYPELIST_20(T0, T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) \
TypeList<T0, POCO_TYPELIST_19(T1, T2, T3, T4, T5, T6, T7, T8, T9, T10, T11, T12, T13, T14, T15, T16, T17, T18, T19) >
template <typename T0 = NullTypeList,
typename T1 = NullTypeList,
typename T2 = NullTypeList,
@ -215,7 +182,7 @@ public:
template <>
struct TypeListType<>
{
typedef NullTypeList HeadType;
typedef NullTypeList HeadType;
};
@ -336,7 +303,7 @@ struct TypeAppender<NullTypeList, NullTypeList>
template <class T>
struct TypeAppender<NullTypeList, T>
{
typedef POCO_TYPELIST_1(T) HeadType;
typedef TypeList<T, NullTypeList> HeadType;
};

View File

@ -1,7 +1,7 @@
//
// URIStreamFactory.h
//
// $Id: //poco/1.3/Foundation/include/Poco/URIStreamFactory.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/URIStreamFactory.h#2 $
//
// Library: Foundation
// Package: URI
@ -66,6 +66,9 @@ public:
///
/// If the stream cannot be opened for whatever reason,
/// an appropriate IOException must be thrown.
///
/// If opening the stream results in a redirect, a
/// URIRedirection exception should be thrown.
protected:
virtual ~URIStreamFactory();
@ -79,6 +82,37 @@ private:
};
class Foundation_API URIRedirection
/// An instance of URIRedirection is thrown by a URIStreamFactory::open()
/// if opening the original URI resulted in a redirection response
/// (such as a MOVED PERMANENTLY in HTTP).
{
public:
URIRedirection(const std::string& uri);
URIRedirection(const URIRedirection& redir);
URIRedirection& operator = (const URIRedirection& redir);
void swap(URIRedirection& redir);
const std::string& uri() const;
/// Returns the new URI.
private:
URIRedirection();
std::string _uri;
};
//
// inlines
//
inline const std::string& URIRedirection::uri() const
{
return _uri;
}
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// URIStreamOpener.h
//
// $Id: //poco/1.3/Foundation/include/Poco/URIStreamOpener.h#1 $
// $Id: //poco/1.3/Foundation/include/Poco/URIStreamOpener.h#2 $
//
// Library: Foundation
// Package: URI
@ -62,6 +62,11 @@ class Foundation_API URIStreamOpener
/// A FileStreamFactory is automatically registered for file URIs.
{
public:
enum
{
MAX_REDIRECTS = 10
};
URIStreamOpener();
/// Creates the URIStreamOpener and registers a FileStreamFactory
/// for file URIs.
@ -133,6 +138,7 @@ public:
protected:
std::istream* openFile(const Path& path) const;
std::istream* openURI(const std::string& scheme, const URI& uri) const;
private:
URIStreamOpener(const URIStreamOpener&);

View File

@ -1,7 +1,7 @@
//
// DateTimeParser.cpp
//
// $Id: //poco/1.3/Foundation/src/DateTimeParser.cpp#2 $
// $Id: //poco/1.3/Foundation/src/DateTimeParser.cpp#3 $
//
// Library: Foundation
// Package: DateTime
@ -154,7 +154,10 @@ void DateTimeParser::parse(const std::string& fmt, const std::string& str, DateT
}
if (month == 0) month = 1;
if (day == 0) day = 1;
dateTime.assign(year, month, day, hour, minute, second, millis);
if (DateTime::isValid(year, month, day, hour, minute, second, millis))
dateTime.assign(year, month, day, hour, minute, second, millis);
else
throw SyntaxException("date/time component out of range");
timeZoneDifferential = tzd;
}

View File

@ -1,7 +1,7 @@
//
// Debugger.cpp
//
// $Id: //poco/1.3/Foundation/src/Debugger.cpp#3 $
// $Id: //poco/1.3/Foundation/src/Debugger.cpp#4 $
//
// Library: Foundation
// Package: Core
@ -47,7 +47,7 @@
#include <lib$routines.h>
#include <ssdef.h>
#endif
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
#include "Poco/UnicodeConverter.h"
#endif
@ -85,7 +85,7 @@ void Debugger::message(const std::string& msg)
#if defined(POCO_OS_FAMILY_WINDOWS)
if (IsDebuggerPresent())
{
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
std::wstring umsg;
UnicodeConverter::toUTF16(msg, umsg);
umsg += '\n';

View File

@ -1,7 +1,7 @@
//
// Exception.cpp
//
// $Id: //poco/1.3/Foundation/src/Exception.cpp#2 $
// $Id: //poco/1.3/Foundation/src/Exception.cpp#3 $
//
// Library: Foundation
// Package: Core
@ -41,17 +41,17 @@
namespace Poco {
Exception::Exception(): _pNested(0)
Exception::Exception(int code): _pNested(0), _code(code)
{
}
Exception::Exception(const std::string& msg): _msg(msg), _pNested(0)
Exception::Exception(const std::string& msg, int code): _msg(msg), _pNested(0), _code(code)
{
}
Exception::Exception(const std::string& msg, const std::string& arg): _msg(msg), _pNested(0)
Exception::Exception(const std::string& msg, const std::string& arg, int code): _msg(msg), _pNested(0), _code(code)
{
if (!arg.empty())
{
@ -61,14 +61,16 @@ Exception::Exception(const std::string& msg, const std::string& arg): _msg(msg),
}
Exception::Exception(const std::string& msg, const Exception& nested): _msg(msg), _pNested(nested.clone())
Exception::Exception(const std::string& msg, const Exception& nested, int code): _msg(msg), _pNested(nested.clone()), _code(code)
{
}
Exception::Exception(const Exception& exc): std::exception(exc)
Exception::Exception(const Exception& exc):
std::exception(exc),
_msg(exc._msg),
_code(exc._code)
{
_msg = exc._msg;
_pNested = exc._pNested ? exc._pNested->clone() : 0;
}
@ -84,8 +86,9 @@ Exception& Exception::operator = (const Exception& exc)
if (&exc != this)
{
delete _pNested;
_msg = exc._msg;
_msg = exc._msg;
_pNested = exc._pNested ? exc._pNested->clone() : 0;
_code = exc._code;
}
return *this;
}

View File

@ -1,7 +1,7 @@
//
// File.cpp
//
// $Id: //poco/1.3/Foundation/src/File.cpp#3 $
// $Id: //poco/1.3/Foundation/src/File.cpp#4 $
//
// Library: Foundation
// Package: Filesystem
@ -160,6 +160,12 @@ bool File::isLink() const
}
bool File::isHidden() const
{
return isHiddenImpl();
}
Timestamp File::created() const
{
return createdImpl();

View File

@ -1,7 +1,7 @@
//
// File_UNIX.cpp
//
// $Id: //poco/1.3/Foundation/src/File_UNIX.cpp#4 $
// $Id: //poco/1.3/Foundation/src/File_UNIX.cpp#6 $
//
// Library: Foundation
// Package: Filesystem
@ -188,6 +188,16 @@ bool FileImpl::isLinkImpl() const
}
bool FileImpl::isHiddenImpl() const
{
poco_assert (!_path.empty());
Path p(_path);
p.makeFile();
return p.getFileName()[0] == '.';
}
Timestamp FileImpl::createdImpl() const
{
poco_assert (!_path.empty());

View File

@ -1,7 +1,7 @@
//
// File_VMS.cpp
//
// $Id: //poco/1.3/Foundation/src/File_VMS.cpp#2 $
// $Id: //poco/1.3/Foundation/src/File_VMS.cpp#3 $
//
// Library: Foundation
// Package: Filesystem
@ -174,6 +174,12 @@ bool FileImpl::isLinkImpl() const
}
bool FileImpl::isHiddenImpl() const
{
return false;
}
Timestamp FileImpl::createdImpl() const
{
poco_assert (!_path.empty());

View File

@ -1,7 +1,7 @@
//
// File_WIN32.cpp
//
// $Id: //poco/1.3/Foundation/src/File_WIN32.cpp#5 $
// $Id: //poco/1.3/Foundation/src/File_WIN32.cpp#7 $
//
// Library: Foundation
// Package: Filesystem
@ -191,6 +191,17 @@ bool FileImpl::isLinkImpl() const
}
bool FileImpl::isHiddenImpl() const
{
poco_assert (!_path.empty());
DWORD attr = GetFileAttributes(_path.c_str());
if (attr == 0xFFFFFFFF)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
}
Timestamp FileImpl::createdImpl() const
{
poco_assert (!_path.empty());

View File

@ -1,7 +1,7 @@
//
// File_WIN32U.cpp
//
// $Id: //poco/1.3/Foundation/src/File_WIN32U.cpp#5 $
// $Id: //poco/1.3/Foundation/src/File_WIN32U.cpp#7 $
//
// Library: Foundation
// Package: Filesystem
@ -195,6 +195,17 @@ bool FileImpl::isLinkImpl() const
}
bool FileImpl::isHiddenImpl() const
{
poco_assert (!_path.empty());
DWORD attr = GetFileAttributesW(_upath.c_str());
if (attr == 0xFFFFFFFF)
handleLastErrorImpl(_path);
return (attr & FILE_ATTRIBUTE_HIDDEN) != 0;
}
Timestamp FileImpl::createdImpl() const
{
poco_assert (!_path.empty());

View File

@ -1,7 +1,7 @@
//
// Format.cpp
//
// $Id: //poco/1.3/Foundation/src/Format.cpp#5 $
// $Id: //poco/1.3/Foundation/src/Format.cpp#6 $
//
// Library: Foundation
// Package: Core
@ -160,6 +160,8 @@ namespace
str << AnyCast<Int64>(any);
else if (any.type() == typeid(UInt64))
str << AnyCast<UInt64>(any);
else if (any.type() == typeid(bool))
str << AnyCast<bool>(any);
}
@ -176,6 +178,9 @@ namespace
prepareFormat(str, type);
switch (type)
{
case 'b':
str << AnyCast<bool>(*itVal++);
break;
case 'c':
str << AnyCast<char>(*itVal++);
break;

View File

@ -1,7 +1,7 @@
//
// LocalDateTime.cpp
//
// $Id: //poco/1.3/Foundation/src/LocalDateTime.cpp#2 $
// $Id: //poco/1.3/Foundation/src/LocalDateTime.cpp#3 $
//
// Library: Foundation
// Package: DateTime
@ -38,22 +38,22 @@
#include "Poco/Timezone.h"
#include "Poco/Timespan.h"
#include <algorithm>
#include <ctime>
namespace Poco {
LocalDateTime::LocalDateTime():
_tzd(Timezone::tzd())
LocalDateTime::LocalDateTime()
{
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
determineTzd(true);
}
LocalDateTime::LocalDateTime(int year, int month, int day, int hour, int minute, int second, int millisecond, int microsecond):
_dateTime(year, month, day, hour, minute, second, millisecond, microsecond),
_tzd(Timezone::tzd())
_dateTime(year, month, day, hour, minute, second, millisecond, microsecond)
{
determineTzd();
}
@ -65,10 +65,9 @@ LocalDateTime::LocalDateTime(int tzd, int year, int month, int day, int hour, in
LocalDateTime::LocalDateTime(double julianDay):
_dateTime(julianDay),
_tzd(Timezone::tzd())
_dateTime(julianDay)
{
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
determineTzd(true);
}
@ -76,15 +75,14 @@ LocalDateTime::LocalDateTime(int tzd, double julianDay):
_dateTime(julianDay),
_tzd(tzd)
{
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
adjustForTzd();
}
LocalDateTime::LocalDateTime(const DateTime& dateTime):
_dateTime(dateTime),
_tzd(Timezone::tzd())
_dateTime(dateTime)
{
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
determineTzd(true);
}
@ -92,7 +90,7 @@ LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime):
_dateTime(dateTime),
_tzd(tzd)
{
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
adjustForTzd();
}
@ -101,7 +99,7 @@ LocalDateTime::LocalDateTime(int tzd, const DateTime& dateTime, bool adjust):
_tzd(tzd)
{
if (adjust)
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
adjustForTzd();
}
@ -116,6 +114,7 @@ LocalDateTime::LocalDateTime(Timestamp::UtcTimeVal utcTime, Timestamp::TimeDiff
_dateTime(utcTime, diff),
_tzd(tzd)
{
adjustForTzd();
}
@ -123,7 +122,7 @@ LocalDateTime::~LocalDateTime()
{
}
LocalDateTime& LocalDateTime::operator = (const LocalDateTime& dateTime)
{
if (&dateTime != this)
@ -138,25 +137,26 @@ LocalDateTime& LocalDateTime::operator = (const LocalDateTime& dateTime)
LocalDateTime& LocalDateTime::operator = (const Timestamp& timestamp)
{
if (timestamp != this->timestamp())
{
_dateTime = timestamp;
determineTzd(true);
}
return *this;
}
LocalDateTime& LocalDateTime::operator = (double julianDay)
{
_tzd = Timezone::tzd();
_dateTime = julianDay;
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
determineTzd(true);
return *this;
}
LocalDateTime& LocalDateTime::assign(int year, int month, int day, int hour, int minute, int second, int millisecond, int microseconds)
{
_dateTime.assign(year, month, day, hour, minute, second, millisecond, microseconds);
_tzd = Timezone::tzd();
determineTzd(false);
return *this;
}
@ -173,7 +173,7 @@ LocalDateTime& LocalDateTime::assign(int tzd, double julianDay)
{
_tzd = tzd;
_dateTime = julianDay;
_dateTime += Timespan(((Timestamp::TimeDiff) _tzd)*Timespan::SECONDS);
adjustForTzd();
return *this;
}
@ -229,13 +229,19 @@ bool LocalDateTime::operator >= (const LocalDateTime& dateTime) const
LocalDateTime LocalDateTime::operator + (const Timespan& span) const
{
return LocalDateTime(_dateTime.utcTime(), span.totalMicroseconds(), _tzd);
// First calculate the adjusted UTC time, then calculate the
// locally adjusted time by constructing a new LocalDateTime.
DateTime tmp(utcTime(), span.totalMicroseconds());
return LocalDateTime(tmp);
}
LocalDateTime LocalDateTime::operator - (const Timespan& span) const
{
return LocalDateTime(_dateTime.utcTime(), -span.totalMicroseconds(), _tzd);
// First calculate the adjusted UTC time, then calculate the
// locally adjusted time by constructing a new LocalDateTime.
DateTime tmp(utcTime(), -span.totalMicroseconds());
return LocalDateTime(tmp);
}
@ -247,16 +253,45 @@ Timespan LocalDateTime::operator - (const LocalDateTime& dateTime) const
LocalDateTime& LocalDateTime::operator += (const Timespan& span)
{
_dateTime += span;
// Use the same trick as in operator+. Create a UTC time, adjust
// it for the span, and convert back to LocalDateTime. This will
// recalculate the tzd correctly in the case where the addition
// crosses a DST boundary.
*this = DateTime(utcTime(), span.totalMicroseconds());
return *this;
}
LocalDateTime& LocalDateTime::operator -= (const Timespan& span)
{
_dateTime -= span;
// Use the same trick as in operator-. Create a UTC time, adjust
// it for the span, and convert back to LocalDateTime. This will
// recalculate the tzd correctly in the case where the subtraction
// crosses a DST boundary.
*this = DateTime(utcTime(), -span.totalMicroseconds());
return *this;
}
void LocalDateTime::determineTzd(bool adjust)
{
std::time_t local;
std::tm broken;
broken.tm_year = (_dateTime.year() - 1900);
broken.tm_mon = (_dateTime.month() - 1);
broken.tm_mday = _dateTime.day();
broken.tm_hour = _dateTime.hour();
broken.tm_min = _dateTime.minute();
broken.tm_sec = _dateTime.second();
broken.tm_isdst = -1;
local = std::mktime(&broken);
_tzd = (Timezone::utcOffset() + ((broken.tm_isdst == 1) ? 3600 : 0));
if (adjust)
adjustForTzd();
}
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// Message.cpp
//
// $Id: //poco/1.3/Foundation/src/Message.cpp#2 $
// $Id: //poco/1.3/Foundation/src/Message.cpp#4 $
//
// Library: Foundation
// Package: Logging
@ -66,15 +66,15 @@ Message::Message(const std::string& source, const std::string& text, Priority pr
}
Message::Message(const Message& msg)
Message::Message(const Message& msg):
_source(msg._source),
_text(msg._text),
_prio(msg._prio),
_time(msg._time),
_tid(msg._tid),
_thread(msg._thread),
_pid(msg._pid)
{
_source = msg._source;
_text = msg._text;
_prio = msg._prio;
_time = msg._time;
_thread = msg._thread;
_tid = msg._tid;
_pid = msg._pid;
if (msg._pMap)
_pMap = new StringMap(*msg._pMap);
else
@ -82,15 +82,15 @@ Message::Message(const Message& msg)
}
Message::Message(const Message& msg, const std::string& text)
Message::Message(const Message& msg, const std::string& text):
_source(msg._source),
_text(text),
_prio(msg._prio),
_time(msg._time),
_tid(msg._tid),
_thread(msg._thread),
_pid(msg._pid)
{
_source = msg._source;
_text = text;
_prio = msg._prio;
_time = msg._time;
_thread = msg._thread;
_tid = msg._tid;
_pid = msg._pid;
if (msg._pMap)
_pMap = new StringMap(*msg._pMap);
else
@ -134,6 +134,7 @@ void Message::swap(Message& msg)
swap(_text, msg._text);
swap(_prio, msg._prio);
swap(_time, msg._time);
swap(_tid, msg._tid);
swap(_thread, msg._thread);
swap(_pid, msg._pid);
swap(_pMap, msg._pMap);
@ -164,12 +165,6 @@ void Message::setTime(const Timestamp& t)
}
const Timestamp& Message::getTime() const
{
return _time;
}
void Message::setThread(const std::string& thread)
{
_thread = thread;

View File

@ -1,13 +1,13 @@
//
// Mutex.cpp
//
// $Id: //poco/1.3/Foundation/src/Mutex.cpp#1 $
// $Id: //poco/1.3/Foundation/src/Mutex.cpp#2 $
//
// Library: Foundation
// Package: Threading
// Module: Mutex
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization

View File

@ -1,13 +1,13 @@
//
// Mutex_POSIX.cpp
//
// $Id: //poco/1.3/Foundation/src/Mutex_POSIX.cpp#1 $
// $Id: //poco/1.3/Foundation/src/Mutex_POSIX.cpp#3 $
//
// Library: Foundation
// Package: Threading
// Module: Mutex
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2004-2008, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
@ -35,6 +35,19 @@
#include "Poco/Mutex_POSIX.h"
#include "Poco/Timestamp.h"
#if !defined(POCO_NO_SYS_SELECT_H)
#include <sys/select.h>
#endif
#include <unistd.h>
#include <sys/time.h>
#if defined(_POSIX_TIMEOUTS) && (_POSIX_TIMEOUTS - 200112L) >= 0L
#if defined(_POSIX_THREADS) && (_POSIX_THREADS - 200112L) >= 0L
#define POCO_HAVE_MUTEX_TIMEOUT
#endif
#endif
namespace Poco {
@ -82,6 +95,48 @@ MutexImpl::~MutexImpl()
}
bool MutexImpl::tryLockImpl(long milliseconds)
{
#if defined(POCO_HAVE_MUTEX_TIMEOUT)
struct timespec abstime;
struct timeval tv;
gettimeofday(&tv, NULL);
abstime.tv_sec = tv.tv_sec + milliseconds / 1000;
abstime.tv_nsec = tv.tv_usec*1000 + (milliseconds % 1000)*1000000;
if (abstime.tv_nsec >= 1000000000)
{
abstime.tv_nsec -= 1000000000;
abstime.tv_sec++;
}
int rc = pthread_mutex_timedlock(&_mutex, &abstime);
if (rc == 0)
return true;
else if (rc == ETIMEDOUT)
return false;
else
throw SystemException("cannot lock mutex");
#else
const int sleepMillis = 5;
Timestamp now;
Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
do
{
int rc = pthread_mutex_trylock(&_mutex);
if (rc == 0)
return true;
else if (rc != EBUSY)
throw SystemException("cannot lock mutex");
struct timeval tv;
tv.tv_sec = 0;
tv.tv_usec = sleepMillis * 1000;
select(0, NULL, NULL, NULL, &tv);
}
while (!now.isElapsed(diff));
return false;
#endif
}
FastMutexImpl::FastMutexImpl(): MutexImpl(true)
{
}

View File

@ -1,7 +1,7 @@
//
// Mutex_WIN32.cpp
//
// $Id: //poco/1.3/Foundation/src/Mutex_WIN32.cpp#2 $
// $Id: //poco/1.3/Foundation/src/Mutex_WIN32.cpp#3 $
//
// Library: Foundation
// Package: Threading
@ -35,6 +35,7 @@
#include "Poco/Mutex_WIN32.h"
#include "Poco/Timestamp.h"
namespace Poco {
@ -54,4 +55,27 @@ MutexImpl::~MutexImpl()
}
bool MutexImpl::tryLockImpl(long milliseconds)
{
const int sleepMillis = 5;
Timestamp now;
Timestamp::TimeDiff diff(Timestamp::TimeDiff(milliseconds)*1000);
do
{
try
{
if (TryEnterCriticalSection(&_cs) == TRUE)
return true;
}
catch (...)
{
throw SystemException("cannot lock mutex");
}
Sleep(sleepMillis);
}
while (!now.isElapsed(diff));
return false;
}
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// PatternFormatter.cpp
//
// $Id: //poco/1.3/Foundation/src/PatternFormatter.cpp#2 $
// $Id: //poco/1.3/Foundation/src/PatternFormatter.cpp#4 $
//
// Library: Foundation
// Package: Logging
@ -41,8 +41,9 @@
#include "Poco/DateTime.h"
#include "Poco/Timestamp.h"
#include "Poco/Timezone.h"
#include "Poco/NumberFormatter.h"
#include "Poco/Environment.h"
#include <cstdio>
#include <cctype>
namespace Poco {
@ -70,6 +71,30 @@ PatternFormatter::~PatternFormatter()
}
inline void PatternFormatter::fmt(std::string& str, int value)
{
char buffer[64];
std::sprintf(buffer, "%d", value);
str.append(buffer);
}
inline void PatternFormatter::fmt(std::string& str, int value, int width)
{
char buffer[64];
std::sprintf(buffer, "%*d", width, value);
str.append(buffer);
}
inline void PatternFormatter::fmt0(std::string& str, int value, int width)
{
char buffer[64];
std::sprintf(buffer, "%0*d", width, value);
str.append(buffer);
}
void PatternFormatter::format(const Message& msg, std::string& text)
{
Timestamp timestamp = msg.getTime();
@ -91,33 +116,33 @@ void PatternFormatter::format(const Message& msg, std::string& text)
{
case 's': text.append(msg.getSource()); break;
case 't': text.append(msg.getText()); break;
case 'l': text.append(NumberFormatter::format((int) msg.getPriority())); break;
case 'l': fmt(text, (int) msg.getPriority()); break;
case 'p': text.append(getPriorityName((int) msg.getPriority())); break;
case 'q': text += getPriorityName((int) msg.getPriority()).at(0); break;
case 'P': text.append(NumberFormatter::format(msg.getPid())); break;
case 'P': fmt(text, msg.getPid()); break;
case 'T': text.append(msg.getThread()); break;
case 'I': text.append(NumberFormatter::format(msg.getTid())); break;
case 'I': fmt(text, msg.getTid()); break;
case 'N': text.append(Environment::nodeName()); break;
case 'w': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()], 0, 3); break;
case 'W': text.append(DateTimeFormat::WEEKDAY_NAMES[dateTime.dayOfWeek()]); break;
case 'b': text.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1], 0, 3); break;
case 'B': text.append(DateTimeFormat::MONTH_NAMES[dateTime.month() - 1]); break;
case 'd': text.append(NumberFormatter::format0(dateTime.day(), 2)); break;
case 'e': text.append(NumberFormatter::format(dateTime.day())); break;
case 'f': text.append(NumberFormatter::format(dateTime.day(), 2)); break;
case 'm': text.append(NumberFormatter::format0(dateTime.month(), 2)); break;
case 'n': text.append(NumberFormatter::format(dateTime.month())); break;
case 'o': text.append(NumberFormatter::format(dateTime.month(), 2)); break;
case 'y': text.append(NumberFormatter::format0(dateTime.year() % 100, 2)); break;
case 'Y': text.append(NumberFormatter::format0(dateTime.year(), 4)); break;
case 'H': text.append(NumberFormatter::format0(dateTime.hour(), 2)); break;
case 'h': text.append(NumberFormatter::format0(dateTime.hourAMPM(), 2)); break;
case 'd': fmt0(text, dateTime.day(), 2); break;
case 'e': fmt(text, dateTime.day()); break;
case 'f': fmt(text, dateTime.day(), 2); break;
case 'm': fmt0(text, dateTime.month(), 2); break;
case 'n': fmt(text, dateTime.month()); break;
case 'o': fmt(text, dateTime.month(), 2); break;
case 'y': fmt0(text, dateTime.year() % 100, 2); break;
case 'Y': fmt0(text, dateTime.year(), 4); break;
case 'H': fmt0(text, dateTime.hour(), 2); break;
case 'h': fmt0(text, dateTime.hourAMPM(), 2); break;
case 'a': text.append(dateTime.isAM() ? "am" : "pm"); break;
case 'A': text.append(dateTime.isAM() ? "AM" : "PM"); break;
case 'M': text.append(NumberFormatter::format0(dateTime.minute(), 2)); break;
case 'S': text.append(NumberFormatter::format0(dateTime.second(), 2)); break;
case 'i': text.append(NumberFormatter::format0(dateTime.millisecond(), 3)); break;
case 'c': text.append(NumberFormatter::format(dateTime.millisecond()/100)); break;
case 'M': fmt0(text, dateTime.minute(), 2); break;
case 'S': fmt0(text, dateTime.second(), 2); break;
case 'i': fmt0(text, dateTime.millisecond(), 3); break;
case 'c': fmt(text, dateTime.millisecond()/100); break;
case 'z': text.append(DateTimeFormatter::tzdISO(_localTime ? Timezone::tzd() : DateTimeFormatter::UTC)); break;
case 'Z': text.append(DateTimeFormatter::tzdRFC(_localTime ? Timezone::tzd() : DateTimeFormatter::UTC)); break;
case '[':

View File

@ -1,7 +1,7 @@
//
// SharedLibrary_UNIX.cpp
//
// $Id: //poco/1.3/Foundation/src/SharedLibrary_UNIX.cpp#1 $
// $Id: //poco/1.3/Foundation/src/SharedLibrary_UNIX.cpp#2 $
//
// Library: Foundation
// Package: SharedLibrary
@ -67,7 +67,7 @@ void SharedLibraryImpl::loadImpl(const std::string& path)
FastMutex::ScopedLock lock(_mutex);
if (_handle) throw LibraryAlreadyLoadedException(path);
_handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_LOCAL);
_handle = dlopen(path.c_str(), RTLD_LAZY | RTLD_GLOBAL);
if (!_handle)
{
const char* err = dlerror();

View File

@ -1,7 +1,7 @@
//
// SharedMemory.cpp
//
// $Id: //poco/1.3/Foundation/src/SharedMemory.cpp#2 $
// $Id: //poco/1.3/Foundation/src/SharedMemory.cpp#4 $
//
// Library: Foundation
// Package: Processes
@ -34,7 +34,7 @@
//
#if POCO_OS == POCO_OS_SOLARIS
#if defined(__sun)
#undef _XOPEN_SOURCE
#define _XOPEN_SOURCE 500
#endif
@ -42,7 +42,9 @@
#include "Poco/SharedMemory.h"
#include "Poco/Exception.h"
#if defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_NO_SHAREDMEMORY)
#include "SharedMemory_DUMMY.cpp"
#elif defined(POCO_OS_FAMILY_WINDOWS)
#include "SharedMemory_WIN32.cpp"
#elif defined(POCO_OS_FAMILY_UNIX)
#include "SharedMemory_POSIX.cpp"

View File

@ -1,7 +1,7 @@
//
// TaskManager.cpp
//
// $Id: //poco/1.3/Foundation/src/TaskManager.cpp#1 $
// $Id: //poco/1.3/Foundation/src/TaskManager.cpp#2 $
//
// Library: Foundation
// Package: Tasks
@ -64,12 +64,24 @@ TaskManager::~TaskManager()
void TaskManager::start(Task* pTask)
{
TaskPtr pAutoTask(pTask); // take ownership immediately
FastMutex::ScopedLock lock(_mutex);
pTask->setOwner(this);
pTask->setState(Task::TASK_STARTING);
_taskList.push_back(TaskPtr(pTask));
_threadPool.start(*pTask, pTask->name());
pAutoTask->setOwner(this);
pAutoTask->setState(Task::TASK_STARTING);
_taskList.push_back(pAutoTask);
try
{
_threadPool.start(*pAutoTask, pAutoTask->name());
}
catch (...)
{
// Make sure that we don't act like we own the task since
// we never started it. If we leave the task on our task
// list, the size of the list is incorrect.
_taskList.pop_back();
throw;
}
}

View File

@ -1,7 +1,7 @@
//
// Timer.cpp
//
// $Id: //poco/1.3/Foundation/src/Timer.cpp#1 $
// $Id: //poco/1.3/Foundation/src/Timer.cpp#2 $
//
// Library: Foundation
// Package: Threading
@ -60,18 +60,30 @@ Timer::~Timer()
void Timer::start(const AbstractTimerCallback& method)
{
start(method, ThreadPool::defaultPool());
start(method, Thread::PRIO_NORMAL, ThreadPool::defaultPool());
}
void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority)
{
start(method, priority, ThreadPool::defaultPool());
}
void Timer::start(const AbstractTimerCallback& method, ThreadPool& threadPool)
{
start(method, Thread::PRIO_NORMAL, threadPool);
}
void Timer::start(const AbstractTimerCallback& method, Thread::Priority priority, ThreadPool& threadPool)
{
poco_assert (!_pCallback);
FastMutex::ScopedLock lock(_mutex);
_pCallback = method.clone();
_wakeUp.reset();
threadPool.start(*this);
threadPool.startWithPriority(priority, *this);
}

View File

@ -1,7 +1,7 @@
//
// URIStreamFactory.cpp
//
// $Id: //poco/1.3/Foundation/src/URIStreamFactory.cpp#1 $
// $Id: //poco/1.3/Foundation/src/URIStreamFactory.cpp#2 $
//
// Library: Foundation
// Package: URI
@ -35,6 +35,7 @@
#include "Poco/URIStreamFactory.h"
#include <algorithm>
namespace Poco {
@ -50,4 +51,30 @@ URIStreamFactory::~URIStreamFactory()
}
URIRedirection::URIRedirection(const std::string& uri):
_uri(uri)
{
}
URIRedirection::URIRedirection(const URIRedirection& redir):
_uri(redir._uri)
{
}
URIRedirection& URIRedirection::operator = (const URIRedirection& redir)
{
URIRedirection tmp(redir);
swap(tmp);
return *this;
}
void URIRedirection::swap(URIRedirection& redir)
{
std::swap(_uri, redir._uri);
}
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// URIStreamOpener.cpp
//
// $Id: //poco/1.3/Foundation/src/URIStreamOpener.cpp#1 $
// $Id: //poco/1.3/Foundation/src/URIStreamOpener.cpp#2 $
//
// Library: Foundation
// Package: URI
@ -68,11 +68,7 @@ std::istream* URIStreamOpener::open(const URI& uri) const
scheme = "file";
else
scheme = uri.getScheme();
FactoryMap::const_iterator it = _map.find(scheme);
if (it != _map.end())
return it->second->open(uri);
else
throw UnknownURISchemeException(scheme);
return openURI(scheme, uri);
}
@ -86,7 +82,7 @@ std::istream* URIStreamOpener::open(const std::string& pathOrURI) const
std::string scheme(uri.getScheme());
FactoryMap::const_iterator it = _map.find(scheme);
if (it != _map.end())
return it->second->open(uri);
return openURI(scheme, uri);
}
catch (Exception&)
{
@ -108,7 +104,7 @@ std::istream* URIStreamOpener::open(const std::string& basePathOrURI, const std:
if (it != _map.end())
{
uri.resolve(pathOrURI);
return it->second->open(uri);
return openURI(scheme, uri);
}
}
catch (Exception&)
@ -170,5 +166,33 @@ std::istream* URIStreamOpener::openFile(const Path& path) const
}
std::istream* URIStreamOpener::openURI(const std::string& scheme, const URI& uri) const
{
std::string actualScheme(scheme);
URI actualURI(uri);
int redirects = 0;
while (redirects < MAX_REDIRECTS)
{
try
{
FactoryMap::const_iterator it = _map.find(actualScheme);
if (it != _map.end())
return it->second->open(actualURI);
else if (redirects > 0)
throw UnknownURISchemeException(actualURI.toString() + std::string("; redirected from ") + uri.toString());
else
throw UnknownURISchemeException(actualURI.toString());
}
catch (URIRedirection& redir)
{
actualURI = redir.uri();
actualScheme = actualURI.getScheme();
++redirects;
}
}
throw IOException("Too many redirects while opening URI", uri.toString());
}
} // namespace Poco

View File

@ -1,7 +1,7 @@
//
// ActiveDispatcherTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveDispatcherTest.cpp#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveDispatcherTest.cpp#2 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// All rights reserved.
@ -68,7 +68,10 @@ namespace
{
public:
ActiveObject():
testMethod(this, &ActiveObject::testMethodImpl)
testMethod(this, &ActiveObject::testMethodImpl),
testVoid(this, &ActiveObject::testVoidImpl),
testVoidInOut(this, &ActiveObject::testVoidInOutImpl),
testVoidIn(this, &ActiveObject::testVoidInImpl)
{
}
@ -77,6 +80,12 @@ namespace
}
ActiveMethod<int, int, ActiveObject, ActiveStarter<ActiveDispatcher> > testMethod;
ActiveMethod<void, int, ActiveObject, ActiveStarter<ActiveDispatcher> > testVoid;
ActiveMethod<void, void, ActiveObject, ActiveStarter<ActiveDispatcher> > testVoidInOut;
ActiveMethod<int, void, ActiveObject, ActiveStarter<ActiveDispatcher> > testVoidIn;
void cont()
{
@ -85,11 +94,28 @@ namespace
protected:
int testMethodImpl(const int& n)
{
{
if (n == 100) throw Exception("n == 100");
_continue.wait();
return n;
}
void testVoidImpl(const int& n)
{
if (n == 100) throw Exception("n == 100");
_continue.wait();
}
void testVoidInOutImpl()
{
_continue.wait();
}
int testVoidInImpl()
{
_continue.wait();
return 123;
}
private:
Event _continue;
@ -167,6 +193,43 @@ void ActiveDispatcherTest::testFailure()
}
void ActiveDispatcherTest::testVoid()
{
ActiveObject activeObj;
ActiveResult<void> result = activeObj.testVoid(123);
assert (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
}
void ActiveDispatcherTest::testVoidInOut()
{
ActiveObject activeObj;
ActiveResult<void> result = activeObj.testVoidInOut();
assert (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
}
void ActiveDispatcherTest::testVoidIn()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testVoidIn();
assert (!result.available());
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assert (result.data() == 123);
}
void ActiveDispatcherTest::setUp()
{
}
@ -185,6 +248,9 @@ CppUnit::Test* ActiveDispatcherTest::suite()
CppUnit_addTest(pSuite, ActiveDispatcherTest, testWaitInterval);
CppUnit_addTest(pSuite, ActiveDispatcherTest, testTryWait);
CppUnit_addTest(pSuite, ActiveDispatcherTest, testFailure);
CppUnit_addTest(pSuite, ActiveDispatcherTest, testVoid);
CppUnit_addTest(pSuite, ActiveDispatcherTest, testVoidIn);
CppUnit_addTest(pSuite, ActiveDispatcherTest, testVoidInOut);
return pSuite;
}

View File

@ -1,7 +1,7 @@
//
// ActiveDispatcherTest.h
//
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveDispatcherTest.h#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveDispatcherTest.h#2 $
//
// Definition of the ActiveDispatcherTest class.
//
@ -63,6 +63,9 @@ public:
void testWaitInterval();
void testTryWait();
void testFailure();
void testVoid();
void testVoidIn();
void testVoidInOut();
void setUp();
void tearDown();

View File

@ -1,7 +1,7 @@
//
// ActiveMethodTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveMethodTest.cpp#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveMethodTest.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -51,8 +51,16 @@ namespace
class ActiveObject
{
public:
typedef ActiveMethod<int, int, ActiveObject> IntIntType;
typedef ActiveMethod<void, int, ActiveObject> VoidIntType;
typedef ActiveMethod<void, void, ActiveObject> VoidVoidType;
typedef ActiveMethod<int, void, ActiveObject> IntVoidType;
ActiveObject():
testMethod(this, &ActiveObject::testMethodImpl)
testMethod(this, &ActiveObject::testMethodImpl),
testVoid(this,&ActiveObject::testVoidOutImpl),
testVoidInOut(this,&ActiveObject::testVoidInOutImpl),
testVoidIn(this,&ActiveObject::testVoidInImpl)
{
}
@ -60,7 +68,13 @@ namespace
{
}
ActiveMethod<int, int, ActiveObject> testMethod;
IntIntType testMethod;
VoidIntType testVoid;
VoidVoidType testVoidInOut;
IntVoidType testVoidIn;
void cont()
{
@ -69,11 +83,28 @@ namespace
protected:
int testMethodImpl(const int& n)
{
{
if (n == 100) throw Exception("n == 100");
_continue.wait();
return n;
}
void testVoidOutImpl(const int& n)
{
if (n == 100) throw Exception("n == 100");
_continue.wait();
}
void testVoidInOutImpl()
{
_continue.wait();
}
int testVoidInImpl()
{
_continue.wait();
return 123;
}
private:
Event _continue;
@ -104,6 +135,46 @@ void ActiveMethodTest::testWait()
}
void ActiveMethodTest::testCopy()
{
ActiveObject activeObj;
ActiveObject::IntIntType ii = activeObj.testMethod;
ActiveResult<int> rii = ii(123);
assert (!rii.available());
activeObj.cont();
rii.wait();
assert (rii.available());
assert (rii.data() == 123);
assert (!rii.failed());
ActiveObject::VoidIntType vi = activeObj.testVoid;
ActiveResult<void> rvi = vi(123);
assert (!rvi.available());
activeObj.cont();
rvi.wait();
assert (rvi.available());
assert (!rvi.failed());
ActiveObject::VoidVoidType vv = activeObj.testVoidInOut;
ActiveResult<void> rvv = vv();
assert (!rvv.available());
activeObj.cont();
rvv.wait();
assert (rvv.available());
assert (!rvv.failed());
ActiveObject::IntVoidType iv = activeObj.testVoidIn;
ActiveResult<int> riv = iv();
assert (!riv.available());
activeObj.cont();
riv.wait();
assert (riv.available());
assert (riv.data() == 123);
assert (!riv.failed());
}
void ActiveMethodTest::testWaitInterval()
{
ActiveObject activeObj;
@ -151,6 +222,40 @@ void ActiveMethodTest::testFailure()
}
void ActiveMethodTest::testVoidOut()
{
ActiveObject activeObj;
ActiveResult<void> result = activeObj.testVoid(101);
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
}
void ActiveMethodTest::testVoidInOut()
{
ActiveObject activeObj;
ActiveResult<void> result = activeObj.testVoidInOut();
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
}
void ActiveMethodTest::testVoidIn()
{
ActiveObject activeObj;
ActiveResult<int> result = activeObj.testVoidIn();
activeObj.cont();
result.wait();
assert (result.available());
assert (!result.failed());
assert (result.data() == 123);
}
void ActiveMethodTest::setUp()
{
}
@ -166,9 +271,13 @@ CppUnit::Test* ActiveMethodTest::suite()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ActiveMethodTest");
CppUnit_addTest(pSuite, ActiveMethodTest, testWait);
CppUnit_addTest(pSuite, ActiveMethodTest, testCopy);
CppUnit_addTest(pSuite, ActiveMethodTest, testWaitInterval);
CppUnit_addTest(pSuite, ActiveMethodTest, testTryWait);
CppUnit_addTest(pSuite, ActiveMethodTest, testFailure);
CppUnit_addTest(pSuite, ActiveMethodTest, testVoidOut);
CppUnit_addTest(pSuite, ActiveMethodTest, testVoidIn);
CppUnit_addTest(pSuite, ActiveMethodTest, testVoidInOut);
return pSuite;
}

View File

@ -1,7 +1,7 @@
//
// ActiveMethodTest.h
//
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveMethodTest.h#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/ActiveMethodTest.h#2 $
//
// Definition of the ActiveMethodTest class.
//
@ -47,9 +47,13 @@ public:
~ActiveMethodTest();
void testWait();
void testCopy();
void testWaitInterval();
void testTryWait();
void testFailure();
void testVoidOut();
void testVoidInOut();
void testVoidIn();
void setUp();
void tearDown();

View File

@ -1,7 +1,7 @@
//
// FileTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/FileTest.cpp#3 $
// $Id: //poco/1.3/Foundation/testsuite/src/FileTest.cpp#4 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -208,6 +208,7 @@ void FileTest::testCreateFile()
File f("testfile.dat");
bool created = f.createFile();
assert (created);
assert (!f.isHidden());
created = f.createFile();
assert (!created);
}

View File

@ -1,7 +1,7 @@
//
// FormatTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.cpp#4 $
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.cpp#5 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// All rights reserved.
@ -46,6 +46,7 @@
#include "FormatTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/Any.h"
#include "Poco/Format.h"
#include "Poco/Exception.h"
@ -211,12 +212,44 @@ void FormatTest::testInt()
}
void FormatTest::testBool()
{
bool b = true;
std::string s = format("%b", b);
assert (s == "1");
b = false;
s = format("%b", b);
assert (s == "0");
std::vector<Poco::Any> bv;
bv.push_back(false);
bv.push_back(true);
bv.push_back(false);
bv.push_back(true);
bv.push_back(false);
bv.push_back(true);
bv.push_back(false);
bv.push_back(true);
bv.push_back(false);
bv.push_back(true);
s.clear();
format(s, "%b%b%b%b%b%b%b%b%b%b", bv);
assert (s == "0101010101");
}
void FormatTest::testAnyInt()
{
char c = 42;
std::string s(format("%?i", c));
assert (s == "42");
bool b = true;
s = format("%?i", b);
assert (s == "1");
signed char sc = -42;
s = format("%?i", sc);
assert (s == "-42");
@ -361,6 +394,7 @@ CppUnit::Test* FormatTest::suite()
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("FormatTest");
CppUnit_addTest(pSuite, FormatTest, testChar);
CppUnit_addTest(pSuite, FormatTest, testBool);
CppUnit_addTest(pSuite, FormatTest, testInt);
CppUnit_addTest(pSuite, FormatTest, testAnyInt);
CppUnit_addTest(pSuite, FormatTest, testFloatFix);

View File

@ -1,7 +1,7 @@
//
// FormatTest.h
//
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.h#2 $
// $Id: //poco/1.3/Foundation/testsuite/src/FormatTest.h#3 $
//
// Definition of the FormatTest class.
//
@ -61,6 +61,7 @@ public:
void testChar();
void testInt();
void testBool();
void testAnyInt();
void testFloatFix();
void testFloatSci();

View File

@ -1,7 +1,7 @@
//
// LocalDateTimeTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/LocalDateTimeTest.cpp#2 $
// $Id: //poco/1.3/Foundation/testsuite/src/LocalDateTimeTest.cpp#3 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -38,6 +38,10 @@
#include "Poco/Timestamp.h"
#include "Poco/Timespan.h"
#include "Poco/Timezone.h"
#include "Poco/DateTimeFormat.h"
#include "Poco/DateTimeFormatter.h"
#include <ctime>
#include <iostream>
using Poco::LocalDateTime;
@ -68,7 +72,9 @@ void LocalDateTimeTest::testGregorian1()
assert (dt.second() == 0);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 4);
assert (dt.tzd() == Timezone::tzd());
// REMOVED: this fails when the current DST offset differs from
// the one on 1970-1-1
//assert (dt.tzd() == Timezone::tzd());
assert (dt.julianDay() == 2440587.5);
dt.assign(2001, 9, 9, 1, 46, 40);
@ -80,7 +86,7 @@ void LocalDateTimeTest::testGregorian1()
assert (dt.second() == 40);
assert (dt.millisecond() == 0);
assert (dt.dayOfWeek() == 0);
assert (dt.tzd() == Timezone::tzd());
//assert (dt.tzd() == Timezone::tzd());
assertEqualDelta (dt.julianDay(), 2452161.574074, 0.000001);
}
@ -371,6 +377,93 @@ void LocalDateTimeTest::testSwap()
}
void LocalDateTimeTest::testTimezone()
{
std::time_t tINCREMENT = (30 * 24 * 60 * 60); // 30 days
Timespan tsINCREMENT(30*Timespan::DAYS);
LocalDateTime now;
std::time_t t = std::time(NULL);
std::tm then;
bool foundDST = false;
then = *std::localtime(&t);
if (then.tm_isdst >= 0)
{
std::string tzNow, tzThen;
char tzBuf[12];
int iterations = 0;
std::strftime(&tzBuf[0], sizeof(tzBuf), "%z", &then);
tzNow = tzThen = tzBuf;
while (iterations < 14)
{
// Add one month until the timezone changes or we roll
// over 13 months.
t += tINCREMENT;
then = *std::localtime(&t);
std::strftime(&tzBuf[0], sizeof(tzBuf), "%z", &then);
tzThen = tzBuf;
foundDST = (tzNow == tzThen);
if (foundDST)
{
break;
}
++iterations;
}
if (foundDST)
{
// We found a timezone change that was induced by changing
// the month, so we crossed a DST boundary. Now we can
// actually do the test...
//
// Start with the current time and add 30 days for 13
// iterations. Do this with both a LocalDateTime object and
// a ANSI C time_t. Then create a LocalDateTime based on the
// time_t and verify that the time_t calculated value is equal
// to the LocalDateTime value. The comparision operator
// verifies the _dateTime and _tzd members.
LocalDateTime dt2;
t = std::time(NULL);
for (iterations = 0; iterations < 14; ++iterations)
{
t += tINCREMENT;
dt2 += tsINCREMENT;
then = *std::localtime(&t);
// This is the tricky part. We have to use the constructor
// from a UTC DateTime object that is constructed from the
// time_t. The LocalDateTime constructor with integer
// arguments, LocalDateTime(yr, mon, day, ...), assumes that
// the time is already adjusted with respect to the time
// zone. The DateTime conversion constructor, however, does
// not. So we want to construct from the UTC time.
//
// The second tricky part is that we want to use the
// sub-second information from the LocalDateTime object
// since ANSI C time routines are not sub-second accurate.
then = *std::gmtime(&t);
LocalDateTime calcd(DateTime((then.tm_year + 1900),
(then.tm_mon + 1),
then.tm_mday,
then.tm_hour,
then.tm_min,
then.tm_sec,
dt2.millisecond(),
dt2.microsecond()));
assert (dt2 == calcd);
}
}
}
if (!foundDST)
{
std::cerr
<< __FILE__ << ":" << __LINE__
<< " - failed to locate DST boundary, timezone test skipped."
<< std::endl;
}
}
void LocalDateTimeTest::setUp()
{
}
@ -395,6 +488,7 @@ CppUnit::Test* LocalDateTimeTest::suite()
CppUnit_addTest(pSuite, LocalDateTimeTest, testArithmetics1);
CppUnit_addTest(pSuite, LocalDateTimeTest, testArithmetics2);
CppUnit_addTest(pSuite, LocalDateTimeTest, testSwap);
CppUnit_addTest(pSuite, LocalDateTimeTest, testTimezone);
return pSuite;
}

View File

@ -1,7 +1,7 @@
//
// LocalDateTimeTest.h
//
// $Id: //poco/1.3/Foundation/testsuite/src/LocalDateTimeTest.h#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/LocalDateTimeTest.h#2 $
//
// Definition of the LocalDateTimeTest class.
//
@ -56,6 +56,7 @@ public:
void testArithmetics1();
void testArithmetics2();
void testSwap();
void testTimezone();
void setUp();
void tearDown();

View File

@ -1,7 +1,7 @@
//
// TaskManagerTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/TaskManagerTest.cpp#2 $
// $Id: //poco/1.3/Foundation/testsuite/src/TaskManagerTest.cpp#3 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -33,11 +33,13 @@
#include "TaskManagerTest.h"
#include "CppUnit/TestCaller.h"
#include "CppUnit/TestSuite.h"
#include "Poco/Exception.h"
#include "Poco/TaskManager.h"
#include "Poco/Task.h"
#include "Poco/TaskNotification.h"
#include "Poco/NotificationCenter.h"
#include "Poco/Thread.h"
#include "Poco/ThreadPool.h"
#include "Poco/Event.h"
#include "Poco/Observer.h"
#include "Poco/Exception.h"
@ -54,9 +56,11 @@ using Poco::TaskFailedNotification;
using Poco::TaskProgressNotification;
using Poco::TaskCustomNotification;
using Poco::Thread;
using Poco::ThreadPool;
using Poco::Event;
using Poco::Observer;
using Poco::Exception;
using Poco::NoThreadAvailableException;
using Poco::SystemException;
using Poco::NullPointerException;
using Poco::AutoPtr;
@ -460,6 +464,38 @@ void TaskManagerTest::testMultiTasks()
}
void TaskManagerTest::testCustomThreadPool()
{
ThreadPool tp(2, 5, 120);
TaskManager tm(tp);
// fill up the thread pool
for (int i=0; i < tp.capacity(); ++i)
{
tm.start(new SimpleTask);
}
assert (tp.allocated() == tp.capacity());
assert (tm.count() == tp.allocated());
// the next one should fail
try
{
tm.start(new SimpleTask);
failmsg("thread pool exhausted - must throw exception");
}
catch (NoThreadAvailableException const&)
{
}
catch (...)
{
failmsg("wrong exception thrown");
}
assert (tm.count() == tp.allocated());
tp.joinAll();
}
void TaskManagerTest::setUp()
{
}
@ -479,6 +515,7 @@ CppUnit::Test* TaskManagerTest::suite()
CppUnit_addTest(pSuite, TaskManagerTest, testError);
CppUnit_addTest(pSuite, TaskManagerTest, testMultiTasks);
CppUnit_addTest(pSuite, TaskManagerTest, testCustom);
CppUnit_addTest(pSuite, TaskManagerTest, testCustomThreadPool);
return pSuite;
}

View File

@ -1,7 +1,7 @@
//
// TaskManagerTest.h
//
// $Id: //poco/1.3/Foundation/testsuite/src/TaskManagerTest.h#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/TaskManagerTest.h#2 $
//
// Definition of the TaskManagerTest class.
//
@ -57,6 +57,7 @@ public:
void testError();
void testCustom();
void testMultiTasks();
void testCustomThreadPool();
void setUp();
void tearDown();

View File

@ -1,7 +1,7 @@
//
// TuplesTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.cpp#3 $
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.cpp#4 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -35,6 +35,7 @@
#include "CppUnit/TestSuite.h"
#include "Poco/Tuple.h"
#include "Poco/Void.h"
#include <algorithm>
using Poco::TypeList;
@ -475,6 +476,45 @@ void TuplesTest::testTuple20()
}
void TuplesTest::testTupleOrder()
{
typedef Tuple<std::string, int, bool, float, char, long, double, short, std::string, int,
std::string, int, bool, float, char, long, double, short, std::string, int> TupleType;
TupleType aTuple;
assert (aTuple.length == 20);
TupleType aTuple2("1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2, "1", 1, true, 3.14f, 'c', 999, 33.14, 32700, "2", 2);
assert (aTuple != aTuple2);
aTuple = aTuple2;
assert (aTuple == aTuple2);
aTuple2.get<1>()++;
assert (aTuple < aTuple2);
TupleType aTuple3;
aTuple3 = aTuple2;
aTuple3.get<1>()++;
assert (aTuple2 < aTuple3);
testTupleStrictWeak(aTuple, aTuple2, aTuple3);
std::vector<TupleType> tv;
tv.push_back(aTuple3);
tv.push_back(aTuple);
tv.push_back(aTuple2);
assert (tv[0] == aTuple3);
assert (tv[1] == aTuple);
assert (tv[2] == aTuple2);
std::sort(tv.begin(), tv.end());
assert (tv[0] == aTuple);
assert (tv[1] == aTuple2);
assert (tv[2] == aTuple3);
}
void TuplesTest::testMemOverhead()
{
Tuple<short> small(0);
@ -520,6 +560,7 @@ CppUnit::Test* TuplesTest::suite()
CppUnit_addTest(pSuite, TuplesTest, testTuple18);
CppUnit_addTest(pSuite, TuplesTest, testTuple19);
CppUnit_addTest(pSuite, TuplesTest, testTuple20);
CppUnit_addTest(pSuite, TuplesTest, testTupleOrder);
CppUnit_addTest(pSuite, TuplesTest, testMemOverhead);
return pSuite;

View File

@ -1,7 +1,7 @@
//
// TuplesTest.h
//
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.h#3 $
// $Id: //poco/1.3/Foundation/testsuite/src/TuplesTest.h#4 $
//
// Definition of the TuplesTest class.
//
@ -66,6 +66,7 @@ public:
void testTuple18();
void testTuple19();
void testTuple20();
void testTupleOrder();
void testMemOverhead();
void setUp();
void tearDown();
@ -73,6 +74,14 @@ public:
static CppUnit::Test* suite();
private:
template <class T>
void testTupleStrictWeak(const T& t1, const T& t2, const T& t3)
{
assert (t1 < t2 && !(t2 < t1)); // antisymmetric
assert (t1 < t2 && t2 < t3 && t1 < t3); // transitive
assert (!(t1 < t1)); // irreflexive
}
};

View File

@ -1,7 +1,7 @@
//
// TypeListTest.cpp
//
// $Id: //poco/1.3/Foundation/testsuite/src/TypeListTest.cpp#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/TypeListTest.cpp#2 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -78,159 +78,7 @@ TypeListTest::~TypeListTest()
}
void TypeListTest::testTypeListMacro()
{
typedef POCO_TYPELIST_15(Int8,
UInt8,
Int16,
UInt16,
Int32,
UInt32,
float,
double,
Int8,
UInt8,
Int16,
UInt16,
Int32,
UInt32,
float) Type15;
Tuple<TypeGetter<0, Type15>::HeadType,
TypeGetter<1, Type15>::HeadType,
TypeGetter<2, Type15>::HeadType,
TypeGetter<3, Type15>::HeadType,
TypeGetter<4, Type15>::HeadType,
TypeGetter<5, Type15>::HeadType,
TypeGetter<6, Type15>::HeadType,
TypeGetter<7, Type15>::HeadType,
TypeGetter<8, Type15>::HeadType,
TypeGetter<9, Type15>::HeadType> tuple;
static TypeLocator<Type15, Int8> pos0;
static TypeLocator<Type15, UInt8> pos1;
static TypeLocator<Type15, Int16> pos2;
static TypeLocator<Type15, UInt16> pos3;
static TypeLocator<Type15, Int32> pos4;
static TypeLocator<Type15, UInt32> pos5;
static TypeLocator<Type15, float> pos6;
static TypeLocator<Type15, double> pos7;
static TypeLocator<Type15, Int8> pos8;
static TypeLocator<Type15, std::string> posUnknown;
assert (pos0.value == 0);
assert (pos1.value == 1);
assert (pos2.value == 2);
assert (pos3.value == 3);
assert (pos4.value == 4);
assert (pos5.value == 5);
assert (pos6.value == 6);
assert (pos7.value == 7);
assert (pos8.value == 0);
assert (posUnknown.value == -1);
tuple.set<TypeLocator<Type15, Int32>::value >(-123);
assert (-123 == tuple.get<4>());
assert (typeid(TypeGetter<0, Type15>::HeadType) == typeid(Int8));
assert (typeid(TypeGetter<0, Type15>::ConstHeadType) == typeid(const Int8));
assert (typeid(TypeGetter<1, Type15>::HeadType) == typeid(UInt8));
assert (typeid(TypeGetter<1, Type15>::ConstHeadType) == typeid(const UInt8));
assert (typeid(TypeGetter<2, Type15>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<2, Type15>::ConstHeadType) == typeid(const Int16));
assert (typeid(TypeGetter<3, Type15>::HeadType) == typeid(UInt16));
assert (typeid(TypeGetter<3, Type15>::ConstHeadType) == typeid(const UInt16));
assert (typeid(TypeGetter<4, Type15>::HeadType) == typeid(Int32));
assert (typeid(TypeGetter<4, Type15>::ConstHeadType) == typeid(const Int32));
assert (typeid(TypeGetter<5, Type15>::HeadType) == typeid(UInt32));
assert (typeid(TypeGetter<5, Type15>::ConstHeadType) == typeid(const UInt32));
assert (typeid(TypeGetter<6, Type15>::HeadType) == typeid(float));
assert (typeid(TypeGetter<6, Type15>::ConstHeadType) == typeid(const float));
assert (typeid(TypeGetter<7, Type15>::HeadType) == typeid(double));
assert (typeid(TypeGetter<7, Type15>::ConstHeadType) == typeid(const double));
assert (typeid(TypeGetter<8, Type15>::HeadType) == typeid(Int8));
assert (typeid(TypeGetter<8, Type15>::ConstHeadType) == typeid(const Int8));
assert (typeid(TypeGetter<9, Type15>::HeadType) == typeid(UInt8));
assert (typeid(TypeGetter<9, Type15>::ConstHeadType) == typeid(const UInt8));
assert (typeid(TypeGetter<10, Type15>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<10, Type15>::ConstHeadType) == typeid(const Int16));
assert (typeid(TypeGetter<11, Type15>::HeadType) == typeid(UInt16));
assert (typeid(TypeGetter<11, Type15>::ConstHeadType) == typeid(const UInt16));
assert (typeid(TypeGetter<12, Type15>::HeadType) == typeid(Int32));
assert (typeid(TypeGetter<12, Type15>::ConstHeadType) == typeid(const Int32));
assert (typeid(TypeGetter<13, Type15>::HeadType) == typeid(UInt32));
assert (typeid(TypeGetter<13, Type15>::ConstHeadType) == typeid(const UInt32));
assert (typeid(TypeGetter<14, Type15>::HeadType) == typeid(float));
assert (typeid(TypeGetter<14, Type15>::ConstHeadType) == typeid(const float));
typedef POCO_TYPELIST_1(Int8) Type1;
assert (1 == Type1::length);
typedef POCO_TYPELIST_2(Int16, Int32) Type2;
assert (2 == Type2::length);
typedef TypeAppender<Type1, Type2>::HeadType Type3;
assert (3 == Type3::length);
assert (typeid(TypeGetter<0, Type3>::HeadType) == typeid(Int8));
assert (typeid(TypeGetter<1, Type3>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<2, Type3>::HeadType) == typeid(Int32));
static TypeLocator<Type3, Int8> posNo1;
static TypeLocator<Type3, Int16> posNo2;
static TypeLocator<Type3, Int32> posNo3;
assert (posNo1.value == 0);
assert (posNo2.value == 1);
assert (posNo3.value == 2);
typedef TypeOneEraser<Type3, Int8>::HeadType TypeEraser1;
assert (2 == TypeEraser1::length);
assert (typeid(TypeGetter<0, TypeEraser1>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<1, TypeEraser1>::HeadType) == typeid(Int32));
typedef TypeOneEraser<Type3, Int16>::HeadType TypeEraser2;
assert (2 == TypeEraser2::length);
assert (typeid(TypeGetter<0, TypeEraser2>::HeadType) == typeid(Int8));
assert (typeid(TypeGetter<1, TypeEraser2>::HeadType) == typeid(Int32));
typedef TypeOneEraser<Type3, Int32>::HeadType TypeEraser3;
assert (2 == TypeEraser3::length);
assert (typeid(TypeGetter<0, TypeEraser3>::HeadType) == typeid(Int8));
assert (typeid(TypeGetter<1, TypeEraser3>::HeadType) == typeid(Int16));
typedef POCO_TYPELIST_5(Int8,
Int16,
Int8,
Int16,
Int8) Type5;
typedef TypeAllEraser<Type5, Int8>::HeadType TypeAllEraser3;
assert (2 == TypeAllEraser3::length);
assert (typeid(TypeGetter<0, TypeAllEraser3>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<1, TypeAllEraser3>::HeadType) == typeid(Int16));
typedef TypeDuplicateEraser<Type5>::HeadType TypeDuplicateEraser1;
assert (2 == TypeDuplicateEraser1::length);
assert (typeid(TypeGetter<0, TypeDuplicateEraser1>::HeadType) == typeid(Int8));
assert (typeid(TypeGetter<1, TypeDuplicateEraser1>::HeadType) == typeid(Int16));
typedef TypeOneReplacer<Type5, Int8, Int32>::HeadType TypeOneReplacer1;
assert (5 == TypeOneReplacer1::length);
assert (typeid(TypeGetter<0, TypeOneReplacer1>::HeadType) == typeid(Int32));
assert (typeid(TypeGetter<1, TypeOneReplacer1>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<2, TypeOneReplacer1>::HeadType) == typeid(Int8));
assert (typeid(TypeGetter<3, TypeOneReplacer1>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<4, TypeOneReplacer1>::HeadType) == typeid(Int8));
typedef TypeAllReplacer<Type5, Int8, Int32>::HeadType TypeAllReplacer1;
assert (5 == TypeAllReplacer1::length);
assert (typeid(TypeGetter<0, TypeAllReplacer1>::HeadType) == typeid(Int32));
assert (typeid(TypeGetter<1, TypeAllReplacer1>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<2, TypeAllReplacer1>::HeadType) == typeid(Int32));
assert (typeid(TypeGetter<3, TypeAllReplacer1>::HeadType) == typeid(Int16));
assert (typeid(TypeGetter<4, TypeAllReplacer1>::HeadType) == typeid(Int32));
}
void TypeListTest::testTypeListTemplate()
void TypeListTest::testTypeList()
{
typedef TypeListType<Int8,
UInt8,
@ -469,8 +317,7 @@ CppUnit::Test* TypeListTest::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("TypeListTest");
CppUnit_addTest(pSuite, TypeListTest, testTypeListMacro);
CppUnit_addTest(pSuite, TypeListTest, testTypeListTemplate);
CppUnit_addTest(pSuite, TypeListTest, testTypeList);
return pSuite;
}

View File

@ -1,7 +1,7 @@
//
// TypeListTest.h
//
// $Id: //poco/1.3/Foundation/testsuite/src/TypeListTest.h#1 $
// $Id: //poco/1.3/Foundation/testsuite/src/TypeListTest.h#2 $
//
// Definition of the TypeListTest class.
//
@ -46,8 +46,7 @@ public:
TypeListTest(const std::string& name);
~TypeListTest();
void testTypeListMacro();
void testTypeListTemplate();
void testTypeList();
void setUp();
void tearDown();

237
MANIFEST
View File

@ -8,12 +8,14 @@ build/config/CYGWIN
build/config/Darwin
build/config/Darwin7
build/config/Darwin_x86_64
build/config/DigiEL
build/config/FreeBSD
build/config/GCCEMBEDLINUX
build/config/HP-UX
build/config/Linux
build/config/MinGW
build/config/OSF1
build/config/PPC-Linux
build/config/QNX
build/config/SSV-LINUX
build/config/SunOS
@ -113,241 +115,6 @@ CppUnit/WinTestRunner/src/TestRunnerDlg.h
CppUnit/WinTestRunner/src/WinTestRunner.cpp
CppUnit/WinTestRunner/WinTestRunner_vs71.vcproj
CppUnit/WinTestRunner/WinTestRunner_vs80.vcproj
Data
Data/Data.vmsbuild
Data/Data_VS71.sln
Data/Data_VS71.vcproj
Data/Data_VS80.sln
Data/Data_VS80.vcproj
Data/doc
Data/doc/DataDeveloperManual.page
Data/doc/DataReleaseNotes.page
Data/doc/DataUserManual.page
Data/doc/info.txt
Data/include
Data/include/Poco
Data/include/Poco/Data
Data/include/Poco/Data/AbstractBinder.h
Data/include/Poco/Data/AbstractBinding.h
Data/include/Poco/Data/AbstractExtraction.h
Data/include/Poco/Data/AbstractExtractor.h
Data/include/Poco/Data/AbstractPreparation.h
Data/include/Poco/Data/AbstractPrepare.h
Data/include/Poco/Data/AbstractSessionImpl.h
Data/include/Poco/Data/Binding.h
Data/include/Poco/Data/BLOB.h
Data/include/Poco/Data/BLOBStream.h
Data/include/Poco/Data/Column.h
Data/include/Poco/Data/Common.h
Data/include/Poco/Data/Connector.h
Data/include/Poco/Data/Data.h
Data/include/Poco/Data/DataException.h
Data/include/Poco/Data/Extraction.h
Data/include/Poco/Data/Limit.h
Data/include/Poco/Data/MetaColumn.h
Data/include/Poco/Data/PooledSessionHolder.h
Data/include/Poco/Data/PooledSessionImpl.h
Data/include/Poco/Data/Prepare.h
Data/include/Poco/Data/Range.h
Data/include/Poco/Data/RecordSet.h
Data/include/Poco/Data/Session.h
Data/include/Poco/Data/SessionFactory.h
Data/include/Poco/Data/SessionImpl.h
Data/include/Poco/Data/SessionPool.h
Data/include/Poco/Data/Statement.h
Data/include/Poco/Data/StatementCreator.h
Data/include/Poco/Data/StatementImpl.h
Data/include/Poco/Data/TypeHandler.h
Data/Makefile
Data/ODBC
Data/ODBC/include
Data/ODBC/include/Poco
Data/ODBC/include/Poco/Data
Data/ODBC/include/Poco/Data/ODBC
Data/ODBC/include/Poco/Data/ODBC/Binder.h
Data/ODBC/include/Poco/Data/ODBC/ConnectionHandle.h
Data/ODBC/include/Poco/Data/ODBC/Connector.h
Data/ODBC/include/Poco/Data/ODBC/DataTypes.h
Data/ODBC/include/Poco/Data/ODBC/Diagnostics.h
Data/ODBC/include/Poco/Data/ODBC/EnvironmentHandle.h
Data/ODBC/include/Poco/Data/ODBC/Error.h
Data/ODBC/include/Poco/Data/ODBC/Extractor.h
Data/ODBC/include/Poco/Data/ODBC/Handle.h
Data/ODBC/include/Poco/Data/ODBC/ODBC.h
Data/ODBC/include/Poco/Data/ODBC/ODBCColumn.h
Data/ODBC/include/Poco/Data/ODBC/ODBCException.h
Data/ODBC/include/Poco/Data/ODBC/ODBCStatementImpl.h
Data/ODBC/include/Poco/Data/ODBC/Parameter.h
Data/ODBC/include/Poco/Data/ODBC/Preparation.h
Data/ODBC/include/Poco/Data/ODBC/SessionImpl.h
Data/ODBC/include/Poco/Data/ODBC/Utility.h
Data/ODBC/Makefile
Data/ODBC/ODBC.vmsbuild
Data/ODBC/ODBC_VS71.sln
Data/ODBC/ODBC_VS71.vcproj
Data/ODBC/ODBC_VS80.sln
Data/ODBC/ODBC_VS80.vcproj
Data/ODBC/src
Data/ODBC/src/Binder.cpp
Data/ODBC/src/ConnectionHandle.cpp
Data/ODBC/src/Connector.cpp
Data/ODBC/src/DataTypes.cpp
Data/ODBC/src/EnvironmentHandle.cpp
Data/ODBC/src/Extractor.cpp
Data/ODBC/src/ODBCColumn.cpp
Data/ODBC/src/ODBCException.cpp
Data/ODBC/src/ODBCStatementImpl.cpp
Data/ODBC/src/Parameter.cpp
Data/ODBC/src/Preparation.cpp
Data/ODBC/src/SessionImpl.cpp
Data/ODBC/src/Utility.cpp
Data/ODBC/testsuite
Data/ODBC/testsuite/Makefile
Data/ODBC/testsuite/src
Data/ODBC/testsuite/src/Driver.cpp
Data/ODBC/testsuite/src/ODBCAccessTest.cpp
Data/ODBC/testsuite/src/ODBCAccessTest.h
Data/ODBC/testsuite/src/ODBCDB2Test.cpp
Data/ODBC/testsuite/src/ODBCDB2Test.h
Data/ODBC/testsuite/src/ODBCMySQLTest.cpp
Data/ODBC/testsuite/src/ODBCMySQLTest.h
Data/ODBC/testsuite/src/ODBCOracleTest.cpp
Data/ODBC/testsuite/src/ODBCOracleTest.h
Data/ODBC/testsuite/src/ODBCPostgreSQLTest.cpp
Data/ODBC/testsuite/src/ODBCPostgreSQLTest.h
Data/ODBC/testsuite/src/ODBCSQLiteTest.cpp
Data/ODBC/testsuite/src/ODBCSQLiteTest.h
Data/ODBC/testsuite/src/ODBCSQLServerTest.cpp
Data/ODBC/testsuite/src/ODBCSQLServerTest.h
Data/ODBC/testsuite/src/ODBCTestSuite.cpp
Data/ODBC/testsuite/src/ODBCTestSuite.h
Data/ODBC/testsuite/src/SQLExecutor.cpp
Data/ODBC/testsuite/src/SQLExecutor.h
Data/ODBC/testsuite/src/WinDriver.cpp
Data/ODBC/testsuite/TestSuite.vmsbuild
Data/ODBC/testsuite/TestSuite_VS71.vcproj
Data/ODBC/testsuite/TestSuite_VS80.vcproj
Data/samples
Data/samples/Binding
Data/samples/Binding/Binding_vs71.vcproj
Data/samples/Binding/Binding_vs80.vcproj
Data/samples/Binding/Makefile
Data/samples/Binding/src
Data/samples/Binding/src/Binding.cpp
Data/samples/Makefile
Data/samples/RecordSet
Data/samples/RecordSet/Makefile
Data/samples/RecordSet/RecordSet_vs71.vcproj
Data/samples/RecordSet/RecordSet_vs80.vcproj
Data/samples/RecordSet/src
Data/samples/RecordSet/src/RecordSet.cpp
Data/samples/samples_vs71.sln
Data/samples/samples_vs80.sln
Data/samples/Tuple
Data/samples/Tuple/Makefile
Data/samples/Tuple/src
Data/samples/Tuple/src/Tuple.cpp
Data/samples/Tuple/Tuple_vs71.vcproj
Data/samples/Tuple/Tuple_vs80.vcproj
Data/samples/TypeHandler
Data/samples/TypeHandler/Makefile
Data/samples/TypeHandler/src
Data/samples/TypeHandler/src/TypeHandler.cpp
Data/samples/TypeHandler/TypeHandler_vs71.vcproj
Data/samples/TypeHandler/TypeHandler_vs80.vcproj
Data/SQLite
Data/SQLite/include
Data/SQLite/include/Poco
Data/SQLite/include/Poco/Data
Data/SQLite/include/Poco/Data/SQLite
Data/SQLite/include/Poco/Data/SQLite/Binder.h
Data/SQLite/include/Poco/Data/SQLite/Connector.h
Data/SQLite/include/Poco/Data/SQLite/Extractor.h
Data/SQLite/include/Poco/Data/SQLite/SessionImpl.h
Data/SQLite/include/Poco/Data/SQLite/SQLite.h
Data/SQLite/include/Poco/Data/SQLite/SQLiteException.h
Data/SQLite/include/Poco/Data/SQLite/SQLiteStatementImpl.h
Data/SQLite/include/Poco/Data/SQLite/Utility.h
Data/SQLite/Makefile
Data/SQLite/SQLite.vmsbuild
Data/SQLite/SQLite_VS71.sln
Data/SQLite/SQLite_VS71.vcproj
Data/SQLite/SQLite_VS80.sln
Data/SQLite/SQLite_VS80.vcproj
Data/SQLite/src
Data/SQLite/src/Binder.cpp
Data/SQLite/src/Connector.cpp
Data/SQLite/src/Extractor.cpp
Data/SQLite/src/SessionImpl.cpp
Data/SQLite/src/sqlite3.c
Data/SQLite/src/sqlite3.h
Data/SQLite/src/SQLiteException.cpp
Data/SQLite/src/SQLiteStatementImpl.cpp
Data/SQLite/src/Utility.cpp
Data/SQLite/testsuite
Data/SQLite/testsuite/Makefile
Data/SQLite/testsuite/src
Data/SQLite/testsuite/src/Driver.cpp
Data/SQLite/testsuite/src/SQLiteTest.cpp
Data/SQLite/testsuite/src/SQLiteTest.h
Data/SQLite/testsuite/src/SQLiteTestSuite.cpp
Data/SQLite/testsuite/src/SQLiteTestSuite.h
Data/SQLite/testsuite/src/WinDriver.cpp
Data/SQLite/testsuite/TestSuite.vmsbuild
Data/SQLite/testsuite/TestSuite_VS71.vcproj
Data/SQLite/testsuite/TestSuite_VS80.vcproj
Data/src
Data/src/AbstractBinder.cpp
Data/src/AbstractBinding.cpp
Data/src/AbstractExtraction.cpp
Data/src/AbstractExtractor.cpp
Data/src/AbstractPreparation.cpp
Data/src/AbstractPrepare.cpp
Data/src/BLOB.cpp
Data/src/BLOBStream.cpp
Data/src/Connector.cpp
Data/src/DataException.cpp
Data/src/Limit.cpp
Data/src/MetaColumn.cpp
Data/src/PooledSessionHolder.cpp
Data/src/PooledSessionImpl.cpp
Data/src/Range.cpp
Data/src/RecordSet.cpp
Data/src/Session.cpp
Data/src/SessionFactory.cpp
Data/src/SessionImpl.cpp
Data/src/SessionPool.cpp
Data/src/Statement.cpp
Data/src/StatementCreator.cpp
Data/src/StatementImpl.cpp
Data/testsuite
Data/testsuite/Makefile
Data/testsuite/src
Data/testsuite/src/Binder.cpp
Data/testsuite/src/Binder.h
Data/testsuite/src/Connector.cpp
Data/testsuite/src/Connector.h
Data/testsuite/src/DataTest.cpp
Data/testsuite/src/DataTest.h
Data/testsuite/src/DataTestSuite.cpp
Data/testsuite/src/DataTestSuite.h
Data/testsuite/src/Driver.cpp
Data/testsuite/src/Extractor.cpp
Data/testsuite/src/Extractor.h
Data/testsuite/src/Preparation.cpp
Data/testsuite/src/Preparation.h
Data/testsuite/src/SessionImpl.cpp
Data/testsuite/src/SessionImpl.h
Data/testsuite/src/SessionPoolTest.cpp
Data/testsuite/src/SessionPoolTest.h
Data/testsuite/src/StatementImpl.cpp
Data/testsuite/src/StatementImpl.h
Data/testsuite/src/TestStatementImpl.cpp
Data/testsuite/src/TestStatementImpl.h
Data/testsuite/src/WinDriver.cpp
Data/testsuite/TestSuite.vmsbuild
Data/testsuite/TestSuite_VS71.vcproj
Data/testsuite/TestSuite_VS80.vcproj
doc
doc/Acknowledgements.html
Foundation

View File

@ -20,7 +20,7 @@ endif
all: libexecs tests samples
INSTALLDIR = $(DESTDIR)$(POCO_PREFIX)
COMPONENTS = Foundation XML Util Net NetSSL_OpenSSL Data Data/SQLite Data/ODBC
COMPONENTS = Foundation XML Util Net NetSSL_OpenSSL
cppunit:
$(MAKE) -C $(POCO_BASE)/CppUnit
@ -39,13 +39,13 @@ install: libexecs
done
find $(POCO_BUILD)/lib -name "libPoco*" -exec cp -Rf {} $(INSTALLDIR)/lib \;
.PHONY: Foundation-libexec XML-libexec Util-libexec Net-libexec NetSSL_OpenSSL-libexec Data-libexec Data/SQLite-libexec Data/ODBC-libexec
.PHONY: Foundation-tests XML-tests Util-tests Net-tests NetSSL_OpenSSL-tests Data-tests Data/SQLite-tests Data/ODBC-tests
.PHONY: Foundation-samples XML-samples Util-samples Net-samples NetSSL_OpenSSL-samples Data-samples
.PHONY: Foundation-libexec XML-libexec Util-libexec Net-libexec NetSSL_OpenSSL-libexec
.PHONY: Foundation-tests XML-tests Util-tests Net-tests NetSSL_OpenSSL-tests
.PHONY: Foundation-samples XML-samples Util-samples Net-samples NetSSL_OpenSSL-samples
libexecs: Foundation-libexec XML-libexec Util-libexec Net-libexec NetSSL_OpenSSL-libexec Data-libexec Data/SQLite-libexec Data/ODBC-libexec
tests: Foundation-tests XML-tests Util-tests Net-tests NetSSL_OpenSSL-tests Data-tests Data/SQLite-tests Data/ODBC-tests
samples: Foundation-samples XML-samples Util-samples Net-samples NetSSL_OpenSSL-samples Data-samples
libexecs: Foundation-libexec XML-libexec Util-libexec Net-libexec NetSSL_OpenSSL-libexec
tests: Foundation-tests XML-tests Util-tests Net-tests NetSSL_OpenSSL-tests
samples: Foundation-samples XML-samples Util-samples Net-samples NetSSL_OpenSSL-samples
Foundation-libexec:
$(MAKE) -C $(POCO_BASE)/Foundation
@ -91,24 +91,3 @@ NetSSL_OpenSSL-tests: NetSSL_OpenSSL-libexec cppunit
NetSSL_OpenSSL-samples: NetSSL_OpenSSL-libexec
$(MAKE) -C $(POCO_BASE)/NetSSL_OpenSSL/samples
Data-libexec: Foundation -libexec
$(MAKE) -C $(POCO_BASE)/Data
Data-tests: Data-libexec cppunit
$(MAKE) -C $(POCO_BASE)/Data/testsuite
Data-samples: Data-libexec Data -libexec Data/SQLite -libexec
$(MAKE) -C $(POCO_BASE)/Data/samples
Data/SQLite-libexec: Foundation -libexec Data -libexec
$(MAKE) -C $(POCO_BASE)/Data/SQLite
Data/SQLite-tests: Data/SQLite-libexec cppunit
$(MAKE) -C $(POCO_BASE)/Data/SQLite/testsuite
Data/ODBC-libexec: Foundation -libexec Data -libexec
$(MAKE) -C $(POCO_BASE)/Data/ODBC
Data/ODBC-tests: Data/ODBC-libexec cppunit
$(MAKE) -C $(POCO_BASE)/Data/ODBC/testsuite

View File

@ -1,7 +1,7 @@
//
// MailMessage.h
//
// $Id: //poco/1.3/Net/include/Poco/Net/MailMessage.h#1 $
// $Id: //poco/1.3/Net/include/Poco/Net/MailMessage.h#2 $
//
// Library: Net
// Package: Mail
@ -107,6 +107,10 @@ public:
void setSender(const std::string& sender);
/// Sets the sender of the message (which
/// ends up in the From header field).
///
/// The sender must either be a valid email
/// address, or a real name followed by
/// an email address enclosed in < and >.
const std::string& getSender() const;
/// Returns the sender of the message (taken

View File

@ -1,7 +1,7 @@
//
// Socket.h
//
// $Id: //poco/1.3/Net/include/Poco/Net/Socket.h#1 $
// $Id: //poco/1.3/Net/include/Poco/Net/Socket.h#2 $
//
// Library: Net
// Package: Sockets
@ -272,6 +272,11 @@ public:
/// Sets the socket in blocking mode if flag is true,
/// disables blocking mode if flag is false.
bool getBlocking() const;
/// Returns the blocking mode of the socket.
/// This method will only work if the blocking modes of
/// the socket are changed via the setBlocking method!
SocketAddress address() const;
/// Returns the IP address and port number of the socket.
@ -543,6 +548,12 @@ inline void Socket::setBlocking(bool flag)
}
inline bool Socket::getBlocking() const
{
return _pImpl->getBlocking();
}
inline SocketImpl* Socket::impl() const
{
return _pImpl;

View File

@ -1,7 +1,7 @@
//
// SocketImpl.h
//
// $Id: //poco/1.3/Net/include/Poco/Net/SocketImpl.h#2 $
// $Id: //poco/1.3/Net/include/Poco/Net/SocketImpl.h#4 $
//
// Library: Net
// Package: Sockets
@ -323,10 +323,15 @@ public:
bool getBroadcast();
/// Returns the value of the SO_BROADCAST socket option.
void setBlocking(bool flag);
virtual void setBlocking(bool flag);
/// Sets the socket in blocking mode if flag is true,
/// disables blocking mode if flag is false.
virtual bool getBlocking() const;
/// Returns the blocking mode of the socket.
/// This method will only work if the blocking modes of
/// the socket are changed via the setBlocking method!
int socketError();
/// Returns the value of the SO_ERROR socket option.
@ -409,6 +414,7 @@ private:
Poco::Timespan _recvTimeout;
Poco::Timespan _sndTimeout;
#endif
bool _blocking;
friend class Socket;
friend class SecureSocketImpl;
@ -446,6 +452,12 @@ inline void SocketImpl::invalidate()
}
inline bool SocketImpl::getBlocking() const
{
return _blocking;
}
} } // namespace Poco::Net

View File

@ -1,7 +1,7 @@
//
// HTTPLoadTest.cpp
//
// $Id: //poco/1.3/Net/samples/HTTPLoadTest/src/HTTPLoadTest.cpp#1 $
// $Id: //poco/1.3/Net/samples/HTTPLoadTest/src/HTTPLoadTest.cpp#3 $
//
// This sample demonstrates the HTTPClientSession class.
//
@ -45,6 +45,8 @@
#include "Poco/Runnable.h"
#include "Poco/Stopwatch.h"
#include "Poco/NumberParser.h"
#include "Poco/StreamCopier.h"
#include "Poco/NullStream.h"
#include "Poco/Exception.h"
#include "Poco/Util/Application.h"
#include "Poco/Util/Option.h"
@ -74,14 +76,17 @@ using Poco::NumberParser;
using Poco::Path;
using Poco::URI;
using Poco::Exception;
using Poco::StreamCopier;
using Poco::NullOutputStream;
class HTTPClient : public Runnable
{
public:
HTTPClient(const URI& uri, int repetitions, bool cookies=false, bool verbose=false):
_uri(uri),
_cookies(cookies),
_verbose(verbose),
_cookies(cookies),
_repetitions(repetitions),
_usec(0),
_success(0)
@ -123,10 +128,12 @@ public:
sw.restart();
session.sendRequest(req);
std::istream& rs = session.receiveResponse(res);
NullOutputStream nos;
StreamCopier::copyStream(rs, nos);
sw.stop();
_success += HTTPResponse::HTTP_OK == res.getStatus() ? 1 : 0;
if (_cookies) res.getCookies(cookies);
usec = sw.elapsed();
usec = int(sw.elapsed());
if (_verbose)
{
@ -218,10 +225,10 @@ class HTTPLoadTest: public Application
public:
HTTPLoadTest():
_helpRequested(false),
_repetitions(1),
_threads(1),
_verbose(false),
_cookies(false)
_cookies(false),
_repetitions(1),
_threads(1)
{
}

View File

@ -1,7 +1,7 @@
//
// HTTPTimeServer.cpp
//
// $Id: //poco/1.3/Net/samples/HTTPTimeServer/src/HTTPTimeServer.cpp#1 $
// $Id: //poco/1.3/Net/samples/HTTPTimeServer/src/HTTPTimeServer.cpp#2 $
//
// This sample demonstrates the HTTPServer and related classes.
//
@ -91,7 +91,7 @@ public:
response.setContentType("text/html");
std::ostream& ostr = response.send();
ostr << "<html><head><title>HTTPTimeServer powered by C++ Portable Components</title>";
ostr << "<html><head><title>HTTPTimeServer powered by POCO C++ Libraries</title>";
ostr << "<meta http-equiv=\"refresh\" content=\"1\"></head>";
ostr << "<body><p style=\"text-align: center; font-size: 48px;\">";
ostr << dt;

View File

@ -1,7 +1,7 @@
//
// Mail.cpp
//
// $Id: //poco/1.3/Net/samples/Mail/src/Mail.cpp#1 $
// $Id: //poco/1.3/Net/samples/Mail/src/Mail.cpp#2 $
//
// This sample demonstrates the MailMessage and SMTPClientSession classes.
//
@ -75,12 +75,12 @@ int main(int argc, char** argv)
MailMessage message;
message.setSender(sender);
message.addRecipient(MailRecipient(MailRecipient::PRIMARY_RECIPIENT, recipient));
message.setSubject("Hello from the C++ Portable Components");
message.setSubject("Hello from the POCO C++ Libraries");
std::string content;
content += "Hello ";
content += recipient;
content += ",\r\n\r\n";
content += "This is a greeting from the C++ Portable Components.\r\n\r\n";
content += "This is a greeting from the POCO C++ Libraries.\r\n\r\n";
std::string logo(reinterpret_cast<const char*>(PocoLogo), sizeof(PocoLogo));
message.addContent(new StringPartSource(content));
message.addAttachment("logo", new StringPartSource(logo, "image/gif"));

View File

@ -1,7 +1,7 @@
//
// HTMLForm.cpp
//
// $Id: //poco/1.3/Net/src/HTMLForm.cpp#3 $
// $Id: //poco/1.3/Net/src/HTMLForm.cpp#4 $
//
// Library: Net
// Package: HTML
@ -319,9 +319,9 @@ void HTMLForm::writeUrl(std::ostream& ostr)
{
if (it != begin()) ostr << "&";
std::string name;
URI::encode(it->first, "=&", name);
URI::encode(it->first, "=&+", name);
std::string value;
URI::encode(it->second, "=&", value);
URI::encode(it->second, "=&+", value);
ostr << name << "=" << value;
}
}

View File

@ -1,7 +1,7 @@
//
// HTTPServerResponseImpl.cpp
//
// $Id: //poco/1.3/Net/src/HTTPServerResponseImpl.cpp#1 $
// $Id: //poco/1.3/Net/src/HTTPServerResponseImpl.cpp#2 $
//
// Library: Net
// Package: HTTPServer
@ -47,6 +47,8 @@
#include "Poco/CountingStream.h"
#include "Poco/Exception.h"
#include "Poco/FileStream.h"
#include "Poco/DateTimeFormatter.h"
#include "Poco/DateTimeFormat.h"
using Poco::File;
@ -54,6 +56,8 @@ using Poco::Timestamp;
using Poco::NumberFormatter;
using Poco::StreamCopier;
using Poco::OpenFileException;
using Poco::DateTimeFormatter;
using Poco::DateTimeFormat;
namespace Poco {
@ -64,6 +68,8 @@ HTTPServerResponseImpl::HTTPServerResponseImpl(HTTPServerSession& session):
_session(session),
_pStream(0)
{
Timestamp now;
setDate(now);
}
@ -114,7 +120,7 @@ void HTTPServerResponseImpl::sendFile(const std::string& path, const std::string
File f(path);
Timestamp dateTime = f.getLastModified();
File::FileSize length = f.getSize();
setDate(dateTime);
set("Last-Modified", DateTimeFormatter::format(dateTime, DateTimeFormat::HTTP_FORMAT));
setContentLength(static_cast<int>(length));
setContentType(mediaType);
setChunkedTransferEncoding(false);

View File

@ -1,7 +1,7 @@
//
// HTTPStreamFactory.cpp
//
// $Id: //poco/1.3/Net/src/HTTPStreamFactory.cpp#1 $
// $Id: //poco/1.3/Net/src/HTTPStreamFactory.cpp#2 $
//
// Library: Net
// Package: HTTP
@ -78,14 +78,21 @@ std::istream* HTTPStreamFactory::open(const URI& uri)
poco_assert (uri.getScheme() == "http");
URI resolvedURI(uri);
URI proxyUri;
HTTPClientSession* pSession = 0;
bool retry = false;
try
{
int redirects = 0;
do
{
pSession = new HTTPClientSession(resolvedURI.getHost(), resolvedURI.getPort());
pSession->setProxy(_proxyHost, _proxyPort);
if (proxyUri.empty())
pSession->setProxy(_proxyHost, _proxyPort);
else
pSession->setProxy(proxyUri.getHost(), proxyUri.getPort());
std::string path = resolvedURI.getPathAndQuery();
if (path.empty()) path = "/";
HTTPRequest req(HTTPRequest::HTTP_GET, path, HTTPMessage::HTTP_1_1);
@ -93,22 +100,35 @@ std::istream* HTTPStreamFactory::open(const URI& uri)
HTTPResponse res;
std::istream& rs = pSession->receiveResponse(res);
bool moved = (res.getStatus() == HTTPResponse::HTTP_MOVED_PERMANENTLY ||
res.getStatus() == HTTPResponse::HTTP_FOUND ||
res.getStatus() == HTTPResponse::HTTP_SEE_OTHER);
res.getStatus() == HTTPResponse::HTTP_FOUND ||
res.getStatus() == HTTPResponse::HTTP_SEE_OTHER ||
res.getStatus() == HTTPResponse::HTTP_TEMPORARY_REDIRECT);
if (moved)
{
resolvedURI.resolve(res.get("Location"));
delete pSession;
if (resolvedURI.getScheme() != "http") throw UnsupportedRedirectException(uri.toString());
++redirects;
throw URIRedirection(resolvedURI.toString());
}
else if (res.getStatus() == HTTPResponse::HTTP_OK)
{
return new HTTPResponseStream(rs, pSession);
}
else throw HTTPException(res.getReason(), uri.toString());
else if (res.getStatus() == HTTPResponse::HTTP_USEPROXY && !retry)
{
//The requested resource MUST be accessed through the proxy
//given by the Location field. The Location field gives the
//URI of the proxy. The recipient is expected to repeat this
//single request via the proxy. 305 responses MUST only be generated by origin servers.
// only use for one single request!
proxyUri.resolve(res.get("Location"));
delete pSession; pSession = 0;
retry = true; //only allow useproxy once
}
else
{
throw HTTPException(res.getReason(), uri.toString());
}
}
while (redirects < MAX_REDIRECTS);
while(retry);
throw HTTPException("Too many redirects", uri.toString());
}
catch (...)

View File

@ -1,7 +1,7 @@
//
// IPAddress.cpp
//
// $Id: //poco/1.3/Net/src/IPAddress.cpp#5 $
// $Id: //poco/1.3/Net/src/IPAddress.cpp#6 $
//
// Library: Net
// Package: NetCore
@ -224,7 +224,15 @@ public:
static IPv4AddressImpl* parse(const std::string& addr)
{
if (addr.empty()) return 0;
#if defined(_WIN32)
#if defined(_WIN32)
struct in_addr ia;
ia.s_addr = inet_addr(addr.c_str());
if (ia.s_addr == INADDR_NONE && addr != "255.255.255.255")
return 0;
else
return new IPv4AddressImpl(&ia);
#else
#if __GNUC__ < 3
struct in_addr ia;
ia.s_addr = inet_addr(addr.c_str());
if (ia.s_addr == INADDR_NONE && addr != "255.255.255.255")
@ -237,6 +245,7 @@ public:
return new IPv4AddressImpl(&ia);
else
return 0;
#endif
#endif
}
@ -517,6 +526,7 @@ IPAddress::IPAddress(const std::string& addr, Family family): _pImpl(0)
_pImpl = IPv6AddressImpl::parse(addr);
#endif
else throw Poco::InvalidArgumentException("Invalid or unsupported address family passed to IPAddress()");
if (!_pImpl) throw InvalidAddressException(addr);
}

View File

@ -1,7 +1,7 @@
//
// SMTPClientSession.cpp
//
// $Id: //poco/1.3/Net/src/SMTPClientSession.cpp#2 $
// $Id: //poco/1.3/Net/src/SMTPClientSession.cpp#3 $
//
// Library: Net
// Package: Mail
@ -133,10 +133,20 @@ void SMTPClientSession::close()
void SMTPClientSession::sendMessage(const MailMessage& message)
{
std::string response;
std::string sender("<");
sender.append(message.getSender());
sender.append(">");
int status = sendCommand("MAIL FROM:", sender, response);
int status = 0;
const std::string& fromField = message.getSender();
std::string::size_type emailPos = fromField.find('<');
if (emailPos == std::string::npos)
{
std::string sender("<");
sender.append(fromField);
sender.append(">");
status = sendCommand("MAIL FROM:", sender, response);
}
else
{
status = sendCommand("MAIL FROM:", fromField.substr(emailPos, fromField.size() - emailPos), response);
}
if (!isPositiveCompletion(status)) throw SMTPException("Cannot send message", response);
for (MailMessage::Recipients::const_iterator it = message.recipients().begin(); it != message.recipients().end(); ++it)
{

View File

@ -1,7 +1,7 @@
//
// SocketImpl.cpp
//
// $Id: //poco/1.3/Net/src/SocketImpl.cpp#4 $
// $Id: //poco/1.3/Net/src/SocketImpl.cpp#5 $
//
// Library: Net
// Package: Sockets
@ -54,13 +54,15 @@ namespace Net {
SocketImpl::SocketImpl():
_sockfd(POCO_INVALID_SOCKET)
_sockfd(POCO_INVALID_SOCKET),
_blocking(true)
{
}
SocketImpl::SocketImpl(poco_socket_t sockfd):
_sockfd(sockfd)
_sockfd(sockfd),
_blocking(true)
{
}
@ -718,6 +720,7 @@ void SocketImpl::setBlocking(bool flag)
{
int arg = flag ? 0 : 1;
ioctl(FIONBIO, arg);
_blocking = flag;
}

View File

@ -1,7 +1,7 @@
//
// TCPServer.cpp
//
// $Id: //poco/1.3/Net/src/TCPServer.cpp#2 $
// $Id: //poco/1.3/Net/src/TCPServer.cpp#3 $
//
// Library: Net
// Package: TCPServer
@ -54,7 +54,7 @@ TCPServer::TCPServer(TCPServerConnectionFactory* pFactory, const ServerSocket& s
_socket(socket),
_pDispatcher(new TCPServerDispatcher(pFactory, Poco::ThreadPool::defaultPool(), pParams)),
_thread(threadName(socket)),
_stopped(false)
_stopped(true)
{
}
@ -63,7 +63,7 @@ TCPServer::TCPServer(TCPServerConnectionFactory* pFactory, Poco::ThreadPool& thr
_socket(socket),
_pDispatcher(new TCPServerDispatcher(pFactory, threadPool, pParams)),
_thread(threadName(socket)),
_stopped(false)
_stopped(true)
{
}
@ -83,8 +83,9 @@ const TCPServerParams& TCPServer::params() const
void TCPServer::start()
{
poco_assert (!_stopped);
poco_assert (_stopped);
_stopped = false;
_thread.start(*this);
}

View File

@ -1,7 +1,7 @@
//
// HTMLFormTest.cpp
//
// $Id: //poco/1.3/Net/testsuite/src/HTMLFormTest.cpp#2 $
// $Id: //poco/1.3/Net/testsuite/src/HTMLFormTest.cpp#3 $
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -111,11 +111,12 @@ void HTMLFormTest::testWriteUrl()
form.set("field2", "value 2");
form.set("field3", "value=3");
form.set("field4", "value&4");
form.set("field5", "value+5");
std::ostringstream ostr;
form.write(ostr);
std::string s = ostr.str();
assert (s == "field1=value1&field2=value%202&field3=value%3D3&field4=value%264");
assert (s == "field1=value1&field2=value%202&field3=value%3D3&field4=value%264&field5=value%2B5");
}

View File

@ -1,7 +1,7 @@
//
// HTTPStreamFactoryTest.cpp
//
// $Id: //poco/1.3/Net/testsuite/src/HTTPStreamFactoryTest.cpp#1 $
// $Id: //poco/1.3/Net/testsuite/src/HTTPStreamFactoryTest.cpp#2 $
//
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@ -36,6 +36,7 @@
#include "Poco/Net/HTTPStreamFactory.h"
#include "Poco/Net/NetException.h"
#include "Poco/URI.h"
#include "Poco/URIStreamOpener.h"
#include "Poco/StreamCopier.h"
#include "HTTPTestServer.h"
#include <sstream>
@ -88,10 +89,11 @@ void HTTPStreamFactoryTest::testEmptyPath()
void HTTPStreamFactoryTest::testRedirect()
{
HTTPTestServer server;
HTTPStreamFactory factory;
Poco::URIStreamOpener opener;
opener.registerStreamFactory("http", new HTTPStreamFactory);
URI uri("http://localhost/redirect");
uri.setPort(server.port());
std::auto_ptr<std::istream> pStr(factory.open(uri));
std::auto_ptr<std::istream> pStr(opener.open(uri));
std::ostringstream ostr;
StreamCopier::copyStream(*pStr.get(), ostr);
assert (ostr.str() == HTTPTestServer::LARGE_BODY);

View File

@ -1,7 +1,7 @@
//
// SSLInitializer.cpp
//
// $Id: //poco/1.3/NetSSL_OpenSSL/src/SSLInitializer.cpp#1 $
// $Id: //poco/1.3/NetSSL_OpenSSL/src/SSLInitializer.cpp#2 $
//
// Library: NetSSL_OpenSSL
// Package: SSLCore
@ -87,7 +87,9 @@ void SSLInitializer::initialize()
int nMutexes = CRYPTO_num_locks();
_mutexes = new FastMutex[nMutexes];
CRYPTO_set_locking_callback(&SSLInitializer::lock);
#ifndef POCO_OS_FAMILY_WINDOWS // SF# 1828231: random unhandled exceptions when linking with ssl
CRYPTO_set_id_callback(&SSLInitializer::id);
#endif
CRYPTO_set_dynlock_create_callback(&SSLInitializer::dynlockCreate);
CRYPTO_set_dynlock_lock_callback(&SSLInitializer::dynlock);
CRYPTO_set_dynlock_destroy_callback(&SSLInitializer::dynlockDestroy);

View File

@ -39,7 +39,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib"
AdditionalDependencies="PocoFoundationd.lib PocoXMLd.lib unicows.lib"
OutputFile="..\bin\PocoUtild.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
@ -104,7 +104,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib"
AdditionalDependencies="PocoFoundation.lib PocoXML.lib unicows.lib"
OutputFile="..\bin\PocoUtil.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"

View File

@ -1,7 +1,7 @@
//
// Application.h
//
// $Id: //poco/1.3/Util/include/Poco/Util/Application.h#6 $
// $Id: //poco/1.3/Util/include/Poco/Util/Application.h#7 $
//
// Library: Util
// Package: Application
@ -148,7 +148,7 @@ public:
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
void init(int argc, wchar_t* argv[]);
/// Initializes the application and all registered subsystems,
/// using the given command line arguments.
@ -445,7 +445,7 @@ inline Poco::Timespan Application::uptime() const
//
// Macro to implement main()
//
#if defined(_WIN32) && defined(POCO_WIN32_UTF8)
#if defined(_WIN32) && defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
#define POCO_APP_MAIN(App) \
int wmain(int argc, wchar_t** argv) \
{ \

View File

@ -1,7 +1,7 @@
//
// Option.h
//
// $Id: //poco/1.3/Util/include/Poco/Util/Option.h#2 $
// $Id: //poco/1.3/Util/include/Poco/Util/Option.h#3 $
//
// Library: Util
// Package: Options
@ -104,7 +104,7 @@ public:
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required = false);
/// Creates an option with the given properties.
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argOptional = false);
Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argRequired = false);
/// Creates an option with the given properties.
~Option();

View File

@ -1,7 +1,7 @@
//
// ServerApplication.h
//
// $Id: //poco/1.3/Util/include/Poco/Util/ServerApplication.h#2 $
// $Id: //poco/1.3/Util/include/Poco/Util/ServerApplication.h#3 $
//
// Library: Util
// Package: Application
@ -141,7 +141,7 @@ public:
/// Runs the application by performing additional initializations
/// and calling the main() method.
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
int run(int argc, wchar_t** argv);
/// Runs the application by performing additional initializations
/// and calling the main() method.
@ -170,7 +170,7 @@ private:
};
static BOOL __stdcall ConsoleCtrlHandler(DWORD ctrlType);
static void __stdcall ServiceControlHandler(DWORD control);
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
static void __stdcall ServiceMain(DWORD argc, LPWSTR* argv);
#else
static void __stdcall ServiceMain(DWORD argc, LPTSTR* argv);

View File

@ -1,7 +1,7 @@
//
// Application.cpp
//
// $Id: //poco/1.3/Util/src/Application.cpp#5 $
// $Id: //poco/1.3/Util/src/Application.cpp#6 $
//
// Library: Util
// Package: Application
@ -58,7 +58,7 @@
#if defined(POCO_OS_FAMILY_UNIX)
#include "Poco/SignalHandler.h"
#endif
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
#include "Poco/UnicodeConverter.h"
#endif
@ -156,7 +156,7 @@ void Application::init(int argc, char* argv[])
}
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
void Application::init(int argc, wchar_t* argv[])
{
std::vector<std::string> args;
@ -398,7 +398,7 @@ void Application::getApplicationPath(Poco::Path& appPath) const
appPath = Path(Path::current(), _command);
}
#elif defined(POCO_OS_FAMILY_WINDOWS)
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
wchar_t path[1024];
int n = GetModuleFileNameW(0, path, sizeof(path)/sizeof(wchar_t));
if (n > 0)

View File

@ -1,7 +1,7 @@
//
// Option.cpp
//
// $Id: //poco/1.3/Util/src/Option.cpp#2 $
// $Id: //poco/1.3/Util/src/Option.cpp#3 $
//
// Library: Util
// Package: Options
@ -107,14 +107,14 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
}
Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argOptional):
Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argRequired):
_shortName(shortName),
_fullName(fullName),
_description(description),
_required(required),
_repeatable(false),
_argName(argName),
_argRequired(argOptional),
_argRequired(argRequired),
_pValidator(0),
_pCallback(0),
_pConfig(0)
@ -243,7 +243,6 @@ Option& Option::validator(Validator* pValidator)
{
if (_pValidator) _pValidator->release();
_pValidator = pValidator;
if (_pValidator) _pValidator->duplicate();
return *this;
}

View File

@ -1,7 +1,7 @@
//
// PropertyFileConfiguration.cpp
//
// $Id: //poco/1.3/Util/src/PropertyFileConfiguration.cpp#4 $
// $Id: //poco/1.3/Util/src/PropertyFileConfiguration.cpp#5 $
//
// Library: Util
// Package: Configuration
@ -39,6 +39,7 @@
#include "Poco/String.h"
#include "Poco/Path.h"
#include "Poco/FileStream.h"
#include "Poco/LineEndingConverter.h"
#include <cctype>
@ -109,7 +110,9 @@ void PropertyFileConfiguration::save(const std::string& path) const
Poco::FileOutputStream ostr(path);
if (ostr.good())
{
save(ostr);
Poco::OutputLineEndingConverter lec(ostr);
save(lec);
lec.flush();
ostr.flush();
if (!ostr.good()) throw Poco::WriteFileException(path);
}

View File

@ -1,7 +1,7 @@
//
// ServerApplication.cpp
//
// $Id: //poco/1.3/Util/src/ServerApplication.cpp#4 $
// $Id: //poco/1.3/Util/src/ServerApplication.cpp#5 $
//
// Library: Util
// Package: Application
@ -53,7 +53,7 @@
#include "Poco/UnWindows.h"
#include <cstring>
#endif
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
#include "Poco/UnicodeConverter.h"
#endif
@ -146,7 +146,7 @@ void ServerApplication::ServiceControlHandler(DWORD control)
}
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
void ServerApplication::ServiceMain(DWORD argc, LPWSTR* argv)
#else
void ServerApplication::ServiceMain(DWORD argc, LPTSTR* argv)
@ -154,7 +154,9 @@ void ServerApplication::ServiceMain(DWORD argc, LPTSTR* argv)
{
ServerApplication& app = static_cast<ServerApplication&>(Application::instance());
#if defined(POCO_WIN32_UTF8)
app.config().setBool("application.runAsService", true);
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
_serviceStatusHandle = RegisterServiceCtrlHandlerW(L"", ServiceControlHandler);
#else
_serviceStatusHandle = RegisterServiceCtrlHandler("", ServiceControlHandler);
@ -173,7 +175,7 @@ void ServerApplication::ServiceMain(DWORD argc, LPTSTR* argv)
try
{
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
std::vector<std::string> args;
for (DWORD i = 0; i < argc; ++i)
{
@ -230,7 +232,6 @@ int ServerApplication::run(int argc, char** argv)
{
if (!hasConsole() && isService())
{
config().setBool("application.runAsService", true);
return 0;
}
else
@ -264,12 +265,11 @@ int ServerApplication::run(int argc, char** argv)
}
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
int ServerApplication::run(int argc, wchar_t** argv)
{
if (!hasConsole() && isService())
{
config().setBool("application.runAsService", true);
return 0;
}
else
@ -306,7 +306,7 @@ int ServerApplication::run(int argc, wchar_t** argv)
bool ServerApplication::isService()
{
#if defined(POCO_WIN32_UTF8)
#if defined(POCO_WIN32_UTF8) && !defined(POCO_NO_WSTRING)
SERVICE_TABLE_ENTRYW svcDispatchTable[2];
svcDispatchTable[0].lpServiceName = L"";
svcDispatchTable[0].lpServiceProc = ServiceMain;

View File

@ -1 +1 @@
1.3.1-data (2007-08-08)
1.3.2-ssl (2008-01-28)

View File

@ -37,7 +37,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundationd.lib"
AdditionalDependencies="PocoFoundationd.lib unicows.lib"
OutputFile="..\bin\PocoXMLd.dll"
LinkIncremental="2"
SuppressStartupBanner="TRUE"
@ -102,7 +102,7 @@
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="PocoFoundation.lib"
AdditionalDependencies="PocoFoundation.lib unicows.lib"
OutputFile="..\bin\PocoXML.dll"
LinkIncremental="1"
SuppressStartupBanner="TRUE"

View File

@ -1,7 +1,7 @@
//
// DOMBuilder.h
//
// $Id: //poco/1.3/XML/include/Poco/DOM/DOMBuilder.h#1 $
// $Id: //poco/1.3/XML/include/Poco/DOM/DOMBuilder.h#2 $
//
// Library: XML
// Package: DOM
@ -81,6 +81,9 @@ public:
virtual Document* parse(InputSource* pInputSource);
/// Parse an XML document from a location identified by an InputSource.
virtual Document* parseMemoryNP(const char* xml, std::size_t size);
/// Parses an XML document from memory.
protected:
// DTDHandler
void notationDecl(const XMLString& name, const XMLString* publicId, const XMLString* systemId);

View File

@ -1,7 +1,7 @@
//
// DOMParser.h
//
// $Id: //poco/1.3/XML/include/Poco/DOM/DOMParser.h#1 $
// $Id: //poco/1.3/XML/include/Poco/DOM/DOMParser.h#2 $
//
// Library: XML
// Package: DOM
@ -105,6 +105,9 @@ public:
Document* parseString(const std::string& xml);
/// Parse an XML document from a string.
Document* parseMemory(const char* xml, std::size_t size);
/// Parse an XML document from memory.
EntityResolver* getEntityResolver() const;
/// Returns the entity resolver used by the underlying SAXParser.

View File

@ -1,7 +1,7 @@
//
// DOMSerializer.h
//
// $Id: //poco/1.3/XML/include/Poco/DOM/DOMSerializer.h#1 $
// $Id: //poco/1.3/XML/include/Poco/DOM/DOMSerializer.h#2 $
//
// Library: XML
// Package: DOM
@ -109,6 +109,10 @@ protected:
/// The DOMSerializer cannot parse from a system identifier,
/// so this method simply throws an XMLException when invoked.
void parseMemoryNP(const char* xml, std::size_t size);
/// The DOMSerializer cannot parse from a system identifier,
/// so this method simply throws an XMLException when invoked.
void iterate(const Node* pNode) const;
void handleNode(const Node* pNode) const;
void handleElement(const Element* pElement) const;

View File

@ -1,7 +1,7 @@
//
// Element.h
//
// $Id: //poco/1.3/XML/include/Poco/DOM/Element.h#1 $
// $Id: //poco/1.3/XML/include/Poco/DOM/Element.h#2 $
//
// Library: XML
// Package: DOM
@ -101,6 +101,13 @@ public:
/// Adds a new attribute. If an attribute with that name is already
/// present in the element, it is replaced by the new one.
Attr* addAttributeNodeNP(Attr* oldAttr, Attr* newAttr);
/// For internal use only.
/// Adds a new attribute after oldAttr.
/// If oldAttr is 0, newAttr is set as first attribute.
/// Returns newAttr.
/// Does not fire any events.
Attr* removeAttributeNode(Attr* oldAttr);
/// Removes the specified attribute.

View File

@ -1,7 +1,7 @@
//
// Attributes.h
//
// $Id: //poco/1.3/XML/include/Poco/SAX/Attributes.h#1 $
// $Id: //poco/1.3/XML/include/Poco/SAX/Attributes.h#2 $
//
// Library: XML
// Package: SAX
@ -83,13 +83,13 @@ public:
///
/// Once you know the number of attributes, you can iterate through the list.
virtual XMLString getLocalName(int i) const = 0;
virtual const XMLString& getLocalName(int i) const = 0;
/// Look up a local attribute name by index.
virtual XMLString getQName(int i) const = 0;
virtual const XMLString& getQName(int i) const = 0;
/// Look up a qualified attribute name by index.
virtual XMLString getType(int i) const = 0;
virtual const XMLString& getType(int i) const = 0;
/// Look up an attribute type by index.
///
/// The attribute type is one of the strings "CDATA", "ID", "IDREF", "IDREFS", "NMTOKEN",
@ -102,33 +102,33 @@ public:
/// For an enumerated attribute that is not a notation, the parser will report the type
/// as "NMTOKEN".
virtual XMLString getType(const XMLString& qname) const = 0;
virtual const XMLString& getType(const XMLString& qname) const = 0;
/// Look up an attribute type by a qualified name.
///
/// See getType(int) for a description of the possible types.
virtual XMLString getType(const XMLString& namespaceURI, const XMLString& localName) const = 0;
virtual const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const = 0;
/// Look up an attribute type by a namespace name.
///
/// See getType(int) for a description of the possible types.
virtual XMLString getValue(int i) const = 0;
virtual const XMLString& getValue(int i) const = 0;
/// Look up an attribute value by index.
///
/// If the attribute value is a list of tokens (IDREFS, ENTITIES, or NMTOKENS), the tokens
/// will be concatenated into a single string with each token separated by a single space.
virtual XMLString getValue(const XMLString& qname) const = 0;
virtual const XMLString& getValue(const XMLString& qname) const = 0;
/// Look up an attribute value by a qualified name.
///
/// See getValue(int) for a description of the possible values.
virtual XMLString getValue(const XMLString& uri, const XMLString& localName) const = 0;
virtual const XMLString& getValue(const XMLString& uri, const XMLString& localName) const = 0;
/// Look up an attribute value by a namespace name.
///
/// See getValue(int) for a description of the possible values.
virtual XMLString getURI(int i) const = 0;
virtual const XMLString& getURI(int i) const = 0;
/// Look up a namespace URI by index.
protected:

View File

@ -1,7 +1,7 @@
//
// AttributesImpl.h
//
// $Id: //poco/1.3/XML/include/Poco/SAX/AttributesImpl.h#1 $
// $Id: //poco/1.3/XML/include/Poco/SAX/AttributesImpl.h#2 $
//
// Library: XML
// Package: SAX
@ -58,6 +58,18 @@ class XML_API AttributesImpl: public Attributes
/// 2. to construct or modify an Attributes object in a SAX2 driver or filter.
{
public:
struct Attribute
{
XMLString localName;
XMLString namespaceURI;
XMLString qname;
XMLString value;
XMLString type;
bool specified;
};
typedef std::vector<Attribute> AttributeVec;
typedef AttributeVec::const_iterator iterator;
AttributesImpl();
/// Creates the AttributesImpl.
@ -76,15 +88,15 @@ public:
int getIndex(const XMLString& name) const;
int getIndex(const XMLString& namespaceURI, const XMLString& localName) const;
int getLength() const;
XMLString getLocalName(int i) const;
XMLString getQName(int i) const;
XMLString getType(int i) const;
XMLString getType(const XMLString& qname) const;
XMLString getType(const XMLString& namespaceURI, const XMLString& localName) const;
XMLString getValue(int i) const;
XMLString getValue(const XMLString& qname) const;
XMLString getValue(const XMLString& namespaceURI, const XMLString& localName) const;
XMLString getURI(int i) const;
const XMLString& getLocalName(int i) const;
const XMLString& getQName(int i) const;
const XMLString& getType(int i) const;
const XMLString& getType(const XMLString& qname) const;
const XMLString& getType(const XMLString& namespaceURI, const XMLString& localName) const;
const XMLString& getValue(int i) const;
const XMLString& getValue(const XMLString& qname) const;
const XMLString& getValue(const XMLString& namespaceURI, const XMLString& localName) const;
const XMLString& getURI(int i) const;
bool isSpecified(int i) const;
/// Returns true unless the attribute value was provided by DTD defaulting.
@ -122,6 +134,11 @@ public:
void addAttribute(const XMLChar* namespaceURI, const XMLChar* localName, const XMLChar* qname, const XMLChar* type, const XMLChar* value, bool specified);
/// Adds an attribute to the end of the list.
Attribute& addAttribute();
/// Add an (empty) attribute to the end of the list.
/// For internal use only.
/// The returned Attribute element must be filled by the caller.
void removeAttribute(int i);
/// Removes an attribute.
@ -133,6 +150,9 @@ public:
void clear();
/// Removes all attributes.
void reserve(std::size_t capacity);
/// Reserves capacity in the internal vector.
void setLocalName(int i, const XMLString& localName);
/// Sets the local name of an attribute.
@ -146,18 +166,6 @@ public:
void setURI(int i, const XMLString& namespaceURI);
/// Sets the namespace URI of an attribute.
struct Attribute
{
XMLString localName;
XMLString namespaceURI;
XMLString qname;
XMLString value;
XMLString type;
bool specified;
};
typedef std::vector<Attribute> AttributeVec;
typedef AttributeVec::const_iterator iterator;
iterator begin() const;
/// Iterator support.
@ -170,6 +178,7 @@ protected:
private:
AttributeVec _attributes;
Attribute _empty;
};
@ -188,6 +197,121 @@ inline AttributesImpl::iterator AttributesImpl::end() const
}
inline AttributesImpl::Attribute& AttributesImpl::addAttribute()
{
_attributes.push_back(_empty);
return _attributes.back();
}
inline int AttributesImpl::getLength() const
{
return (int) _attributes.size();
}
inline const XMLString& AttributesImpl::getLocalName(int i) const
{
poco_assert (i < _attributes.size());
return _attributes[i].localName;
}
inline const XMLString& AttributesImpl::getQName(int i) const
{
poco_assert (i < _attributes.size());
return _attributes[i].qname;
}
inline const XMLString& AttributesImpl::getType(int i) const
{
poco_assert (i < _attributes.size());
return _attributes[i].type;
}
inline const XMLString& AttributesImpl::getType(const XMLString& qname) const
{
Attribute* pAttr = find(qname);
if (pAttr)
return pAttr->type;
else
return _empty.type;
}
inline const XMLString& AttributesImpl::getType(const XMLString& namespaceURI, const XMLString& localName) const
{
Attribute* pAttr = find(namespaceURI, localName);
if (pAttr)
return pAttr->type;
else
return _empty.type;
}
inline const XMLString& AttributesImpl::getValue(int i) const
{
poco_assert (i < _attributes.size());
return _attributes[i].value;
}
inline const XMLString& AttributesImpl::getValue(const XMLString& qname) const
{
Attribute* pAttr = find(qname);
if (pAttr)
return pAttr->value;
else
return _empty.value;
}
inline const XMLString& AttributesImpl::getValue(const XMLString& namespaceURI, const XMLString& localName) const
{
Attribute* pAttr = find(namespaceURI, localName);
if (pAttr)
return pAttr->value;
else
return _empty.value;
}
inline const XMLString& AttributesImpl::getURI(int i) const
{
poco_assert (i < _attributes.size());
return _attributes[i].namespaceURI;
}
inline bool AttributesImpl::isSpecified(int i) const
{
poco_assert (i < _attributes.size());
return _attributes[i].specified;
}
inline bool AttributesImpl::isSpecified(const XMLString& qname) const
{
Attribute* pAttr = find(qname);
if (pAttr)
return pAttr->specified;
else
return false;
}
inline bool AttributesImpl::isSpecified(const XMLString& namespaceURI, const XMLString& localName) const
{
Attribute* pAttr = find(namespaceURI, localName);
if (pAttr)
return pAttr->specified;
else
return false;
}
} } // namespace Poco::XML

View File

@ -1,7 +1,7 @@
//
// ContentHandler.h
//
// $Id: //poco/1.3/XML/include/Poco/SAX/ContentHandler.h#1 $
// $Id: //poco/1.3/XML/include/Poco/SAX/ContentHandler.h#2 $
//
// Library: XML
// Package: SAX
@ -160,19 +160,20 @@ public:
/// The application must not attempt to read from the array outside of the specified
/// range.
///
/// Individual characters may consist of more than one Java char value. There
/// are two important cases where this happens, because characters can't be
/// Individual characters may consist of more than one XMLChar value. There
/// are three important cases where this happens, because characters can't be
/// represented in just sixteen bits. In one case, characters are represented
/// in a Surrogate Pair, using two special Unicode values. Such characters are
/// in the so-called "Astral Planes", with a code point above U+FFFF. A second
/// case involves composite characters, such as a base character combining with
/// one or more accent characters.
/// one or more accent characters. And most important, if XMLChar is a plain
/// char, characters are encoded in UTF-8.
///
/// Your code should not assume that algorithms using char-at-a-time idioms
/// will be working in character units; in some cases they will split characters.
/// This is relevant wherever XML permits arbitrary characters, such as attribute
/// values, processing instruction data, and comments as well as in data reported
/// from this method. It's also generally relevant whenever Java code manipulates
/// from this method. It's also generally relevant whenever C++ code manipulates
/// internationalized text; the issue isn't unique to XML.
///
/// Note that some parsers will report whitespace in element content using the

View File

@ -1,7 +1,7 @@
//
// SAXParser.h
//
// $Id: //poco/1.3/XML/include/Poco/SAX/SAXParser.h#1 $
// $Id: //poco/1.3/XML/include/Poco/SAX/SAXParser.h#2 $
//
// Library: XML
// Package: SAX
@ -98,6 +98,7 @@ public:
void* getProperty(const XMLString& propertyId) const;
void parse(InputSource* pSource);
void parse(const XMLString& systemId);
void parseMemoryNP(const char* xml, std::size_t size);
/// Extensions
void parseString(const std::string& xml);

Some files were not shown because too many files have changed in this diff Show More