integrated changes from main repository for upcoming 1.2.5 release

This commit is contained in:
Guenter Obiltschnig 2006-10-12 15:08:28 +00:00
parent 41ee6e0ffa
commit 89111b52b3
26 changed files with 283 additions and 171 deletions

View File

@ -1,5 +1,21 @@
This is the changelog file for POCO - the C++ Portable Components. This is the changelog file for POCO - the C++ Portable Components.
Release 1.2.5 (2006-10-xx)
==========================
- Improved LoggingConfigurator: channel creation and configuration is now a two-step process.
This means that the previous problems with PropertyFileConfiguration and IniFileConfiguration when referencing other channels are solved.
- improved options handling: better handling of (non) ambiguities.
If both an option named "help" and one named "helper" is specified, this no longer causes ambiguity errors.
- added check for duplicate option definition
- ThreadPool bugfix: fixed a crash that occurs on Linux multiprocessor machines
(caused by an thread unsafe string assignment corrupting the heap...)
(SF# 1575315)
- improved ThreadPool performance
- XML now compiles with -DXML_UNICODE_WCHAR_T (SF# 1575174)
- fixed SF# 1572757: HTML forms can have more than one key/value pair with the same name
Release 1.2.4 (2006-10-02) Release 1.2.4 (2006-10-02)
========================== ==========================
@ -513,4 +529,4 @@ building the libraries.
-- --
$Id: //poco/1.2/dist/CHANGELOG#9 $ $Id: //poco/1.2/dist/CHANGELOG#10 $

View File

@ -1,7 +1,7 @@
// //
// Configurable.h // Configurable.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/Configurable.h#1 $ // $Id: //poco/1.2/Foundation/include/Poco/Configurable.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging
@ -59,6 +59,13 @@ class Foundation_API Configurable
/// Every property controls a certain aspect of a /// Every property controls a certain aspect of a
/// Formatter or Channel. For example, the PatternFormatter's /// Formatter or Channel. For example, the PatternFormatter's
/// formatting pattern is set via a property. /// formatting pattern is set via a property.
///
/// NOTE: The following property names are use internally
/// by the logging framework and must not be used by
/// channels or formatters:
/// - class
/// - pattern (Channel)
/// - formatter (Channel)
{ {
public: public:
Configurable(); Configurable();

View File

@ -1,7 +1,7 @@
// //
// FormattingChannel.h // FormattingChannel.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/FormattingChannel.h#1 $ // $Id: //poco/1.2/Foundation/include/Poco/FormattingChannel.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging
@ -94,6 +94,8 @@ public:
/// Only the "channel" and "formatter" properties are supported, which allow /// Only the "channel" and "formatter" properties are supported, which allow
/// setting the target channel and formatter, respectively, via the LoggingRegistry. /// setting the target channel and formatter, respectively, via the LoggingRegistry.
/// The "channel" and "formatter" properties are set-only. /// The "channel" and "formatter" properties are set-only.
///
/// Unsupported properties are passed to the attached Channel.
void open(); void open();
/// Opens the attached channel. /// Opens the attached channel.

View File

@ -1,7 +1,7 @@
// //
// SharedPtr.h // SharedPtr.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#4 $ // $Id: //poco/1.2/Foundation/include/Poco/SharedPtr.h#5 $
// //
// Library: Foundation // Library: Foundation
// Package: Core // Package: Core
@ -133,8 +133,9 @@ public:
{ {
if (get() != ptr) if (get() != ptr)
{ {
ReferenceCounter* pTmp = new ReferenceCounter;
release(); release();
_pCounter = new ReferenceCounter; _pCounter = pTmp;
_ptr = ptr; _ptr = ptr;
} }
return *this; return *this;
@ -144,10 +145,8 @@ public:
{ {
if (&ptr != this) if (&ptr != this)
{ {
release(); SharedPtr tmp(ptr);
_pCounter = ptr._pCounter; swap(tmp);
_pCounter->duplicate();
_ptr = const_cast<C*>(ptr.get());
} }
return *this; return *this;
} }
@ -157,10 +156,8 @@ public:
{ {
if (ptr.get() != _ptr) if (ptr.get() != _ptr)
{ {
release(); SharedPtr tmp(ptr);
_pCounter = ptr._pCounter; swap(tmp);
_pCounter->duplicate();
_ptr = const_cast<Other*>(ptr.get());
} }
return *this; return *this;
} }
@ -183,6 +180,7 @@ public:
void swap(SharedPtr& ptr) void swap(SharedPtr& ptr)
{ {
std::swap(_ptr, ptr._ptr); std::swap(_ptr, ptr._ptr);
std::swap(_pCounter, ptr._pCounter);
} }
C* operator -> () C* operator -> ()

View File

@ -1,7 +1,7 @@
// //
// ThreadPool.h // ThreadPool.h
// //
// $Id: //poco/1.2/Foundation/include/Poco/ThreadPool.h#1 $ // $Id: //poco/1.2/Foundation/include/Poco/ThreadPool.h#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading
@ -158,6 +158,7 @@ private:
int _maxCapacity; int _maxCapacity;
int _idleTime; int _idleTime;
int _serial; int _serial;
int _age;
ThreadVec _threads; ThreadVec _threads;
mutable FastMutex _mutex; mutable FastMutex _mutex;
}; };

View File

@ -1,7 +1,7 @@
// //
// FormattingChannel.cpp // FormattingChannel.cpp
// //
// $Id: //poco/1.2/Foundation/src/FormattingChannel.cpp#1 $ // $Id: //poco/1.2/Foundation/src/FormattingChannel.cpp#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Logging // Package: Logging
@ -126,8 +126,8 @@ void FormattingChannel::setProperty(const std::string& name, const std::string&
setChannel(LoggingRegistry::defaultRegistry().channelForName(value)); setChannel(LoggingRegistry::defaultRegistry().channelForName(value));
else if (name == "formatter") else if (name == "formatter")
setFormatter(LoggingRegistry::defaultRegistry().formatterForName(value)); setFormatter(LoggingRegistry::defaultRegistry().formatterForName(value));
else else if (_pChannel)
Channel::setProperty(name, value); _pChannel->setProperty(name, value);
} }

View File

@ -1,7 +1,7 @@
// //
// ThreadPool.cpp // ThreadPool.cpp
// //
// $Id: //poco/1.2/Foundation/src/ThreadPool.cpp#1 $ // $Id: //poco/1.2/Foundation/src/ThreadPool.cpp#2 $
// //
// Library: Foundation // Library: Foundation
// Package: Threading // Package: Threading
@ -66,13 +66,13 @@ public:
private: private:
volatile bool _idle; volatile bool _idle;
volatile time_t _idleTime; volatile time_t _idleTime;
Runnable* _pTarget; Runnable* _pTarget;
std::string _name; std::string _name;
Thread _thread; Thread _thread;
Event _targetReady; Event _targetReady;
Event _targetCompleted; Event _targetCompleted;
Event _started; Event _started;
FastMutex _mutex; FastMutex _mutex;
}; };
@ -146,10 +146,7 @@ int PooledThread::idleTime()
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
if (_idle) return (int) (time(NULL) - _idleTime);
return (int) (time(NULL) - _idleTime);
else
return 0;
} }
@ -214,11 +211,10 @@ void PooledThread::run()
{ {
ErrorHandler::handle(); ErrorHandler::handle();
} }
_mutex.lock(); FastMutex::ScopedLock lock(_mutex);
_idle = true; _pTarget = 0;
_idleTime = time(NULL); _idleTime = time(NULL);
_pTarget = 0; _idle = true;
_mutex.unlock();
_targetCompleted.set(); _targetCompleted.set();
ThreadLocalStorage::clear(); ThreadLocalStorage::clear();
_thread.setName(_name); _thread.setName(_name);
@ -238,7 +234,8 @@ ThreadPool::ThreadPool(int minCapacity, int maxCapacity, int idleTime):
_minCapacity(minCapacity), _minCapacity(minCapacity),
_maxCapacity(maxCapacity), _maxCapacity(maxCapacity),
_idleTime(idleTime), _idleTime(idleTime),
_serial(0) _serial(0),
_age(0)
{ {
poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0); poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);
@ -256,7 +253,8 @@ ThreadPool::ThreadPool(const std::string& name, int minCapacity, int maxCapacity
_minCapacity(minCapacity), _minCapacity(minCapacity),
_maxCapacity(maxCapacity), _maxCapacity(maxCapacity),
_idleTime(idleTime), _idleTime(idleTime),
_serial(0) _serial(0),
_age(0)
{ {
poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0); poco_assert (minCapacity >= 1 && maxCapacity >= minCapacity && idleTime > 0);
@ -383,21 +381,42 @@ void ThreadPool::collect()
void ThreadPool::housekeep() void ThreadPool::housekeep()
{ {
bool moreThreads = true; if (_threads.size() <= _minCapacity)
while (moreThreads && _threads.size() > _minCapacity) return;
ThreadVec idleThreads;
ThreadVec expiredThreads;
ThreadVec activeThreads;
idleThreads.reserve(_threads.size());
activeThreads.reserve(_threads.size());
for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
{ {
moreThreads = false; if ((*it)->idle())
for (ThreadVec::iterator it = _threads.begin(); it != _threads.end(); ++it)
{ {
if ((*it)->idleTime() >= _idleTime) if ((*it)->idleTime() < _idleTime)
{ idleThreads.push_back(*it);
(*it)->release(); else
_threads.erase(it); expiredThreads.push_back(*it);
moreThreads = true;
break;
}
} }
else activeThreads.push_back(*it);
} }
int n = (int) activeThreads.size();
int limit = (int) idleThreads.size() + n;
if (limit < _minCapacity) limit = _minCapacity;
idleThreads.insert(idleThreads.end(), expiredThreads.begin(), expiredThreads.end());
_threads.clear();
for (ThreadVec::iterator it = idleThreads.begin(); it != idleThreads.end(); ++it)
{
if (n < limit)
{
_threads.push_back(*it);
++n;
}
else (*it)->release();
}
_threads.insert(_threads.end(), activeThreads.begin(), activeThreads.end());
_age = 0;
} }
@ -405,7 +424,8 @@ PooledThread* ThreadPool::getThread()
{ {
FastMutex::ScopedLock lock(_mutex); FastMutex::ScopedLock lock(_mutex);
housekeep(); if (++_age == 32)
housekeep();
PooledThread* pThread = 0; PooledThread* pThread = 0;
for (ThreadVec::iterator it = _threads.begin(); !pThread && it != _threads.end(); ++it) for (ThreadVec::iterator it = _threads.begin(); !pThread && it != _threads.end(); ++it)
@ -420,10 +440,7 @@ PooledThread* ThreadPool::getThread()
_threads.push_back(pThread); _threads.push_back(pThread);
pThread->start(); pThread->start();
} }
else else throw NoThreadAvailableException();
{
throw NoThreadAvailableException();
}
} }
pThread->activate(); pThread->activate();
return pThread; return pThread;

View File

@ -1,7 +1,7 @@
// //
// ThreadPoolTest.cpp // ThreadPoolTest.cpp
// //
// $Id: //poco/1.2/Foundation/testsuite/src/ThreadPoolTest.cpp#1 $ // $Id: //poco/1.2/Foundation/testsuite/src/ThreadPoolTest.cpp#2 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.

View File

@ -1,7 +1,7 @@
// //
// HTMLForm.cpp // HTMLForm.cpp
// //
// $Id: //poco/1.2/Net/src/HTMLForm.cpp#2 $ // $Id: //poco/1.2/Net/src/HTMLForm.cpp#3 $
// //
// Library: Net // Library: Net
// Package: HTML // Package: HTML
@ -263,7 +263,7 @@ void HTMLForm::readUrl(std::istream& istr)
std::string decodedValue; std::string decodedValue;
URI::decode(name, decodedName); URI::decode(name, decodedName);
URI::decode(value, decodedValue); URI::decode(value, decodedValue);
set(decodedName, decodedValue); add(decodedName, decodedValue);
if (ch == '&') ch = istr.get(); if (ch == '&') ch = istr.get();
} }
} }
@ -302,7 +302,7 @@ void HTMLForm::readMultipart(std::istream& istr, PartHandler& handler)
value += (char) ch; value += (char) ch;
ch = istr.get(); ch = istr.get();
} }
set(name, value); add(name, value);
} }
} }
} }

View File

@ -1,7 +1,7 @@
// //
// TCPServerParams.cpp // TCPServerParams.cpp
// //
// $Id: //poco/1.2/Net/src/TCPServerParams.cpp#1 $ // $Id: //poco/1.2/Net/src/TCPServerParams.cpp#2 $
// //
// Library: Net // Library: Net
// Package: TCPServer // Package: TCPServer
@ -76,6 +76,4 @@ void TCPServerParams::setMaxQueued(int count)
} }
} } // namespace Poco::Net } } // namespace Poco::Net

View File

@ -1,7 +1,7 @@
// //
// LoggingConfigurator.h // LoggingConfigurator.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/LoggingConfigurator.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/LoggingConfigurator.h#2 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
@ -66,7 +66,7 @@ class Util_API LoggingConfigurator
/// Configuring Formatters /// Configuring Formatters
/// ///
/// A formatter is configured using the "logging.formatters" property. Every /// A formatter is configured using the "logging.formatters" property. Every
/// formatter has an internal name, which is only used for referring to it in /// formatter has an internal name, which is only used for referring to it
/// during configuration time. This name becomes part of the property name. /// during configuration time. This name becomes part of the property name.
/// Every formatter has a mandatory "class" property, which specifies the actual /// Every formatter has a mandatory "class" property, which specifies the actual
/// class implementing the formatter. Any other properties are passed on to /// class implementing the formatter. Any other properties are passed on to
@ -126,38 +126,6 @@ class Util_API LoggingConfigurator
/// logging.loggers.l1.channel.class = ConsoleChannel /// logging.loggers.l1.channel.class = ConsoleChannel
/// logging.loggers.l1.channel.pattern = %s: [%p] %t /// logging.loggers.l1.channel.pattern = %s: [%p] %t
/// logging.loggers.l1.level = information /// logging.loggers.l1.level = information
///
/// Known Problems
///
/// When using a PropertyFileConfiguration or IniFileConfiguration with the
/// LoggingConfigurator, the channels are constructed in alphabetical order
/// with regard to their internal name. When a channel (e.g., a SplitterChannel)
/// references another channel, the referenced channel must have a "higher" name
/// than the referring channel, otherwise it will not be found.
///
/// For example, the following configuration won't work:
///
/// logging.channels.c1.class = SplitterChannel
/// logging.channels.c1.channel1 = c2
/// logging.channels.c1.channel2 = c3
/// logging.channels.c2.class = ...
/// ...
/// logging.channels.c3.class = ...
/// ...
///
/// The workaround is to change the internal channel names:
///
/// logging.channels.cx.class = SplitterChannel
/// logging.channels.cx.channel1 = c1
/// logging.channels.cx.channel2 = c2
/// logging.channels.c1.class = ...
/// ...
/// logging.channels.c2.class = ...
/// ...
///
/// When using an XMLConfiguration, the channels are created in the order
/// in which they are specified in the configuration file, so this problem
/// does not occur.
{ {
public: public:
LoggingConfigurator(); LoggingConfigurator();
@ -179,6 +147,7 @@ private:
void configureLoggers(AbstractConfiguration* pConfig); void configureLoggers(AbstractConfiguration* pConfig);
Poco::Formatter* createFormatter(AbstractConfiguration* pConfig); Poco::Formatter* createFormatter(AbstractConfiguration* pConfig);
Poco::Channel* createChannel(AbstractConfiguration* pConfig); Poco::Channel* createChannel(AbstractConfiguration* pConfig);
void configureChannel(Channel* pChannel, AbstractConfiguration* pConfig);
void configureLogger(AbstractConfiguration* pConfig); void configureLogger(AbstractConfiguration* pConfig);
LoggingConfigurator(const LoggingConfigurator&); LoggingConfigurator(const LoggingConfigurator&);

View File

@ -1,7 +1,7 @@
// //
// Option.h // Option.h
// //
// $Id: //poco/1.2/Util/include/Poco/Util/Option.h#1 $ // $Id: //poco/1.2/Util/include/Poco/Util/Option.h#2 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
@ -217,6 +217,13 @@ public:
/// Returns true if the given option string matches the /// Returns true if the given option string matches the
/// full name. /// full name.
/// ///
/// The option string must match the full
/// name (case insensitive).
bool matchesPartial(const std::string& option) const;
/// Returns true if the given option string partially matches the
/// full name.
///
/// The option string must partially match the full /// The option string must partially match the full
/// name (case insensitive). /// name (case insensitive).

View File

@ -1,7 +1,7 @@
// //
// LoggingConfigurator.cpp // LoggingConfigurator.cpp
// //
// $Id: //poco/1.2/Util/src/LoggingConfigurator.cpp#1 $ // $Id: //poco/1.2/Util/src/LoggingConfigurator.cpp#2 $
// //
// Library: Util // Library: Util
// Package: Configuration // Package: Configuration
@ -74,13 +74,13 @@ void LoggingConfigurator::configure(AbstractConfiguration* pConfig)
{ {
poco_check_ptr (pConfig); poco_check_ptr (pConfig);
AutoPtr<AbstractConfiguration> pFormattersConfig = pConfig->createView("logging.formatters"); AutoPtr<AbstractConfiguration> pFormattersConfig(pConfig->createView("logging.formatters"));
configureFormatters(pFormattersConfig); configureFormatters(pFormattersConfig);
AutoPtr<AbstractConfiguration> pChannelsConfig = pConfig->createView("logging.channels"); AutoPtr<AbstractConfiguration> pChannelsConfig(pConfig->createView("logging.channels"));
configureChannels(pChannelsConfig); configureChannels(pChannelsConfig);
AutoPtr<AbstractConfiguration> pLoggersConfig = pConfig->createView("logging.loggers"); AutoPtr<AbstractConfiguration> pLoggersConfig(pConfig->createView("logging.loggers"));
configureLoggers(pLoggersConfig); configureLoggers(pLoggersConfig);
} }
@ -91,8 +91,8 @@ void LoggingConfigurator::configureFormatters(AbstractConfiguration* pConfig)
pConfig->keys(formatters); pConfig->keys(formatters);
for (AbstractConfiguration::Keys::const_iterator it = formatters.begin(); it != formatters.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = formatters.begin(); it != formatters.end(); ++it)
{ {
AutoPtr<AbstractConfiguration> pFormatterConfig = pConfig->createView(*it); AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it));
AutoPtr<Formatter> pFormatter = createFormatter(pFormatterConfig); AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
LoggingRegistry::defaultRegistry().registerFormatter(*it, pFormatter); LoggingRegistry::defaultRegistry().registerFormatter(*it, pFormatter);
} }
} }
@ -104,10 +104,16 @@ void LoggingConfigurator::configureChannels(AbstractConfiguration* pConfig)
pConfig->keys(channels); pConfig->keys(channels);
for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
{ {
AutoPtr<AbstractConfiguration> pChannelConfig = pConfig->createView(*it); AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
AutoPtr<Channel> pChannel = createChannel(pChannelConfig); AutoPtr<Channel> pChannel = createChannel(pChannelConfig);
LoggingRegistry::defaultRegistry().registerChannel(*it, pChannel); LoggingRegistry::defaultRegistry().registerChannel(*it, pChannel);
} }
for (AbstractConfiguration::Keys::const_iterator it = channels.begin(); it != channels.end(); ++it)
{
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
Channel* pChannel = LoggingRegistry::defaultRegistry().channelForName(*it);
configureChannel(pChannel, pChannelConfig);
}
} }
@ -117,7 +123,7 @@ void LoggingConfigurator::configureLoggers(AbstractConfiguration* pConfig)
pConfig->keys(loggers); pConfig->keys(loggers);
for (AbstractConfiguration::Keys::const_iterator it = loggers.begin(); it != loggers.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = loggers.begin(); it != loggers.end(); ++it)
{ {
AutoPtr<AbstractConfiguration> pLoggerConfig = pConfig->createView(*it); AutoPtr<AbstractConfiguration> pLoggerConfig(pConfig->createView(*it));
configureLogger(pLoggerConfig); configureLogger(pLoggerConfig);
} }
} }
@ -125,7 +131,7 @@ void LoggingConfigurator::configureLoggers(AbstractConfiguration* pConfig)
Formatter* LoggingConfigurator::createFormatter(AbstractConfiguration* pConfig) Formatter* LoggingConfigurator::createFormatter(AbstractConfiguration* pConfig)
{ {
AutoPtr<Formatter> pFormatter = LoggingFactory::defaultFactory().createFormatter(pConfig->getString("class")); AutoPtr<Formatter> pFormatter(LoggingFactory::defaultFactory().createFormatter(pConfig->getString("class")));
AbstractConfiguration::Keys props; AbstractConfiguration::Keys props;
pConfig->keys(props); pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
@ -139,24 +145,24 @@ Formatter* LoggingConfigurator::createFormatter(AbstractConfiguration* pConfig)
Channel* LoggingConfigurator::createChannel(AbstractConfiguration* pConfig) Channel* LoggingConfigurator::createChannel(AbstractConfiguration* pConfig)
{ {
AutoPtr<Channel> pChannel = LoggingFactory::defaultFactory().createChannel(pConfig->getString("class")); AutoPtr<Channel> pChannel(LoggingFactory::defaultFactory().createChannel(pConfig->getString("class")));
AutoPtr<Channel> pWrapper = pChannel; AutoPtr<Channel> pWrapper(pChannel);
AbstractConfiguration::Keys props; AbstractConfiguration::Keys props;
pConfig->keys(props); pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it) for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{ {
if (*it == "pattern") if (*it == "pattern")
{ {
AutoPtr<Formatter> pPatternFormatter = new PatternFormatter(pConfig->getString(*it)); AutoPtr<Formatter> pPatternFormatter(new PatternFormatter(pConfig->getString(*it)));
pWrapper = new FormattingChannel(pPatternFormatter, pChannel); pWrapper = new FormattingChannel(pPatternFormatter, pChannel);
} }
else if (*it == "formatter") else if (*it == "formatter")
{ {
AutoPtr<FormattingChannel> pFormattingChannel = new FormattingChannel(0, pChannel); AutoPtr<FormattingChannel> pFormattingChannel(new FormattingChannel(0, pChannel));
if (pConfig->hasProperty("formatter.class")) if (pConfig->hasProperty("formatter.class"))
{ {
AutoPtr<AbstractConfiguration> pFormatterConfig = pConfig->createView(*it); AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(*it));
AutoPtr<Formatter> pFormatter = createFormatter(pFormatterConfig); AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
pFormattingChannel->setFormatter(pFormatter); pFormattingChannel->setFormatter(pFormatter);
} }
else pFormattingChannel->setProperty(*it, pConfig->getString(*it)); else pFormattingChannel->setProperty(*it, pConfig->getString(*it));
@ -166,12 +172,22 @@ Channel* LoggingConfigurator::createChannel(AbstractConfiguration* pConfig)
pWrapper = pFormattingChannel; pWrapper = pFormattingChannel;
#endif #endif
} }
else if (*it != "class") }
return pWrapper.duplicate();
}
void LoggingConfigurator::configureChannel(Channel* pChannel, AbstractConfiguration* pConfig)
{
AbstractConfiguration::Keys props;
pConfig->keys(props);
for (AbstractConfiguration::Keys::const_iterator it = props.begin(); it != props.end(); ++it)
{
if (*it != "pattern" && *it != "formatter" && *it != "class")
{ {
pChannel->setProperty(*it, pConfig->getString(*it)); pChannel->setProperty(*it, pConfig->getString(*it));
} }
} }
return pWrapper.duplicate();
} }
@ -184,8 +200,9 @@ void LoggingConfigurator::configureLogger(AbstractConfiguration* pConfig)
{ {
if (*it == "channel" && pConfig->hasProperty("channel.class")) if (*it == "channel" && pConfig->hasProperty("channel.class"))
{ {
AutoPtr<AbstractConfiguration> pChannelConfig = pConfig->createView(*it); AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(*it));
AutoPtr<Channel> pChannel = createChannel(pChannelConfig); AutoPtr<Channel> pChannel(createChannel(pChannelConfig));
configureChannel(pChannel, pChannelConfig);
logger.setChannel(pChannel); logger.setChannel(pChannel);
} }
else if (*it != "name") else if (*it != "name")

View File

@ -1,7 +1,7 @@
// //
// Option.cpp // Option.cpp
// //
// $Id: //poco/1.2/Util/src/Option.cpp#1 $ // $Id: //poco/1.2/Util/src/Option.cpp#2 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
@ -238,6 +238,15 @@ bool Option::matchesShort(const std::string& option) const
bool Option::matchesFull(const std::string& option) const bool Option::matchesFull(const std::string& option) const
{
std::string::size_type pos = option.find_first_of(":=");
std::string::size_type len = pos == std::string::npos ? option.length() : pos;
return len == _fullName.length()
&& icompare(option, 0, len, _fullName, 0, len) == 0;
}
bool Option::matchesPartial(const std::string& option) const
{ {
std::string::size_type pos = option.find_first_of(":="); std::string::size_type pos = option.find_first_of(":=");
std::string::size_type len = pos == std::string::npos ? option.length() : pos; std::string::size_type len = pos == std::string::npos ? option.length() : pos;

View File

@ -1,7 +1,7 @@
// //
// OptionSet.cpp // OptionSet.cpp
// //
// $Id: //poco/1.2/Util/src/OptionSet.cpp#1 $ // $Id: //poco/1.2/Util/src/OptionSet.cpp#2 $
// //
// Library: Util // Library: Util
// Package: Options // Package: Options
@ -70,6 +70,15 @@ OptionSet& OptionSet::operator = (const OptionSet& options)
void OptionSet::addOption(const Option& option) void OptionSet::addOption(const Option& option)
{ {
poco_assert (!option.fullName().empty()); poco_assert (!option.fullName().empty());
OptionVec::const_iterator it = _options.begin();
OptionVec::const_iterator itEnd = _options.end();
for (; it != itEnd; ++it)
{
if (it->fullName() == option.fullName())
{
throw DuplicateOptionException(it->fullName());
}
}
_options.push_back(option); _options.push_back(option);
} }
@ -97,12 +106,20 @@ const Option& OptionSet::getOption(const std::string& name, bool matchShort) con
const Option* pOption = 0; const Option* pOption = 0;
for (Iterator it = _options.begin(); it != _options.end(); ++it) for (Iterator it = _options.begin(); it != _options.end(); ++it)
{ {
if (matchShort && it->matchesShort(name) || !matchShort && it->matchesFull(name)) if (matchShort && it->matchesShort(name) || !matchShort && it->matchesPartial(name))
{ {
if (!pOption) if (!pOption)
{
pOption = &*it; pOption = &*it;
else if (!matchShort && it->matchesFull(name))
throw AmbiguousOptionException(name); break;
}
else if (!matchShort && it->matchesFull(name))
{
pOption = &*it;
break;
}
else throw AmbiguousOptionException(name);
} }
} }
if (pOption) if (pOption)

View File

@ -1,7 +1,7 @@
// //
// OptionSetTest.cpp // OptionSetTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/OptionSetTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/OptionSetTest.cpp#2 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@ -55,6 +55,14 @@ OptionSetTest::~OptionSetTest()
void OptionSetTest::testOptionSet() void OptionSetTest::testOptionSet()
{ {
OptionSet set; OptionSet set;
set.addOption(
Option("helper", "H", "start helper")
.required(false)
.repeatable(false));
set.addOption(
Option("help", "h", "print help text")
.required(false)
.repeatable(false));
set.addOption( set.addOption(
Option("include-dir", "I", "specify a search path for locating header files") Option("include-dir", "I", "specify a search path for locating header files")
.required(false) .required(false)
@ -65,19 +73,22 @@ void OptionSetTest::testOptionSet()
.required(false) .required(false)
.repeatable(true) .repeatable(true)
.argument("path")); .argument("path"));
set.addOption( set.addOption(
Option("insert", "it", "insert something") Option("insert", "it", "insert something")
.required(false) .required(false)
.repeatable(true) .repeatable(true)
.argument("path")); .argument("path"));
set.addOption( set.addOption(
Option("item", "", "insert something") Option("item", "", "insert something")
.required(false) .required(false)
.repeatable(true) .repeatable(true)
.argument("path")); .argument("path"));
set.addOption(
Option("include", "J", "specify a search path for locating header files")
.required(false)
.repeatable(true)
.argument("path"));
assert (set.hasOption("include", false)); assert (set.hasOption("include", false));
assert (set.hasOption("I", true)); assert (set.hasOption("I", true));
assert (set.hasOption("Include", true)); assert (set.hasOption("Include", true));
@ -88,14 +99,28 @@ void OptionSetTest::testOptionSet()
assert (!set.hasOption("i", false)); assert (!set.hasOption("i", false));
assert (!set.hasOption("in", false)); assert (!set.hasOption("in", false));
assert (set.hasOption("help"));
assert (set.hasOption("h", true));
assert (set.hasOption("helper"));
assert (set.hasOption("H", true));
const Option& opt1 = set.getOption("include"); const Option& opt1 = set.getOption("include");
assert (opt1.fullName() == "include-dir"); assert (opt1.fullName() == "include");
const Option& opt2 = set.getOption("item"); const Option& opt2 = set.getOption("item");
assert (opt2.fullName() == "item"); assert (opt2.fullName() == "item");
const Option& opt3 = set.getOption("I", true); const Option& opt3 = set.getOption("I", true);
assert (opt3.fullName() == "include-dir"); assert (opt3.fullName() == "include-dir");
const Option& opt4 = set.getOption("include-d");
assert (opt4.fullName() == "include-dir");
const Option& opt5 = set.getOption("help");
assert (opt5.fullName() == "help");
const Option& opt6 = set.getOption("helpe");
assert (opt6.fullName() == "helper");
try try
{ {
@ -106,6 +131,15 @@ void OptionSetTest::testOptionSet()
{ {
} }
try
{
set.getOption("he");
fail("ambiguous - must throw");
}
catch (Poco::Util::AmbiguousOptionException&)
{
}
try try
{ {
set.getOption("i"); set.getOption("i");

View File

@ -1,7 +1,7 @@
// //
// OptionTest.cpp // OptionTest.cpp
// //
// $Id: //poco/1.2/Util/testsuite/src/OptionTest.cpp#1 $ // $Id: //poco/1.2/Util/testsuite/src/OptionTest.cpp#2 $
// //
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH. // Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors. // and Contributors.
@ -124,15 +124,20 @@ void OptionTest::testMatches1()
.argument("path"); .argument("path");
assert (incOpt.matchesShort("Iinclude")); assert (incOpt.matchesShort("Iinclude"));
assert (incOpt.matchesFull("include:include")); assert (incOpt.matchesPartial("include:include"));
assert (incOpt.matchesFull("include-dir:include")); assert (incOpt.matchesPartial("include-dir:include"));
assert (incOpt.matchesFull("inc=include")); assert (incOpt.matchesPartial("inc=include"));
assert (incOpt.matchesFull("INCLUDE=include")); assert (incOpt.matchesPartial("INCLUDE=include"));
assert (incOpt.matchesFull("include")); assert (incOpt.matchesPartial("include"));
assert (incOpt.matchesShort("I")); assert (incOpt.matchesShort("I"));
assert (incOpt.matchesFull("i")); assert (incOpt.matchesPartial("i"));
assert (!incOpt.matchesFull("include-dir2=include")); assert (incOpt.matchesFull("include-dir:include"));
assert (incOpt.matchesFull("INClude-dir:include"));
assert (!incOpt.matchesFull("include:include"));
assert (!incOpt.matchesFull("include-dir2:include"));
assert (!incOpt.matchesPartial("include-dir2=include"));
assert (!incOpt.matchesShort("linclude")); assert (!incOpt.matchesShort("linclude"));
} }
@ -145,12 +150,17 @@ void OptionTest::testMatches2()
.argument("path"); .argument("path");
assert (!incOpt.matchesShort("Iinclude")); assert (!incOpt.matchesShort("Iinclude"));
assert (incOpt.matchesFull("include:include")); assert (incOpt.matchesPartial("include:include"));
assert (incOpt.matchesPartial("include-dir:include"));
assert (incOpt.matchesPartial("inc=include"));
assert (incOpt.matchesPartial("INCLUDE=include"));
assert (incOpt.matchesPartial("I"));
assert (incOpt.matchesPartial("i"));
assert (incOpt.matchesFull("include-dir:include")); assert (incOpt.matchesFull("include-dir:include"));
assert (incOpt.matchesFull("inc=include")); assert (incOpt.matchesFull("INClude-dir:include"));
assert (incOpt.matchesFull("INCLUDE=include")); assert (!incOpt.matchesFull("include:include"));
assert (incOpt.matchesFull("I")); assert (!incOpt.matchesFull("include-dir2:include"));
assert (incOpt.matchesFull("i"));
assert (!incOpt.matchesFull("include-dir2=include")); assert (!incOpt.matchesFull("include-dir2=include"));
assert (!incOpt.matchesShort("linclude")); assert (!incOpt.matchesShort("linclude"));

View File

@ -1,7 +1,7 @@
// //
// DOMImplementation.h // DOMImplementation.h
// //
// $Id: //poco/1.2/XML/include/Poco/DOM/DOMImplementation.h#1 $ // $Id: //poco/1.2/XML/include/Poco/DOM/DOMImplementation.h#2 $
// //
// Library: XML // Library: XML
// Package: DOM // Package: DOM
@ -93,6 +93,8 @@ private:
static const XMLString FEATURE_EVENTS; static const XMLString FEATURE_EVENTS;
static const XMLString FEATURE_MUTATIONEVENTS; static const XMLString FEATURE_MUTATIONEVENTS;
static const XMLString FEATURE_TRAVERSAL; static const XMLString FEATURE_TRAVERSAL;
static const XMLString VERSION_1_0;
static const XMLString VERSION_2_0;
}; };

View File

@ -1,7 +1,7 @@
// //
// DOMWriter.h // DOMWriter.h
// //
// $Id: //poco/1.2/XML/include/Poco/DOM/DOMWriter.h#1 $ // $Id: //poco/1.2/XML/include/Poco/DOM/DOMWriter.h#2 $
// //
// Library: XML // Library: XML
// Package: DOM // Package: DOM
@ -69,7 +69,7 @@ public:
void setEncoding(const std::string& encodingName, Poco::TextEncoding& textEncoding); void setEncoding(const std::string& encodingName, Poco::TextEncoding& textEncoding);
/// Sets the encoding, which will be reflected in the written XML declaration. /// Sets the encoding, which will be reflected in the written XML declaration.
const XMLString& getEncoding() const; const std::string& getEncoding() const;
/// Returns the encoding name set with setEncoding. /// Returns the encoding name set with setEncoding.
void setOptions(int options); void setOptions(int options);
@ -97,7 +97,7 @@ public:
/// using a standard file output stream (std::ofstream). /// using a standard file output stream (std::ofstream).
private: private:
XMLString _encodingName; std::string _encodingName;
Poco::TextEncoding* _pTextEncoding; Poco::TextEncoding* _pTextEncoding;
int _options; int _options;
std::string _newLine; std::string _newLine;
@ -107,7 +107,7 @@ private:
// //
// inlines // inlines
// //
inline const XMLString& DOMWriter::getEncoding() const inline const std::string& DOMWriter::getEncoding() const
{ {
return _encodingName; return _encodingName;
} }

View File

@ -1,7 +1,7 @@
// //
// DOMImplementation.cpp // DOMImplementation.cpp
// //
// $Id: //poco/1.2/XML/src/DOMImplementation.cpp#1 $ // $Id: //poco/1.2/XML/src/DOMImplementation.cpp#2 $
// //
// Library: XML // Library: XML
// Package: DOM // Package: DOM
@ -51,6 +51,8 @@ const XMLString DOMImplementation::FEATURE_CORE = toXMLString("core");
const XMLString DOMImplementation::FEATURE_EVENTS = toXMLString("events"); const XMLString DOMImplementation::FEATURE_EVENTS = toXMLString("events");
const XMLString DOMImplementation::FEATURE_MUTATIONEVENTS = toXMLString("mutationevents"); const XMLString DOMImplementation::FEATURE_MUTATIONEVENTS = toXMLString("mutationevents");
const XMLString DOMImplementation::FEATURE_TRAVERSAL = toXMLString("traversal"); const XMLString DOMImplementation::FEATURE_TRAVERSAL = toXMLString("traversal");
const XMLString DOMImplementation::VERSION_1_0 = toXMLString("1.0");
const XMLString DOMImplementation::VERSION_2_0 = toXMLString("2.0");
DOMImplementation::DOMImplementation() DOMImplementation::DOMImplementation()
@ -66,11 +68,11 @@ DOMImplementation::~DOMImplementation()
bool DOMImplementation::hasFeature(const XMLString& feature, const XMLString& version) const bool DOMImplementation::hasFeature(const XMLString& feature, const XMLString& version) const
{ {
XMLString lcFeature = Poco::toLower(feature); XMLString lcFeature = Poco::toLower(feature);
return lcFeature == FEATURE_XML && version == "1.0" || return lcFeature == FEATURE_XML && version == VERSION_1_0 ||
lcFeature == FEATURE_CORE && version == "2.0" || lcFeature == FEATURE_CORE && version == VERSION_2_0 ||
lcFeature == FEATURE_EVENTS && version == "2.0" || lcFeature == FEATURE_EVENTS && version == VERSION_2_0 ||
lcFeature == FEATURE_MUTATIONEVENTS && version == "2.0" || lcFeature == FEATURE_MUTATIONEVENTS && version == VERSION_2_0 ||
lcFeature == FEATURE_TRAVERSAL && version == "2.0"; lcFeature == FEATURE_TRAVERSAL && version == VERSION_2_0;
} }

View File

@ -1,7 +1,7 @@
// //
// DOMWriter.cpp // DOMWriter.cpp
// //
// $Id: //poco/1.2/XML/src/DOMWriter.cpp#1 $ // $Id: //poco/1.2/XML/src/DOMWriter.cpp#2 $
// //
// Library: XML // Library: XML
// Package: DOM // Package: DOM
@ -63,7 +63,7 @@ DOMWriter::~DOMWriter()
} }
void DOMWriter::setEncoding(const XMLString& encodingName, Poco::TextEncoding& textEncoding) void DOMWriter::setEncoding(const std::string& encodingName, Poco::TextEncoding& textEncoding)
{ {
_encodingName = encodingName; _encodingName = encodingName;
_pTextEncoding = &textEncoding; _pTextEncoding = &textEncoding;
@ -76,7 +76,7 @@ void DOMWriter::setOptions(int options)
} }
void DOMWriter::setNewLine(const XMLString& newLine) void DOMWriter::setNewLine(const std::string& newLine)
{ {
_newLine = newLine; _newLine = newLine;
} }
@ -101,7 +101,7 @@ void DOMWriter::writeNode(XMLByteOutputStream& ostr, const Node* pNode)
} }
void DOMWriter::writeNode(const XMLString& systemId, const Node* pNode) void DOMWriter::writeNode(const std::string& systemId, const Node* pNode)
{ {
std::ofstream ostr(systemId.c_str()); std::ofstream ostr(systemId.c_str());
if (ostr.good()) if (ostr.good())

View File

@ -1,7 +1,7 @@
// //
// NamespaceStrategy.cpp // NamespaceStrategy.cpp
// //
// $Id: //poco/1.2/XML/src/NamespaceStrategy.cpp#2 $ // $Id: //poco/1.2/XML/src/NamespaceStrategy.cpp#3 $
// //
// Library: XML // Library: XML
// Package: XML // Package: XML
@ -186,7 +186,7 @@ void NamespacePrefixesStrategy::startElement(const XMLChar* name, const XMLChar*
XMLString attrLocal; XMLString attrLocal;
XMLString attrQName; XMLString attrQName;
splitName(attrName, attrURI, attrLocal, attrQName); splitName(attrName, attrURI, attrLocal, attrQName);
if (!attrQName.empty()) attrQName.append(":"); if (!attrQName.empty()) attrQName += ':';
attrQName.append(attrLocal); attrQName.append(attrLocal);
attributes.addAttribute(attrURI, attrLocal, attrQName, CDATA, attrValue, i < specifiedCount); attributes.addAttribute(attrURI, attrLocal, attrQName, CDATA, attrValue, i < specifiedCount);
} }
@ -194,7 +194,7 @@ void NamespacePrefixesStrategy::startElement(const XMLChar* name, const XMLChar*
XMLString local; XMLString local;
XMLString qname; XMLString qname;
splitName(name, uri, local, qname); splitName(name, uri, local, qname);
if (!qname.empty()) qname.append(":"); if (!qname.empty()) qname += ':';
qname.append(local); qname.append(local);
pContentHandler->startElement(uri, local, qname, attributes); pContentHandler->startElement(uri, local, qname, attributes);
} }
@ -208,7 +208,7 @@ void NamespacePrefixesStrategy::endElement(const XMLChar* name, ContentHandler*
XMLString local; XMLString local;
XMLString qname; XMLString qname;
splitName(name, uri, local, qname); splitName(name, uri, local, qname);
if (!qname.empty()) qname.append(":"); if (!qname.empty()) qname += ':';
qname.append(local); qname.append(local);
pContentHandler->endElement(uri, local, qname); pContentHandler->endElement(uri, local, qname);
} }

View File

@ -1,7 +1,7 @@
// //
// ParserEngine.cpp // ParserEngine.cpp
// //
// $Id: //poco/1.2/XML/src/ParserEngine.cpp#1 $ // $Id: //poco/1.2/XML/src/ParserEngine.cpp#2 $
// //
// Library: XML // Library: XML
// Package: XML // Package: XML
@ -659,18 +659,18 @@ int ParserEngine::handleExternalEntityRef(XML_Parser parser, const XML_Char* con
XMLString pubId; XMLString pubId;
if (publicId) pubId.assign(publicId); if (publicId) pubId.assign(publicId);
URI uri(pThis->_context.back()->getSystemId()); URI uri(fromXMLString(pThis->_context.back()->getSystemId()));
uri.resolve(sysId); uri.resolve(fromXMLString(sysId));
if (pThis->_pEntityResolver) if (pThis->_pEntityResolver)
{ {
pEntityResolver = pThis->_pEntityResolver; pEntityResolver = pThis->_pEntityResolver;
pInputSource = pEntityResolver->resolveEntity(publicId ? &pubId : 0, uri.toString()); pInputSource = pEntityResolver->resolveEntity(publicId ? &pubId : 0, toXMLString(uri.toString()));
} }
if (!pInputSource && pThis->_externalGeneralEntities) if (!pInputSource && pThis->_externalGeneralEntities)
{ {
pEntityResolver = &defaultResolver; pEntityResolver = &defaultResolver;
pInputSource = pEntityResolver->resolveEntity(publicId ? &pubId : 0, uri.toString()); pInputSource = pEntityResolver->resolveEntity(publicId ? &pubId : 0, toXMLString(uri.toString()));
} }
if (pInputSource) if (pInputSource)
@ -719,8 +719,13 @@ void ParserEngine::handleComment(void* userData, const XML_Char* data)
{ {
ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData); ParserEngine* pThis = reinterpret_cast<ParserEngine*>(userData);
#if defined(XML_UNICODE_WCHAR_T)
if (pThis->_pLexicalHandler)
pThis->_pLexicalHandler->comment(data, 0, (int) wcslen(data));
#else
if (pThis->_pLexicalHandler) if (pThis->_pLexicalHandler)
pThis->_pLexicalHandler->comment(data, 0, (int) strlen(data)); pThis->_pLexicalHandler->comment(data, 0, (int) strlen(data));
#endif
} }

View File

@ -1,7 +1,7 @@
// //
// SAXParser.cpp // SAXParser.cpp
// //
// $Id: //poco/1.2/XML/src/SAXParser.cpp#1 $ // $Id: //poco/1.2/XML/src/SAXParser.cpp#2 $
// //
// Library: XML // Library: XML
// Package: SAX // Package: SAX
@ -222,7 +222,7 @@ void SAXParser::parse(const XMLString& systemId)
} }
entityResolver.releaseInputSource(pInputSource); entityResolver.releaseInputSource(pInputSource);
} }
else throw XMLException("Cannot resolve system identifier", systemId); else throw XMLException("Cannot resolve system identifier", fromXMLString(systemId));
} }

View File

@ -1,7 +1,7 @@
// //
// XMLFilterImpl.cpp // XMLFilterImpl.cpp
// //
// $Id: //poco/1.2/XML/src/XMLFilterImpl.cpp#1 $ // $Id: //poco/1.2/XML/src/XMLFilterImpl.cpp#2 $
// //
// Library: XML // Library: XML
// Package: SAX // Package: SAX
@ -132,7 +132,7 @@ void XMLFilterImpl::setFeature(const XMLString& featureId, bool state)
if (_pParent) if (_pParent)
_pParent->setFeature(featureId, state); _pParent->setFeature(featureId, state);
else else
throw SAXNotRecognizedException(featureId); throw SAXNotRecognizedException(fromXMLString(featureId));
} }
@ -141,7 +141,7 @@ bool XMLFilterImpl::getFeature(const XMLString& featureId) const
if (_pParent) if (_pParent)
return _pParent->getFeature(featureId); return _pParent->getFeature(featureId);
else else
throw SAXNotRecognizedException(featureId); throw SAXNotRecognizedException(fromXMLString(featureId));
} }
@ -150,7 +150,7 @@ void XMLFilterImpl::setProperty(const XMLString& propertyId, const XMLString& va
if (_pParent) if (_pParent)
_pParent->setProperty(propertyId, value); _pParent->setProperty(propertyId, value);
else else
throw SAXNotRecognizedException(propertyId); throw SAXNotRecognizedException(fromXMLString(propertyId));
} }
@ -159,7 +159,7 @@ void XMLFilterImpl::setProperty(const XMLString& propertyId, void* value)
if (_pParent) if (_pParent)
_pParent->setProperty(propertyId, value); _pParent->setProperty(propertyId, value);
else else
throw SAXNotRecognizedException(propertyId); throw SAXNotRecognizedException(fromXMLString(propertyId));
} }
@ -168,7 +168,7 @@ void* XMLFilterImpl::getProperty(const XMLString& propertyId) const
if (_pParent) if (_pParent)
return _pParent->getProperty(propertyId); return _pParent->getProperty(propertyId);
else else
throw SAXNotRecognizedException(propertyId); throw SAXNotRecognizedException(fromXMLString(propertyId));
} }

View File

@ -1,7 +1,7 @@
// //
// XMLWriter.cpp // XMLWriter.cpp
// //
// $Id: //poco/1.2/XML/src/XMLWriter.cpp#1 $ // $Id: //poco/1.2/XML/src/XMLWriter.cpp#2 $
// //
// Library: XML // Library: XML
// Package: XML // Package: XML
@ -39,6 +39,7 @@
#include "Poco/XML/XMLException.h" #include "Poco/XML/XMLException.h"
#include "Poco/SAX/AttributesImpl.h" #include "Poco/SAX/AttributesImpl.h"
#include "Poco/UTF8Encoding.h" #include "Poco/UTF8Encoding.h"
#include "Poco/UTF16Encoding.h"
#include <sstream> #include <sstream>
@ -682,7 +683,7 @@ void XMLWriter::addNamespaceAttributes(AttributeMap& attributeMap)
if (!prefix.empty()) if (!prefix.empty())
{ {
qname.append(MARKUP_COLON); qname.append(toXMLString(MARKUP_COLON));
qname.append(prefix); qname.append(prefix);
} }
attributeMap[qname] = uri; attributeMap[qname] = uri;
@ -705,7 +706,7 @@ void XMLWriter::addAttributes(AttributeMap& attributeMap, const Attributes& attr
if (!prefix.empty()) if (!prefix.empty())
{ {
qname = prefix; qname = prefix;
qname.append(MARKUP_COLON); qname.append(toXMLString(MARKUP_COLON));
} }
else qname.clear(); else qname.clear();
qname.append(localName); qname.append(localName);
@ -746,7 +747,7 @@ void XMLWriter::writeXML(XMLChar ch) const
} }
void XMLWriter::writeName(const std::string& prefix, const std::string& localName) void XMLWriter::writeName(const XMLString& prefix, const XMLString& localName)
{ {
if (prefix.empty()) if (prefix.empty())
{ {