GH #1050 Util: fix gcc -Wshadow warnings

This commit is contained in:
Miklos Vajna
2015-12-21 09:05:00 +01:00
parent 8778fb679f
commit 873c471427
12 changed files with 83 additions and 83 deletions

View File

@@ -54,9 +54,9 @@ public:
/// A key-value pair, used as event argument. /// A key-value pair, used as event argument.
{ {
public: public:
KeyValue(const std::string& key, std::string& value): KeyValue(const std::string& rKey, std::string& rValue):
_key(key), _key(rKey),
_value(value) _value(rValue)
{ {
} }

View File

@@ -471,9 +471,9 @@ inline const Poco::Timestamp& Application::startTime() const
inline Poco::Timespan Application::uptime() const inline Poco::Timespan Application::uptime() const
{ {
Poco::Timestamp now; Poco::Timestamp now;
Poco::Timespan uptime = now - _startTime; Poco::Timespan ret = now - _startTime;
return uptime; return ret;
} }

View File

@@ -423,11 +423,11 @@ std::string AbstractConfiguration::internalExpand(const std::string& value) cons
} }
std::string AbstractConfiguration::uncheckedExpand(const std::string& value) const std::string AbstractConfiguration::uncheckedExpand(const std::string& rValue) const
{ {
std::string result; std::string result;
std::string::const_iterator it = value.begin(); std::string::const_iterator it = rValue.begin();
std::string::const_iterator end = value.end(); std::string::const_iterator end = rValue.end();
while (it != end) while (it != end)
{ {
if (*it == '$') if (*it == '$')

View File

@@ -78,7 +78,7 @@ Application::Application():
} }
Application::Application(int argc, char* argv[]): Application::Application(int argc, char* pArgv[]):
_pConfig(new LayeredConfiguration), _pConfig(new LayeredConfiguration),
_initialized(false), _initialized(false),
_unixOptions(true), _unixOptions(true),
@@ -87,7 +87,7 @@ Application::Application(int argc, char* argv[]):
_loadedConfigs(0) _loadedConfigs(0)
{ {
setup(); setup();
init(argc, argv); init(argc, pArgv);
} }
@@ -131,9 +131,9 @@ void Application::addSubsystem(Subsystem* pSubsystem)
} }
void Application::init(int argc, char* argv[]) void Application::init(int argc, char* pArgv[])
{ {
setArgs(argc, argv); setArgs(argc, pArgv);
init(); init();
} }
@@ -363,15 +363,15 @@ int Application::main(const ArgVec& args)
} }
void Application::setArgs(int argc, char* argv[]) void Application::setArgs(int argc, char* pArgv[])
{ {
_command = argv[0]; _command = pArgv[0];
_pConfig->setInt("application.argc", argc); _pConfig->setInt("application.argc", argc);
_unprocessedArgs.reserve(argc); _unprocessedArgs.reserve(argc);
std::string argvKey = "application.argv["; std::string argvKey = "application.argv[";
for (int i = 0; i < argc; ++i) for (int i = 0; i < argc; ++i)
{ {
std::string arg(argv[i]); std::string arg(pArgv[i]);
_pConfig->setString(argvKey + NumberFormatter::format(i) + "]", arg); _pConfig->setString(argvKey + NumberFormatter::format(i) + "]", arg);
_unprocessedArgs.push_back(arg); _unprocessedArgs.push_back(arg);
} }
@@ -403,13 +403,13 @@ void Application::processOptions()
ArgVec::iterator it = _unprocessedArgs.begin(); ArgVec::iterator it = _unprocessedArgs.begin();
while (it != _unprocessedArgs.end() && !_stopOptionsProcessing) while (it != _unprocessedArgs.end() && !_stopOptionsProcessing)
{ {
std::string name; std::string argName;
std::string value; std::string value;
if (processor.process(*it, name, value)) if (processor.process(*it, argName, value))
{ {
if (!name.empty()) // "--" option to end options processing or deferred argument if (!argName.empty()) // "--" option to end options processing or deferred argument
{ {
handleOption(name, value); handleOption(argName, value);
} }
it = _unprocessedArgs.erase(it); it = _unprocessedArgs.erase(it);
} }
@@ -536,18 +536,18 @@ bool Application::findAppConfigFile(const Path& basePath, const std::string& app
} }
void Application::defineOptions(OptionSet& options) void Application::defineOptions(OptionSet& rOptions)
{ {
for (SubsystemVec::iterator it = _subsystems.begin(); it != _subsystems.end(); ++it) for (SubsystemVec::iterator it = _subsystems.begin(); it != _subsystems.end(); ++it)
{ {
(*it)->defineOptions(options); (*it)->defineOptions(rOptions);
} }
} }
void Application::handleOption(const std::string& name, const std::string& value) void Application::handleOption(const std::string& rName, const std::string& value)
{ {
const Option& option = _options.getOption(name); const Option& option = _options.getOption(rName);
if (option.validator()) if (option.validator())
{ {
option.validator()->validate(option, value); option.validator()->validate(option, value);
@@ -560,14 +560,14 @@ void Application::handleOption(const std::string& name, const std::string& value
} }
if (option.callback()) if (option.callback())
{ {
option.callback()->invoke(name, value); option.callback()->invoke(rName, value);
} }
} }
void Application::setLogger(Logger& logger) void Application::setLogger(Logger& rLogger)
{ {
_pLogger = &logger; _pLogger = &rLogger;
} }

View File

@@ -100,7 +100,7 @@ void IniFileConfiguration::setRaw(const std::string& key, const std::string& val
void IniFileConfiguration::enumerate(const std::string& key, Keys& range) const void IniFileConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
std::set<std::string> keys; std::set<std::string> keySet;
std::string prefix = key; std::string prefix = key;
if (!prefix.empty()) prefix += '.'; if (!prefix.empty()) prefix += '.';
std::string::size_type psize = prefix.size(); std::string::size_type psize = prefix.size();
@@ -114,10 +114,10 @@ void IniFileConfiguration::enumerate(const std::string& key, Keys& range) const
subKey = it->first.substr(psize); subKey = it->first.substr(psize);
else else
subKey = it->first.substr(psize, end - psize); subKey = it->first.substr(psize, end - psize);
if (keys.find(subKey) == keys.end()) if (keySet.find(subKey) == keySet.end())
{ {
range.push_back(subKey); range.push_back(subKey);
keys.insert(subKey); keySet.insert(subKey);
} }
} }
} }

View File

@@ -167,7 +167,7 @@ JSON::Object::Ptr JSONConfiguration::findStart(const std::string& key, std::stri
parentArray->add(newArray); parentArray->add(newArray);
} }
for(int i = 0; i <= *it - 1; ++i) for(int j = 0; j <= *it - 1; ++j)
{ {
Poco::DynamicAny nullValue; Poco::DynamicAny nullValue;
newArray->add(nullValue); newArray->add(nullValue);

View File

@@ -140,17 +140,17 @@ void LayeredConfiguration::setRaw(const std::string& key, const std::string& val
void LayeredConfiguration::enumerate(const std::string& key, Keys& range) const void LayeredConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
std::set<std::string> keys; std::set<std::string> keySet;
for (ConfigList::const_iterator itc = _configs.begin(); itc != _configs.end(); ++itc) for (ConfigList::const_iterator itc = _configs.begin(); itc != _configs.end(); ++itc)
{ {
Keys partRange; Keys partRange;
itc->pConfig->enumerate(key, partRange); itc->pConfig->enumerate(key, partRange);
for (Keys::const_iterator itr = partRange.begin(); itr != partRange.end(); ++itr) for (Keys::const_iterator itr = partRange.begin(); itr != partRange.end(); ++itr)
{ {
if (keys.find(*itr) == keys.end()) if (keySet.find(*itr) == keySet.end())
{ {
range.push_back(*itr); range.push_back(*itr);
keys.insert(*itr); keySet.insert(*itr);
} }
} }
} }

View File

@@ -58,7 +58,7 @@ void MapConfiguration::setRaw(const std::string& key, const std::string& value)
void MapConfiguration::enumerate(const std::string& key, Keys& range) const void MapConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
std::set<std::string> keys; std::set<std::string> keySet;
std::string prefix = key; std::string prefix = key;
if (!prefix.empty()) prefix += '.'; if (!prefix.empty()) prefix += '.';
std::string::size_type psize = prefix.size(); std::string::size_type psize = prefix.size();
@@ -67,15 +67,15 @@ void MapConfiguration::enumerate(const std::string& key, Keys& range) const
if (it->first.compare(0, psize, prefix) == 0) if (it->first.compare(0, psize, prefix) == 0)
{ {
std::string subKey; std::string subKey;
std::string::size_type end = it->first.find('.', psize); std::string::size_type pos = it->first.find('.', psize);
if (end == std::string::npos) if (pos == std::string::npos)
subKey = it->first.substr(psize); subKey = it->first.substr(psize);
else else
subKey = it->first.substr(psize, end - psize); subKey = it->first.substr(psize, pos - psize);
if (keys.find(subKey) == keys.end()) if (keySet.find(subKey) == keySet.end())
{ {
range.push_back(subKey); range.push_back(subKey);
keys.insert(subKey); keySet.insert(subKey);
} }
} }
} }

View File

@@ -60,9 +60,9 @@ Option::Option(const Option& option):
} }
Option::Option(const std::string& fullName, const std::string& shortName): Option::Option(const std::string& rFullName, const std::string& rShortName):
_shortName(shortName), _shortName(rShortName),
_fullName(fullName), _fullName(rFullName),
_required(false), _required(false),
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
@@ -73,11 +73,11 @@ Option::Option(const std::string& fullName, const std::string& shortName):
} }
Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required): Option::Option(const std::string& rFullName, const std::string& rShortName, const std::string& rDescription, bool isRequired):
_shortName(shortName), _shortName(rShortName),
_fullName(fullName), _fullName(rFullName),
_description(description), _description(rDescription),
_required(required), _required(isRequired),
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
_pValidator(0), _pValidator(0),
@@ -87,11 +87,11 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
} }
Option::Option(const std::string& fullName, const std::string& shortName, const std::string& description, bool required, const std::string& argName, bool argRequired): Option::Option(const std::string& rFullName, const std::string& rShortName, const std::string& rDescription, bool isRequired, const std::string& argName, bool argRequired):
_shortName(shortName), _shortName(rShortName),
_fullName(fullName), _fullName(rFullName),
_description(description), _description(rDescription),
_required(required), _required(isRequired),
_repeatable(false), _repeatable(false),
_argName(argName), _argName(argName),
_argRequired(argRequired), _argRequired(argRequired),
@@ -173,10 +173,10 @@ Option& Option::repeatable(bool flag)
} }
Option& Option::argument(const std::string& name, bool required) Option& Option::argument(const std::string& name, bool isRequired)
{ {
_argName = name; _argName = name;
_argRequired = required; _argRequired = isRequired;
return *this; return *this;
} }
@@ -189,9 +189,9 @@ Option& Option::noArgument()
} }
Option& Option::group(const std::string& group) Option& Option::group(const std::string& rGroup)
{ {
_group = group; _group = rGroup;
return *this; return *this;
} }

View File

@@ -610,16 +610,16 @@ void ServerApplication::waitForTerminationRequest()
} }
int ServerApplication::run(int argc, char** argv) int ServerApplication::run(int argc, char** pArgv)
{ {
bool runAsDaemon = isDaemon(argc, argv); bool runAsDaemon = isDaemon(argc, pArgv);
if (runAsDaemon) if (runAsDaemon)
{ {
beDaemon(); beDaemon();
} }
try try
{ {
init(argc, argv); init(argc, pArgv);
if (runAsDaemon) if (runAsDaemon)
{ {
int rc = chdir("/"); int rc = chdir("/");
@@ -668,12 +668,12 @@ int ServerApplication::run(const std::vector<std::string>& args)
} }
bool ServerApplication::isDaemon(int argc, char** argv) bool ServerApplication::isDaemon(int argc, char** pArgv)
{ {
std::string option("--daemon"); std::string option("--daemon");
for (int i = 1; i < argc; ++i) for (int i = 1; i < argc; ++i)
{ {
if (option == argv[i]) if (option == pArgv[i])
return true; return true;
} }
return false; return false;
@@ -708,17 +708,17 @@ void ServerApplication::beDaemon()
} }
void ServerApplication::defineOptions(OptionSet& options) void ServerApplication::defineOptions(OptionSet& rOptions)
{ {
Application::defineOptions(options); Application::defineOptions(rOptions);
options.addOption( rOptions.addOption(
Option("daemon", "", "Run application as a daemon.") Option("daemon", "", "Run application as a daemon.")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
.callback(OptionCallback<ServerApplication>(this, &ServerApplication::handleDaemon))); .callback(OptionCallback<ServerApplication>(this, &ServerApplication::handleDaemon)));
options.addOption( rOptions.addOption(
Option("pidfile", "", "Write the process ID of the application to given file.") Option("pidfile", "", "Write the process ID of the application to given file.")
.required(false) .required(false)
.repeatable(false) .repeatable(false)
@@ -727,13 +727,13 @@ void ServerApplication::defineOptions(OptionSet& options)
} }
void ServerApplication::handleDaemon(const std::string& name, const std::string& value) void ServerApplication::handleDaemon(const std::string& rName, const std::string& Value)
{ {
config().setBool("application.runAsDaemon", true); config().setBool("application.runAsDaemon", true);
} }
void ServerApplication::handlePidFile(const std::string& name, const std::string& value) void ServerApplication::handlePidFile(const std::string& rName, const std::string& value)
{ {
std::ofstream ostr(value.c_str()); std::ofstream ostr(value.c_str());
if (ostr.good()) if (ostr.good())

View File

@@ -30,8 +30,8 @@ namespace Util {
class TimerNotification: public Poco::Notification class TimerNotification: public Poco::Notification
{ {
public: public:
TimerNotification(Poco::TimedNotificationQueue& queue): TimerNotification(Poco::TimedNotificationQueue& rQueue):
_queue(queue) _queue(rQueue)
{ {
} }
@@ -54,8 +54,8 @@ private:
class StopNotification: public TimerNotification class StopNotification: public TimerNotification
{ {
public: public:
StopNotification(Poco::TimedNotificationQueue& queue): StopNotification(Poco::TimedNotificationQueue& rQueue):
TimerNotification(queue) TimerNotification(rQueue)
{ {
} }
@@ -74,8 +74,8 @@ public:
class CancelNotification: public TimerNotification class CancelNotification: public TimerNotification
{ {
public: public:
CancelNotification(Poco::TimedNotificationQueue& queue): CancelNotification(Poco::TimedNotificationQueue& rQueue):
TimerNotification(queue) TimerNotification(rQueue)
{ {
} }
@@ -103,8 +103,8 @@ private:
class TaskNotification: public TimerNotification class TaskNotification: public TimerNotification
{ {
public: public:
TaskNotification(Poco::TimedNotificationQueue& queue, TimerTask::Ptr pTask): TaskNotification(Poco::TimedNotificationQueue& rQueue, TimerTask::Ptr pTask):
TimerNotification(queue), TimerNotification(rQueue),
_pTask(pTask) _pTask(pTask)
{ {
} }
@@ -151,8 +151,8 @@ private:
class PeriodicTaskNotification: public TaskNotification class PeriodicTaskNotification: public TaskNotification
{ {
public: public:
PeriodicTaskNotification(Poco::TimedNotificationQueue& queue, TimerTask::Ptr pTask, long interval): PeriodicTaskNotification(Poco::TimedNotificationQueue& rQueue, TimerTask::Ptr pTask, long interval):
TaskNotification(queue, pTask), TaskNotification(rQueue, pTask),
_interval(interval) _interval(interval)
{ {
} }
@@ -185,8 +185,8 @@ private:
class FixedRateTaskNotification: public TaskNotification class FixedRateTaskNotification: public TaskNotification
{ {
public: public:
FixedRateTaskNotification(Poco::TimedNotificationQueue& queue, TimerTask::Ptr pTask, long interval, Poco::Clock clock): FixedRateTaskNotification(Poco::TimedNotificationQueue& rQueue, TimerTask::Ptr pTask, long interval, Poco::Clock clock):
TaskNotification(queue, pTask), TaskNotification(rQueue, pTask),
_interval(interval), _interval(interval),
_nextExecution(clock) _nextExecution(clock)
{ {

View File

@@ -260,7 +260,7 @@ void XMLConfiguration::enumerate(const std::string& key, Keys& range) const
{ {
using Poco::NumberFormatter; using Poco::NumberFormatter;
std::multiset<std::string> keys; std::multiset<std::string> keySet;
const Poco::XML::Node* pNode = findNode(key); const Poco::XML::Node* pNode = findNode(key);
if (pNode) if (pNode)
{ {
@@ -270,12 +270,12 @@ void XMLConfiguration::enumerate(const std::string& key, Keys& range) const
if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE) if (pChild->nodeType() == Poco::XML::Node::ELEMENT_NODE)
{ {
const std::string& nodeName = pChild->nodeName(); const std::string& nodeName = pChild->nodeName();
int n = (int) keys.count(nodeName); int n = (int) keySet.count(nodeName);
if (n) if (n)
range.push_back(nodeName + "[" + NumberFormatter::format(n) + "]"); range.push_back(nodeName + "[" + NumberFormatter::format(n) + "]");
else else
range.push_back(nodeName); range.push_back(nodeName);
keys.insert(nodeName); keySet.insert(nodeName);
} }
pChild = pChild->nextSibling(); pChild = pChild->nextSibling();
} }