1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-10-15 07:27:19 +02:00

Update POCO library.

This commit is contained in:
Sandu Liviu Catalin
2023-03-23 20:19:11 +02:00
parent 8d15f4b6e9
commit 233fc103f9
2521 changed files with 257092 additions and 72789 deletions

View File

@@ -14,6 +14,7 @@
#include "Poco/Util/AbstractConfiguration.h"
#include "Poco/Util/ConfigurationView.h"
#include "Poco/Util/LocalConfigurationView.h"
#include "Poco/Exception.h"
#include "Poco/NumberParser.h"
#include "Poco/NumberFormatter.h"
@@ -33,7 +34,7 @@ namespace Poco {
namespace Util {
AbstractConfiguration::AbstractConfiguration():
AbstractConfiguration::AbstractConfiguration():
_depth(0),
_eventsEnabled(true)
{
@@ -65,7 +66,7 @@ bool AbstractConfiguration::has(const std::string& key) const
return hasProperty(key);
}
std::string AbstractConfiguration::getString(const std::string& key) const
{
Mutex::ScopedLock lock(_mutex);
@@ -77,7 +78,7 @@ std::string AbstractConfiguration::getString(const std::string& key) const
throw NotFoundException(key);
}
std::string AbstractConfiguration::getString(const std::string& key, const std::string& defaultValue) const
{
Mutex::ScopedLock lock(_mutex);
@@ -101,10 +102,10 @@ std::string AbstractConfiguration::getRawString(const std::string& key) const
throw NotFoundException(key);
}
std::string AbstractConfiguration::getRawString(const std::string& key, const std::string& defaultValue) const
{
Mutex::ScopedLock lock(_mutex);
std::string value;
@@ -114,7 +115,7 @@ std::string AbstractConfiguration::getRawString(const std::string& key, const st
return defaultValue;
}
int AbstractConfiguration::getInt(const std::string& key) const
{
Mutex::ScopedLock lock(_mutex);
@@ -126,7 +127,7 @@ int AbstractConfiguration::getInt(const std::string& key) const
throw NotFoundException(key);
}
int AbstractConfiguration::getInt(const std::string& key, int defaultValue) const
{
Mutex::ScopedLock lock(_mutex);
@@ -228,7 +229,7 @@ double AbstractConfiguration::getDouble(const std::string& key) const
throw NotFoundException(key);
}
double AbstractConfiguration::getDouble(const std::string& key, double defaultValue) const
{
Mutex::ScopedLock lock(_mutex);
@@ -270,13 +271,13 @@ void AbstractConfiguration::setString(const std::string& key, const std::string&
setRawWithEvent(key, value);
}
void AbstractConfiguration::setInt(const std::string& key, int value)
{
setRawWithEvent(key, NumberFormatter::format(value));
}
void AbstractConfiguration::setUInt(const std::string& key, unsigned int value)
{
setRawWithEvent(key, NumberFormatter::format(value));
@@ -348,6 +349,18 @@ AbstractConfiguration::Ptr AbstractConfiguration::createView(const std::string&
}
const AbstractConfiguration::Ptr AbstractConfiguration::createLocalView(const std::string& prefix) const
{
return new LocalConfigurationView(prefix, AbstractConfiguration::Ptr(const_cast<AbstractConfiguration*>(this), true));
}
AbstractConfiguration::Ptr AbstractConfiguration::createLocalView(const std::string& prefix)
{
return new LocalConfigurationView(prefix, AbstractConfiguration::Ptr(this, true));
}
namespace
{
class AutoCounter
@@ -357,12 +370,12 @@ namespace
{
++_count;
}
~AutoCounter()
{
--_count;
}
private:
int& _count;
};
@@ -384,7 +397,7 @@ void AbstractConfiguration::remove(const std::string& key)
propertyRemoving(this, key);
}
{
Mutex::ScopedLock lock(_mutex);
removeRaw(key);
}
@@ -400,7 +413,7 @@ void AbstractConfiguration::enableEvents(bool enable)
_eventsEnabled = enable;
}
bool AbstractConfiguration::eventsEnabled() const
{
return _eventsEnabled;
@@ -510,7 +523,7 @@ bool AbstractConfiguration::parseBool(const std::string& value)
return false;
else if (icompare(value, "off") == 0)
return false;
else
else
throw SyntaxException("Cannot convert to boolean", value);
}

View File

@@ -42,6 +42,10 @@
#include "Poco/SignalHandler.h"
#include <stdio.h>
#include <sys/ioctl.h>
#if POCO_OS == POCO_OS_SOLARIS
#include <stropts.h>
#include <termios.h>
#endif
#endif
#include "Poco/UnicodeConverter.h"

View File

@@ -46,7 +46,7 @@ bool ConfigurationMapper::getRaw(const std::string& key, std::string& value) con
void ConfigurationMapper::setRaw(const std::string& key, const std::string& value)
{
std::string translatedKey = translateKey(key);
_pConfig->setRaw(translatedKey, value);
_pConfig->setRaw(translatedKey, value);
}

View File

@@ -42,7 +42,7 @@ bool ConfigurationView::getRaw(const std::string& key, std::string& value) const
void ConfigurationView::setRaw(const std::string& key, const std::string& value)
{
std::string translatedKey = translateKey(key);
_pConfig->setRaw(translatedKey, value);
_pConfig->setRaw(translatedKey, value);
}

View File

@@ -119,7 +119,7 @@ Path FilesystemConfiguration::keyToPath(const std::string& key) const
for (const auto& tok: tokenizer)
{
result.pushDirectory(tok);
}
}
return result;
}

View File

@@ -25,7 +25,7 @@ const int HelpFormatter::TAB_WIDTH = 4;
const int HelpFormatter::LINE_WIDTH = 78;
HelpFormatter::HelpFormatter(const OptionSet& options):
HelpFormatter::HelpFormatter(const OptionSet& options):
_options(options),
_width(LINE_WIDTH),
_indent(0),
@@ -94,7 +94,7 @@ void HelpFormatter::format(std::ostream& ostr) const
void HelpFormatter::setWidth(int width)
{
poco_assert (width > 0);
_width = width;
}
@@ -102,7 +102,7 @@ void HelpFormatter::setWidth(int width)
void HelpFormatter::setIndent(int indent)
{
poco_assert (indent >= 0 && indent < _width);
_indent = indent;
}
@@ -240,7 +240,7 @@ void HelpFormatter::formatText(std::ostream& ostr, const std::string& text, int
clearWord(ostr, pos, word, indent);
if (pos < _width) { ostr << ' '; ++pos; }
}
else
else
{
if (word.length() == maxWordLen)
{

View File

@@ -45,7 +45,7 @@ IniFileConfiguration::IniFileConfiguration(std::istream& istr)
load(istr);
}
IniFileConfiguration::IniFileConfiguration(const std::string& path)
{
load(path);
@@ -66,7 +66,7 @@ void IniFileConfiguration::load(std::istream& istr)
parseLine(istr);
}
}
void IniFileConfiguration::load(const std::string& path)
{
@@ -148,7 +148,7 @@ bool IniFileConfiguration::ICompare::operator () (const std::string& s1, const s
void IniFileConfiguration::parseLine(std::istream& istr)
{
static const int eof = std::char_traits<char>::eof();
static const int eof = std::char_traits<char>::eof();
int c = istr.get();
while (c != eof && Poco::Ascii::isSpace(c)) c = istr.get();

View File

@@ -70,7 +70,7 @@ void JSONConfiguration::load(std::istream& istr)
JSON::Parser parser;
parser.parse(istr);
DynamicAny result = parser.result();
if ( result.type() == typeid(JSON::Object::Ptr) )
if (result.type() == typeid(JSON::Object::Ptr))
{
_object = result.extract<JSON::Object::Ptr>();
}
@@ -89,7 +89,7 @@ bool JSONConfiguration::getRaw(const std::string & key, std::string & value) con
{
JSON::Query query(_object);
Poco::DynamicAny result = query.find(key);
if ( ! result.isEmpty() )
if (!result.isEmpty())
{
value = result.convert<std::string>();
return true;
@@ -106,9 +106,9 @@ void JSONConfiguration::getIndexes(std::string& name, std::vector<int>& indexes)
int firstOffset = -1;
int offset = 0;
RegularExpression regex("\\[([0-9]+)\\]");
while(regex.match(name, offset, matches) > 0 )
while(regex.match(name, offset, matches) > 0)
{
if ( firstOffset == -1 )
if (firstOffset == -1)
{
firstOffset = static_cast<int>(matches[0].offset);
}
@@ -117,7 +117,7 @@ void JSONConfiguration::getIndexes(std::string& name, std::vector<int>& indexes)
offset = static_cast<int>(matches[0].offset + matches[0].length);
}
if ( firstOffset != -1 )
if (firstOffset != -1)
{
name = name.substr(0, firstOffset);
}
@@ -139,9 +139,9 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
DynamicAny result = currentObject->get(name);
if ( result.isEmpty() ) // Not found
if (result.isEmpty()) // Not found
{
if ( indexes.empty() ) // We want an object, create it
if (indexes.empty()) // We want an object, create it
{
JSON::Object::Ptr newObject = new JSON::Object();
currentObject->set(name, newObject);
@@ -155,12 +155,12 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
for(std::vector<int>::iterator it = indexes.begin(); it != indexes.end(); ++it)
{
newArray = new JSON::Array();
if ( topArray.isNull() )
if (topArray.isNull())
{
topArray = newArray;
}
if ( ! parentArray.isNull() )
if (! parentArray.isNull())
{
parentArray->add(newArray);
}
@@ -181,9 +181,9 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
}
else // We have a value
{
if ( indexes.empty() ) // We want an object
if (indexes.empty()) // We want an object
{
if ( result.type() == typeid(JSON::Object::Ptr) )
if (result.type() == typeid(JSON::Object::Ptr))
{
currentObject = result.extract<JSON::Object::Ptr>();
}
@@ -194,7 +194,7 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
}
else
{
if ( result.type() == typeid(JSON::Array::Ptr) )
if (result.type() == typeid(JSON::Array::Ptr))
{
JSON::Array::Ptr arr = result.extract<JSON::Array::Ptr>();
@@ -202,7 +202,7 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
{
JSON::Array::Ptr currentArray = arr;
arr = arr->getArray(*it);
if ( arr.isNull() )
if (arr.isNull())
{
arr = new JSON::Array();
currentArray->add(arr);
@@ -210,7 +210,7 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
}
result = arr->get(*indexes.rbegin());
if ( result.isEmpty() ) // Index doesn't exist
if (result.isEmpty()) // Index doesn't exist
{
JSON::Object::Ptr newObject = new JSON::Object();
arr->add(newObject);
@@ -218,7 +218,7 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
}
else // Index is available
{
if ( result.type() == typeid(JSON::Object::Ptr) )
if (result.type() == typeid(JSON::Object::Ptr))
{
currentObject = result.extract<JSON::Object::Ptr>();
}
@@ -243,34 +243,34 @@ void JSONConfiguration::setValue(const std::string& key, const Poco::DynamicAny&
{
std::string sValue;
value.convert<std::string>(sValue);
KeyValue kv(key, sValue);
if (eventsEnabled())
{
propertyChanging(this, kv);
}
std::string lastPart;
JSON::Object::Ptr parentObject = findStart(key, lastPart);
std::vector<int> indexes;
getIndexes(lastPart, indexes);
if ( indexes.empty() ) // No Array
if (indexes.empty()) // No Array
{
parentObject->set(lastPart, value);
}
else
{
DynamicAny result = parentObject->get(lastPart);
if ( result.isEmpty() )
if (result.isEmpty())
{
result = JSON::Array::Ptr(new JSON::Array());
parentObject->set(lastPart, result);
}
else if ( result.type() != typeid(JSON::Array::Ptr) )
else if (result.type() != typeid(JSON::Array::Ptr))
{
throw SyntaxException("Expected a JSON array");
}
@@ -279,7 +279,7 @@ void JSONConfiguration::setValue(const std::string& key, const Poco::DynamicAny&
for(std::vector<int>::iterator it = indexes.begin(); it != indexes.end() - 1; ++it)
{
JSON::Array::Ptr nextArray = arr->getArray(*it);
if ( nextArray.isNull() )
if (nextArray.isNull())
{
for(int i = static_cast<int>(arr->size()); i <= *it; ++i)
{
@@ -335,7 +335,7 @@ void JSONConfiguration::enumerate(const std::string& key, Keys& range) const
{
JSON::Query query(_object);
Poco::DynamicAny result = query.find(key);
if ( result.type() == typeid(JSON::Object::Ptr) )
if (result.type() == typeid(JSON::Object::Ptr))
{
JSON::Object::Ptr object = result.extract<JSON::Object::Ptr>();
object->getNames(range);
@@ -352,13 +352,13 @@ void JSONConfiguration::save(std::ostream& ostr, unsigned int indent) const
void JSONConfiguration::removeRaw(const std::string& key)
{
std::string lastPart;
JSON::Object::Ptr parentObject = findStart(key, lastPart);
std::vector<int> indexes;
getIndexes(lastPart, indexes);
if ( indexes.empty() ) // No Array
if (indexes.empty()) // No Array
{
parentObject->remove(lastPart);
}

View File

@@ -78,7 +78,7 @@ void LayeredConfiguration::add(AbstractConfiguration::Ptr pConfig, const std::st
item.priority = priority;
item.writeable = writeable;
item.label = label;
ConfigList::iterator it = _configs.begin();
while (it != _configs.end() && it->priority < priority) ++it;
_configs.insert(it, item);
@@ -124,7 +124,7 @@ void LayeredConfiguration::setRaw(const std::string& key, const std::string& val
{
if (conf.writeable)
{
conf.pConfig->setRaw(key, value);
conf.pConfig->setRaw(key, value);
return;
}
}

View File

@@ -0,0 +1,70 @@
//
// LocalConfigurationView.cpp
//
// Library: Util
// Package: Configuration
// Module: LocalConfigurationView
//
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
//
#include "Poco/Util/LocalConfigurationView.h"
namespace Poco {
namespace Util {
LocalConfigurationView::LocalConfigurationView(const std::string& prefix, AbstractConfiguration::Ptr pConfig) :
_prefix(prefix), _pConfig(pConfig)
{
poco_check_ptr(pConfig);
}
LocalConfigurationView::~LocalConfigurationView()
{
}
bool LocalConfigurationView::getRaw(const std::string& key, std::string& value) const
{
std::string translatedKey = translateKey(key);
return _pConfig->getRaw(translatedKey, value);
}
void LocalConfigurationView::setRaw(const std::string& key, const std::string& value)
{
std::string translatedKey = translateKey(key);
_pConfig->setRaw(translatedKey, value);
}
void LocalConfigurationView::enumerate(const std::string& key, Keys& range) const
{
std::string translatedKey = translateKey(key);
_pConfig->enumerate(translatedKey, range);
}
void LocalConfigurationView::removeRaw(const std::string& key)
{
std::string translatedKey = translateKey(key);
_pConfig->remove(translatedKey);
}
std::string LocalConfigurationView::translateKey(const std::string& key) const
{
std::string result = _prefix;
if (!result.empty() && !key.empty() && key[0] != '[') result += '.';
result += key;
return result;
}
}} // namespace Poco::Util

View File

@@ -102,7 +102,7 @@ void LoggingConfigurator::configureLoggers(AbstractConfiguration::Ptr pConfig)
AbstractConfiguration::Keys loggers;
pConfig->keys(loggers);
// use a map to sort loggers by their name, ensuring initialization in correct order (parents before children)
LoggerMap loggerMap;
LoggerMap loggerMap;
for (const auto& l: loggers)
{
AutoPtr<AbstractConfiguration> pLoggerConfig(pConfig->createView(l));
@@ -123,7 +123,7 @@ Formatter::Ptr LoggingConfigurator::createFormatter(AbstractConfiguration::Ptr p
for (const auto& p: props)
{
if (p != "class")
pFormatter->setProperty(p, pConfig->getString(p));
pFormatter->setProperty(p, pConfig->getString(p));
}
return pFormatter;
}
@@ -147,7 +147,7 @@ Channel::Ptr LoggingConfigurator::createChannel(AbstractConfiguration::Ptr pConf
AutoPtr<FormattingChannel> pFormattingChannel(new FormattingChannel(0, pChannel));
if (pConfig->hasProperty("formatter.class"))
{
AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(p));
AutoPtr<AbstractConfiguration> pFormatterConfig(pConfig->createView(p));
AutoPtr<Formatter> pFormatter(createFormatter(pFormatterConfig));
pFormattingChannel->setFormatter(pFormatter);
}
@@ -182,7 +182,7 @@ void LoggingConfigurator::configureLogger(AbstractConfiguration::Ptr pConfig)
{
if (p == "channel" && pConfig->hasProperty("channel.class"))
{
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(p));
AutoPtr<AbstractConfiguration> pChannelConfig(pConfig->createView(p));
AutoPtr<Channel> pChannel(createChannel(pChannelConfig));
configureChannel(pChannel, pChannelConfig);
Logger::setChannel(logger.name(), pChannel);

View File

@@ -40,7 +40,7 @@ const char* LoggingSubsystem::name() const
return "Logging Subsystem";
}
void LoggingSubsystem::initialize(Application& app)
{
LoggingConfigurator configurator;

View File

@@ -27,13 +27,12 @@ namespace Poco {
namespace Util {
Option::Option():
_required(false),
_repeatable(false),
Option::Option():
_required(false),
_repeatable(false),
_argRequired(false),
_pValidator(0),
_pCallback(0),
_pConfig(0)
_pCallback(0)
{
}
@@ -54,7 +53,6 @@ Option::Option(const Option& option):
{
if (_pValidator) _pValidator->duplicate();
if (_pCallback) _pCallback = _pCallback->clone();
if (_pConfig) _pConfig->duplicate();
}
@@ -65,8 +63,7 @@ Option::Option(const std::string& fullName, const std::string& shortName):
_repeatable(false),
_argRequired(false),
_pValidator(0),
_pCallback(0),
_pConfig(0)
_pCallback(0)
{
}
@@ -79,8 +76,7 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
_repeatable(false),
_argRequired(false),
_pValidator(0),
_pCallback(0),
_pConfig(0)
_pCallback(0)
{
}
@@ -94,8 +90,7 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
_argName(argName),
_argRequired(argRequired),
_pValidator(0),
_pCallback(0),
_pConfig(0)
_pCallback(0)
{
}
@@ -103,7 +98,6 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
Option::~Option()
{
if (_pValidator) _pValidator->release();
if (_pConfig) _pConfig->release();
delete _pCallback;
}
@@ -119,7 +113,7 @@ Option& Option::operator = (const Option& option)
}
void Option::swap(Option& option)
void Option::swap(Option& option) noexcept
{
std::swap(_shortName, option._shortName);
std::swap(_fullName, option._fullName);
@@ -135,7 +129,7 @@ void Option::swap(Option& option)
std::swap(_pConfig, option._pConfig);
}
Option& Option::shortName(const std::string& name)
{
_shortName = name;
@@ -149,14 +143,14 @@ Option& Option::fullName(const std::string& name)
return *this;
}
Option& Option::description(const std::string& text)
{
_description = text;
return *this;
}
Option& Option::required(bool flag)
{
_required = flag;
@@ -170,7 +164,7 @@ Option& Option::repeatable(bool flag)
return *this;
}
Option& Option::argument(const std::string& name, bool required)
{
_argName = name;
@@ -178,7 +172,7 @@ Option& Option::argument(const std::string& name, bool required)
return *this;
}
Option& Option::noArgument()
{
_argName.clear();
@@ -200,12 +194,10 @@ Option& Option::binding(const std::string& propertyName)
}
Option& Option::binding(const std::string& propertyName, AbstractConfiguration* pConfig)
Option& Option::binding(const std::string& propertyName, AbstractConfiguration::Ptr pConfig)
{
_binding = propertyName;
if (_pConfig) _pConfig->release();
_pConfig = pConfig;
if (_pConfig) _pConfig->duplicate();
return *this;
}
@@ -227,7 +219,7 @@ Option& Option::validator(Validator* pValidator)
bool Option::matchesShort(const std::string& option) const
{
return option.length() > 0
return option.length() > 0
&& !_shortName.empty() && option.compare(0, _shortName.length(), _shortName) == 0;
}
@@ -245,7 +237,7 @@ bool Option::matchesPartial(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 option.length() > 0
return option.length() > 0
&& icompare(option, 0, len, _fullName, 0, len) == 0;
}

View File

@@ -22,7 +22,7 @@ namespace Poco {
namespace Util {
OptionProcessor::OptionProcessor(const OptionSet& options):
OptionProcessor::OptionProcessor(const OptionSet& options):
_options(options),
_unixStyle(true),
_ignore(false)

View File

@@ -78,7 +78,7 @@ bool OptionSet::hasOption(const std::string& name, bool matchShort) const
return found;
}
const Option& OptionSet::getOption(const std::string& name, bool matchShort) const
{
const Option* pOption = 0;

View File

@@ -39,7 +39,7 @@ PropertyFileConfiguration::PropertyFileConfiguration(std::istream& istr)
load(istr);
}
PropertyFileConfiguration::PropertyFileConfiguration(const std::string& path)
{
load(path);
@@ -50,7 +50,7 @@ PropertyFileConfiguration::~PropertyFileConfiguration()
{
}
void PropertyFileConfiguration::load(std::istream& istr)
{
clear();
@@ -60,7 +60,7 @@ void PropertyFileConfiguration::load(std::istream& istr)
}
}
void PropertyFileConfiguration::load(const std::string& path)
{
Poco::FileInputStream istr(path);
@@ -125,7 +125,7 @@ void PropertyFileConfiguration::save(const std::string& path) const
void PropertyFileConfiguration::parseLine(std::istream& istr)
{
static const int eof = std::char_traits<char>::eof();
static const int eof = std::char_traits<char>::eof();
int c = istr.get();
while (c != eof && Poco::Ascii::isSpace(c)) c = istr.get();

View File

@@ -93,6 +93,11 @@ public:
_finished.set();
return false;
}
Poco::AutoPtr<CancelNotification> pCnf = pNf.cast<CancelNotification>();
if (pCnf)
{
pCnf->_finished.set();
}
pNf = static_cast<TimerNotification*>(queue().dequeueNotification());
}
@@ -135,7 +140,7 @@ public:
{
try
{
_pTask->_lastExecution.update();
_pTask->updateLastExecution();
_pTask->run();
}
catch (Exception& exc)

View File

@@ -102,7 +102,7 @@ void WinService::registerService(const std::string& path, const std::string& dis
_svcHandle = CreateServiceW(
_scmHandle,
uname.c_str(),
udisplayName.c_str(),
udisplayName.c_str(),
SERVICE_ALL_ACCESS,
SERVICE_WIN32_OWN_PROCESS,
SERVICE_DEMAND_START,
@@ -113,7 +113,7 @@ void WinService::registerService(const std::string& path, const std::string& dis
throw SystemException("cannot register service", _name);
}
void WinService::registerService(const std::string& path)
{
registerService(path, _name);
@@ -144,7 +144,7 @@ bool WinService::isRunning() const
return ss.dwCurrentState == SERVICE_RUNNING;
}
bool WinService::isStopped() const
bool WinService::isStopped() const
{
open();
SERVICE_STATUS ss;
@@ -153,7 +153,7 @@ bool WinService::isStopped() const
return ss.dwCurrentState == SERVICE_STOPPED;
}
void WinService::start()
{
open();
@@ -209,7 +209,7 @@ void WinService::setStartup(WinService::Startup startup)
}
}
WinService::Startup WinService::getStartup() const
{
POCO_LPQUERY_SERVICE_CONFIG pSvcConfig = config();
@@ -252,15 +252,15 @@ void WinService::setFailureActions(FailureActionVector failureActions, const std
Poco::UnicodeConverter::toUTF16(rebootMessage, urebootMessage);
std::vector<wchar_t> rebootMessageVector{ urebootMessage.begin(), urebootMessage.end() };
rebootMessageVector.push_back('\0');
std::wstring uComamnd;
Poco::UnicodeConverter::toUTF16(command, uComamnd);
std::vector<wchar_t> commandVector{ uComamnd.begin(), uComamnd.end() };
commandVector.push_back('\0');
for (auto i = 0; i < failureActions.size(); i++)
for (auto i = 0; i < failureActions.size(); i++)
{
switch (failureActions[i].type)
switch (failureActions[i].type)
{
case SVC_REBOOT:
actions[i].Type = SC_ACTION_REBOOT;
@@ -311,15 +311,15 @@ WinService::FailureActionTypeVector WinService::getFailureActions() const {
} else throw SystemException("cannot query service configuration", _name);
}
}
catch (...)
catch (...)
{
LocalFree(pSvcFailureAction);
throw;
}
FailureActionTypeVector result(3, SVC_NONE);
for (auto i = 0; i < pSvcFailureAction->cActions; i++)
for (auto i = 0; i < pSvcFailureAction->cActions; i++)
{
switch (pSvcFailureAction->lpsaActions->Type)
switch (pSvcFailureAction->lpsaActions->Type)
{
case SC_ACTION_NONE:
result[i] = SVC_NONE;

View File

@@ -103,7 +103,7 @@ XMLConfiguration::XMLConfiguration(const Poco::XML::Document* pDocument, char de
load(pDocument);
}
XMLConfiguration::XMLConfiguration(const Poco::XML::Node* pNode):
_delim('.')
{
@@ -126,7 +126,7 @@ XMLConfiguration::~XMLConfiguration()
void XMLConfiguration::load(Poco::XML::InputSource* pInputSource, unsigned long namePoolSize)
{
poco_check_ptr (pInputSource);
Poco::XML::DOMParser parser(namePoolSize);
parser.setFeature(Poco::XML::XMLReader::FEATURE_NAMESPACES, false);
parser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
@@ -144,21 +144,21 @@ void XMLConfiguration::load(Poco::XML::InputSource* pInputSource)
void XMLConfiguration::load(std::istream& istr)
{
Poco::XML::InputSource src(istr);
load(&src);
load(&src);
}
void XMLConfiguration::load(const std::string& path)
{
Poco::XML::InputSource src(path);
load(&src);
load(&src);
}
void XMLConfiguration::load(const Poco::XML::Document* pDocument)
{
poco_check_ptr (pDocument);
_pDocument = Poco::XML::AutoPtr<Poco::XML::Document>(const_cast<Poco::XML::Document*>(pDocument), true);
_pRoot = Poco::XML::AutoPtr<Poco::XML::Node>(pDocument->documentElement(), true);
}
@@ -265,8 +265,8 @@ void XMLConfiguration::setRaw(const std::string& key, const std::string& value)
void XMLConfiguration::enumerate(const std::string& key, Keys& range) const
{
using Poco::NumberFormatter;
std::multiset<std::string> keys;
std::map<std::string, size_t> keys;
const Poco::XML::Node* pNode = findNode(key);
if (pNode)
{
@@ -276,12 +276,12 @@ void XMLConfiguration::enumerate(const std::string& key, Keys& range) const
if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE)
{
const std::string& nodeName = pChild->nodeName();
int n = (int) keys.count(nodeName);
if (n)
range.push_back(nodeName + "[" + NumberFormatter::format(n) + "]");
size_t& count = keys[nodeName];
if (count)
range.push_back(nodeName + "[" + NumberFormatter::format(count) + "]");
else
range.push_back(nodeName);
keys.insert(nodeName);
++count;
}
pChild = pChild->nextSibling();
}