Index: src/libchcore/TPath.cpp =================================================================== diff -u -r3fc1109991e7311d6b1e34ef0b730f9b4e1fd42a -rb684bec49aaaea4b89ab2e599497f4085d8698a3 --- src/libchcore/TPath.cpp (.../TPath.cpp) (revision 3fc1109991e7311d6b1e34ef0b730f9b4e1fd42a) +++ src/libchcore/TPath.cpp (.../TPath.cpp) (revision b684bec49aaaea4b89ab2e599497f4085d8698a3) @@ -1078,6 +1078,24 @@ return !m_pPath || m_pPath->m_strPath.empty(); } +void TSmartPath::StoreInConfig(chcore::TConfig& rConfig, PCTSTR pszPropName) const +{ + rConfig.SetValue(pszPropName, m_pPath ? m_pPath->m_strPath : std::wstring()); +} + +bool TSmartPath::ReadFromConfig(const chcore::TConfig& rConfig, PCTSTR pszPropName) +{ + std::wstring wstrPath; + if(rConfig.GetValue(pszPropName, wstrPath)) + { + PrepareToWrite(); + m_pPath->m_strPath = wstrPath; + return true; + } + else + return false; +} + // ============================================================================ /// TSmartPath::AppendIfNotExists /// @date 2009/11/29 @@ -1303,4 +1321,34 @@ return m_vPaths.empty(); } +void TPathContainer::StoreInConfig(chcore::TConfig& rConfig, PCTSTR pszPropName) const +{ + std::vector vPaths; + + // store as vector of strings (ineffective; should be done better) + BOOST_FOREACH(const TSmartPath& spPath, m_vPaths) + { + vPaths.push_back(spPath.ToWString()); + } + + rConfig.SetValue(pszPropName, vPaths); +} + +bool TPathContainer::ReadFromConfig(const chcore::TConfig& rConfig, PCTSTR pszPropName) +{ + m_vPaths.clear(); + + std::vector vPaths; + if(rConfig.GetValue(pszPropName, vPaths)) + { + BOOST_FOREACH(const std::wstring& wstrPath, vPaths) + { + m_vPaths.push_back(PathFromString(wstrPath)); + } + return true; + } + else + return false; +} + END_CHCORE_NAMESPACE