mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-15 07:14:46 +02:00
latest changes from main repository
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ASCIIEncoding.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ASCIIEncoding.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ASCIIEncoding.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the ASCIIEncoding class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -53,11 +53,14 @@ class Foundation_API ASCIIEncoding: public TextEncoding
|
||||
public:
|
||||
ASCIIEncoding();
|
||||
~ASCIIEncoding();
|
||||
const char* canonicalName() const;
|
||||
bool isA(const std::string& encodingName) const;
|
||||
const CharacterMap& characterMap() const;
|
||||
int convert(const unsigned char* bytes) const;
|
||||
int convert(int ch, unsigned char* bytes, int length) const;
|
||||
|
||||
private:
|
||||
static const char* _names[];
|
||||
static const CharacterMap _charMap;
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Bugcheck.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Bugcheck.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Bugcheck.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -86,6 +86,9 @@ protected:
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
//
|
||||
// useful macros (these automatically supply line number and file name)
|
||||
//
|
||||
@@ -121,7 +124,42 @@ protected:
|
||||
Poco::Bugcheck::debugger(msg, __FILE__, __LINE__)
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
//
|
||||
// poco_static_assert
|
||||
//
|
||||
// The following was ported from <boost/static_assert.hpp>
|
||||
//
|
||||
|
||||
|
||||
template <bool x>
|
||||
struct POCO_STATIC_ASSERTION_FAILURE;
|
||||
|
||||
|
||||
template <>
|
||||
struct POCO_STATIC_ASSERTION_FAILURE<true>
|
||||
{
|
||||
enum
|
||||
{
|
||||
value = 1
|
||||
};
|
||||
};
|
||||
|
||||
|
||||
template <int x>
|
||||
struct poco_static_assert_test
|
||||
{
|
||||
};
|
||||
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
|
||||
#define poco_static_assert(B) \
|
||||
typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
|
||||
[POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>::value]
|
||||
#else
|
||||
#define poco_static_assert(B) \
|
||||
typedef poco_static_assert_test<sizeof(POCO_STATIC_ASSERTION_FAILURE<(bool) (B)>)> \
|
||||
POCO_JOIN(poco_static_assert_typedef_, __LINE__)
|
||||
#endif
|
||||
|
||||
|
||||
#endif // Foundation_Bugcheck_INCLUDED
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// ClassLibrary.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ClassLibrary.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ClassLibrary.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: SharedLibrary
|
||||
@@ -76,13 +76,13 @@ extern "C"
|
||||
//
|
||||
#define POCO_BEGIN_MANIFEST(base) \
|
||||
bool pocoBuildManifest(Poco::ManifestBase* pManifest_) \
|
||||
{ \
|
||||
typedef base _Base; \
|
||||
typedef Poco::Manifest<_Base> _Manifest; \
|
||||
std::string requiredType(typeid(_Manifest).name()); \
|
||||
std::string actualType(pManifest_->className()); \
|
||||
if (requiredType == actualType) \
|
||||
{ \
|
||||
{ \
|
||||
typedef base _Base; \
|
||||
typedef Poco::Manifest<_Base> _Manifest; \
|
||||
std::string requiredType(typeid(_Manifest).name()); \
|
||||
std::string actualType(pManifest_->className()); \
|
||||
if (requiredType == actualType) \
|
||||
{ \
|
||||
Poco::Manifest<_Base>* pManifest = static_cast<_Manifest*>(pManifest_);
|
||||
|
||||
|
||||
|
159
Foundation/include/Poco/Condition.h
Normal file
159
Foundation/include/Poco/Condition.h
Normal file
@@ -0,0 +1,159 @@
|
||||
//
|
||||
// Condition.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Condition.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
// Module: Condition
|
||||
//
|
||||
// Definition of the Condition class template.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_Condition_INCLUDED
|
||||
#define Foundation_Condition_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Mutex.h"
|
||||
#include "Poco/ScopedUnlock.h"
|
||||
#include "Poco/Event.h"
|
||||
#include "Poco/Exception.h"
|
||||
#include <deque>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class Foundation_API Condition
|
||||
/// A Condition is a synchronization object used to block a thread
|
||||
/// until a particular condition is met.
|
||||
/// A Condition object is always used in conjunction with
|
||||
/// a Mutex (or FastMutex) object.
|
||||
///
|
||||
/// Condition objects are similar to POSIX condition variables, which the
|
||||
/// difference that Condition is not subject to spurious wakeups.
|
||||
///
|
||||
/// Threads waiting on a Condition are resumed in FIFO order.
|
||||
{
|
||||
public:
|
||||
Condition();
|
||||
/// Creates the Condition.
|
||||
|
||||
~Condition();
|
||||
/// Destroys the Condition.
|
||||
|
||||
template <class Mtx>
|
||||
void wait(Mtx& mutex)
|
||||
/// Unlocks the mutex (which must be locked upon calling
|
||||
/// wait()) and waits until the Condition is signalled.
|
||||
///
|
||||
/// The given mutex will be locked again upon
|
||||
/// leaving the function, even in case of an exception.
|
||||
{
|
||||
ScopedUnlock<Mtx> unlock(mutex, false);
|
||||
Event event;
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
mutex.unlock();
|
||||
enqueue(event);
|
||||
}
|
||||
event.wait();
|
||||
}
|
||||
|
||||
template <class Mtx>
|
||||
void wait(Mtx& mutex, long milliseconds)
|
||||
/// Unlocks the mutex (which must be locked upon calling
|
||||
/// wait()) and waits for the given time until the Condition is signalled.
|
||||
///
|
||||
/// The given mutex will be locked again upon successfully leaving the
|
||||
/// function, even in case of an exception.
|
||||
///
|
||||
/// Throws a TimeoutException if the Condition is not signalled
|
||||
/// within the given time interval.
|
||||
{
|
||||
if (!tryWait(mutex, milliseconds))
|
||||
throw TimeoutException();
|
||||
}
|
||||
|
||||
template <class Mtx>
|
||||
bool tryWait(Mtx& mutex, long milliseconds)
|
||||
/// Unlocks the mutex (which must be locked upon calling
|
||||
/// tryWait()) and waits for the given time until the Condition is signalled.
|
||||
///
|
||||
/// The given mutex will be locked again upon leaving the
|
||||
/// function, even in case of an exception.
|
||||
///
|
||||
/// Returns true if the Condition has been signalled
|
||||
/// within the given time interval, otherwise false.
|
||||
{
|
||||
ScopedUnlock<Mtx> unlock(mutex, false);
|
||||
Event event;
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
mutex.unlock();
|
||||
enqueue(event);
|
||||
}
|
||||
if (!event.tryWait(milliseconds))
|
||||
{
|
||||
FastMutex::ScopedLock lock(_mutex);
|
||||
dequeue(event);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void signal();
|
||||
/// Signals the Condition and allows one waiting thread
|
||||
/// to continue execution.
|
||||
|
||||
void broadcast();
|
||||
/// Signals the Condition and allows all waiting
|
||||
/// threads to continue their execution.
|
||||
|
||||
protected:
|
||||
void enqueue(Event& event);
|
||||
void dequeue();
|
||||
void dequeue(Event& event);
|
||||
|
||||
private:
|
||||
Condition(const Condition&);
|
||||
Condition& operator = (const Condition&);
|
||||
|
||||
typedef std::deque<Event*> WaitQueue;
|
||||
|
||||
FastMutex _mutex;
|
||||
WaitQueue _waitQueue;
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_Condition_INCLUDED
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicAny.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAny.h#4 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Core
|
||||
@@ -61,7 +61,7 @@ class Foundation_API DynamicAny
|
||||
/// Precision loss, such as in conversion from floating-point types to integers or from double to float on platforms
|
||||
/// where they differ in size (provided internal actual value fits in float min/max range), is allowed.
|
||||
///
|
||||
/// String truncation is allowed - it is possible to convert between string and character when string length is
|
||||
/// String truncation is allowed -- it is possible to convert between string and character when string length is
|
||||
/// greater than 1. An empty string gets converted to the char '\0', a non-empty string is truncated to the first character.
|
||||
///
|
||||
/// Bolean conversion are performed as follows:
|
||||
@@ -99,23 +99,33 @@ public:
|
||||
|
||||
template <typename T>
|
||||
void convert(T& val) const
|
||||
/// Invoke this method to perform conversion.
|
||||
/// Invoke this method to perform a safe conversion.
|
||||
///
|
||||
/// Example usage:
|
||||
/// DynamicAny any("42");
|
||||
/// int i;
|
||||
/// any.convert(i);
|
||||
///
|
||||
/// Throws a RangeException if the value does not fit
|
||||
/// into the result variable.
|
||||
/// Throws a NotImplementedException if conversion is
|
||||
/// not available for the given type.
|
||||
{
|
||||
_pHolder->convert(val);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
T convert() const
|
||||
/// Invoke this method to perform conversion.
|
||||
/// Invoke this method to perform a safe conversion.
|
||||
///
|
||||
/// Example usage:
|
||||
/// DynamicAny any("42");
|
||||
/// int i = any.convert<int>();
|
||||
///
|
||||
/// Throws a RangeException if the value does not fit
|
||||
/// into the result variable.
|
||||
/// Throws a NotImplementedException if conversion is
|
||||
/// not available for the given type.
|
||||
{
|
||||
T result;
|
||||
_pHolder->convert(result);
|
||||
@@ -124,8 +134,13 @@ public:
|
||||
|
||||
template <typename T>
|
||||
operator T() const
|
||||
/// Conversion operator for implicit type
|
||||
/// Safe conversion operator for implicit type
|
||||
/// conversions.
|
||||
///
|
||||
/// Throws a RangeException if the value does not fit
|
||||
/// into the result variable.
|
||||
/// Throws a NotImplementedException if conversion is
|
||||
/// not available for the given type.
|
||||
{
|
||||
T result;
|
||||
_pHolder->convert(result);
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// DynamicAnyHolder.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAnyHolder.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/DynamicAnyHolder.h#3 $
|
||||
//
|
||||
// Library: Poco
|
||||
// Package: Core
|
||||
@@ -48,35 +48,6 @@
|
||||
#include <typeinfo>
|
||||
#include <limits>
|
||||
|
||||
///BEGIN ported from boost
|
||||
/// following macros were ported from boost to help the DynamicAnyHolder development
|
||||
/// for complete multi-platform code, see static_assert.hpp in boost libraries
|
||||
|
||||
// Helper macro POCO_JOIN:
|
||||
// The following piece of macro magic joins the two
|
||||
// arguments together, even when one of the arguments is
|
||||
// itself a macro (see 16.3.1 in C++ standard). The key
|
||||
// is that macro expansion of macro arguments does not
|
||||
// occur in POCO_DO_JOIN2 but does in POCO_DO_JOIN.
|
||||
//
|
||||
#define POCO_JOIN(X, Y) POCO_DO_JOIN( X, Y )
|
||||
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X,Y)
|
||||
#define POCO_DO_JOIN2(X, Y) X##Y
|
||||
|
||||
template <bool x> struct STATIC_ASSERTION_FAILURE;
|
||||
template <> struct STATIC_ASSERTION_FAILURE<true> { enum { value = 1 }; };
|
||||
template<int x> struct static_assert_test{};
|
||||
|
||||
#if defined(__GNUC__) && (__GNUC__ == 3) && ((__GNUC_MINOR__ == 3) || (__GNUC_MINOR__ == 4))
|
||||
# define poco_static_assert( B ) \
|
||||
typedef char POCO_JOIN(poco_static_assert_typedef_, __LINE__) \
|
||||
[ STATIC_ASSERTION_FAILURE< (bool)(B) >::value ]
|
||||
#else
|
||||
# define poco_static_assert(B) \
|
||||
typedef static_assert_test<sizeof(STATIC_ASSERTION_FAILURE<(bool)(B)>)> poco_static_assert_typedef_
|
||||
#endif
|
||||
///END ported from boost
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
@@ -203,7 +174,6 @@ private:
|
||||
if (from < std::numeric_limits<T>::min())
|
||||
throw RangeException("Value too small.");
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -326,7 +296,6 @@ class DynamicAnyHolderImpl: public DynamicAnyHolder
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <>
|
||||
class DynamicAnyHolderImpl<Int8>: public DynamicAnyHolder
|
||||
{
|
||||
@@ -419,7 +388,6 @@ private:
|
||||
};
|
||||
|
||||
|
||||
|
||||
template <>
|
||||
class DynamicAnyHolderImpl<Int16>: public DynamicAnyHolder
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Event.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Event.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Event.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -84,7 +84,7 @@ public:
|
||||
|
||||
void wait(long milliseconds);
|
||||
/// Waits for the event to become signalled.
|
||||
/// Throws a TimeOutException if the event
|
||||
/// Throws a TimeoutException if the event
|
||||
/// does not become signalled within the specified
|
||||
/// time interval.
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// File.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File.h#4 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/File.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@@ -164,12 +164,14 @@ public:
|
||||
/// Does nothing on Windows and OpenVMS.
|
||||
|
||||
void copyTo(const std::string& path) const;
|
||||
/// Copies the file to the given path. The target path
|
||||
/// can be a directory.
|
||||
/// Copies the file (or directory) to the given path.
|
||||
/// The target path can be a directory.
|
||||
///
|
||||
/// A directory is copied recursively.
|
||||
|
||||
void moveTo(const std::string& path);
|
||||
/// Copies the file to the given path and removes the
|
||||
/// original file. The target path can be a directory.
|
||||
/// Copies the file (or directory) to the given path and
|
||||
/// removes the original file. The target path can be a directory.
|
||||
|
||||
void renameTo(const std::string& path);
|
||||
/// Renames the file to the new name.
|
||||
@@ -212,6 +214,10 @@ public:
|
||||
static void handleLastError(const std::string& path);
|
||||
/// For internal use only. Throws an appropriate
|
||||
/// exception for the last file-related error.
|
||||
|
||||
protected:
|
||||
void copyDirectory(const std::string& path) const;
|
||||
/// Copies a directory. Used internally by copyTo().
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Foundation.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Foundation.h#6 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Foundation.h#7 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -93,6 +93,20 @@
|
||||
#endif
|
||||
|
||||
|
||||
//
|
||||
// POCO_JOIN
|
||||
//
|
||||
// The following piece of macro magic joins the two
|
||||
// arguments together, even when one of the arguments is
|
||||
// itself a macro (see 16.3.1 in C++ standard). The key
|
||||
// is that macro expansion of macro arguments does not
|
||||
// occur in POCO_DO_JOIN2 but does in POCO_DO_JOIN.
|
||||
//
|
||||
#define POCO_JOIN(X, Y) POCO_DO_JOIN( X, Y )
|
||||
#define POCO_DO_JOIN(X, Y) POCO_DO_JOIN2(X,Y)
|
||||
#define POCO_DO_JOIN2(X, Y) X##Y
|
||||
|
||||
|
||||
//
|
||||
// Pull in basic definitions
|
||||
//
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Latin1Encoding.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Latin1Encoding.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Latin1Encoding.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the Latin1Encoding class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -53,11 +53,14 @@ class Foundation_API Latin1Encoding: public TextEncoding
|
||||
public:
|
||||
Latin1Encoding();
|
||||
~Latin1Encoding();
|
||||
const char* canonicalName() const;
|
||||
bool isA(const std::string& encodingName) const;
|
||||
const CharacterMap& characterMap() const;
|
||||
int convert(const unsigned char* bytes) const;
|
||||
int convert(int ch, unsigned char* bytes, int length) const;
|
||||
|
||||
private:
|
||||
static const char* _names[];
|
||||
static const CharacterMap _charMap;
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Latin9Encoding.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Latin9Encoding.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Latin9Encoding.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the Latin9Encoding class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -56,11 +56,14 @@ class Foundation_API Latin9Encoding: public TextEncoding
|
||||
public:
|
||||
Latin9Encoding();
|
||||
~Latin9Encoding();
|
||||
const char* canonicalName() const;
|
||||
bool isA(const std::string& encodingName) const;
|
||||
const CharacterMap& characterMap() const;
|
||||
int convert(const unsigned char* bytes) const;
|
||||
int convert(int ch, unsigned char* bytes, int length) const;
|
||||
|
||||
private:
|
||||
static const char* _names[];
|
||||
static const CharacterMap _charMap;
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Path.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Path.h#5 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Path.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Filesystem
|
||||
@@ -96,6 +96,10 @@ public:
|
||||
/// Creates a path from a parent path and a filename.
|
||||
/// The parent path is expected to reference a directory.
|
||||
|
||||
Path(const Path& parent, const char* fileName);
|
||||
/// Creates a path from a parent path and a filename.
|
||||
/// The parent path is expected to reference a directory.
|
||||
|
||||
Path(const Path& parent, const Path& relative);
|
||||
/// Creates a path from a parent path and a relative path.
|
||||
/// The parent path is expected to reference a directory.
|
||||
|
79
Foundation/include/Poco/ScopedUnlock.h
Normal file
79
Foundation/include/Poco/ScopedUnlock.h
Normal file
@@ -0,0 +1,79 @@
|
||||
//
|
||||
// ScopedUnlock.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/ScopedUnlock.h#1 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
// Module: Mutex
|
||||
//
|
||||
// Definition of the ScopedUnlock template class.
|
||||
//
|
||||
// Copyright (c) 2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
// obtaining a copy of the software and accompanying documentation covered by
|
||||
// this license (the "Software") to use, reproduce, display, distribute,
|
||||
// execute, and transmit the Software, and to prepare derivative works of the
|
||||
// Software, and to permit third-parties to whom the Software is furnished to
|
||||
// do so, all subject to the following:
|
||||
//
|
||||
// The copyright notices in the Software and this entire statement, including
|
||||
// the above license grant, this restriction and the following disclaimer,
|
||||
// must be included in all copies of the Software, in whole or in part, and
|
||||
// all derivative works of the Software, unless such copies or derivative
|
||||
// works are solely in the form of machine-executable object code generated by
|
||||
// a source language processor.
|
||||
//
|
||||
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
// DEALINGS IN THE SOFTWARE.
|
||||
//
|
||||
|
||||
|
||||
#ifndef Foundation_ScopedUnlock_INCLUDED
|
||||
#define Foundation_ScopedUnlock_INCLUDED
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
template <class M>
|
||||
class ScopedUnlock
|
||||
/// A class that simplifies thread synchronization
|
||||
/// with a mutex.
|
||||
/// The constructor accepts a Mutex and unlocks it.
|
||||
/// The destructor unlocks the mutex.
|
||||
{
|
||||
public:
|
||||
inline ScopedUnlock(M& mutex, bool unlockNow = true): _mutex(mutex)
|
||||
{
|
||||
if (unlockNow)
|
||||
_mutex.unlock();
|
||||
}
|
||||
inline ~ScopedUnlock()
|
||||
{
|
||||
_mutex.lock();
|
||||
}
|
||||
|
||||
private:
|
||||
M& _mutex;
|
||||
|
||||
ScopedUnlock();
|
||||
ScopedUnlock(const ScopedUnlock&);
|
||||
ScopedUnlock& operator = (const ScopedUnlock&);
|
||||
};
|
||||
|
||||
|
||||
} // namespace Poco
|
||||
|
||||
|
||||
#endif // Foundation_ScopedUnlock_INCLUDED
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Semaphore.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Semaphore.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Semaphore.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -100,7 +100,7 @@ public:
|
||||
/// Waits for the semaphore to become signalled.
|
||||
/// To become signalled, a semaphore's value must
|
||||
/// be greater than zero.
|
||||
/// Throws a TimeOutException if the semaphore
|
||||
/// Throws a TimeoutException if the semaphore
|
||||
/// does not become signalled within the specified
|
||||
/// time interval.
|
||||
/// Decrements the semaphore's value by one
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// String.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/String.h#5 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/String.h#6 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Core
|
||||
@@ -475,7 +475,7 @@ S& replaceInPlace(S& str, const typename S::value_type* from, const typename S::
|
||||
|
||||
S result;
|
||||
typename S::size_type pos = 0;
|
||||
typename S::size_type fromLen = strlen(from);
|
||||
typename S::size_type fromLen = std::strlen(from);
|
||||
result.append(str, 0, start);
|
||||
do
|
||||
{
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// SynchronizedObject.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SynchronizedObject.h#3 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/SynchronizedObject.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -86,7 +86,7 @@ public:
|
||||
|
||||
void wait(long milliseconds) const;
|
||||
/// Waits for the object to become signalled.
|
||||
/// Throws a TimeOutException if the object
|
||||
/// Throws a TimeoutException if the object
|
||||
/// does not become signalled within the specified
|
||||
/// time interval.
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// TextEncoding.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/TextEncoding.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/TextEncoding.h#4 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the abstract TextEncoding class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -41,19 +41,30 @@
|
||||
|
||||
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/SharedPtr.h"
|
||||
|
||||
|
||||
namespace Poco {
|
||||
|
||||
|
||||
class TextEncodingManager;
|
||||
|
||||
|
||||
class Foundation_API TextEncoding
|
||||
/// An abstract base class for implementing text encodings
|
||||
/// like UTF-8 or ISO 8859-1.
|
||||
///
|
||||
/// Subclasses must override the characterMap() and convert()
|
||||
/// methods.
|
||||
/// Subclasses must override the canonicalName(), isA(),
|
||||
/// characterMap() and convert() methods and need to be
|
||||
/// thread safe and stateless.
|
||||
///
|
||||
/// TextEncoding also provides static member functions
|
||||
/// for managing mappings from encoding names to
|
||||
/// TextEncoding objects.
|
||||
{
|
||||
public:
|
||||
typedef SharedPtr<TextEncoding> Ptr;
|
||||
|
||||
enum
|
||||
{
|
||||
MAX_SEQUENCE_LENGTH = 6 /// The maximum character byte sequence length supported.
|
||||
@@ -70,6 +81,17 @@ public:
|
||||
|
||||
virtual ~TextEncoding();
|
||||
/// Destroys the encoding.
|
||||
|
||||
virtual const char* canonicalName() const = 0;
|
||||
/// Returns the canonical name of this encoding,
|
||||
/// e.g. "ISO-8859-1". Encoding name comparisons are case
|
||||
/// insensitive.
|
||||
|
||||
virtual bool isA(const std::string& encodingName) const = 0;
|
||||
/// Returns true if the given name is one of the names of this encoding.
|
||||
/// For example, the "ISO-8859-1" encoding is also known as "Latin-1".
|
||||
///
|
||||
/// Encoding name comparision are be case insensitive.
|
||||
|
||||
virtual const CharacterMap& characterMap() const = 0;
|
||||
/// Returns the CharacterMap for the encoding.
|
||||
@@ -97,6 +119,49 @@ public:
|
||||
/// If the character cannot be converted, 0 is returned and
|
||||
/// the byte sequence remains unchanged.
|
||||
/// The default implementation simply returns 0.
|
||||
|
||||
static TextEncoding& byName(const std::string& encodingName);
|
||||
/// Returns the TextEncoding object for the given encoding name.
|
||||
///
|
||||
/// Throws a NotFoundException if the encoding with given name is not available.
|
||||
|
||||
static TextEncoding::Ptr find(const std::string& encodingName);
|
||||
/// Returns a pointer to the TextEncoding object for the given encodingName,
|
||||
/// or NULL if no such TextEncoding object exists.
|
||||
|
||||
static void add(TextEncoding::Ptr encoding);
|
||||
/// Adds the given TextEncoding to the table of text encodings,
|
||||
/// under the encoding's canonical name.
|
||||
///
|
||||
/// If an encoding with the given name is already registered,
|
||||
/// it is replaced.
|
||||
|
||||
static void add(TextEncoding::Ptr encoding, const std::string& name);
|
||||
/// Adds the given TextEncoding to the table of text encodings,
|
||||
/// under the given name.
|
||||
///
|
||||
/// If an encoding with the given name is already registered,
|
||||
/// it is replaced.
|
||||
|
||||
static void remove(const std::string& encodingName);
|
||||
/// Removes the encoding with the given name from the table
|
||||
/// of text encodings.
|
||||
|
||||
static TextEncoding::Ptr global(TextEncoding::Ptr encoding);
|
||||
/// Sets global TextEncoding object.
|
||||
///
|
||||
/// This function sets the global encoding to the argument and returns a
|
||||
/// reference of the previous global encoding.
|
||||
|
||||
static TextEncoding& global();
|
||||
/// Return the current global TextEncoding object
|
||||
|
||||
static const std::string GLOBAL;
|
||||
/// Name of the global TextEncoding, which is the empty string.
|
||||
|
||||
protected:
|
||||
static TextEncodingManager& manager();
|
||||
/// Returns the TextEncodingManager.
|
||||
};
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Thread.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -107,6 +107,16 @@ public:
|
||||
/// Waits until the thread completes execution.
|
||||
/// If multiple threads try to join the same
|
||||
/// thread, the result is undefined.
|
||||
|
||||
void join(long milliseconds);
|
||||
/// Waits for at most the given interval for the thread
|
||||
/// to complete. Throws a TimeoutException if the thread
|
||||
/// does not complete within the specified time interval.
|
||||
|
||||
bool tryJoin(long milliseconds);
|
||||
/// Waits for at most the given interval for the thread
|
||||
/// to complete. Returns true if the thread has finished,
|
||||
/// false otherwise.
|
||||
|
||||
bool isRunning() const;
|
||||
/// Returns true if the thread is running.
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Thread_POSIX.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread_POSIX.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread_POSIX.h#5 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the ThreadImpl class for POSIX Threads.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -43,6 +43,9 @@
|
||||
#include "Poco/Foundation.h"
|
||||
#include "Poco/Runnable.h"
|
||||
#include "Poco/SignalHandler.h"
|
||||
#include "Poco/Event.h"
|
||||
#include "Poco/RefCountedObject.h"
|
||||
#include "Poco/AutoPtr.h"
|
||||
#include <pthread.h>
|
||||
#if !defined(POCO_NO_SYS_SELECT_H)
|
||||
#include <sys/select.h>
|
||||
@@ -74,6 +77,7 @@ public:
|
||||
void startImpl(Runnable& target);
|
||||
|
||||
void joinImpl();
|
||||
bool joinImpl(long milliseconds);
|
||||
bool isRunningImpl() const;
|
||||
static void sleepImpl(long milliseconds);
|
||||
static void yieldImpl();
|
||||
@@ -84,9 +88,23 @@ protected:
|
||||
static int mapPrio(int prio);
|
||||
|
||||
private:
|
||||
Runnable* _pTarget;
|
||||
pthread_t _thread;
|
||||
int _prio;
|
||||
struct ThreadData: public RefCountedObject
|
||||
{
|
||||
ThreadData():
|
||||
pTarget(0),
|
||||
thread(0),
|
||||
prio(PRIO_NORMAL_IMPL),
|
||||
done(false)
|
||||
{
|
||||
}
|
||||
|
||||
Runnable* pTarget;
|
||||
pthread_t thread;
|
||||
int prio;
|
||||
Event done;
|
||||
};
|
||||
|
||||
AutoPtr<ThreadData> _pData;
|
||||
|
||||
static pthread_key_t _currentKey;
|
||||
static bool _haveCurrentKey;
|
||||
@@ -103,7 +121,7 @@ private:
|
||||
//
|
||||
inline int ThreadImpl::getPriorityImpl() const
|
||||
{
|
||||
return _prio;
|
||||
return _pData->prio;
|
||||
}
|
||||
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Thread_WIN32.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread_WIN32.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Thread_WIN32.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Threading
|
||||
@@ -68,6 +68,7 @@ public:
|
||||
void startImpl(Runnable& target);
|
||||
|
||||
void joinImpl();
|
||||
bool joinImpl(long milliseconds);
|
||||
bool isRunningImpl() const;
|
||||
static void sleepImpl(long milliseconds);
|
||||
static void yieldImpl();
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// UTF16Encoding.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UTF16Encoding.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UTF16Encoding.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the UTF16Encoding class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -86,12 +86,15 @@ public:
|
||||
/// byte order mark, which is the Unicode
|
||||
/// character 0xFEFF.
|
||||
|
||||
const char* canonicalName() const;
|
||||
bool isA(const std::string& encodingName) const;
|
||||
const CharacterMap& characterMap() const;
|
||||
int convert(const unsigned char* bytes) const;
|
||||
int convert(int ch, unsigned char* bytes, int length) const;
|
||||
|
||||
private:
|
||||
bool _flipBytes;
|
||||
static const char* _names[];
|
||||
static const CharacterMap _charMap;
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// UTF8Encoding.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UTF8Encoding.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/UTF8Encoding.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the UTF8Encoding class.
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2004-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -53,11 +53,14 @@ class Foundation_API UTF8Encoding: public TextEncoding
|
||||
public:
|
||||
UTF8Encoding();
|
||||
~UTF8Encoding();
|
||||
const char* canonicalName() const;
|
||||
bool isA(const std::string& encodingName) const;
|
||||
const CharacterMap& characterMap() const;
|
||||
int convert(const unsigned char* bytes) const;
|
||||
int convert(int ch, unsigned char* bytes, int length) const;
|
||||
|
||||
private:
|
||||
static const char* _names[];
|
||||
static const CharacterMap _charMap;
|
||||
};
|
||||
|
||||
|
@@ -1,7 +1,7 @@
|
||||
//
|
||||
// Windows1252Encoding.h
|
||||
//
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Windows1252Encoding.h#2 $
|
||||
// $Id: //poco/Main/Foundation/include/Poco/Windows1252Encoding.h#3 $
|
||||
//
|
||||
// Library: Foundation
|
||||
// Package: Text
|
||||
@@ -9,7 +9,7 @@
|
||||
//
|
||||
// Definition of the Windows1252Encoding class.
|
||||
//
|
||||
// Copyright (c) 2005-2006, Applied Informatics Software Engineering GmbH.
|
||||
// Copyright (c) 2005-2007, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// Permission is hereby granted, free of charge, to any person or organization
|
||||
@@ -53,11 +53,14 @@ class Foundation_API Windows1252Encoding: public TextEncoding
|
||||
public:
|
||||
Windows1252Encoding();
|
||||
~Windows1252Encoding();
|
||||
const char* canonicalName() const;
|
||||
bool isA(const std::string& encodingName) const;
|
||||
const CharacterMap& characterMap() const;
|
||||
int convert(const unsigned char* bytes) const;
|
||||
int convert(int ch, unsigned char* bytes, int length) const;
|
||||
|
||||
private:
|
||||
static const char* _names[];
|
||||
static const CharacterMap _charMap;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user