sources for 1.3

This commit is contained in:
Guenter Obiltschnig
2006-11-17 16:21:51 +00:00
parent 7ff71d107f
commit 768642ae98
744 changed files with 6781 additions and 1036 deletions

View File

@@ -302,9 +302,6 @@
Name="VCCLCompilerTool"/> Name="VCCLCompilerTool"/>
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\src\HashStatistic.cpp">
</File>
<File <File
RelativePath=".\src\MemoryPool.cpp"> RelativePath=".\src\MemoryPool.cpp">
</File> </File>
@@ -402,18 +399,15 @@
<File <File
RelativePath=".\include\Poco\FPEnvironment_WIN32.h"> RelativePath=".\include\Poco\FPEnvironment_WIN32.h">
</File> </File>
<File
RelativePath=".\include\Poco\HashFunction.h">
</File>
<File
RelativePath=".\include\Poco\HashTable.h">
</File>
<File <File
RelativePath=".\include\Poco\Instantiator.h"> RelativePath=".\include\Poco\Instantiator.h">
</File> </File>
<File <File
RelativePath=".\include\Poco\MemoryPool.h"> RelativePath=".\include\Poco\MemoryPool.h">
</File> </File>
<File
RelativePath=".\include\Poco\MetaProgramming.h">
</File>
<File <File
RelativePath=".\include\Poco\NestedDiagnosticContext.h"> RelativePath=".\include\Poco\NestedDiagnosticContext.h">
</File> </File>
@@ -444,9 +438,6 @@
<File <File
RelativePath=".\include\Poco\SharedPtr.h"> RelativePath=".\include\Poco\SharedPtr.h">
</File> </File>
<File
RelativePath=".\include\Poco\SimpleHashTable.h">
</File>
<File <File
RelativePath=".\include\Poco\SingletonHolder.h"> RelativePath=".\include\Poco\SingletonHolder.h">
</File> </File>
@@ -456,6 +447,12 @@
<File <File
RelativePath=".\include\Poco\StringTokenizer.h"> RelativePath=".\include\Poco\StringTokenizer.h">
</File> </File>
<File
RelativePath=".\include\Poco\Tuple.h">
</File>
<File
RelativePath=".\include\Poco\TypeList.h">
</File>
<File <File
RelativePath=".\include\Poco\Types.h"> RelativePath=".\include\Poco\Types.h">
</File> </File>
@@ -1453,6 +1450,9 @@
<Filter <Filter
Name="Source Files" Name="Source Files"
Filter=""> Filter="">
<File
RelativePath=".\src\AbstractObserver.cpp">
</File>
<File <File
RelativePath=".\src\Notification.cpp"> RelativePath=".\src\Notification.cpp">
</File> </File>
@@ -1462,13 +1462,16 @@
<File <File
RelativePath=".\src\NotificationQueue.cpp"> RelativePath=".\src\NotificationQueue.cpp">
</File> </File>
<File
RelativePath=".\src\AbstractObserver.cpp">
</File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
Filter=""> Filter="">
<File
RelativePath=".\include\Poco\AbstractObserver.h">
</File>
<File
RelativePath=".\include\Poco\NObserver.h">
</File>
<File <File
RelativePath=".\include\Poco\Notification.h"> RelativePath=".\include\Poco\Notification.h">
</File> </File>
@@ -1478,15 +1481,9 @@
<File <File
RelativePath=".\include\Poco\NotificationQueue.h"> RelativePath=".\include\Poco\NotificationQueue.h">
</File> </File>
<File
RelativePath=".\include\Poco\AbstractObserver.h">
</File>
<File <File
RelativePath=".\include\Poco\Observer.h"> RelativePath=".\include\Poco\Observer.h">
</File> </File>
<File
RelativePath=".\include\Poco\NObserver.h">
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
@@ -2405,6 +2402,9 @@
<File <File
RelativePath=".\include\Poco\AbstractStrategy.h"> RelativePath=".\include\Poco\AbstractStrategy.h">
</File> </File>
<File
RelativePath=".\include\Poco\ExpirationDecorator.h">
</File>
<File <File
RelativePath=".\include\Poco\ExpireCache.h"> RelativePath=".\include\Poco\ExpireCache.h">
</File> </File>
@@ -2426,11 +2426,62 @@
<File <File
RelativePath=".\include\Poco\StrategyCollection.h"> RelativePath=".\include\Poco\StrategyCollection.h">
</File> </File>
<File
RelativePath=".\include\Poco\UniqueExpireCache.h">
</File>
<File
RelativePath=".\include\Poco\UniqueExpireLRUCache.h">
</File>
<File
RelativePath=".\include\Poco\UniqueExpireStrategy.h">
</File>
<File <File
RelativePath=".\include\Poco\ValidArgs.h"> RelativePath=".\include\Poco\ValidArgs.h">
</File> </File>
</Filter> </Filter>
</Filter> </Filter>
<Filter
Name="Hashing"
Filter="">
<Filter
Name="Header Files"
Filter="">
<File
RelativePath=".\include\Poco\Hash.h">
</File>
<File
RelativePath=".\include\Poco\HashFunction.h">
</File>
<File
RelativePath=".\include\Poco\HashMap.h">
</File>
<File
RelativePath=".\include\Poco\HashSet.h">
</File>
<File
RelativePath=".\include\Poco\HashStatistic.h">
</File>
<File
RelativePath=".\include\Poco\HashTable.h">
</File>
<File
RelativePath=".\include\Poco\LinearHashTable.h">
</File>
<File
RelativePath=".\include\Poco\SimpleHashTable.h">
</File>
</Filter>
<Filter
Name="Source Files"
Filter="">
<File
RelativePath=".\src\Hash.cpp">
</File>
<File
RelativePath=".\src\HashStatistic.cpp">
</File>
</Filter>
</Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>

View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="Windows-1252"?> <?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject <VisualStudioProject
ProjectType="Visual C++" ProjectType="Visual C++"
Version="8.00" Version="8,00"
Name="Foundation" Name="Foundation"
ProjectGUID="{8164D41D-B053-405B-826C-CF37AC0EF176}" ProjectGUID="{8164D41D-B053-405B-826C-CF37AC0EF176}"
RootNamespace="Foundation" RootNamespace="Foundation"
@@ -417,10 +417,6 @@
/> />
</FileConfiguration> </FileConfiguration>
</File> </File>
<File
RelativePath=".\src\HashStatistic.cpp"
>
</File>
<File <File
RelativePath=".\src\MemoryPool.cpp" RelativePath=".\src\MemoryPool.cpp"
> >
@@ -549,18 +545,6 @@
RelativePath=".\include\Poco\FPEnvironment_WIN32.h" RelativePath=".\include\Poco\FPEnvironment_WIN32.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\HashFunction.h"
>
</File>
<File
RelativePath=".\include\Poco\HashStatistic.h"
>
</File>
<File
RelativePath=".\include\Poco\HashTable.h"
>
</File>
<File <File
RelativePath=".\include\Poco\Instantiator.h" RelativePath=".\include\Poco\Instantiator.h"
> >
@@ -569,6 +553,10 @@
RelativePath=".\include\Poco\MemoryPool.h" RelativePath=".\include\Poco\MemoryPool.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\MetaProgramming.h"
>
</File>
<File <File
RelativePath=".\include\Poco\NestedDiagnosticContext.h" RelativePath=".\include\Poco\NestedDiagnosticContext.h"
> >
@@ -609,10 +597,6 @@
RelativePath=".\include\Poco\SharedPtr.h" RelativePath=".\include\Poco\SharedPtr.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\SimpleHashTable.h"
>
</File>
<File <File
RelativePath=".\include\Poco\SingletonHolder.h" RelativePath=".\include\Poco\SingletonHolder.h"
> >
@@ -625,6 +609,14 @@
RelativePath=".\include\Poco\StringTokenizer.h" RelativePath=".\include\Poco\StringTokenizer.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\Tuple.h"
>
</File>
<File
RelativePath=".\include\Poco\TypeList.h"
>
</File>
<File <File
RelativePath=".\include\Poco\Types.h" RelativePath=".\include\Poco\Types.h"
> >
@@ -1919,6 +1911,10 @@
<Filter <Filter
Name="Source Files" Name="Source Files"
> >
<File
RelativePath=".\src\AbstractObserver.cpp"
>
</File>
<File <File
RelativePath=".\src\Notification.cpp" RelativePath=".\src\Notification.cpp"
> >
@@ -1931,14 +1927,18 @@
RelativePath=".\src\NotificationQueue.cpp" RelativePath=".\src\NotificationQueue.cpp"
> >
</File> </File>
<File
RelativePath=".\src\AbstractObserver.cpp"
>
</File>
</Filter> </Filter>
<Filter <Filter
Name="Header Files" Name="Header Files"
> >
<File
RelativePath=".\include\Poco\AbstractObserver.h"
>
</File>
<File
RelativePath=".\include\Poco\NObserver.h"
>
</File>
<File <File
RelativePath=".\include\Poco\Notification.h" RelativePath=".\include\Poco\Notification.h"
> >
@@ -1951,18 +1951,10 @@
RelativePath=".\include\Poco\NotificationQueue.h" RelativePath=".\include\Poco\NotificationQueue.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\AbstractObserver.h"
>
</File>
<File <File
RelativePath=".\include\Poco\Observer.h" RelativePath=".\include\Poco\Observer.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\NObserver.h"
>
</File>
</Filter> </Filter>
</Filter> </Filter>
<Filter <Filter
@@ -3147,6 +3139,10 @@
RelativePath=".\include\Poco\AbstractStrategy.h" RelativePath=".\include\Poco\AbstractStrategy.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\ExpirationDecorator.h"
>
</File>
<File <File
RelativePath=".\include\Poco\ExpireCache.h" RelativePath=".\include\Poco\ExpireCache.h"
> >
@@ -3175,6 +3171,18 @@
RelativePath=".\include\Poco\StrategyCollection.h" RelativePath=".\include\Poco\StrategyCollection.h"
> >
</File> </File>
<File
RelativePath=".\include\Poco\UniqueExpireCache.h"
>
</File>
<File
RelativePath=".\include\Poco\UniqueExpireLRUCache.h"
>
</File>
<File
RelativePath=".\include\Poco\UniqueExpireStrategy.h"
>
</File>
<File <File
RelativePath=".\include\Poco\ValidArgs.h" RelativePath=".\include\Poco\ValidArgs.h"
> >
@@ -3185,6 +3193,58 @@
> >
</Filter> </Filter>
</Filter> </Filter>
<Filter
Name="Hashing"
>
<Filter
Name="Header Files"
>
<File
RelativePath=".\include\Poco\Hash.h"
>
</File>
<File
RelativePath=".\include\Poco\HashFunction.h"
>
</File>
<File
RelativePath=".\include\Poco\HashMap.h"
>
</File>
<File
RelativePath=".\include\Poco\HashSet.h"
>
</File>
<File
RelativePath=".\include\Poco\HashStatistic.h"
>
</File>
<File
RelativePath=".\include\Poco\HashTable.h"
>
</File>
<File
RelativePath=".\include\Poco\LinearHashTable.h"
>
</File>
<File
RelativePath=".\include\Poco\SimpleHashTable.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
>
<File
RelativePath=".\src\Hash.cpp"
>
</File>
<File
RelativePath=".\src\HashStatistic.cpp"
>
</File>
</Filter>
</Filter>
</Files> </Files>
<Globals> <Globals>
</Globals> </Globals>

View File

@@ -1,7 +1,7 @@
# #
# Makefile # Makefile
# #
# $Id: //poco/1.2/Foundation/Makefile#2 $ # $Id: //poco/1.3/Foundation/Makefile#1 $
# #
# Makefile for Poco Foundation # Makefile for Poco Foundation
# #
@@ -24,7 +24,7 @@ objects = ArchiveStrategy ASCIIEncoding AsyncChannel Base64Decoder Base64Encoder
SHA1Engine Semaphore SharedLibrary SimpleFileChannel \ SHA1Engine Semaphore SharedLibrary SimpleFileChannel \
SignalHandler SplitterChannel Stopwatch StreamChannel StreamConverter StreamCopier \ SignalHandler SplitterChannel Stopwatch StreamChannel StreamConverter StreamCopier \
StreamTokenizer String StringTokenizer SynchronizedObject SyslogChannel \ StreamTokenizer String StringTokenizer SynchronizedObject SyslogChannel \
Task TaskManager TaskNotification TeeStream HashStatistic\ Task TaskManager TaskNotification TeeStream Hash HashStatistic \
TemporaryFile TextConverter TextEncoding TextIterator Thread ThreadLocal \ TemporaryFile TextConverter TextEncoding TextIterator Thread ThreadLocal \
ThreadPool ActiveDispatcher Timer Timespan Timestamp Timezone Token URI \ ThreadPool ActiveDispatcher Timer Timespan Timestamp Timezone Token URI \
FileStreamFactory URIStreamFactory URIStreamOpener UTF16Encoding Windows1252Encoding \ FileStreamFactory URIStreamFactory URIStreamOpener UTF16Encoding Windows1252Encoding \

View File

@@ -1,7 +1,7 @@
// //
// ASCIIEncoding.h // ASCIIEncoding.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ASCIIEncoding.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ASCIIEncoding.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Text // Package: Text

View File

@@ -1,7 +1,7 @@
// //
// AbstractCache.h // AbstractCache.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AbstractCache.h#4 $ // $Id: //poco/1.3/Foundation/include/Poco/AbstractCache.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache
@@ -44,7 +44,7 @@
#include "Poco/ValidArgs.h" #include "Poco/ValidArgs.h"
#include "Poco/Mutex.h" #include "Poco/Mutex.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include "Poco/BasicEvent.h" #include "Poco/FIFOEvent.h"
#include "Poco/EventArgs.h" #include "Poco/EventArgs.h"
#include "Poco/Delegate.h" #include "Poco/Delegate.h"
#include "Poco/SharedPtr.h" #include "Poco/SharedPtr.h"
@@ -60,10 +60,10 @@ class AbstractCache
/// An AbstractCache is the interface of all caches. /// An AbstractCache is the interface of all caches.
{ {
public: public:
BasicEvent<const KeyValueArgs<TKey, TValue > > Add; FIFOEvent<const KeyValueArgs<TKey, TValue > > Add;
BasicEvent<const TKey> Remove; FIFOEvent<const TKey> Remove;
BasicEvent<const TKey> Get; FIFOEvent<const TKey> Get;
BasicEvent<const EventArgs> Clear; FIFOEvent<const EventArgs> Clear;
typedef std::map<TKey, SharedPtr<TValue > > DataHolder; typedef std::map<TKey, SharedPtr<TValue > > DataHolder;
typedef typename DataHolder::iterator Iterator; typedef typename DataHolder::iterator Iterator;
@@ -98,7 +98,8 @@ public:
/// the remove is ignored. /// the remove is ignored.
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
doRemove(key); Iterator it = _data.find(key);
doRemove(it);
} }
bool has(const TKey& key) const bool has(const TKey& key) const
@@ -124,10 +125,11 @@ public:
doClear(); doClear();
} }
std::size_t size() const std::size_t size()
/// Returns the number of cached elements /// Returns the number of cached elements
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
doReplace();
return _data.size(); return _data.size();
} }
@@ -142,10 +144,23 @@ public:
doReplace(); doReplace();
} }
std::set<TKey> getAllKeys()
/// Returns a copy of all keys stored in the cache
{
FastMutex::ScopedLock lock(_mutex);
doReplace();
ConstIterator it = _data.begin();
ConstIterator itEnd = _data.end();
std::set<TKey> result;
for (; it != itEnd; ++it)
result.insert(it->first);
return result;
}
protected: protected:
mutable BasicEvent<ValidArgs<TKey> > IsValid; mutable FIFOEvent<ValidArgs<TKey> > IsValid;
mutable BasicEvent<KeySet> Replace; mutable FIFOEvent<KeySet> Replace;
void initialize() void initialize()
/// Sets up event registration. /// Sets up event registration.
@@ -173,10 +188,8 @@ protected:
/// Adds the key value pair to the cache. /// Adds the key value pair to the cache.
/// If for the key already an entry exists, it will be overwritten. /// If for the key already an entry exists, it will be overwritten.
{ {
if (doHas(key)) Iterator it = _data.find(key);
{ doRemove(it);
doRemove(key);
}
KeyValueArgs<TKey, TValue> args(key, val); KeyValueArgs<TKey, TValue> args(key, val);
Add.notify(this, args); Add.notify(this, args);
@@ -185,12 +198,15 @@ protected:
doReplace(); doReplace();
} }
void doRemove(const TKey& key) void doRemove(Iterator it)
/// Removes an entry from the cache. If the entry is not found /// Removes an entry from the cache. If the entry is not found
/// the remove is ignored. /// the remove is ignored.
{ {
Remove.notify(this, key); if (it != _data.end())
_data.erase(key); {
Remove.notify(this, it->first);
_data.erase(it);
}
} }
bool doHas(const TKey& key) const bool doHas(const TKey& key) const
@@ -227,7 +243,7 @@ protected:
if (!args.isValid()) if (!args.isValid())
{ {
doRemove(key); doRemove(it);
} }
else else
{ {
@@ -255,7 +271,8 @@ protected:
for (; it != endIt; ++it) for (; it != endIt; ++it)
{ {
doRemove(*it); Iterator itH = _data.find(*it);
doRemove(itH);
} }
} }

View File

@@ -1,7 +1,7 @@
// //
// AbstractDelegate.h // AbstractDelegate.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AbstractDelegate.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/AbstractDelegate.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// AbstractEvent.h // AbstractEvent.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AbstractEvent.h#3 $ // $Id: //poco/1.3/Foundation/include/Poco/AbstractEvent.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events
@@ -76,12 +76,15 @@ class AbstractEvent
/// ... /// ...
/// }; /// };
/// ///
/// Throwing the event can be done either by the events notify or notifyAsync method: /// Throwing the event can be done either by the events notify() or notifyAsync() method:
///
///
/// Alternatively, instead of notify(), operator () can be used.
/// ///
/// void MyData::setAge(int i) /// void MyData::setAge(int i)
/// { /// {
/// this->_age = i; /// this->_age = i;
/// AgeChanged.notify(this, this->_age); /// AgeChanged(this, this->_age);
/// } /// }
/// ///
/// Note that notify and notifyAsync do not catch exceptions, i.e. in case a delegate /// Note that notify and notifyAsync do not catch exceptions, i.e. in case a delegate
@@ -171,6 +174,11 @@ public:
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
_strategy.remove(aDelegate); _strategy.remove(aDelegate);
} }
void operator () (const void* pSender, TArgs& args)
{
notify(pSender, args);
}
void notify(const void* pSender, TArgs& args) void notify(const void* pSender, TArgs& args)
/// Sends a notification to all registered delegates. The order is /// Sends a notification to all registered delegates. The order is

View File

@@ -1,7 +1,7 @@
// //
// AbstractObserver.h // AbstractObserver.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AbstractObserver.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/AbstractObserver.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Notifications // Package: Notifications

View File

@@ -1,7 +1,7 @@
// //
// AbstractPriorityDelegate.h // AbstractPriorityDelegate.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AbstractPriorityDelegate.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/AbstractPriorityDelegate.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// AbstractStrategy.h // AbstractStrategy.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AbstractStrategy.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/AbstractStrategy.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache

View File

@@ -1,7 +1,7 @@
// //
// ActiveDispatcher.h // ActiveDispatcher.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ActiveDispatcher.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ActiveDispatcher.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// ActiveMethod.h // ActiveMethod.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ActiveMethod.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ActiveMethod.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// ActiveResult.h // ActiveResult.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ActiveResult.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ActiveResult.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading
@@ -45,6 +45,7 @@
#include "Poco/Event.h" #include "Poco/Event.h"
#include "Poco/RefCountedObject.h" #include "Poco/RefCountedObject.h"
#include "Poco/Exception.h" #include "Poco/Exception.h"
#include <algorithm>
namespace Poco { namespace Poco {
@@ -60,16 +61,24 @@ class ActiveResultHolder: public RefCountedObject
{ {
public: public:
ActiveResultHolder(): ActiveResultHolder():
_pData(0),
_pExc(0), _pExc(0),
_event(false) _event(false)
/// Creates an ActiveResultHolder. /// Creates an ActiveResultHolder.
{ {
} }
ResultType& data() ResultType& data()
/// Returns a reference to the actual result. /// Returns a reference to the actual result.
{ {
return _data; poco_check_ptr(_pData);
return *_pData;
}
void data(ResultType* pData)
{
delete _pData;
_pData = pData;
} }
void wait() void wait()
@@ -142,13 +151,14 @@ public:
protected: protected:
~ActiveResultHolder() ~ActiveResultHolder()
{ {
delete _pData;
delete _pExc; delete _pExc;
} }
private: private:
ResultType _data; ResultType* _pData;
Exception* _pExc; Exception* _pExc;
Event _event; Event _event;
}; };
@@ -185,21 +195,28 @@ public:
ActiveResult& operator = (const ActiveResult& result) ActiveResult& operator = (const ActiveResult& result)
/// Assignment operator. /// Assignment operator.
{ {
if (&result != this) ActiveResult tmp(result);
{ swap(tmp);
_pHolder->release();
_pHolder = result._pHolder;
_pHolder->duplicate();
}
return *this; return *this;
} }
const ResultType& data() const void swap(const ActiveResult& result)
{
using std::swap;
swap(_pHolder, result._pHolder);
}
ResultType& data() const
/// Returns a reference to the result data. /// Returns a reference to the result data.
{ {
return _pHolder->data(); return _pHolder->data();
} }
void data(ResultType* pValue)
{
_pHolder->data(pValue);
}
void wait() void wait()
/// Pauses the caller until the result becomes available. /// Pauses the caller until the result becomes available.
{ {

View File

@@ -1,7 +1,7 @@
// //
// ActiveRunnable.h // ActiveRunnable.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ActiveRunnable.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ActiveRunnable.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading
@@ -71,7 +71,7 @@ public:
{ {
try try
{ {
_result.data() = (_pOwner->*_method)(_arg); _result.data(new ResultType((_pOwner->*_method)(_arg)));
} }
catch (Exception& e) catch (Exception& e)
{ {

View File

@@ -1,7 +1,7 @@
// //
// ActiveStarter.h // ActiveStarter.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ActiveStarter.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ActiveStarter.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// Activity.h // Activity.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Activity.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Activity.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// Any.h // Any.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Any.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Any.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// ArchiveStrategy.h // ArchiveStrategy.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ArchiveStrategy.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ArchiveStrategy.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// AsyncChannel.h // AsyncChannel.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AsyncChannel.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/AsyncChannel.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// AutoPtr.h // AutoPtr.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AutoPtr.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/AutoPtr.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@@ -111,8 +111,8 @@ public:
{ {
if (_ptr) _ptr->release(); if (_ptr) _ptr->release();
} }
AutoPtr& operator = (C* ptr) AutoPtr& assign(C* ptr)
{ {
if (_ptr != ptr) if (_ptr != ptr)
{ {
@@ -122,7 +122,18 @@ public:
return *this; return *this;
} }
AutoPtr& operator = (const AutoPtr& ptr) AutoPtr& assign(C* ptr, bool shared)
{
if (_ptr != ptr)
{
if (_ptr) _ptr->release();
_ptr = ptr;
if (shared && _ptr) _ptr->duplicate();
}
return *this;
}
AutoPtr& assign(const AutoPtr& ptr)
{ {
if (&ptr != this) if (&ptr != this)
{ {
@@ -133,13 +144,8 @@ public:
return *this; return *this;
} }
void swap(AutoPtr& ptr)
{
std::swap(_ptr, ptr._ptr);
}
template <class Other> template <class Other>
AutoPtr& operator = (const AutoPtr<Other>& ptr) AutoPtr& assign(const AutoPtr<Other>& ptr)
{ {
if (ptr.get() != _ptr) if (ptr.get() != _ptr)
{ {
@@ -150,8 +156,29 @@ public:
return *this; return *this;
} }
AutoPtr& operator = (C* ptr)
{
return assign(ptr);
}
AutoPtr& operator = (const AutoPtr& ptr)
{
return assign(ptr);
}
template <class Other> template <class Other>
AutoPtr<Other> cast() AutoPtr& operator = (const AutoPtr<Other>& ptr)
{
return assign<Other>(ptr);
}
void swap(AutoPtr& ptr)
{
std::swap(_ptr, ptr._ptr);
}
template <class Other>
AutoPtr<Other> cast() const
/// Casts the AutoPtr via a dynamic cast to the given type. /// Casts the AutoPtr via a dynamic cast to the given type.
/// Returns an AutoPtr containing NULL if the cast fails. /// Returns an AutoPtr containing NULL if the cast fails.
/// Example: (assume class Sub: public Super) /// Example: (assume class Sub: public Super)
@@ -159,10 +186,8 @@ public:
/// AutoPtr<Sub> sub = super.cast<Sub>(); /// AutoPtr<Sub> sub = super.cast<Sub>();
/// poco_assert (sub.get()); /// poco_assert (sub.get());
{ {
Other* pOther = dynamic_cast <Other*>(_ptr); Other* pOther = dynamic_cast<Other*>(_ptr);
if (pOther) return AutoPtr<Other>(pOther, true);
pOther->duplicate();
return AutoPtr<Other>(pOther);
} }
C* operator -> () C* operator -> ()
@@ -202,11 +227,11 @@ public:
return _ptr; return _ptr;
} }
bool isNull() const const C* get() const
{ {
return _ptr == 0; return _ptr;
} }
operator C* () operator C* ()
{ {
return _ptr; return _ptr;
@@ -216,12 +241,17 @@ public:
{ {
return _ptr; return _ptr;
} }
const C* get() const bool operator ! () const
{ {
return _ptr; return _ptr == 0;
} }
bool isNull() const
{
return _ptr == 0;
}
C* duplicate() C* duplicate()
{ {
if (_ptr) _ptr->duplicate(); if (_ptr) _ptr->duplicate();

View File

@@ -1,7 +1,7 @@
// //
// AutoReleasePool.h // AutoReleasePool.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/AutoReleasePool.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/AutoReleasePool.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Base64Decoder.h // Base64Decoder.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Base64Decoder.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Base64Decoder.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// Base64Encoder.h // Base64Encoder.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Base64Encoder.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Base64Encoder.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// BasicEvent.h // BasicEvent.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/BasicEvent.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/BasicEvent.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// BinaryReader.h // BinaryReader.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/BinaryReader.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/BinaryReader.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// BinaryWriter.h // BinaryWriter.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/BinaryWriter.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/BinaryWriter.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// Buffer.h // Buffer.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Buffer.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Buffer.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@@ -41,6 +41,7 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include <cstddef>
namespace Poco { namespace Poco {
@@ -56,7 +57,7 @@ class Buffer
/// is needed. /// is needed.
{ {
public: public:
Buffer(int size): Buffer(std::size_t size):
_size(size), _size(size),
_ptr(new T[size]) _ptr(new T[size])
/// Creates and allocates the Buffer. /// Creates and allocates the Buffer.
@@ -69,7 +70,7 @@ public:
delete [] _ptr; delete [] _ptr;
} }
int size() const std::size_t size() const
/// Returns the size of the buffer. /// Returns the size of the buffer.
{ {
return _size; return _size;
@@ -99,14 +100,14 @@ public:
return _ptr + _size; return _ptr + _size;
} }
T& operator [] (int index) T& operator [] (std::size_t index)
{ {
poco_assert (index >= 0 && index < _size); poco_assert (index >= 0 && index < _size);
return _ptr[index]; return _ptr[index];
} }
const T& operator [] (int index) const const T& operator [] (std::size_t index) const
{ {
poco_assert (index >= 0 && index < _size); poco_assert (index >= 0 && index < _size);
@@ -118,8 +119,8 @@ private:
Buffer(const Buffer&); Buffer(const Buffer&);
Buffer& operator = (const Buffer&); Buffer& operator = (const Buffer&);
int _size; std::size_t _size;
T* _ptr; T* _ptr;
}; };

View File

@@ -1,7 +1,7 @@
// //
// BufferAllocator.h // BufferAllocator.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/BufferAllocator.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/BufferAllocator.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// BufferedBidirectionalStreamBuf.h // BufferedBidirectionalStreamBuf.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/BufferedBidirectionalStreamBuf.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// BufferedStreamBuf.h // BufferedStreamBuf.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/BufferedStreamBuf.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/BufferedStreamBuf.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// Bugcheck.h // Bugcheck.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Bugcheck.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Bugcheck.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@@ -90,7 +90,8 @@ protected:
// useful macros (these automatically supply line number and file name) // useful macros (these automatically supply line number and file name)
// //
#if defined(_DEBUG) #if defined(_DEBUG)
#define poco_assert_dbg(cond) if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0 #define poco_assert_dbg(cond) \
if (!(cond)) Poco::Bugcheck::assertion(#cond, __FILE__, __LINE__); else (void) 0
#else #else
#define poco_assert_dbg(cond) #define poco_assert_dbg(cond)
#endif #endif

View File

@@ -1,7 +1,7 @@
// //
// ByteOrder.h // ByteOrder.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ByteOrder.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ByteOrder.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Channel.h // Channel.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Channel.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Channel.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// ClassLibrary.h // ClassLibrary.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ClassLibrary.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ClassLibrary.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: SharedLibrary // Package: SharedLibrary

View File

@@ -1,7 +1,7 @@
// //
// ClassLoader.h // ClassLoader.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ClassLoader.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ClassLoader.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: SharedLibrary // Package: SharedLibrary

View File

@@ -1,7 +1,7 @@
// //
// CompareFunctions.h // CompareFunctions.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/CompareFunctions.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/CompareFunctions.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// Config.h // Config.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Config.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/Config.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Configurable.h // Configurable.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Configurable.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/Configurable.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// ConsoleChannel.h // ConsoleChannel.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ConsoleChannel.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ConsoleChannel.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// CountingStream.h // CountingStream.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/CountingStream.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/CountingStream.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// DateTime.h // DateTime.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DateTime.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DateTime.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: DateTime // Package: DateTime

View File

@@ -1,7 +1,7 @@
// //
// DateTimeFormat.h // DateTimeFormat.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DateTimeFormat.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DateTimeFormat.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: DateTime // Package: DateTime

View File

@@ -1,7 +1,7 @@
// //
// DateTimeFormatter.h // DateTimeFormatter.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DateTimeFormatter.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DateTimeFormatter.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: DateTime // Package: DateTime

View File

@@ -1,7 +1,7 @@
// //
// DateTimeParser.h // DateTimeParser.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DateTimeParser.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DateTimeParser.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: DateTime // Package: DateTime

View File

@@ -1,7 +1,7 @@
// //
// Debugger.h // Debugger.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Debugger.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Debugger.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// DefaultStrategy.h // DefaultStrategy.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DefaultStrategy.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DefaultStrategy.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// DeflatingStream.h // DeflatingStream.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DeflatingStream.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DeflatingStream.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Streams // Package: Streams

View File

@@ -1,7 +1,7 @@
// //
// Delegate.h // Delegate.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Delegate.h#3 $ // $Id: //poco/1.3/Foundation/include/Poco/Delegate.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// DigestEngine.h // DigestEngine.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DigestEngine.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DigestEngine.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Crypt // Package: Crypt

View File

@@ -1,7 +1,7 @@
// //
// DigestStream.h // DigestStream.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DigestStream.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DigestStream.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Crypt // Package: Crypt

View File

@@ -1,7 +1,7 @@
// //
// DirectoryIterator.h // DirectoryIterator.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DirectoryIterator.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem
@@ -54,6 +54,14 @@ class DirectoryIteratorImpl;
class Foundation_API DirectoryIterator class Foundation_API DirectoryIterator
/// The DirectoryIterator class is used to enumerate /// The DirectoryIterator class is used to enumerate
/// all files in a directory. /// all files in a directory.
///
/// DirectoryIterator has some limitations:
/// * only forward iteration (++) is supported
/// * an iterator copied from another one will always
/// * point to the same file as the original iterator,
/// * even is the original iterator has been advanced
/// (all copies of an iterator share their state with
/// the original iterator)
{ {
public: public:
DirectoryIterator(); DirectoryIterator();

View File

@@ -1,7 +1,7 @@
// //
// DirectoryIterator_UNIX.h // DirectoryIterator_UNIX.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DirectoryIterator_UNIX.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_UNIX.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// DirectoryIterator_VMS.h // DirectoryIterator_VMS.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DirectoryIterator_VMS.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_VMS.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// DirectoryIterator_WIN32.h // DirectoryIterator_WIN32.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DirectoryIterator_WIN32.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_WIN32.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// DirectoryIterator_WIN32U.h // DirectoryIterator_WIN32U.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DirectoryIterator_WIN32U.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DirectoryIterator_WIN32U.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// DynamicFactory.h // DynamicFactory.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/DynamicFactory.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/DynamicFactory.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Environment.h // Environment.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Environment.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Environment.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@@ -56,6 +56,11 @@ public:
/// with the given name. Throws a NotFoundException /// with the given name. Throws a NotFoundException
/// if the variable does not exist. /// if the variable does not exist.
static std::string get(const std::string& name, const std::string& defaultValue);
/// Returns the value of the environment variable
/// with the given name. If the environment variable
/// is undefined, returns defaultValue instead.
static bool has(const std::string& name); static bool has(const std::string& name);
/// Returns true iff an environment variable /// Returns true iff an environment variable
/// with the given name is defined. /// with the given name is defined.

View File

@@ -1,7 +1,7 @@
// //
// Environment_UNIX.h // Environment_UNIX.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Environment_UNIX.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Environment_UNIX.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Environment_VMS.h // Environment_VMS.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Environment_VMS.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Environment_VMS.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Environment_WIN32.h // Environment_WIN32.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Environment_WIN32.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Environment_WIN32.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Environment_WIN32U.h // Environment_WIN32U.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Environment_WIN32U.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Environment_WIN32U.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// ErrorHandler.h // ErrorHandler.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ErrorHandler.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/ErrorHandler.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// Event.h // Event.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Event.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Event.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// EventArgs.h // EventArgs.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/EventArgs.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/EventArgs.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// EventLogChannel.h // EventLogChannel.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/EventLogChannel.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/EventLogChannel.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// Event_POSIX.h // Event_POSIX.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Event_POSIX.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Event_POSIX.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// Event_WIN32.h // Event_WIN32.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Event_WIN32.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Event_WIN32.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading

View File

@@ -1,7 +1,7 @@
// //
// Exception.h // Exception.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Exception.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Exception.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@@ -78,7 +78,9 @@ public:
/// Returns the name of the exception class. /// Returns the name of the exception class.
virtual const char* what() const throw(); virtual const char* what() const throw();
/// Returns the message text as a C string. /// Returns a static string describing the exception.
///
/// Same as name(), but for compatibility with std::exception.
const Exception* nested() const; const Exception* nested() const;
/// Returns a pointer to the nested exception, or /// Returns a pointer to the nested exception, or
@@ -136,19 +138,19 @@ inline const std::string& Exception::message() const
// are not allowed as template arguments. // are not allowed as template arguments.
// //
#define POCO_DECLARE_EXCEPTION(API, CLS, BASE) \ #define POCO_DECLARE_EXCEPTION(API, CLS, BASE) \
class API CLS: public BASE \ class API CLS: public BASE \
{ \ { \
public: \ public: \
CLS(); \ CLS(); \
CLS(const std::string& msg); \ CLS(const std::string& msg); \
CLS(const std::string& msg, const std::string& arg); \ CLS(const std::string& msg, const std::string& arg); \
CLS(const std::string& msg, const Poco::Exception& exc); \ CLS(const std::string& msg, const Poco::Exception& exc); \
CLS(const CLS& exc); \ CLS(const CLS& exc); \
~CLS() throw(); \ ~CLS() throw(); \
CLS& operator = (const CLS& exc); \ CLS& operator = (const CLS& exc); \
const char* name() const throw(); \ const char* name() const throw(); \
const char* className() const throw(); \ const char* className() const throw(); \
Poco::Exception* clone() const; \ Poco::Exception* clone() const; \
void rethrow() const; \ void rethrow() const; \
}; };
@@ -163,7 +165,7 @@ inline const std::string& Exception::message() const
CLS::CLS(const std::string& msg, const std::string& arg): BASE(msg, arg) \ 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 std::string& msg, const Poco::Exception& exc): BASE(msg, exc) \
{ \ { \
} \ } \
CLS::CLS(const CLS& exc): BASE(exc) \ CLS::CLS(const CLS& exc): BASE(exc) \
@@ -185,7 +187,7 @@ inline const std::string& Exception::message() const
{ \ { \
return typeid(*this).name(); \ return typeid(*this).name(); \
} \ } \
Poco::Exception* CLS::clone() const \ Poco::Exception* CLS::clone() const \
{ \ { \
return new CLS(*this); \ return new CLS(*this); \
} \ } \

View File

@@ -0,0 +1,113 @@
//
// ExpirationDecorator.h
//
// $Id: //poco/1.3/Foundation/include/Poco/ExpirationDecorator.h#1 $
//
// Library: Foundation
// Package: Events
// Module: ExpirationDecorator
//
// Implementation of the ExpirationDecorator template.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_ExpirationDecorator_INCLUDED
#define Foundation_ExpirationDecorator_INCLUDED
#include "Poco/Timestamp.h"
#include "Poco/Timespan.h"
namespace Poco {
template <typename TArgs>
class ExpirationDecorator
/// ExpirationDecorator adds an expiration method to values so that they can be used
/// with the UniqueExpireCache
{
public:
ExpirationDecorator():
_value(),
_expiresAt()
{
}
ExpirationDecorator(const TArgs& p, const Poco::Timespan::TimeDiff& diffInMs):
/// Creates an element that will expire in diff milliseconds
_value(p),
_expiresAt()
{
_expiresAt += (diffInMs*1000);
}
ExpirationDecorator(const TArgs& p, const Poco::Timespan& timeSpan):
/// Creates an element that will expire after the given timeSpan
_value(p),
_expiresAt()
{
_expiresAt += timeSpan.totalMicroseconds();
}
ExpirationDecorator(const TArgs& p, const Poco::Timestamp& timeStamp):
/// Creates an element that will expire at the given time point
_value(p),
_expiresAt(timeStamp)
{
}
~ExpirationDecorator()
{
}
const Poco::Timestamp& getExpiration() const
{
return _expiresAt;
}
const TArgs& value() const
{
return _value;
}
TArgs& value()
{
return _value;
}
private:
TArgs _value;
Timestamp _expiresAt;
};
} // namespace Poco
#endif

View File

@@ -1,7 +1,7 @@
// //
// Expire.h // Expire.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Expire.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/Expire.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// ExpireCache.h // ExpireCache.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ExpireCache.h#3 $ // $Id: //poco/1.3/Foundation/include/Poco/ExpireCache.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache

View File

@@ -1,7 +1,7 @@
// //
// ExpireLRUCache.h // ExpireLRUCache.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ExpireLRUCache.h#4 $ // $Id: //poco/1.3/Foundation/include/Poco/ExpireLRUCache.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache

View File

@@ -1,7 +1,7 @@
// //
// ExpireStrategy.h // ExpireStrategy.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ExpireStrategy.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/ExpireStrategy.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Cache // Package: Cache

View File

@@ -1,7 +1,7 @@
// //
// FIFOEvent.h // FIFOEvent.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FIFOEvent.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FIFOEvent.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// FIFOStrategy.h // FIFOStrategy.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FIFOStrategy.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FIFOStrategy.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Events // Package: Events

View File

@@ -1,7 +1,7 @@
// //
// FPEnvironment.h // FPEnvironment.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FPEnvironment.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// FPEnvironment_C99.h // FPEnvironment_C99.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FPEnvironment_C99.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_C99.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// FPEnvironment_DEC.h // FPEnvironment_DEC.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FPEnvironment_DEC.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_DEC.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// FPEnvironment_DUMMY.h // FPEnvironment_DUMMY.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FPEnvironment_DUMMY.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_DUMMY.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// FPEnvironment_SUN.h // FPEnvironment_SUN.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FPEnvironment_SUN.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_SUN.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// FPEnvironment_WIN32.h // FPEnvironment_WIN32.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FPEnvironment_WIN32.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FPEnvironment_WIN32.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// File.h // File.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/File.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/File.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// FileChannel.h // FileChannel.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FileChannel.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FileChannel.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// FileStreamFactory.h // FileStreamFactory.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FileStreamFactory.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/FileStreamFactory.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: URI // Package: URI

View File

@@ -1,7 +1,7 @@
// //
// File_UNIX.h // File_UNIX.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/File_UNIX.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/File_UNIX.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// File_VMS.h // File_VMS.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/File_VMS.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/File_VMS.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// File_WIN32.h // File_WIN32.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/File_WIN32.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/File_WIN32.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// File_WIN32U.h // File_WIN32U.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/File_WIN32U.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/File_WIN32U.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem

View File

@@ -1,7 +1,7 @@
// //
// Format.h // Format.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Format.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Format.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core

View File

@@ -1,7 +1,7 @@
// //
// Formatter.h // Formatter.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Formatter.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Formatter.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// FormattingChannel.h // FormattingChannel.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FormattingChannel.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/FormattingChannel.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging

View File

@@ -1,7 +1,7 @@
// //
// Foundation.h // Foundation.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Foundation.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/Foundation.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@@ -42,6 +42,12 @@
#define Foundation_Foundation_INCLUDED #define Foundation_Foundation_INCLUDED
//
// Include library configuration
//
#include "Poco/Config.h"
// //
// Ensure that POCO_DLL is default unless POCO_STATIC is defined // Ensure that POCO_DLL is default unless POCO_STATIC is defined
// //
@@ -74,12 +80,6 @@
#endif #endif
//
// Include library configuration
//
#include "Poco/Config.h"
// //
// Include platform-specific definitions // Include platform-specific definitions
// //

View File

@@ -1,7 +1,7 @@
// //
// Glob.h // Glob.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Glob.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/Glob.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Filesystem // Package: Filesystem
@@ -55,9 +55,9 @@ class Foundation_API Glob
/// as known from Unix shells. /// as known from Unix shells.
/// ///
/// In the pattern string, '*' matches any sequence of characters, /// In the pattern string, '*' matches any sequence of characters,
/// '?' matches any character, [SET] matches any character in the /// '?' matches any single character, [SET] matches any single character
/// specified set, [!SET] matches any character not in the specified /// in the specified set, [!SET] matches any character not in the
/// set. /// specified set.
/// ///
/// A set is composed of characters or ranges; a range looks like /// A set is composed of characters or ranges; a range looks like
/// character hyphen character (as in 0-9 or A-Z). /// character hyphen character (as in 0-9 or A-Z).

View File

@@ -1,7 +1,7 @@
// //
// HMACEngine.h // HMACEngine.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/HMACEngine.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/HMACEngine.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Crypt // Package: Crypt

View File

@@ -0,0 +1,127 @@
//
// Hash.h
//
// $Id: //poco/1.3/Foundation/include/Poco/Hash.h#1 $
//
// Library: Foundation
// Package: Hashing
// Module: Hash
//
// Definition of the Hash class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_Hash_INCLUDED
#define Foundation_Hash_INCLUDED
#include "Poco/Foundation.h"
#include <cstddef>
namespace Poco {
template <class T>
struct Hash
/// A generic hash function.
{
std::size_t operator () (T value) const
/// Returns the hash for the given value.
{
return hash(value);
}
};
std::size_t Foundation_API hash(Int8 n);
std::size_t Foundation_API hash(UInt8 n);
std::size_t Foundation_API hash(Int16 n);
std::size_t Foundation_API hash(UInt16 n);
std::size_t Foundation_API hash(Int32 n);
std::size_t Foundation_API hash(UInt32 n);
std::size_t Foundation_API hash(Int64 n);
std::size_t Foundation_API hash(UInt64 n);
std::size_t Foundation_API hash(const std::string& str);
//
// inlines
//
inline std::size_t hash(Int8 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt8 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(Int16 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt16 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(Int32 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt32 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(Int64 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
inline std::size_t hash(UInt64 n)
{
return static_cast<std::size_t>(n)*2654435761U;
}
} // namespace Poco
#endif // Foundation_Hash_INCLUDED

View File

@@ -1,10 +1,10 @@
// //
// HashFunction.h // HashFunction.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/HashFunction.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/HashFunction.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Hashing
// Module: HashFunction // Module: HashFunction
// //
// Definition of the HashFunction class. // Definition of the HashFunction class.
@@ -41,37 +41,21 @@
#include "Poco/Foundation.h" #include "Poco/Foundation.h"
#include "Poco/Hash.h"
namespace Poco { namespace Poco {
//@ deprecated
template <class T> template <class T>
struct HashFunction struct HashFunction
/// A generic hash function for numeric values. /// A generic hash function.
{ {
static UInt32 hash(T key, UInt32 maxValue) UInt32 operator () (T key, UInt32 maxValue) const
/// Returns the hash value for the given key /// Returns the hash value for the given key.
{ {
return key * 0xf4243 % maxValue; return ((UInt32) hash(key)) % maxValue;
}
};
template <>
struct HashFunction<std::string>
/// A specialization of HashFunction for strings.
{
static UInt32 hash(const std::string& key, UInt32 maxValue)
{
// hash function taken from XML expat
UInt32 h = 0;
for (int i = 0; i < key.length(); ++i)
{
h = h * 0xf4243 ^ key[i];
}
return h % maxValue;
} }
}; };

View File

@@ -0,0 +1,244 @@
//
// HashMap.h
//
// $Id: //poco/1.3/Foundation/include/Poco/HashMap.h#1 $
//
// Library: Foundation
// Package: Hashing
// Module: HashMap
//
// Definition of the HashMap class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_HashMap_INCLUDED
#define Foundation_HashMap_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/LinearHashTable.h"
#include "Poco/Exception.h"
#include <utility>
namespace Poco {
template <class Key, class Value>
struct HashMapEntry
/// This class template is used internally by HashMap.
{
Key first;
Value second;
HashMapEntry():
first(),
second()
{
}
HashMapEntry(const Key& key):
first(key),
second()
{
}
HashMapEntry(const Key& key, const Value& value):
first(key),
second(value)
{
}
bool operator == (const HashMapEntry& entry) const
{
return first == entry.first;
}
bool operator != (const HashMapEntry& entry) const
{
return first != entry.first;
}
};
template <class HME, class KeyHashFunc>
struct HashMapEntryHash
/// This class template is used internally by HashMap.
{
std::size_t operator () (const HME& entry) const
{
return _func(entry.first);
}
private:
KeyHashFunc _func;
};
template <class Key, class Mapped, class HashFunc = Hash<Key> >
class HashMap
/// This class implements a map using a LinearHashTable.
///
/// A HashMap can be used just like a std::map.
{
public:
typedef Key KeyType;
typedef Mapped MappedType;
typedef Mapped& Reference;
typedef const Mapped& ConstReference;
typedef Mapped* Pointer;
typedef const Mapped* ConstPointer;
typedef HashMapEntry<Key, Mapped> ValueType;
typedef std::pair<KeyType, MappedType> PairType;
typedef HashMapEntryHash<ValueType, HashFunc> HashType;
typedef LinearHashTable<ValueType, HashType> HashTable;
typedef typename HashTable::Iterator Iterator;
typedef typename HashTable::ConstIterator ConstIterator;
HashMap()
/// Creates an empty HashMap.
{
}
HashMap(std::size_t initialReserve):
_table(initialReserve)
/// Creates the HashMap with room for initialReserve entries.
{
}
HashMap& operator = (const HashMap& map)
/// Assigns another HashMap.
{
HashMap tmp(map);
swap(tmp);
return *this;
}
void swap(HashMap& map)
/// Swaps the HashMap with another one.
{
_table.swap(map._table);
}
ConstIterator begin() const
{
return _table.begin();
}
ConstIterator end() const
{
return _table.end();
}
Iterator begin()
{
return _table.begin();
}
Iterator end()
{
return _table.end();
}
ConstIterator find(const KeyType& key) const
{
ValueType value(key);
return _table.find(value);
}
Iterator find(const KeyType& key)
{
ValueType value(key);
return _table.find(value);
}
std::pair<Iterator, bool> insert(const PairType& pair)
{
ValueType value(pair.first, pair.second);
return _table.insert(value);
}
std::pair<Iterator, bool> insert(const ValueType& value)
{
return _table.insert(value);
}
void erase(Iterator it)
{
_table.erase(it);
}
void erase(const KeyType& key)
{
Iterator it = find(key);
_table.erase(it);
}
void clear()
{
_table.clear();
}
std::size_t size() const
{
return _table.size();
}
bool empty() const
{
return _table.empty();
}
ConstReference operator [] (const KeyType& key) const
{
ConstIterator it = _table.find(key);
if (it != _table.end())
return it->second;
else
throw NotFoundException();
}
Reference operator [] (const KeyType& key)
{
ValueType value(key);
std::pair<Iterator, bool> res = _table.insert(value);
return res.first->second;
}
private:
HashTable _table;
};
} // namespace Poco
#endif // Foundation_HashMap_INCLUDED

View File

@@ -0,0 +1,199 @@
//
// HashSet.h
//
// $Id: //poco/1.3/Foundation/include/Poco/HashSet.h#1 $
//
// Library: Foundation
// Package: Hashing
// Module: HashSet
//
// Definition of the HashSet class.
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// Permission is hereby granted, free of charge, to any person or organization
// obtaining a copy of the software and accompanying documentation covered by
// this license (the "Software") to use, reproduce, display, distribute,
// execute, and transmit the Software, and to prepare derivative works of the
// Software, and to permit third-parties to whom the Software is furnished to
// do so, all subject to the following:
//
// The copyright notices in the Software and this entire statement, including
// the above license grant, this restriction and the following disclaimer,
// must be included in all copies of the Software, in whole or in part, and
// all derivative works of the Software, unless such copies or derivative
// works are solely in the form of machine-executable object code generated by
// a source language processor.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
// DEALINGS IN THE SOFTWARE.
//
#ifndef Foundation_HashSet_INCLUDED
#define Foundation_HashSet_INCLUDED
#include "Poco/Foundation.h"
#include "Poco/LinearHashTable.h"
namespace Poco {
template <class Value, class HashFunc = Hash<Value> >
class HashSet
/// This class implements a set using a LinearHashTable.
///
/// A HashSet can be used just like a std::set.
{
public:
typedef Value ValueType;
typedef Value& Reference;
typedef const Value& ConstReference;
typedef Value* Pointer;
typedef const Value* ConstPointer;
typedef HashFunc Hash;
typedef LinearHashTable<ValueType, Hash> HashTable;
typedef typename HashTable::Iterator Iterator;
typedef typename HashTable::ConstIterator ConstIterator;
HashSet()
/// Creates an empty HashSet.
{
}
HashSet(std::size_t initialReserve):
_table(initialReserve)
/// Creates the HashSet, using the given initialReserve.
{
}
HashSet(const HashSet& set):
_table(set._table)
/// Creates the HashSet by copying another one.
{
}
~HashSet()
/// Destroys the HashSet.
{
}
HashSet& operator = (const HashSet& table)
/// Assigns another HashSet.
{
HashSet tmp(table);
swap(tmp);
return *this;
}
void swap(HashSet& set)
/// Swaps the HashSet with another one.
{
_table.swap(set._table);
}
ConstIterator begin() const
/// Returns an iterator pointing to the first entry, if one exists.
{
return _table.begin();
}
ConstIterator end() const
/// Returns an iterator pointing to the end of the table.
{
return _table.end();
}
Iterator begin()
/// Returns an iterator pointing to the first entry, if one exists.
{
return _table.begin();
}
Iterator end()
/// Returns an iterator pointing to the end of the table.
{
return _table.end();
}
ConstIterator find(const ValueType& value) const
/// Finds an entry in the table.
{
return _table.find(value);
}
Iterator find(const ValueType& value)
/// Finds an entry in the table.
{
return _table.find(value);
}
std::size_t count(const ValueType& value) const
/// Returns the number of elements with the given
/// value, with is either 1 or 0.
{
return _table.count(value);
}
std::pair<Iterator, bool> insert(const ValueType& value)
/// Inserts an element into the set.
///
/// If the element already exists in the set,
/// a pair(iterator, false) with iterator pointing to the
/// existing element is returned.
/// Otherwise, the element is inserted an a
/// pair(iterator, true) with iterator
/// pointing to the new element is returned.
{
return _table.insert(value);
}
void erase(Iterator it)
/// Erases the element pointed to by it.
{
_table.erase(it);
}
void erase(const ValueType& value)
/// Erases the element with the given value, if it exists.
{
_table.erase(value);
}
void clear()
/// Erases all elements.
{
_table.clear();
}
std::size_t size() const
/// Returns the number of elements in the table.
{
return _table.size();
}
bool empty() const
/// Returns true iff the table is empty.
{
return _table.empty();
}
private:
HashTable _table;
};
} // namespace Poco
#endif // Foundation_HashSet_INCLUDED

View File

@@ -1,10 +1,10 @@
// //
// HashStatistic.h // HashStatistic.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/HashStatistic.h#1 $ // $Id: //poco/1.3/Foundation/include/Poco/HashStatistic.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Hashing
// Module: HashStatistic // Module: HashStatistic
// //
// Definition of the HashStatistic class. // Definition of the HashStatistic class.
@@ -47,6 +47,7 @@
namespace Poco { namespace Poco {
//@ deprecated
class Foundation_API HashStatistic class Foundation_API HashStatistic
/// HashStatistic class bundles statistical information on the current state of a HashTable /// HashStatistic class bundles statistical information on the current state of a HashTable
{ {

View File

@@ -1,10 +1,10 @@
// //
// HashTable.h // HashTable.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/HashTable.h#2 $ // $Id: //poco/1.3/Foundation/include/Poco/HashTable.h#1 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Hashing
// Module: HashTable // Module: HashTable
// //
// Definition of the HashTable class. // Definition of the HashTable class.
@@ -52,6 +52,7 @@
namespace Poco { namespace Poco {
//@ deprecated
template <class Key, class Value, class KeyHashFunction = HashFunction<Key> > template <class Key, class Value, class KeyHashFunction = HashFunction<Key> >
class HashTable class HashTable
/// A HashTable stores a key value pair that can be looked up via a hashed key. /// A HashTable stores a key value pair that can be looked up via a hashed key.
@@ -146,15 +147,17 @@ public:
return hsh; return hsh;
} }
void insertRaw(const Key& key, UInt32 hsh, const Value& value) Value& insertRaw(const Key& key, UInt32 hsh, const Value& value)
/// Returns the hash value of the inserted item. /// Returns the hash value of the inserted item.
/// Throws an exception if the entry was already inserted /// Throws an exception if the entry was already inserted
{ {
if (!_entries[hsh]) if (!_entries[hsh])
_entries[hsh] = new HashEntryMap(); _entries[hsh] = new HashEntryMap();
if (!_entries[hsh]->insert(std::make_pair(key, value)).second) std::pair<typename HashEntryMap::iterator, bool> res(_entries[hsh]->insert(std::make_pair(key, value)));
if (!res.second)
throw InvalidArgumentException("HashTable::insert, key already exists."); throw InvalidArgumentException("HashTable::insert, key already exists.");
_size++; _size++;
return res.first->second;
} }
UInt32 update(const Key& key, const Value& value) UInt32 update(const Key& key, const Value& value)
@@ -196,7 +199,7 @@ public:
UInt32 hash(const Key& key) const UInt32 hash(const Key& key) const
{ {
return KeyHashFunction::hash(key, _maxCapacity); return _hash(key, _maxCapacity);
} }
const Value& get(const Key& key) const const Value& get(const Key& key) const
@@ -219,6 +222,32 @@ public:
return it->second; return it->second;
} }
Value& get(const Key& key)
/// Throws an exception if the value does not exist
{
UInt32 hsh = hash(key);
return const_cast<Value&>(getRaw(key, hsh));
}
const Value& operator [] (const Key& key) const
{
return get(key);
}
Value& operator [] (const Key& key)
{
UInt32 hsh = hash(key);
if (!_entries[hsh])
return insertRaw(key, hsh, Value());
ConstIterator it = _entries[hsh]->find(key);
if (it == _entries[hsh]->end())
return insertRaw(key, hsh, Value());
return it->second;
}
const Key& getKeyRaw(const Key& key, UInt32 hsh) const Key& getKeyRaw(const Key& key, UInt32 hsh)
/// Throws an exception if the key does not exist. returns a reference to the internally /// Throws an exception if the key does not exist. returns a reference to the internally
/// stored key. Useful when someone does an insert and wants for performance reason only to store /// stored key. Useful when someone does an insert and wants for performance reason only to store
@@ -264,7 +293,6 @@ public:
return _entries[hsh] && (_entries[hsh]->end() != _entries[hsh]->find(key)); return _entries[hsh] && (_entries[hsh]->end() != _entries[hsh]->find(key));
} }
size_t size() const size_t size() const
/// Returns the number of elements already inserted into the HashTable /// Returns the number of elements already inserted into the HashTable
{ {
@@ -353,6 +381,7 @@ private:
HashTableVector _entries; HashTableVector _entries;
size_t _size; size_t _size;
UInt32 _maxCapacity; UInt32 _maxCapacity;
KeyHashFunction _hash;
}; };

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