/* ******************************************************************************* * INCLUDE ******************************************************************************* */ #include "PocoConfigurationCopier.h" #include 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().isNull(); Poco::AutoPtr pJConfig = from.cast(); if (pJConfig && usingJSON) { std::stringstream ss; pJConfig->save(ss); to.cast()->load(ss); } else { Poco::Util::AbstractConfiguration::Keys keys; from->keys(keys); for (const auto& key : keys) to->setString(key, from->getString(key)); } } }