Index: src/ch/TConfig.cpp =================================================================== diff -u -N -r3f72015a9db19bd1b0a5e20e0f1aa0ec00bda529 -r69b48f0b4d7fad78f95854e95fca166014311474 --- src/ch/TConfig.cpp (.../TConfig.cpp) (revision 3f72015a9db19bd1b0a5e20e0f1aa0ec00bda529) +++ src/ch/TConfig.cpp (.../TConfig.cpp) (revision 69b48f0b4d7fad78f95854e95fca166014311474) @@ -363,22 +363,22 @@ chcore::TSmartPath TConfig::GetPath(PCTSTR pszPropName, const chcore::TSmartPath& pathDefault) const { boost::shared_lock lock(m_lock); - std::wstring wstrData = m_propTree.get(pszPropName, std::wstring(pathDefault)); - return chcore::TSmartPath(wstrData); + std::wstring wstrData = m_propTree.get(pszPropName, pathDefault.ToWString()); + return chcore::PathFromString(wstrData); } bool TConfig::GetValue(PCTSTR pszPropName, chcore::TSmartPath& rpathValue) const { std::wstring wstrData; bool bResult = ::GetValue(m_propTree, pszPropName, wstrData, m_lock); - rpathValue = wstrData.c_str(); + rpathValue.FromString(wstrData); return bResult; } TConfig& TConfig::SetValue(PCTSTR pszPropName, const chcore::TSmartPath& pathValue) { - std::wstring wstrData = pathValue; + std::wstring wstrData(pathValue.ToWString()); if(::SetValue(m_propTree, m_bModified, m_lock, pszPropName, wstrData)) SendNotification(pszPropName); @@ -421,6 +421,42 @@ SendNotification(pszPropName); } +bool TConfig::GetValue(PCTSTR pszPropName, chcore::TPathContainer& rvValues) const +{ + rvValues.Clear(); + boost::shared_lock lock(m_lock); + + boost::optional children = m_propTree.get_child_optional(pszPropName); + if(children.is_initialized()) + { + BOOST_FOREACH(const boost::property_tree::wiptree::value_type& rEntry, children.get()) + { + rvValues.Add(chcore::PathFromString(rEntry.second.data())); + } + + return true; + } + else + return false; +} + +void TConfig::SetValue(PCTSTR pszPropName, const chcore::TPathContainer& rvValues) +{ + // separate scope for mutex (to avoid calling notifier inside critical section) + { + boost::unique_lock lock(m_lock); + m_propTree.erase(pszPropName); + for(size_t stIndex = 0; stIndex < rvValues.GetCount(); ++stIndex) + { + m_propTree.add(pszPropName, rvValues.GetAt(stIndex).ToWString()); + } + + m_bModified = true; + } + + SendNotification(pszPropName); +} + // extraction of subtrees void TConfig::ExtractSubConfig(PCTSTR pszSubTreeName, TConfig& rSubConfig) const {