整理代码
This commit is contained in:
commit
c7b4e178ec
364 changed files with 59691 additions and 0 deletions
44
util/PocoConfigurationCopier.cpp
Normal file
44
util/PocoConfigurationCopier.cpp
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
*******************************************************************************
|
||||
* INCLUDE
|
||||
*******************************************************************************
|
||||
*/
|
||||
#include "PocoConfigurationCopier.h"
|
||||
#include <Poco/Util/JSONConfiguration.h>
|
||||
|
||||
namespace Util
|
||||
{
|
||||
/*
|
||||
*******************************************************************************
|
||||
* CLASS DEFINE
|
||||
*******************************************************************************
|
||||
*/
|
||||
void PocoConfigurationCopier::copy(Poco::Util::AbstractConfiguration::Ptr& from,
|
||||
Poco::Util::AbstractConfiguration::Ptr& to)
|
||||
{
|
||||
bool usingJSON = false;
|
||||
|
||||
if (to.isNull())
|
||||
{
|
||||
to = new Poco::Util::JSONConfiguration();
|
||||
usingJSON = true;
|
||||
}
|
||||
else
|
||||
usingJSON = !to.cast<Poco::Util::JSONConfiguration>().isNull();
|
||||
|
||||
Poco::AutoPtr<Poco::Util::JSONConfiguration> pJConfig = from.cast<Poco::Util::JSONConfiguration>();
|
||||
if (pJConfig && usingJSON)
|
||||
{
|
||||
std::stringstream ss;
|
||||
pJConfig->save(ss);
|
||||
to.cast<Poco::Util::JSONConfiguration>()->load(ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
Poco::Util::AbstractConfiguration::Keys keys;
|
||||
from->keys(keys);
|
||||
for (const auto& key : keys)
|
||||
to->setString(key, from->getString(key));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue