changes for 1.2.7

This commit is contained in:
Guenter Obiltschnig
2006-12-07 16:51:51 +00:00
parent aef78bcc5f
commit dd49be79aa
67 changed files with 913 additions and 341 deletions

View File

@@ -1,5 +1,53 @@
This is the changelog file for POCO - the C++ Portable Components.
Release 1.2.7 (2006-12-07)
==========================
- Poco::File: fixed root directory handling
- fixed UUIDGenerator documentation
- clarified Application::setUnixOptions() documentation
- fixes for issue [SOAPLite Transport 0000023]: SOAP Transport Listener should be able to use existing HTTPServer instance
- fixing mantis issues 13, 14, 15, 16, 17, 18, 19, 21
- fixed SF# 1597022: Signed/unsigned warning in StringTokenizer::operator[]
- fixed SF# 1598601: Message::op= leaks
- fixed SF# 1605960: PatternFormatter crashes on custom property
- fixed SF# 1605950: Memory leak in Logger sample code
- fixed SF# 1591635: Copy Paste Error in sample code
- fixed SF# 1591512: SMTPClientSession response stream
- fixed SF #1592776: LayeredConfiguration: getRaw should enumerate in reverse order
- SF Patch # 1599848 ] VS 2005 Util build fails
- Logger::dump() now uses std::size_t instead of int for buffer size
- LayeredConfiguration now supports a priority value for each configuration.
Also, it's possible to specify for each configuration added whether it
should be writeable.
- ServerApplication: cd to root directory only if running as a daemon
- added Message::swap()
- improvements to build system:
global Makefile has correct dependencies for samples
on Windows, samples build after libraries are ready
configure supports --no-wstring and --no-fpenvironment flags
build system supports POCO_FLAGS environment variable for compiler flags
- RemoteGen: fixed error handling for write protected files (SystemException)
fixing integral constant overflow messages with large cache expiration, m_ support for type serializers,
case-insensitive comparison added
Release 1.2.6 (2006-11-19)
==========================
- added additional match() method to RegularExpression and documented the fact that the simple
match() method internally sets RE_ANCHORED and RE_NOTEMPTY.
- added ExpirationDecorator template. Decorates data types so that they can be used with UniqueExpireCaches
- added operator ! to AutoPtr and SharedPtr
- Buffer uses std::size_t instead of int
- added poco_ndc_dbg() macro (same as poco_ndc(), but only enabled in debug builds)
- Foundation.h now includes Config.h at the very beginning.
- added AutoPtr::assign() and SharedPtr::assign()
- added operator () to AbstractEvent
- gcc Makefiles now strip release builds
- documentation improvements
Release 1.2.5 (2006-10-23)
==========================
@@ -543,4 +591,4 @@ building the libraries.
--
$Id: //poco/1.2/dist/CHANGELOG#13 $
$Id: //poco/1.2/dist/CHANGELOG#16 $

View File

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

View File

@@ -1,7 +1,7 @@
//
// AbstractEvent.h
//
// $Id: //poco/1.2/Foundation/include/Poco/AbstractEvent.h#3 $
// $Id: //poco/1.2/Foundation/include/Poco/AbstractEvent.h#4 $
//
// Library: Foundation
// 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)
/// {
/// 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
@@ -171,6 +174,11 @@ public:
FastMutex::ScopedLock lock(_mutex);
_strategy.remove(aDelegate);
}
void operator () (const void* pSender, TArgs& args)
{
notify(pSender, args);
}
void notify(const void* pSender, TArgs& args)
/// Sends a notification to all registered delegates. The order is

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
//
// Bugcheck.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Bugcheck.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Bugcheck.h#2 $
//
// Library: Foundation
// Package: Core
@@ -90,7 +90,8 @@ protected:
// useful macros (these automatically supply line number and file name)
//
#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
#define poco_assert_dbg(cond)
#endif

View File

@@ -1,7 +1,7 @@
//
// DirectoryIterator.h
//
// $Id: //poco/1.2/Foundation/include/Poco/DirectoryIterator.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/DirectoryIterator.h#2 $
//
// Library: Foundation
// Package: Filesystem
@@ -54,6 +54,14 @@ class DirectoryIteratorImpl;
class Foundation_API DirectoryIterator
/// The DirectoryIterator class is used to enumerate
/// 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:
DirectoryIterator();

View File

@@ -1,7 +1,7 @@
//
// Environment.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Environment.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Environment.h#2 $
//
// Library: Foundation
// Package: Core
@@ -56,6 +56,11 @@ public:
/// with the given name. Throws a NotFoundException
/// 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);
/// Returns true iff an environment variable
/// with the given name is defined.

View File

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

View File

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

View File

@@ -1,7 +1,7 @@
//
// Logger.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Logger.h#2 $
// $Id: //poco/1.2/Foundation/include/Poco/Logger.h#3 $
//
// Library: Foundation
// Package: Logging
@@ -45,6 +45,7 @@
#include "Poco/Message.h"
#include <map>
#include <vector>
#include <cstddef>
namespace Poco {
@@ -177,7 +178,7 @@ public:
/// and the given message text and sends it
/// to the attached channel.
void dump(const std::string& msg, const void* buffer, int length, Message::Priority prio = Message::PRIO_DEBUG);
void dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio = Message::PRIO_DEBUG);
/// Logs the given message, followed by the data in buffer.
///
/// The data in buffer is written in canonical hex+ASCII form:
@@ -299,7 +300,7 @@ protected:
void log(const std::string& text, Message::Priority prio);
static std::string format(const std::string& fmt, int argc, std::string argv[]);
static void formatDump(std::string& message, const void* buffer, int length);
static void formatDump(std::string& message, const void* buffer, std::size_t length);
static Logger& parent(const std::string& name);
static void add(Logger* pLogger);
static Logger* find(const std::string& name);

View File

@@ -1,7 +1,7 @@
//
// MemoryPool.h
//
// $Id: //poco/1.2/Foundation/include/Poco/MemoryPool.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/MemoryPool.h#2 $
//
// Library: Foundation
// Package: Core
@@ -43,6 +43,7 @@
#include "Poco/Foundation.h"
#include "Poco/Mutex.h"
#include <vector>
#include <cstddef>
namespace Poco {
@@ -62,7 +63,7 @@ class Foundation_API MemoryPool
/// Blocks can be preallocated.
{
public:
MemoryPool(size_t blockSize, int preAlloc = 0, int maxAlloc = 0);
MemoryPool(std::size_t blockSize, int preAlloc = 0, int maxAlloc = 0);
/// Creates a MemoryPool for blocks with the given blockSize.
/// The number of blocks given in preAlloc are preallocated.
@@ -78,7 +79,7 @@ public:
void release(void* ptr);
/// Releases a memory block and returns it to the pool.
size_t blockSize() const;
std::size_t blockSize() const;
/// Returns the block size.
int allocated() const;
@@ -99,18 +100,18 @@ private:
typedef std::vector<char*> BlockVec;
size_t _blockSize;
int _maxAlloc;
int _allocated;
BlockVec _blocks;
FastMutex _mutex;
std::size_t _blockSize;
int _maxAlloc;
int _allocated;
BlockVec _blocks;
FastMutex _mutex;
};
//
// inlines
//
inline size_t MemoryPool::blockSize() const
inline std::size_t MemoryPool::blockSize() const
{
return _blockSize;
}

View File

@@ -1,7 +1,7 @@
//
// Message.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Message.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Message.h#2 $
//
// Library: Foundation
// Package: Logging
@@ -94,6 +94,9 @@ public:
Message& operator = (const Message& msg);
/// Assignment operator.
void swap(Message& msg);
/// Swaps the message with another one.
void setSource(const std::string& src);
/// Sets the source of the message.
@@ -202,6 +205,12 @@ inline long Message::getPid() const
}
inline void swap(Message& m1, Message& m2)
{
m1.swap(m2);
}
} // namespace Poco

View File

@@ -1,7 +1,7 @@
//
// NestedDiagnosticContext.h
//
// $Id: //poco/1.2/Foundation/include/Poco/NestedDiagnosticContext.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/NestedDiagnosticContext.h#2 $
//
// Library: Foundation
// Package: Core
@@ -178,8 +178,16 @@ inline NDCScope::~NDCScope()
//
// helper macros
//
#define poco_ndc(msg) \
Poco::NDCScope _theNdcScope(msg, __LINE__, __FILE__)
#define poco_ndc(func) \
Poco::NDCScope _theNdcScope(#func, __LINE__, __FILE__)
#if defined(_DEBUG)
#define poco_ndc_dbg(func) \
Poco::NDCScope _theNdcScope(#func, __LINE__, __FILE__)
#else
#define poco_ndc_dbg(func)
#endif
} // namespace Poco

View File

@@ -1,7 +1,7 @@
//
// Path.h
//
// $Id: //poco/1.2/Foundation/include/Poco/Path.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/Path.h#2 $
//
// Library: Foundation
// Package: Filesystem
@@ -108,16 +108,16 @@ public:
/// Assignment operator.
Path& operator = (const std::string& path);
/// Assigns a string containing a path.
/// Assigns a string containing a path in native format.
Path& operator = (const char* path);
/// Assigns a string containing a path.
/// Assigns a string containing a path in native format.
void swap(Path& path);
/// Swaps the path with another one.
Path& assign(const std::string& path);
/// Assigns a string containing a path.
/// Assigns a string containing a path in native format.
Path& assign(const std::string& path, Style style);
/// Assigns a string containing a path.
@@ -141,7 +141,8 @@ public:
/// Assigns a string containing a path.
bool tryParse(const std::string& path);
/// Tries to interpret the given string as a path.
/// Tries to interpret the given string as a path
/// in native format.
/// If the path is syntactically valid, assigns the
/// path and returns true. Otherwise leaves the
/// object unchanged and returns false.

View File

@@ -1,7 +1,7 @@
//
// RegularExpression.h
//
// $Id: //poco/1.2/Foundation/include/Poco/RegularExpression.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/RegularExpression.h#2 $
//
// Library: Foundation
// Package: RegExp
@@ -73,24 +73,32 @@ class Foundation_API RegularExpression
{
public:
enum Options // These must match the corresponsing options in pcre.h!
/// Some of the following options can only be passed to the constructor;
/// some can be passed only to matching functions, and some can be used
/// everywhere.
///
/// * Options marked [ctor] can be passed to the constructor.
/// * Options marked [match] can be passed to match, extract, split and subst.
/// * Options marked [subst] can be passed to subst.
///
/// See the PCRE documentation for more information.
{
RE_CASELESS = 0x00001, /// case insensitive matching (/i)
RE_MULTILINE = 0x00002, /// enable multi-line mode; affects ^ and $ (/m)
RE_DOTALL = 0x00004, /// dot matches all characters, including newline (/s)
RE_EXTENDED = 0x00004, /// totally ignore whitespace (/x)
RE_ANCHORED = 0x00010, /// treat pattern as if it starts with a ^
RE_DOLLAR_ENDONLY = 0x00020, /// dollar matches end-of-string only, not last newline in string
RE_EXTRA = 0x00040, /// enable optional PCRE functionality
RE_NOTBOL = 0x00080, /// circumflex does not match beginning of string
RE_NOTEOL = 0x00100, /// $ does not match end of string
RE_UNGREEDY = 0x00200, /// make quantifiers ungreedy
RE_NOTEMPTY = 0x00400, /// empty string never matches
RE_UTF8 = 0x00800, /// assume pattern and subject is UTF-8 encoded
RE_NO_AUTO_CAPTURE = 0x01000, /// disable numbered capturing parentheses
RE_NO_UTF8_CHECK = 0x02000, /// do not check validity of UTF-8 code sequences
RE_GLOBAL = 0x10000, /// replace all occurences (/g)
RE_NO_VARS = 0x20000 /// treat dollar in replacement string as ordinary character
RE_CASELESS = 0x00001, /// case insensitive matching (/i) [ctor]
RE_MULTILINE = 0x00002, /// enable multi-line mode; affects ^ and $ (/m) [ctor]
RE_DOTALL = 0x00004, /// dot matches all characters, including newline (/s) [ctor]
RE_EXTENDED = 0x00004, /// totally ignore whitespace (/x) [ctor]
RE_ANCHORED = 0x00010, /// treat pattern as if it starts with a ^ [ctor, match]
RE_DOLLAR_ENDONLY = 0x00020, /// dollar matches end-of-string only, not last newline in string [ctor]
RE_EXTRA = 0x00040, /// enable optional PCRE functionality [ctor]
RE_NOTBOL = 0x00080, /// circumflex does not match beginning of string [match]
RE_NOTEOL = 0x00100, /// $ does not match end of string [match]
RE_UNGREEDY = 0x00200, /// make quantifiers ungreedy [ctor]
RE_NOTEMPTY = 0x00400, /// empty string never matches [match]
RE_UTF8 = 0x00800, /// assume pattern and subject is UTF-8 encoded [ctor]
RE_NO_AUTO_CAPTURE = 0x01000, /// disable numbered capturing parentheses [ctor, match]
RE_NO_UTF8_CHECK = 0x02000, /// do not check validity of UTF-8 code sequences [match]
RE_GLOBAL = 0x10000, /// replace all occurences (/g) [subst]
RE_NO_VARS = 0x20000 /// treat dollar in replacement string as ordinary character [subst]
};
struct Match
@@ -137,6 +145,13 @@ public:
bool match(const std::string& subject, std::string::size_type offset = 0) const;
/// Returns true if and only if the subject matches the regular expression.
///
/// Internally, this method sets the RE_ANCHORED and RE_NOTEMPTY options for
/// matching, which means that the empty string will never match and
/// the pattern is treated as if it starts with a ^.
bool match(const std::string& subject, std::string::size_type offset, int options) const;
/// Returns true if and only if the subject matches the regular expression.
int extract(const std::string& subject, std::string& str, int options = 0) const;
/// Matches the given subject string against the pattern.

View File

@@ -1,7 +1,7 @@
//
// SharedPtr.h
//
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#5 $
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#6 $
//
// Library: Foundation
// Package: Core
@@ -104,7 +104,6 @@ class SharedPtr
/// is required.
{
public:
SharedPtr(): _pCounter(new ReferenceCounter), _ptr(0)
{
}
@@ -129,7 +128,7 @@ public:
release();
}
SharedPtr& operator = (C* ptr)
SharedPtr& assign(C* ptr)
{
if (get() != ptr)
{
@@ -140,8 +139,8 @@ public:
}
return *this;
}
SharedPtr& operator = (const SharedPtr& ptr)
SharedPtr& assign(const SharedPtr& ptr)
{
if (&ptr != this)
{
@@ -150,9 +149,9 @@ public:
}
return *this;
}
template <class Other>
SharedPtr& operator = (const SharedPtr<Other>& ptr)
SharedPtr& assign(const SharedPtr<Other>& ptr)
{
if (ptr.get() != _ptr)
{
@@ -162,8 +161,30 @@ public:
return *this;
}
SharedPtr& operator = (C* ptr)
{
return assign(ptr);
}
SharedPtr& operator = (const SharedPtr& ptr)
{
return assign(ptr);
}
template <class Other>
SharedPtr& operator = (const SharedPtr<Other>& ptr)
{
return assign<Other>(ptr);
}
void swap(SharedPtr& ptr)
{
std::swap(_ptr, ptr._ptr);
std::swap(_pCounter, ptr._pCounter);
}
template <class Other>
SharedPtr<Other> cast()
SharedPtr<Other> cast() const
/// Casts the SharedPtr via a dynamic cast to the given type.
/// Returns an SharedPtr containing NULL if the cast fails.
/// Example: (assume class Sub: public Super)
@@ -171,18 +192,12 @@ public:
/// SharedPtr<Sub> sub = super.cast<Sub>();
/// poco_assert (sub.get());
{
Other* pOther = dynamic_cast <Other*>(_ptr);
Other* pOther = dynamic_cast<Other*>(_ptr);
if (pOther)
return SharedPtr<Other> (_pCounter, pOther);
return SharedPtr<Other>(_pCounter, pOther);
return SharedPtr<Other>();
}
void swap(SharedPtr& ptr)
{
std::swap(_ptr, ptr._ptr);
std::swap(_pCounter, ptr._pCounter);
}
C* operator -> ()
{
return deref();
@@ -208,11 +223,11 @@ public:
return _ptr;
}
bool isNull() const
const C* get() const
{
return _ptr == 0;
return _ptr;
}
operator C* ()
{
return _ptr;
@@ -223,9 +238,14 @@ public:
return _ptr;
}
const C* get() const
bool operator ! () const
{
return _ptr;
return _ptr == 0;
}
bool isNull() const
{
return _ptr == 0;
}
bool operator == (const SharedPtr& ptr) const

View File

@@ -1,7 +1,7 @@
//
// StringTokenizer.h
//
// $Id: //poco/1.2/Foundation/include/Poco/StringTokenizer.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/StringTokenizer.h#2 $
//
// Library: Foundation
// Package: Core
@@ -43,6 +43,7 @@
#include "Poco/Foundation.h"
#include "Poco/Exception.h"
#include <vector>
#include <cstddef>
namespace Poco {
@@ -79,11 +80,11 @@ public:
Iterator begin() const;
Iterator end() const;
const std::string& operator [] (int index) const;
const std::string& operator [] (std::size_t index) const;
/// Returns the index'th token.
/// Throws a RangeException if the index is out of range.
int count() const;
std::size_t count() const;
/// Returns the number of tokens.
private:
@@ -111,16 +112,16 @@ inline StringTokenizer::Iterator StringTokenizer::end() const
}
inline const std::string& StringTokenizer::operator [] (int index) const
inline const std::string& StringTokenizer::operator [] (std::size_t index) const
{
if (index < 0 || index >= _tokens.size()) throw RangeException();
if (index >= _tokens.size()) throw RangeException();
return _tokens[index];
}
inline int StringTokenizer::count() const
inline std::size_t StringTokenizer::count() const
{
return (int) _tokens.size();
return _tokens.size();
}

View File

@@ -1,7 +1,7 @@
//
// UUIDGenerator.h
//
// $Id: //poco/1.2/Foundation/include/Poco/UUIDGenerator.h#1 $
// $Id: //poco/1.2/Foundation/include/Poco/UUIDGenerator.h#2 $
//
// Library: Foundation
// Package: UUID
@@ -85,9 +85,9 @@ public:
/// Creates a random UUID.
UUID createOne();
/// Tries to create and return a time-based UUID (see createSecure()), and,
/// Tries to create and return a time-based UUID (see create()), and,
/// if that does not work due to the unavailability of a MAC address,
/// creates and returns a random UUID.
/// creates and returns a random UUID (see createRandom()).
///
/// The UUID::version() method can be used to determine the actual kind of
/// the UUID generated.

View File

@@ -1,7 +1,7 @@
//
// Base64Decoder.cpp
//
// $Id: //poco/1.2/Foundation/src/Base64Decoder.cpp#1 $
// $Id: //poco/1.2/Foundation/src/Base64Decoder.cpp#2 $
//
// Library: Foundation
// Package: Streams
@@ -64,7 +64,7 @@ Base64DecoderBuf::Base64DecoderBuf(std::istream& istr):
{
IN_ENCODING[Base64EncoderBuf::OUT_ENCODING[i]] = i;
}
IN_ENCODING['='] = 0;
IN_ENCODING[static_cast<unsigned char>('=')] = '\0';
IN_ENCODING_INIT = true;
}
}

View File

@@ -1,7 +1,7 @@
//
// Exception.cpp
//
// $Id: //poco/1.2/Foundation/src/Exception.cpp#1 $
// $Id: //poco/1.2/Foundation/src/Exception.cpp#2 $
//
// Library: Foundation
// Package: Core
@@ -150,7 +150,7 @@ POCO_IMPLEMENT_EXCEPTION(NotFoundException, RuntimeException, "Not found")
POCO_IMPLEMENT_EXCEPTION(ExistsException, RuntimeException, "Exists")
POCO_IMPLEMENT_EXCEPTION(TimeoutException, RuntimeException, "Timeout")
POCO_IMPLEMENT_EXCEPTION(SystemException, RuntimeException, "System exception")
POCO_IMPLEMENT_EXCEPTION(RegularExpressionException, RuntimeException, "Error in regular exception")
POCO_IMPLEMENT_EXCEPTION(RegularExpressionException, RuntimeException, "Error in regular expression")
POCO_IMPLEMENT_EXCEPTION(LibraryLoadException, RuntimeException, "Cannot load library")
POCO_IMPLEMENT_EXCEPTION(LibraryAlreadyLoadedException, RuntimeException, "Library already loaded")
POCO_IMPLEMENT_EXCEPTION(NoThreadAvailableException, RuntimeException, "No thread available")

View File

@@ -1,7 +1,7 @@
//
// File_UNIX.cpp
//
// $Id: //poco/1.2/Foundation/src/File_UNIX.cpp#1 $
// $Id: //poco/1.2/Foundation/src/File_UNIX.cpp#2 $
//
// Library: Foundation
// Package: Filesystem
@@ -59,7 +59,7 @@ FileImpl::FileImpl()
FileImpl::FileImpl(const std::string& path): _path(path)
{
std::string::size_type n = _path.size();
if (n > 0 && _path[n - 1] == '/')
if (n > 1 && _path[n - 1] == '/')
_path.resize(n - 1);
}
@@ -78,6 +78,9 @@ void FileImpl::swapImpl(FileImpl& file)
void FileImpl::setPathImpl(const std::string& path)
{
_path = path;
std::string::size_type n = _path.size();
if (n > 1 && _path[n - 1] == '/')
_path.resize(n - 1);
}

View File

@@ -1,7 +1,7 @@
//
// File_WIN32.cpp
//
// $Id: //poco/1.2/Foundation/src/File_WIN32.cpp#1 $
// $Id: //poco/1.2/Foundation/src/File_WIN32.cpp#2 $
//
// Library: Foundation
// Package: Filesystem
@@ -74,8 +74,10 @@ FileImpl::FileImpl()
FileImpl::FileImpl(const std::string& path): _path(path)
{
std::string::size_type n = _path.size();
if (n > 0 && (_path[n - 1] == '\\' || _path[n - 1] == '/'))
if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
{
_path.resize(n - 1);
}
}
@@ -93,6 +95,11 @@ void FileImpl::swapImpl(FileImpl& file)
void FileImpl::setPathImpl(const std::string& path)
{
_path = path;
std::string::size_type n = _path.size();
if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
{
_path.resize(n - 1);
}
}
@@ -242,7 +249,7 @@ void FileImpl::setSizeImpl(FileSizeImpl size)
}
void FileImpl::setWriteableImpl(bool flag)
void FileImpl::setWriteableImpl(bool flag)
{
poco_assert (!_path.empty());

View File

@@ -1,7 +1,7 @@
//
// File_WIN32U.cpp
//
// $Id: //poco/1.2/Foundation/src/File_WIN32U.cpp#1 $
// $Id: //poco/1.2/Foundation/src/File_WIN32U.cpp#2 $
//
// Library: Foundation
// Package: Filesystem
@@ -75,8 +75,11 @@ FileImpl::FileImpl()
FileImpl::FileImpl(const std::string& path): _path(path)
{
std::string::size_type n = _path.size();
if (n > 0 && (_path[n - 1] == '\\' || _path[n - 1] == '/'))
std::string::size_type n = _path.size();
if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
{
_path.resize(n - 1);
}
UnicodeConverter::toUTF16(_path, _upath);
}
@@ -96,6 +99,12 @@ void FileImpl::swapImpl(FileImpl& file)
void FileImpl::setPathImpl(const std::string& path)
{
_path = path;
std::string::size_type n = _path.size();
std::string::size_type n = _path.size();
if (n > 1 && (_path[n - 1] == '\\' || _path[n - 1] == '/') && !((n == 3 && _path[1]==':')))
{
_path.resize(n - 1);
}
UnicodeConverter::toUTF16(_path, _upath);
}

View File

@@ -1,7 +1,7 @@
//
// Logger.cpp
//
// $Id: //poco/1.2/Foundation/src/Logger.cpp#2 $
// $Id: //poco/1.2/Foundation/src/Logger.cpp#3 $
//
// Library: Foundation
// Package: Logging
@@ -130,7 +130,7 @@ void Logger::log(const Exception& exc)
}
void Logger::dump(const std::string& msg, const void* buffer, int length, Message::Priority prio)
void Logger::dump(const std::string& msg, const void* buffer, std::size_t length, Message::Priority prio)
{
if (_level >= prio && _pChannel)
{
@@ -267,7 +267,7 @@ std::string Logger::format(const std::string& fmt, int argc, std::string argv[])
}
void Logger::formatDump(std::string& message, const void* buffer, int length)
void Logger::formatDump(std::string& message, const void* buffer, std::size_t length)
{
const int BYTES_PER_LINE = 16;

View File

@@ -1,7 +1,7 @@
//
// MemoryPool.cpp
//
// $Id: //poco/1.2/Foundation/src/MemoryPool.cpp#1 $
// $Id: //poco/1.2/Foundation/src/MemoryPool.cpp#2 $
//
// Library: Foundation
// Package: Core
@@ -41,7 +41,7 @@
namespace Poco {
MemoryPool::MemoryPool(size_t blockSize, int preAlloc, int maxAlloc):
MemoryPool::MemoryPool(std::size_t blockSize, int preAlloc, int maxAlloc):
_blockSize(blockSize),
_maxAlloc(maxAlloc),
_allocated(preAlloc)

View File

@@ -1,7 +1,7 @@
//
// Message.cpp
//
// $Id: //poco/1.2/Foundation/src/Message.cpp#1 $
// $Id: //poco/1.2/Foundation/src/Message.cpp#2 $
//
// Library: Foundation
// Package: Logging
@@ -38,6 +38,7 @@
#include "Poco/Exception.h"
#include "Poco/Process.h"
#include "Poco/Thread.h"
#include <algorithm>
namespace Poco {
@@ -117,23 +118,28 @@ void Message::init()
Message& Message::operator = (const Message& msg)
{
if (this == &msg) return *this;
_source = msg._source;
_text = msg._text;
_prio = msg._prio;
_time = msg._time;
_thread = msg._thread;
_pid = msg._pid;
if (msg._pMap)
_pMap = new StringMap(*msg._pMap);
else
_pMap = 0;
if (&msg != this)
{
Message tmp(msg);
swap(tmp);
}
return *this;
}
void Message::swap(Message& msg)
{
using std::swap;
swap(_source, msg._source);
swap(_text, msg._text);
swap(_prio, msg._prio);
swap(_time, msg._time);
swap(_thread, msg._thread);
swap(_pid, msg._pid);
swap(_pMap, msg._pMap);
}
void Message::setSource(const std::string& src)
{
_source = src;

View File

@@ -1,7 +1,7 @@
//
// PatternFormatter.cpp
//
// $Id: //poco/1.2/Foundation/src/PatternFormatter.cpp#1 $
// $Id: //poco/1.2/Foundation/src/PatternFormatter.cpp#2 $
//
// Library: Foundation
// Package: Logging
@@ -125,7 +125,7 @@ void PatternFormatter::format(const Message& msg, std::string& text)
++it;
std::string prop;
while (it != end && *it != ']') prop += *it++;
if (it != end) ++it;
if (it == end) --it;
try
{
text.append(msg[prop]);

View File

@@ -1,7 +1,7 @@
//
// RegularExpression.h
//
// $Id: //poco/1.2/Foundation/src/RegularExpression.cpp#1 $
// $Id: //poco/1.2/Foundation/src/RegularExpression.cpp#2 $
//
// Library: Foundation
// Package: RegExp
@@ -147,6 +147,14 @@ bool RegularExpression::match(const std::string& subject, std::string::size_type
}
bool RegularExpression::match(const std::string& subject, std::string::size_type offset, int options) const
{
Match mtch;
match(subject, offset, mtch, options);
return mtch.offset == offset && mtch.length == subject.length() - offset;
}
int RegularExpression::extract(const std::string& subject, std::string& str, int options) const
{
Match mtch;
@@ -283,8 +291,10 @@ std::string::size_type RegularExpression::substOne(std::string& subject, std::st
bool RegularExpression::match(const std::string& subject, const std::string& pattern, int options)
{
RegularExpression re(pattern, options, false);
return re.match(subject);
int ctorOptions = options & (RE_CASELESS | RE_MULTILINE | RE_DOTALL | RE_EXTENDED | RE_ANCHORED | RE_DOLLAR_ENDONLY | RE_EXTRA | RE_UNGREEDY | RE_UTF8 | RE_NO_AUTO_CAPTURE);
int mtchOptions = options & (RE_ANCHORED | RE_NOTBOL | RE_NOTEOL | RE_NOTEMPTY | RE_NO_AUTO_CAPTURE | RE_NO_UTF8_CHECK);
RegularExpression re(pattern, ctorOptions, false);
return re.match(subject, 0, mtchOptions);
}

View File

@@ -1,7 +1,7 @@
#
# Makefile
#
# $Id: //poco/1.2/Foundation/testsuite/Makefile-Driver#1 $
# $Id: //poco/1.2/Foundation/testsuite/Makefile-Driver#2 $
#
# Makefile for Poco Foundation testsuite
#
@@ -33,7 +33,8 @@ objects = ActiveMethodTest ActivityTest ActiveDispatcherTest \
TimespanTest TimestampTest TimezoneTest URIStreamOpenerTest URITest \
URITestSuite UUIDGeneratorTest UUIDTest UUIDTestSuite ZLibTest \
TestPlugin DummyDelegate BasicEventTest FIFOEventTest PriorityEventTest EventTestSuite \
LRUCacheTest ExpireCacheTest ExpireLRUCacheTest CacheTestSuite AnyTest HashTest FormatTest
LRUCacheTest ExpireCacheTest ExpireLRUCacheTest UniqueExpireCacheTest UniqueExpireLRUCacheTest \
CacheTestSuite AnyTest HashTest FormatTest
target = testrunner
target_version = 1

View File

@@ -965,6 +965,12 @@
<File
RelativePath=".\src\LRUCacheTest.cpp">
</File>
<File
RelativePath=".\src\UniqueExpireCacheTest.cpp">
</File>
<File
RelativePath=".\src\UniqueExpireLRUCacheTest.cpp">
</File>
</Filter>
<Filter
Name="Header Files"
@@ -981,6 +987,12 @@
<File
RelativePath=".\src\LRUCacheTest.h">
</File>
<File
RelativePath=".\src\UniqueExpireCacheTest.h">
</File>
<File
RelativePath=".\src\UniqueExpireLRUCacheTest.h">
</File>
</Filter>
</Filter>
</Files>

View File

@@ -1237,6 +1237,14 @@
RelativePath=".\src\LRUCacheTest.h"
>
</File>
<File
RelativePath=".\src\UniqueExpireCacheTest.h"
>
</File>
<File
RelativePath=".\src\UniqueExpireLRUCacheTest.h"
>
</File>
</Filter>
<Filter
Name="Source Files"
@@ -1257,6 +1265,14 @@
RelativePath=".\src\LRUCacheTest.cpp"
>
</File>
<File
RelativePath=".\src\UniqueExpireCacheTest.cpp"
>
</File>
<File
RelativePath=".\src\UniqueExpireLRUCacheTest.cpp"
>
</File>
</Filter>
</Filter>
</Files>

View File

@@ -1,7 +1,7 @@
//
// AutoPtrTest.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/AutoPtrTest.cpp#2 $
// $Id: //poco/1.2/Foundation/testsuite/src/AutoPtrTest.cpp#3 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -180,6 +180,10 @@ void AutoPtrTest::testOps()
ptr4 = ptr2;
assert (ptr4 == ptr2);
assert (!(ptr4 != ptr2));
assert (!(!ptr1));
ptr1 = 0;
assert (!ptr1);
}

View File

@@ -1,7 +1,7 @@
//
// CacheTestSuite.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/CacheTestSuite.cpp#1 $
// $Id: //poco/1.2/Foundation/testsuite/src/CacheTestSuite.cpp#2 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -34,6 +34,8 @@
#include "LRUCacheTest.h"
#include "ExpireCacheTest.h"
#include "ExpireLRUCacheTest.h"
#include "UniqueExpireCacheTest.h"
#include "UniqueExpireLRUCacheTest.h"
CppUnit::Test* CacheTestSuite::suite()
{
@@ -41,7 +43,9 @@ CppUnit::Test* CacheTestSuite::suite()
pSuite->addTest(LRUCacheTest::suite());
pSuite->addTest(ExpireCacheTest::suite());
pSuite->addTest(UniqueExpireCacheTest::suite());
pSuite->addTest(ExpireLRUCacheTest::suite());
pSuite->addTest(UniqueExpireLRUCacheTest::suite());
return pSuite;
}

View File

@@ -1,7 +1,7 @@
//
// ExpireCacheTest.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireCacheTest.cpp#2 $
// $Id: //poco/1.2/Foundation/testsuite/src/ExpireCacheTest.cpp#3 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -99,7 +99,9 @@ void ExpireCacheTest::testExpireN()
SharedPtr<int> tmp = aCache.get(1);
assert (!tmp.isNull());
assert (*tmp == 2);
assert (aCache.size() == 1);
Thread::sleep(DURWAIT);
assert (aCache.size() == 0);
assert (!aCache.has(1));
// tmp must still be valid, access it

View File

@@ -1,7 +1,7 @@
//
// FileTest.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/FileTest.cpp#1 $
// $Id: //poco/1.2/Foundation/testsuite/src/FileTest.cpp#3 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -269,6 +269,24 @@ void FileTest::testCompare()
}
void FileTest::testRootDir()
{
#if defined(POCO_OS_FAMILY_WINDOWS)
File f1("/");
File f2("c:/");
File f3("c:\\");
File f4("\\");
assert (f1.exists());
assert (f2.exists());
assert (f3.exists());
assert (f4.exists());
#else
File f1("/");
assert (f1.exists());
#endif
}
void FileTest::testSwap()
{
File f1("abc.txt");
@@ -429,6 +447,7 @@ CppUnit::Test* FileTest::suite()
CppUnit_addTest(pSuite, FileTest, testCopy);
CppUnit_addTest(pSuite, FileTest, testMove);
CppUnit_addTest(pSuite, FileTest, testRename);
CppUnit_addTest(pSuite, FileTest, testRootDir);
return pSuite;
}

View File

@@ -1,7 +1,7 @@
//
// FileTest.h
//
// $Id: //poco/1.2/Foundation/testsuite/src/FileTest.h#1 $
// $Id: //poco/1.2/Foundation/testsuite/src/FileTest.h#2 $
//
// Definition of the FileTest class.
//
@@ -56,6 +56,7 @@ public:
void testCopy();
void testMove();
void testRename();
void testRootDir();
void setUp();
void tearDown();

View File

@@ -1,7 +1,7 @@
//
// LRUCacheTest.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/LRUCacheTest.cpp#3 $
// $Id: //poco/1.2/Foundation/testsuite/src/LRUCacheTest.cpp#4 $
//
// Copyright (c) 2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -55,10 +55,12 @@ void LRUCacheTest::testClear()
{
LRUCache<int, int> aCache(3);
assert (aCache.size() == 0);
assert (aCache.getAllKeys().size() == 0);
aCache.add(1, 2);
aCache.add(3, 4);
aCache.add(5, 6);
assert (aCache.size() == 3);
assert (aCache.getAllKeys().size() == 3);
assert (aCache.has(1));
assert (aCache.has(3));
assert (aCache.has(5));

View File

@@ -1,7 +1,7 @@
//
// PatternFormatterTest.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/PatternFormatterTest.cpp#1 $
// $Id: //poco/1.2/Foundation/testsuite/src/PatternFormatterTest.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -88,6 +88,16 @@ void PatternFormatterTest::testPatternFormatter()
fmt.format(msg, result);
assert (result.find("2005-01-01 ") == 0);
assert (result.find(":TestSource]3-Test message text") != std::string::npos);
result.clear();
fmt.setProperty("pattern", "%[testParam]");
fmt.format(msg, result);
assert (result == "Test Parameter");
result.clear();
fmt.setProperty("pattern", "%[testParam] %p");
fmt.format(msg, result);
assert (result == "Test Parameter Error");
}

View File

@@ -1,7 +1,7 @@
//
// RegularExpressionTest.cpp
//
// $Id: //poco/1.2/Foundation/testsuite/src/RegularExpressionTest.cpp#1 $
// $Id: //poco/1.2/Foundation/testsuite/src/RegularExpressionTest.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -149,6 +149,15 @@ void RegularExpressionTest::testMatch5()
}
void RegularExpressionTest::testMatch6()
{
RegularExpression expr("^([a-z]*)?$");
assert (expr.match("", 0, 0));
assert (expr.match("abcde", 0, 0));
assert (!expr.match("123", 0, 0));
}
void RegularExpressionTest::testExtract()
{
RegularExpression re("[0-9]+");
@@ -296,6 +305,7 @@ CppUnit::Test* RegularExpressionTest::suite()
CppUnit_addTest(pSuite, RegularExpressionTest, testMatch3);
CppUnit_addTest(pSuite, RegularExpressionTest, testMatch4);
CppUnit_addTest(pSuite, RegularExpressionTest, testMatch5);
CppUnit_addTest(pSuite, RegularExpressionTest, testMatch6);
CppUnit_addTest(pSuite, RegularExpressionTest, testExtract);
CppUnit_addTest(pSuite, RegularExpressionTest, testSplit1);
CppUnit_addTest(pSuite, RegularExpressionTest, testSplit2);

View File

@@ -1,7 +1,7 @@
//
// RegularExpressionTest.h
//
// $Id: //poco/1.2/Foundation/testsuite/src/RegularExpressionTest.h#1 $
// $Id: //poco/1.2/Foundation/testsuite/src/RegularExpressionTest.h#2 $
//
// Definition of the RegularExpressionTest class.
//
@@ -52,6 +52,7 @@ public:
void testMatch3();
void testMatch4();
void testMatch5();
void testMatch6();
void testExtract();
void testSplit1();
void testSplit2();

View File

@@ -182,6 +182,7 @@ Foundation/include/Poco/EventLogChannel.h
Foundation/include/Poco/Event_POSIX.h
Foundation/include/Poco/Event_WIN32.h
Foundation/include/Poco/Exception.h
Foundation/include/Poco/ExpirationDecorator.h
Foundation/include/Poco/Expire.h
Foundation/include/Poco/ExpireCache.h
Foundation/include/Poco/ExpireLRUCache.h
@@ -347,6 +348,9 @@ Foundation/include/Poco/Token.h
Foundation/include/Poco/Types.h
Foundation/include/Poco/UnbufferedStreamBuf.h
Foundation/include/Poco/UnicodeConverter.h
Foundation/include/Poco/UniqueExpireCache.h
Foundation/include/Poco/UniqueExpireLRUCache.h
Foundation/include/Poco/UniqueExpireStrategy.h
Foundation/include/Poco/URI.h
Foundation/include/Poco/URIStreamFactory.h
Foundation/include/Poco/URIStreamOpener.h
@@ -912,6 +916,10 @@ Foundation/testsuite/src/TimestampTest.cpp
Foundation/testsuite/src/TimestampTest.h
Foundation/testsuite/src/TimezoneTest.cpp
Foundation/testsuite/src/TimezoneTest.h
Foundation/testsuite/src/UniqueExpireCacheTest.cpp
Foundation/testsuite/src/UniqueExpireCacheTest.h
Foundation/testsuite/src/UniqueExpireLRUCacheTest.cpp
Foundation/testsuite/src/UniqueExpireLRUCacheTest.h
Foundation/testsuite/src/URIStreamOpenerTest.cpp
Foundation/testsuite/src/URIStreamOpenerTest.h
Foundation/testsuite/src/URITest.cpp

View File

@@ -15,9 +15,9 @@ ifndef POCO_PREFIX
export POCO_PREFIX=/usr/local
endif
.PHONY: all libs cppunit tests samples install
.PHONY: all libexecs cppunit tests samples install
all: libs tests samples
all: libexecs tests samples
INSTALLDIR = $(DESTDIR)$(POCO_PREFIX)
COMPONENTS = Foundation XML Util Net
@@ -25,54 +25,60 @@ COMPONENTS = Foundation XML Util Net
cppunit:
$(MAKE) -C $(POCO_BASE)/CppUnit
install: libs
install: libexecs
mkdir -p $(INSTALLDIR)/include/Poco
mkdir -p $(INSTALLDIR)/lib
mkdir -p $(INSTALLDIR)/bin
for comp in $(COMPONENTS) ; do \
cp -Rf $(POCO_BASE)/$$comp/include/* $(INSTALLDIR)/include/ ; \
if [ -d "$(POCO_BASE)/$$comp/include" ] ; then \
cp -Rf $(POCO_BASE)/$$comp/include/* $(INSTALLDIR)/include/ ; \
fi ; \
if [ -d "$(POCO_BUILD)/$$comp/bin" ] ; then \
find $(POCO_BUILD)/$$comp/bin -perm -700 -type f -exec cp -Rf {} $(INSTALLDIR)/bin \; ; \
fi ; \
done
find $(POCO_BUILD)/lib -name "libPoco*" -exec cp -Rf {} $(INSTALLDIR)/lib \;
.PHONY: Foundation-lib XML-lib Util-lib Net-lib
.PHONY: Foundation-libexec XML-libexec Util-libexec Net-libexec
.PHONY: Foundation-tests XML-tests Util-tests Net-tests
.PHONY: Foundation-samples XML-samples Util-samples Net-samples
libs: Foundation-lib XML-lib Util-lib Net-lib
libexecs: Foundation-libexec XML-libexec Util-libexec Net-libexec
tests: Foundation-tests XML-tests Util-tests Net-tests
samples: Foundation-samples XML-samples Util-samples Net-samples
Foundation-lib:
Foundation-libexec:
$(MAKE) -C $(POCO_BASE)/Foundation
Foundation-tests: Foundation-lib cppunit
Foundation-tests: Foundation-libexec cppunit
$(MAKE) -C $(POCO_BASE)/Foundation/testsuite
Foundation-samples: Foundation-lib
Foundation-samples: Foundation-libexec
$(MAKE) -C $(POCO_BASE)/Foundation/samples
XML-lib: Foundation-lib
XML-libexec: Foundation-libexec
$(MAKE) -C $(POCO_BASE)/XML
XML-tests: XML-lib cppunit
XML-tests: XML-libexec cppunit
$(MAKE) -C $(POCO_BASE)/XML/testsuite
XML-samples: XML-lib
XML-samples: XML-libexec
$(MAKE) -C $(POCO_BASE)/XML/samples
Util-lib: Foundation-lib XML-lib
Util-libexec: Foundation-libexec XML-libexec
$(MAKE) -C $(POCO_BASE)/Util
Util-tests: Util-lib cppunit
Util-tests: Util-libexec cppunit
$(MAKE) -C $(POCO_BASE)/Util/testsuite
Util-samples: Util-lib
Util-samples: Util-libexec
$(MAKE) -C $(POCO_BASE)/Util/samples
Net-lib: Foundation-lib
Net-libexec: Foundation-libexec XML-libexec Util-libexec
$(MAKE) -C $(POCO_BASE)/Net
Net-tests: Net-lib cppunit
Net-tests: Net-libexec cppunit
$(MAKE) -C $(POCO_BASE)/Net/testsuite
Net-samples: Net-lib
Net-samples: Net-libexec Foundation-libexec XML-libexec Util-libexec
$(MAKE) -C $(POCO_BASE)/Net/samples

4
NEWS
View File

@@ -1,4 +1,4 @@
Release 1.2.5 (2006-10-23)
Release 1.2.7 (2006-12-07)
==========================
This release contains bugfixes and minor enchancements.
@@ -124,4 +124,4 @@ Please refer to the README file for more information and instructions for
building the libraries.
--
$Id: //poco/1.2/dist/NEWS#6 $
$Id: //poco/1.2/dist/NEWS#9 $

View File

@@ -1,7 +1,7 @@
//
// SMTPClientSession.h
//
// $Id: //poco/1.2/Net/include/Poco/Net/SMTPClientSession.h#1 $
// $Id: //poco/1.2/Net/include/Poco/Net/SMTPClientSession.h#2 $
//
// Library: Net
// Package: Mail
@@ -94,6 +94,15 @@ public:
void login();
/// Calls login(hostname) with the current host name.
void open();
/// Reads the initial response from the SMTP server.
///
/// Usually called implicitly through login(), but can
/// also be called explicitly to implement different forms
/// of SMTP authentication.
///
/// Does nothing if called more than once.
void close();
/// Sends a QUIT command and closes the connection to the server.
///

View File

@@ -1,7 +1,7 @@
//
// TCPServer.h
//
// $Id: //poco/1.2/Net/include/Poco/Net/TCPServer.h#1 $
// $Id: //poco/1.2/Net/include/Poco/Net/TCPServer.h#2 $
//
// Library: Net
// Package: TCPServer
@@ -152,17 +152,20 @@ public:
/// Returns the total number of handled connections.
int currentConnections() const;
/// Returns the number of currently handled connections.
/// Returns the number of currently handled connections.
int maxConcurrentConnections() const;
/// Returns the maximum number of concurrently handled connections.
int queuedConnections() const;
/// Returns the number of queued connections.
/// Returns the number of queued connections.
int refusedConnections() const;
/// Returns the number of refused connections.
Poco::UInt16 port() const;
/// Returns the port the server socket listens to
protected:
void run();
/// Runs the server. The server will run until
@@ -185,6 +188,12 @@ private:
};
inline Poco::UInt16 TCPServer::port() const
{
return _socket.address().port();
}
} } // namespace Poco::Net

View File

@@ -1,7 +1,7 @@
//
// HTTPTimeServer.cpp
//
// $Id: //poco/1.2/Net/samples/HTTPTimeServer/src/HTTPTimeServer.cpp#1 $
// $Id: //poco/1.2/Net/samples/HTTPTimeServer/src/HTTPTimeServer.cpp#2 $
//
// This sample demonstrates the HTTPServer and related classes.
//

View File

@@ -1,7 +1,7 @@
//
// dict.cpp
//
// $Id: //poco/1.2/Net/samples/dict/src/dict.cpp#1 $
// $Id: //poco/1.2/Net/samples/dict/src/dict.cpp#2 $
//
// This sample demonstrates the StreamSocket and SocketStream classes.
//

View File

@@ -1,7 +1,7 @@
//
// MulticastSocket.cpp
//
// $Id: //poco/1.2/Net/src/MulticastSocket.cpp#1 $
// $Id: //poco/1.2/Net/src/MulticastSocket.cpp#2 $
//
// Library: Net
// Package: Sockets
@@ -185,7 +185,7 @@ void MulticastSocket::setTimeToLive(unsigned value)
unsigned MulticastSocket::getTimeToLive() const
{
unsigned ttl;
unsigned ttl(0);
if (address().af() == AF_INET)
{
unsigned char cttl;

View File

@@ -1,7 +1,7 @@
//
// SMTPClientSession.cpp
//
// $Id: //poco/1.2/Net/src/SMTPClientSession.cpp#1 $
// $Id: //poco/1.2/Net/src/SMTPClientSession.cpp#2 $
//
// Library: Net
// Package: Mail
@@ -53,14 +53,14 @@ namespace Net {
SMTPClientSession::SMTPClientSession(const StreamSocket& socket):
_socket(socket),
_isOpen(true)
_isOpen(false)
{
}
SMTPClientSession::SMTPClientSession(const std::string& host, Poco::UInt16 port):
_socket(SocketAddress(host, port)),
_isOpen(true)
_isOpen(false)
{
}
@@ -91,10 +91,9 @@ Poco::Timespan SMTPClientSession::getTimeout() const
void SMTPClientSession::login(const std::string& hostname)
{
open();
std::string response;
int status = _socket.receiveStatusMessage(response);
if (!isPositiveCompletion(status)) throw SMTPException("The mail service is unavailable", response);
status = sendCommand("EHLO", hostname, response);
int status = sendCommand("EHLO", hostname, response);
if (isPermanentNegative(status))
status = sendCommand("HELO", hostname, response);
if (!isPositiveCompletion(status)) throw SMTPException("Login failed", response);
@@ -107,6 +106,18 @@ void SMTPClientSession::login()
}
void SMTPClientSession::open()
{
if (!_isOpen)
{
std::string response;
int status = _socket.receiveStatusMessage(response);
if (!isPositiveCompletion(status)) throw SMTPException("The mail service is unavailable", response);
_isOpen = true;
}
}
void SMTPClientSession::close()
{
if (_isOpen)

View File

@@ -1,7 +1,7 @@
//
// Application.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Application.h#2 $
// $Id: //poco/1.2/Util/include/Poco/Util/Application.h#3 $
//
// Library: Util
// Package: Application
@@ -78,14 +78,21 @@ class Util_API Application: public Subsystem
/// There may be at most one instance of the Application class
/// in a process.
///
/// The Application class maintains a LayeredConfiguration (available
/// via the config() member function) consisting of:
/// - a MapConfiguration (priority -100) storing application-specific
/// properties, as well as properties from bound command line arguments.
/// - a SystemConfiguration (priority 100)
/// - the configurations loaded with loadConfiguration().
///
/// The Application class sets a few default properties in
/// its configuration (available via the config() method).
/// These are:
/// its configuration. These are:
/// - application.path: the absolute path to application executable
/// - application.name: the file name of the application executable
/// - application.baseName: the file name (excluding extension) of the application executable
/// - application.dir: the path to the directory where the application executable resides
/// - application.configDir: the path to the directory where the last configuration file loaded with loadConfiguration() was found.
///
/// If loadConfiguration() has never been called, application.configDir will be equal to application.dir.
///
/// The POCO_APP_MAIN macro can be used to implement main(argc, argv).
@@ -115,6 +122,13 @@ public:
EXIT_CONFIG = 78 /// configuration error
};
enum ConfigPriority
{
PRIO_APPLICATION = -100,
PRIO_DEFAULT = 0,
PRIO_SYSTEM = 100
};
Application();
/// Creates the Application.
@@ -152,10 +166,16 @@ public:
void setUnixOptions(bool flag);
/// Specify whether command line option handling is Unix-style
/// (flag == true; default) or Windows/OpenVMS-style (flag == false).
///
/// This member function should be called from the constructor of
/// a subclass to be effective.
int loadConfiguration();
int loadConfiguration(int priority = PRIO_DEFAULT);
/// Loads configuration information from a default location.
///
/// The configuration(s) will be added to the application's
/// LayeredConfiguration with the given priority.
///
/// The configuration file(s) must be located in the same directory
/// as the executable or a parent directory of it, and must have the
/// same base name as the executable, with one of the following extensions:
@@ -179,7 +199,7 @@ public:
/// This method must not be called before initialize(argc, argv)
/// has been called.
void loadConfiguration(const std::string& path);
void loadConfiguration(const std::string& path, int priority = PRIO_DEFAULT);
/// Loads configuration information from the file specified by
/// the given path. The file type is determined by the file
/// extension. The following extensions are supported:
@@ -188,6 +208,10 @@ public:
/// - .xml - XML file (XMLConfiguration)
///
/// Extensions are not case sensitive.
///
/// The configuration will be added to the application's
/// LayeredConfiguration with the given priority.
///
template <class C> C& getSubsystem() const;
/// Returns a reference to the subsystem of the class
@@ -354,8 +378,9 @@ template <class C> C& Application::getSubsystem() const
{
for (SubsystemVec::const_iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)
{
if (dynamic_cast<C*>(*it))
return **it;
Poco::AutoPtr<C> pSubsystem(it->cast<C>());
if (!pSubsystem.isNull())
return *pSubsystem;
}
throw Poco::NotFoundException("The subsystem has not been registered");
}

View File

@@ -1,7 +1,7 @@
//
// LayeredConfiguration.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/LayeredConfiguration.h#1 $
// $Id: //poco/1.2/Util/include/Poco/Util/LayeredConfiguration.h#2 $
//
// Library: Util
// Package: Configuration
@@ -43,7 +43,7 @@
#include "Poco/Util/Util.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/AutoPtr.h"
#include <vector>
#include <list>
namespace Poco {
@@ -54,53 +54,106 @@ class Util_API LayeredConfiguration: public AbstractConfiguration
/// A LayeredConfiguration consists of a number of AbstractConfigurations.
///
/// When reading a configuration property in a LayeredConfiguration,
/// all added configurations are searched, from the first added to the last added.
/// all added configurations are searched, in order of their priority.
/// Configurations with lower priority values have precedence.
///
/// When setting a property, the property is always written to the last configuration
/// added. If no configurations have been added to the LayeredConfiguration, and an
/// When setting a property, the property is always written to the first writeable
/// configuration (see addWriteable()).
/// If no writeable configuration has been added to the LayeredConfiguration, and an
/// attempt is made to set a property, a RuntimeException is thrown.
///
/// Every configuration added to the LayeredConfiguration has a priority value.
/// The priority determines the position where the configuration is inserted,
/// with lower priority values coming before higher priority values.
///
/// If no priority is specified, a priority of 0 is assumed.
{
public:
LayeredConfiguration();
/// Creates the LayeredConfiguration.
void add(AbstractConfiguration* pConfig);
/// Adds a configuration to the back of the LayeredConfiguration.
/// Adds a read-only configuration to the back of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
void add(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the back of the LayeredConfiguration.
/// Adds a read-only configuration to the back of the LayeredConfiguration.
/// If shared is false, the LayeredConfiguration takes ownership
/// of the given configuration (and the configuration's reference
/// count remains unchanged).
void addFront(AbstractConfiguration* pConfig);
/// Adds a configuration to the front of the LayeredConfiguration.
void add(AbstractConfiguration* pConfig, int priority);
/// Adds a read-only configuration to the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
void add(AbstractConfiguration* pConfig, int priority, bool shared);
/// Adds a read-only configuration the LayeredConfiguration.
/// If shared is false, the LayeredConfiguration takes ownership
/// of the given configuration (and the configuration's reference
/// count remains unchanged).
void add(AbstractConfiguration* pConfig, int priority, bool writeable, bool shared);
/// Adds a configuration to the LayeredConfiguration.
/// If shared is false, the LayeredConfiguration takes ownership
/// of the given configuration (and the configuration's reference
/// count remains unchanged).
void addWriteable(AbstractConfiguration* pConfig, int priority);
/// Adds a writeable configuration to the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
void addWriteable(AbstractConfiguration* pConfig, int priority, bool shared);
/// Adds a writeable configuration to the LayeredConfiguration.
/// If shared is false, the LayeredConfiguration takes ownership
/// of the given configuration (and the configuration's reference
/// count remains unchanged).
//@ deprecated
void addFront(AbstractConfiguration* pConfig);
/// Adds a read-only configuration to the front of the LayeredConfiguration.
/// The LayeredConfiguration does not take ownership of the given
/// configuration. In other words, the configuration's reference
/// count is incremented.
//@ deprecated
void addFront(AbstractConfiguration* pConfig, bool shared);
/// Adds a configuration to the front of the LayeredConfiguration.
/// Adds a read-only configuration to the front of the LayeredConfiguration.
/// If shared is true, the LayeredConfiguration takes ownership
/// of the given configuration.
protected:
typedef Poco::AutoPtr<AbstractConfiguration> ConfigPtr;
struct ConfigItem
{
ConfigPtr pConfig;
int priority;
bool writeable;
};
bool getRaw(const std::string& key, std::string& value) const;
void setRaw(const std::string& key, const std::string& value);
void enumerate(const std::string& key, Keys& range) const;
int lowest() const;
int highest() const;
void insert(const ConfigItem& item);
~LayeredConfiguration();
private:
LayeredConfiguration(const LayeredConfiguration&);
LayeredConfiguration& operator = (const LayeredConfiguration&);
typedef Poco::AutoPtr<AbstractConfiguration> ConfigPtr;
typedef std::vector<ConfigPtr> ConfigVec;
typedef std::list<ConfigItem> ConfigList;
ConfigVec _configs;
ConfigList _configs;
};

View File

@@ -1,7 +1,7 @@
//
// Option.h
//
// $Id: //poco/1.2/Util/include/Poco/Util/Option.h#2 $
// $Id: //poco/1.2/Util/include/Poco/Util/Option.h#3 $
//
// Library: Util
// Package: Options
@@ -50,6 +50,7 @@ namespace Util {
class Application;
class Validator;
class AbstractConfiguration;
class Util_API Option
@@ -146,6 +147,12 @@ public:
/// Binds the option to the configuration property with the given name.
///
/// The configuration will automatically receive the option's argument.
Option& binding(const std::string& propertyName, AbstractConfiguration* pConfig);
/// Binds the option to the configuration property with the given name,
/// using the given AbstractConfiguration.
///
/// The configuration will automatically receive the option's argument.
Option& callback(const AbstractOptionCallback& cb);
/// Binds the option to the given method.
@@ -204,6 +211,9 @@ public:
/// Returns the option's Validator, if one has been specified,
/// or NULL otherwise.
AbstractConfiguration* config() const;
/// Returns the configuration, if specified, or NULL otherwise.
bool matchesShort(const std::string& option) const;
/// Returns true if the given option string matches the
/// short name.
@@ -251,6 +261,7 @@ private:
std::string _binding;
Validator* _pValidator;
AbstractOptionCallback* _pCallback;
AbstractConfiguration* _pConfig;
};
@@ -331,6 +342,12 @@ inline Validator* Option::validator() const
}
inline AbstractConfiguration* Option::config() const
{
return _pConfig;
}
} } // namespace Poco::Util

View File

@@ -1,7 +1,7 @@
//
// Application.cpp
//
// $Id: //poco/1.2/Util/src/Application.cpp#1 $
// $Id: //poco/1.2/Util/src/Application.cpp#2 $
//
// Library: Util
// Package: Application
@@ -121,8 +121,9 @@ void Application::setup()
{
poco_assert (_pInstance == 0);
_pConfig->add(new SystemConfiguration, false);
_pConfig->add(new MapConfiguration, false);
_pConfig->add(new SystemConfiguration, PRIO_SYSTEM, false, false);
_pConfig->add(new MapConfiguration, PRIO_APPLICATION, true, false);
addSubsystem(new LoggingSubsystem);
#if defined(POCO_OS_FAMILY_UNIX)
@@ -238,7 +239,7 @@ void Application::setUnixOptions(bool flag)
}
int Application::loadConfiguration()
int Application::loadConfiguration(int priority)
{
int n = 0;
Path appPath;
@@ -246,17 +247,17 @@ int Application::loadConfiguration()
Path cfgPath;
if (findAppConfigFile(appPath.getBaseName(), "properties", cfgPath))
{
_pConfig->addFront(new PropertyFileConfiguration(cfgPath.toString()), false);
_pConfig->add(new PropertyFileConfiguration(cfgPath.toString()), priority, false, false);
++n;
}
if (findAppConfigFile(appPath.getBaseName(), "ini", cfgPath))
{
_pConfig->addFront(new IniFileConfiguration(cfgPath.toString()), false);
_pConfig->add(new IniFileConfiguration(cfgPath.toString()), priority, false, false);
++n;
}
if (findAppConfigFile(appPath.getBaseName(), "xml", cfgPath))
{
_pConfig->addFront(new XMLConfiguration(cfgPath.toString()), false);
_pConfig->add(new XMLConfiguration(cfgPath.toString()), priority, false, false);
++n;
}
if (n > 0)
@@ -267,16 +268,16 @@ int Application::loadConfiguration()
}
void Application::loadConfiguration(const std::string& path)
void Application::loadConfiguration(const std::string& path, int priority)
{
Path confPath(path);
std::string ext = confPath.getExtension();
if (icompare(ext, "properties") == 0)
_pConfig->addFront(new PropertyFileConfiguration(confPath.toString()), false);
_pConfig->add(new PropertyFileConfiguration(confPath.toString()), priority, false, false);
else if (icompare(ext, "ini") == 0)
_pConfig->addFront(new IniFileConfiguration(confPath.toString()), false);
_pConfig->add(new IniFileConfiguration(confPath.toString()), priority, false, false);
else if (icompare(ext, "xml") == 0)
_pConfig->addFront(new XMLConfiguration(confPath.toString()), false);
_pConfig->add(new XMLConfiguration(confPath.toString()), priority, false, false);
else
throw Poco::InvalidArgumentException("Unsupported configuration file type", ext);
}
@@ -480,7 +481,9 @@ void Application::handleOption(const std::string& name, const std::string& value
}
if (!option.binding().empty())
{
config().setString(option.binding(), value);
AbstractConfiguration* pConfig = option.config();
if (!pConfig) pConfig = &config();
pConfig->setString(option.binding(), value);
}
if (option.callback())
{

View File

@@ -1,7 +1,7 @@
//
// LayeredConfiguration.cpp
//
// $Id: //poco/1.2/Util/src/LayeredConfiguration.cpp#1 $
// $Id: //poco/1.2/Util/src/LayeredConfiguration.cpp#2 $
//
// Library: Util
// Package: Configuration
@@ -59,37 +59,72 @@ LayeredConfiguration::~LayeredConfiguration()
void LayeredConfiguration::add(AbstractConfiguration* pConfig)
{
add(pConfig, true);
add(pConfig, highest(), false, true);
}
void LayeredConfiguration::add(AbstractConfiguration* pConfig, bool shared)
{
poco_check_ptr (pConfig);
add(pConfig, highest(), false, shared);
}
_configs.push_back(ConfigPtr(pConfig, shared));
void LayeredConfiguration::add(AbstractConfiguration* pConfig, int priority)
{
add(pConfig, priority, false, true);
}
void LayeredConfiguration::add(AbstractConfiguration* pConfig, int priority, bool shared)
{
add(pConfig, priority, false, shared);
}
void LayeredConfiguration::addFront(AbstractConfiguration* pConfig)
{
addFront(pConfig, true);
add(pConfig, lowest(), false, true);
}
void LayeredConfiguration::addFront(AbstractConfiguration* pConfig, bool shared)
{
poco_check_ptr (pConfig);
add(pConfig, lowest(), false, shared);
}
_configs.insert(_configs.begin(), ConfigPtr(pConfig, shared));
void LayeredConfiguration::addWriteable(AbstractConfiguration* pConfig, int priority)
{
add(pConfig, priority, true, true);
}
void LayeredConfiguration::addWriteable(AbstractConfiguration* pConfig, int priority, bool shared)
{
add(pConfig, priority, true, shared);
}
void LayeredConfiguration::add(AbstractConfiguration* pConfig, int priority, bool writeable, bool shared)
{
ConfigItem item;
item.pConfig = ConfigPtr(pConfig, shared);
item.priority = priority;
item.writeable = writeable;
ConfigList::iterator it = _configs.begin();
while (it != _configs.end() && it->priority < priority)
++it;
_configs.insert(it, item);
}
bool LayeredConfiguration::getRaw(const std::string& key, std::string& value) const
{
for (ConfigVec::const_iterator it = _configs.begin(); it != _configs.end(); ++it)
for (ConfigList::const_iterator it = _configs.begin(); it != _configs.end(); ++it)
{
if ((*it)->getRaw(key, value))
if (it->pConfig->getRaw(key, value))
return true;
}
return false;
@@ -98,20 +133,25 @@ bool LayeredConfiguration::getRaw(const std::string& key, std::string& value) co
void LayeredConfiguration::setRaw(const std::string& key, const std::string& value)
{
if (!_configs.empty())
_configs.back()->setRaw(key, value);
else
throw RuntimeException("No configuration object to store the property", key);
for (ConfigList::iterator it = _configs.begin(); it != _configs.end(); ++it)
{
if (it->writeable)
{
it->pConfig->setRaw(key, value);
return;
}
}
throw RuntimeException("No writeable configuration object to store the property", key);
}
void LayeredConfiguration::enumerate(const std::string& key, Keys& range) const
{
std::set<std::string> keys;
for (ConfigVec::const_iterator itc = _configs.begin(); itc != _configs.end(); ++itc)
for (ConfigList::const_iterator itc = _configs.begin(); itc != _configs.end(); ++itc)
{
Keys partRange;
(*itc)->enumerate(key, partRange);
itc->pConfig->enumerate(key, partRange);
for (Keys::const_iterator itr = partRange.begin(); itr != partRange.end(); ++itr)
{
if (keys.find(*itr) == keys.end())
@@ -124,4 +164,22 @@ void LayeredConfiguration::enumerate(const std::string& key, Keys& range) const
}
int LayeredConfiguration::lowest() const
{
if (_configs.empty())
return 0;
else
return _configs.front().priority - 1;
}
int LayeredConfiguration::highest() const
{
if (_configs.empty())
return 0;
else
return _configs.back().priority + 1;
}
} } // namespace Poco::Util

View File

@@ -1,7 +1,7 @@
//
// Option.cpp
//
// $Id: //poco/1.2/Util/src/Option.cpp#2 $
// $Id: //poco/1.2/Util/src/Option.cpp#3 $
//
// Library: Util
// Package: Options
@@ -37,6 +37,7 @@
#include "Poco/Util/Option.h"
#include "Poco/Util/OptionException.h"
#include "Poco/Util/Validator.h"
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/String.h"
#include <algorithm>
@@ -53,7 +54,8 @@ Option::Option():
_repeatable(false),
_argRequired(false),
_pValidator(0),
_pCallback(0)
_pCallback(0),
_pConfig(0)
{
}
@@ -69,10 +71,12 @@ Option::Option(const Option& option):
_group(option._group),
_binding(option._binding),
_pValidator(option._pValidator),
_pCallback(option._pCallback)
_pCallback(option._pCallback),
_pConfig(option._pConfig)
{
if (_pValidator) _pValidator->duplicate();
if (_pCallback) _pCallback = _pCallback->clone();
if (_pConfig) _pConfig->duplicate();
}
@@ -83,7 +87,8 @@ Option::Option(const std::string& fullName, const std::string& shortName):
_repeatable(false),
_argRequired(false),
_pValidator(0),
_pCallback(0)
_pCallback(0),
_pConfig(0)
{
}
@@ -96,7 +101,8 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
_repeatable(false),
_argRequired(false),
_pValidator(0),
_pCallback(0)
_pCallback(0),
_pConfig(0)
{
}
@@ -110,7 +116,8 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
_argName(argName),
_argRequired(argOptional),
_pValidator(0),
_pCallback(0)
_pCallback(0),
_pConfig(0)
{
}
@@ -118,6 +125,7 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
Option::~Option()
{
if (_pValidator) _pValidator->release();
if (_pConfig) _pConfig->release();
delete _pCallback;
}
@@ -146,6 +154,7 @@ void Option::swap(Option& option)
std::swap(_binding, option._binding);
std::swap(_pValidator, option._pValidator);
std::swap(_pCallback, option._pCallback);
std::swap(_pConfig, option._pConfig);
}
@@ -208,8 +217,17 @@ Option& Option::group(const std::string& group)
Option& Option::binding(const std::string& propertyName)
{
return binding(propertyName, 0);
}
Option& Option::binding(const std::string& propertyName, AbstractConfiguration* pConfig)
{
_binding = propertyName;
if (_pConfig) _pConfig->release();
_pConfig = pConfig;
if (_pConfig) _pConfig->duplicate();
return *this;
}

View File

@@ -1,7 +1,7 @@
//
// ServerApplication.cpp
//
// $Id: //poco/1.2/Util/src/ServerApplication.cpp#1 $
// $Id: //poco/1.2/Util/src/ServerApplication.cpp#2 $
//
// Library: Util
// Package: Application
@@ -403,14 +403,18 @@ void ServerApplication::waitForTerminationRequest()
int ServerApplication::run(int argc, char** argv)
{
if (isDaemon(argc, argv))
bool runAsDaemon = isDaemon(argc, argv);
if (runAsDaemon)
{
beDaemon();
}
try
{
init(argc, argv);
chdir("/");
if (runAsDaemon)
{
chdir("/");
}
}
catch (Exception& exc)
{

View File

@@ -1,7 +1,7 @@
//
// WinRegistryConfiguration.cpp
//
// $Id: //poco/1.2/Util/src/WinRegistryConfiguration.cpp#1 $
// $Id: //poco/1.2/Util/src/WinRegistryConfiguration.cpp#2 $
//
// Library: Util
// Package: Windows
@@ -47,7 +47,8 @@ namespace Util {
WinRegistryConfiguration::WinRegistryConfiguration(const std::string& rootPath): _rootPath(rootPath)
{
// rootPath must end with backslash
if (*(--_rootPath.end()) != '\\')
std::string::iterator it = _rootPath.end();
if (*(--it) != '\\')
_rootPath.append("\\");
}

View File

@@ -1,7 +1,7 @@
//
// LayeredConfigurationTest.cpp
//
// $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.cpp#1 $
// $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -95,7 +95,7 @@ void LayeredConfigurationTest::testOneLayer()
pMC->setString("prop1", "value1");
pMC->setString("prop2", "value2");
pLC->add(pMC);
pLC->addWriteable(pMC, 0);
AbstractConfiguration::Keys keys;
pLC->keys(keys);
@@ -122,8 +122,8 @@ void LayeredConfigurationTest::testTwoLayers()
pMC2->setString("prop2", "value3");
pMC2->setString("prop3", "value4");
pLC->add(pMC1);
pLC->add(pMC2);
pLC->add(pMC1, 0);
pLC->addWriteable(pMC2, 1);
AbstractConfiguration::Keys keys;
pLC->keys(keys);
@@ -148,6 +148,33 @@ void LayeredConfigurationTest::testTwoLayers()
}
void LayeredConfigurationTest::testThreeLayers()
{
AutoPtr<LayeredConfiguration> pLC = new LayeredConfiguration;
AutoPtr<MapConfiguration> pMC1 = new MapConfiguration;
AutoPtr<MapConfiguration> pMC2 = new MapConfiguration;
AutoPtr<MapConfiguration> pMC3 = new MapConfiguration;
pMC1->setString("prop1", "value1");
pMC1->setString("prop2", "value2");
pMC1->setString("prop3", "value3");
pMC2->setString("prop2", "value4");
pMC2->setString("prop4", "value5");
pMC3->setString("prop5", "value6");
pMC3->setString("prop1", "value7");
pLC->add(pMC1, 0);
pLC->add(pMC2, 1);
pLC->add(pMC3, -1);
assert (pLC->getString("prop1") == "value7");
assert (pLC->getString("prop2") == "value2");
assert (pLC->getString("prop3") == "value3");
assert (pLC->getString("prop4") == "value5");
assert (pLC->getString("prop5") == "value6");
}
void LayeredConfigurationTest::setUp()
{
}
@@ -165,6 +192,7 @@ CppUnit::Test* LayeredConfigurationTest::suite()
CppUnit_addTest(pSuite, LayeredConfigurationTest, testEmpty);
CppUnit_addTest(pSuite, LayeredConfigurationTest, testOneLayer);
CppUnit_addTest(pSuite, LayeredConfigurationTest, testTwoLayers);
CppUnit_addTest(pSuite, LayeredConfigurationTest, testThreeLayers);
return pSuite;
}

View File

@@ -1,7 +1,7 @@
//
// LayeredConfigurationTest.h
//
// $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.h#1 $
// $Id: //poco/1.2/Util/testsuite/src/LayeredConfigurationTest.h#2 $
//
// Definition of the LayeredConfigurationTest class.
//
@@ -49,6 +49,7 @@ public:
void testEmpty();
void testOneLayer();
void testTwoLayers();
void testThreeLayers();
void setUp();
void tearDown();

View File

@@ -1,7 +1,7 @@
//
// UtilTestSuite.cpp
//
// $Id: //poco/1.2/Util/testsuite/src/UtilTestSuite.cpp#1 $
// $Id: //poco/1.2/Util/testsuite/src/UtilTestSuite.cpp#2 $
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
@@ -40,7 +40,7 @@
CppUnit::Test* UtilTestSuite::suite()
{
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("ConfigurationTestSuite");
CppUnit::TestSuite* pSuite = new CppUnit::TestSuite("UtilTestSuite");
pSuite->addTest(ConfigurationTestSuite::suite());
pSuite->addTest(OptionsTestSuite::suite());

View File

@@ -1 +1 @@
1.2.5 (2006-10-23)
1.2.7 (2006-12-07)

View File

@@ -1,7 +1,7 @@
//
// SAXParser.h
//
// $Id: //poco/1.2/XML/include/Poco/SAX/SAXParser.h#1 $
// $Id: //poco/1.2/XML/include/Poco/SAX/SAXParser.h#2 $
//
// Library: XML
// Package: SAX
@@ -80,7 +80,7 @@ public:
/// the XML document.
void addEncoding(const XMLString& name, Poco::TextEncoding* pEncoding);
/// Adds an encoding to the parser.
/// Adds an encoding to the parser. Does not take ownership of the pointer!
/// XMLReader
void setEntityResolver(EntityResolver* pResolver);

View File

@@ -1,5 +1,5 @@
#
# $Id: //poco/1.2/build/rules/global#1 $
# $Id: //poco/1.2/build/rules/global#2 $
#
# global
#
@@ -130,7 +130,7 @@ endif
#
# Compose compiler flags
#
COMMONFLAGS = -DPOCO_BUILD_HOST=$(HOSTNAME)
COMMONFLAGS = -DPOCO_BUILD_HOST=$(HOSTNAME) $(POCO_FLAGS)
CFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
CXXFLAGS += $(COMMONFLAGS) $(SYSFLAGS)
LINKFLAGS += $(COMMONFLAGS) $(SYSFLAGS)

View File

@@ -13,43 +13,49 @@ set OPENSSL_LIB=%OPENSSL_DIR%\lib\VC
set INCLUDE=%INCLUDE%;%OPENSSL_INCLUDE%
set LIB=%LIB%;%OPENSSL_LIB%
set POCOBASE=%CD%
cd CppUnit
devenv /useenv /rebuild debug_shared CppUnit_vs71.sln
devenv /useenv /rebuild release_shared CppUnit_vs71.sln
cd ..
cd %POCOBASE%
cd Foundation
devenv /useenv /rebuild debug_shared Foundation_vs71.sln
devenv /useenv /rebuild release_shared Foundation_vs71.sln
cd samples
devenv /useenv /rebuild debug_shared samples_vs71.sln
devenv /useenv /rebuild release_shared samples_vs71.sln
cd ..
cd ..
cd %POCOBASE%
cd XML
devenv /useenv /rebuild debug_shared XML_vs71.sln
devenv /useenv /rebuild release_shared XML_vs71.sln
cd samples
devenv /useenv /rebuild debug_shared samples_vs71.sln
devenv /useenv /rebuild release_shared samples_vs71.sln
cd ..
cd ..
cd %POCOBASE%
cd Util
devenv /useenv /rebuild debug_shared Util_vs71.sln
devenv /useenv /rebuild release_shared Util_vs71.sln
cd samples
devenv /useenv /rebuild debug_shared samples_vs71.sln
devenv /useenv /rebuild release_shared samples_vs71.sln
cd ..
cd ..
cd %POCOBASE%
cd Net
devenv /useenv /rebuild debug_shared Net_vs71.sln
devenv /useenv /rebuild release_shared Net_vs71.sln
cd samples
cd %POCOBASE%
cd Foundation/samples
devenv /useenv /rebuild debug_shared samples_vs71.sln
devenv /useenv /rebuild release_shared samples_vs71.sln
cd ..
cd ..
cd %POCOBASE%
cd XML/samples
devenv /useenv /rebuild debug_shared samples_vs71.sln
devenv /useenv /rebuild release_shared samples_vs71.sln
cd %POCOBASE%
cd Util/samples
devenv /useenv /rebuild debug_shared samples_vs71.sln
devenv /useenv /rebuild release_shared samples_vs71.sln
cd %POCOBASE%
cd Net/samples
devenv /useenv /rebuild debug_shared samples_vs71.sln
devenv /useenv /rebuild release_shared samples_vs71.sln
cd %POCOBASE%

View File

@@ -13,43 +13,49 @@ set OPENSSL_LIB=%OPENSSL_DIR%\lib\VC
set INCLUDE=%INCLUDE%;%OPENSSL_INCLUDE%
set LIB=%LIB%;%OPENSSL_LIB%
set POCOBASE=%CD%
cd CppUnit
devenv /useenv /rebuild debug_shared CppUnit_vs80.sln
devenv /useenv /rebuild release_shared CppUnit_vs80.sln
cd ..
cd %POCOBASE%
cd Foundation
devenv /useenv /rebuild debug_shared Foundation_vs80.sln
devenv /useenv /rebuild release_shared Foundation_vs80.sln
cd samples
devenv /useenv /rebuild debug_shared samples_vs80.sln
devenv /useenv /rebuild release_shared samples_vs80.sln
cd ..
cd ..
cd %POCOBASE%
cd XML
devenv /useenv /rebuild debug_shared XML_vs80.sln
devenv /useenv /rebuild release_shared XML_vs80.sln
cd samples
devenv /useenv /rebuild debug_shared samples_vs80.sln
devenv /useenv /rebuild release_shared samples_vs80.sln
cd ..
cd ..
cd %POCOBASE%
cd Util
devenv /useenv /rebuild debug_shared Util_vs80.sln
devenv /useenv /rebuild release_shared Util_vs80.sln
cd samples
devenv /useenv /rebuild debug_shared samples_vs80.sln
devenv /useenv /rebuild release_shared samples_vs80.sln
cd ..
cd ..
cd %POCOBASE%
cd Net
devenv /useenv /rebuild debug_shared Net_vs80.sln
devenv /useenv /rebuild release_shared Net_vs80.sln
cd samples
cd %POCOBASE%
cd Foundation/samples
devenv /useenv /rebuild debug_shared samples_vs80.sln
devenv /useenv /rebuild release_shared samples_vs80.sln
cd ..
cd ..
cd %POCOBASE%
cd XML/samples
devenv /useenv /rebuild debug_shared samples_vs80.sln
devenv /useenv /rebuild release_shared samples_vs80.sln
cd %POCOBASE%
cd Util/samples
devenv /useenv /rebuild debug_shared samples_vs80.sln
devenv /useenv /rebuild release_shared samples_vs80.sln
cd %POCOBASE%
cd Net/samples
devenv /useenv /rebuild debug_shared samples_vs80.sln
devenv /useenv /rebuild release_shared samples_vs80.sln
cd %POCOBASE%

42
configure vendored
View File

@@ -2,7 +2,7 @@
#
# configure
#
# $Id: //poco/1.2/dist/configure#3 $
# $Id: //poco/1.2/dist/configure#7 $
#
# Configuration script for POCO.
#
@@ -16,7 +16,7 @@
#
# --prefix=<install_prefix>
# Use the given install directory for make install.
# Default is /usr/local"
# Default is /usr/local
#
# --no-tests
# Do not build testsuites.
@@ -24,6 +24,12 @@
# --no-samples
# Do not build samples.
#
# --no-wstring
# Compile with -DPOCO_NO_WSTRING.
#
# --no-fpenvironment
# Compile with -DPOCO_NO_FPENVIRONMENT
#
# save cwd
build=`pwd`
@@ -34,6 +40,7 @@ cd $build
tests="tests"
samples="samples"
flags=""
# parse arguments
while [ "$1" != "" ] ; do
val=`expr $1 : '--config=\(.*\)'`
@@ -53,6 +60,15 @@ while [ "$1" != "" ] ; do
if [ "$1" = "--no-tests" ] ; then
tests=""
fi
if [ "$1" = "--no-wstring" ] ; then
flags="$flags -DPOCO_NO_WSTRING"
fi
if [ "$1" = "--no-fpenvironment" ] ; then
flags="$flags -DPOCO_NO_FPENVIRONMENT"
fi
shift
done
@@ -81,17 +97,19 @@ fi
# create config.make
echo '# config.make generated by configure script' >$build/config.make
echo "POCO_CONFIG = $config" >> $build/config.make
echo "POCO_BASE = $base" >> $build/config.make
echo "POCO_BUILD = $build" >> $build/config.make
echo "POCO_PREFIX = $prefix" >> $build/config.make
echo "POCO_CONFIG = $config" >>$build/config.make
echo "POCO_BASE = $base" >>$build/config.make
echo "POCO_BUILD = $build" >>$build/config.make
echo "POCO_PREFIX = $prefix" >>$build/config.make
echo "POCO_FLAGS = $flags" >>$build/config.make
echo "export POCO_CONFIG" >> $build/config.make
echo "export POCO_BASE" >> $build/config.make
echo "export POCO_BUILD" >> $build/config.make
echo "export POCO_PREFIX" >> $build/config.make
echo "export POCO_CONFIG" >>$build/config.make
echo "export POCO_BASE" >>$build/config.make
echo "export POCO_BUILD" >>$build/config.make
echo "export POCO_PREFIX" >>$build/config.make
echo "export POCO_FLAGS" >>$build/config.make
echo ".PHONY: poco" >> $build/config.make
echo "poco: libs $tests $samples" >> $build/config.make
echo ".PHONY: poco" >>$build/config.make
echo "poco: libexecs $tests $samples" >>$build/config.make
echo "Configured for $config"