mirror of
https://github.com/VCMP-SqMod/SqMod.git
synced 2026-10-25 14:07:09 +01:00
Major plugin refactor and cleanup.
Switched to POCO library for unified platform/library interface. Deprecated the external module API. It was creating more problems than solving. Removed most built-in libraries in favor of system libraries for easier maintenance. Cleaned and secured code with help from static analyzers.
This commit is contained in:
1 parent
e0e34b4030
commit
4a6bfc086c
6219 files changed
+1209835
-454916
No files matched your search
+122
@@ -0,0 +1,122 @@
|
||||
//
|
||||
// MapConfiguration.cpp
|
||||
//
|
||||
// Library: Util
|
||||
// Package: Configuration
|
||||
// Module: MapConfiguration
|
||||
//
|
||||
// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
|
||||
// and Contributors.
|
||||
//
|
||||
// SPDX-License-Identifier: BSL-1.0
|
||||
//
|
||||
|
||||
|
||||
#include "Poco/Util/MapConfiguration.h"
|
||||
#include <set>
|
||||
|
||||
|
||||
namespace Poco {
|
||||
namespace Util {
|
||||
|
||||
|
||||
MapConfiguration::MapConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
MapConfiguration::~MapConfiguration()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void MapConfiguration::copyTo(AbstractConfiguration& config)
|
||||
{
|
||||
for (const auto& p: _map)
|
||||
{
|
||||
config.setString(p.first, p.second);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MapConfiguration::clear()
|
||||
{
|
||||
_map.clear();
|
||||
}
|
||||
|
||||
|
||||
bool MapConfiguration::getRaw(const std::string& key, std::string& value) const
|
||||
{
|
||||
StringMap::const_iterator it = _map.find(key);
|
||||
if (it != _map.end())
|
||||
{
|
||||
value = it->second;
|
||||
return true;
|
||||
}
|
||||
else return false;
|
||||
}
|
||||
|
||||
|
||||
void MapConfiguration::setRaw(const std::string& key, const std::string& value)
|
||||
{
|
||||
_map[key] = value;
|
||||
}
|
||||
|
||||
|
||||
void MapConfiguration::enumerate(const std::string& key, Keys& range) const
|
||||
{
|
||||
std::set<std::string> keys;
|
||||
std::string prefix = key;
|
||||
if (!prefix.empty()) prefix += '.';
|
||||
std::string::size_type psize = prefix.size();
|
||||
for (const auto& p: _map)
|
||||
{
|
||||
if (p.first.compare(0, psize, prefix) == 0)
|
||||
{
|
||||
std::string subKey;
|
||||
std::string::size_type end = p.first.find('.', psize);
|
||||
if (end == std::string::npos)
|
||||
subKey = p.first.substr(psize);
|
||||
else
|
||||
subKey = p.first.substr(psize, end - psize);
|
||||
if (keys.find(subKey) == keys.end())
|
||||
{
|
||||
range.push_back(subKey);
|
||||
keys.insert(subKey);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MapConfiguration::removeRaw(const std::string& key)
|
||||
{
|
||||
std::string prefix = key;
|
||||
if (!prefix.empty()) prefix += '.';
|
||||
std::string::size_type psize = prefix.size();
|
||||
StringMap::iterator it = _map.begin();
|
||||
StringMap::iterator itCur;
|
||||
while (it != _map.end())
|
||||
{
|
||||
itCur = it++;
|
||||
if ((itCur->first == key) || (itCur->first.compare(0, psize, prefix) == 0))
|
||||
{
|
||||
_map.erase(itCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
MapConfiguration::iterator MapConfiguration::begin() const
|
||||
{
|
||||
return _map.begin();
|
||||
}
|
||||
|
||||
|
||||
MapConfiguration::iterator MapConfiguration::end() const
|
||||
{
|
||||
return _map.end();
|
||||
}
|
||||
|
||||
|
||||
} } // namespace Poco::Util
|
||||
Reference in new issue
Block a user