Index: src/libchengine/ConfigNodeContainer.cpp =================================================================== diff -u -N -r0d5b67ee96b435d63f7bf075dc8e28603793b187 -r782902eb6d63ccceb0c1f3808403a23b8372d66f --- src/libchengine/ConfigNodeContainer.cpp (.../ConfigNodeContainer.cpp) (revision 0d5b67ee96b435d63f7bf075dc8e28603793b187) +++ src/libchengine/ConfigNodeContainer.cpp (.../ConfigNodeContainer.cpp) (revision 782902eb6d63ccceb0c1f3808403a23b8372d66f) @@ -285,7 +285,6 @@ { bool bFound = false; TString strReplace(pszNode); - strReplace += _T("["); boost::shared_lock lock(m_lock); @@ -300,13 +299,23 @@ TString strName = iter->m_strNodeName.Get(); strName.MidSelf(strReplace.GetLength()); - size_t stPos = strName.Find(_T("]")); - if (stPos == std::numeric_limits::max()) - throw TCoreException(eErr_InvalidData, L"] character not found", LOCATION); - if (strName.GetAt(stPos + 1) != _T('.')) - throw TCoreException(eErr_InvalidData, L". character not found", LOCATION); - size_t stNodeIndex = boost::lexical_cast(strName.Left(stPos)); + size_t stNodeIndex = 0; + if (strName.StartsWith(L"[")) + { + size_t stPos = strName.Find(_T("]")); + if (stPos == std::numeric_limits::max()) + throw TCoreException(eErr_InvalidData, L"] character not found", LOCATION); + if (strName.GetAt(stPos + 1) != _T('.')) + throw TCoreException(eErr_InvalidData, L". character not found", LOCATION); + + stNodeIndex = boost::lexical_cast(strName.Mid(1, stPos - 1)); + + strName.Delete(0, stPos + 2); // skip "]." at the beginning + } + else + strName.Delete(0, 1); // skip "." at the beginning + if (stNodeIndex != stLastIndex) { tNewContainers.push_back(ConfigNodeContainer()); @@ -315,7 +324,6 @@ stLastIndex = stNodeIndex; } - strName.Delete(0, stPos + 2); // skip "]." at the beginning if (!pCurrentContainer) throw TCoreException(eErr_InvalidPointer, L"pCurrentContainer", LOCATION); Index: src/libchengine/Tests/TestsTConfig.cpp =================================================================== diff -u -N -r07f5ed57f11f0b908313f692fc4830401f0db552 -r782902eb6d63ccceb0c1f3808403a23b8372d66f --- src/libchengine/Tests/TestsTConfig.cpp (.../TestsTConfig.cpp) (revision 07f5ed57f11f0b908313f692fc4830401f0db552) +++ src/libchengine/Tests/TestsTConfig.cpp (.../TestsTConfig.cpp) (revision 782902eb6d63ccceb0c1f3808403a23b8372d66f) @@ -116,6 +116,12 @@ SecondName\ \ \ + \ + \ + <WINDOWS>\\FirstPath\ + FirstName\ + \ + \ \ "; @@ -583,11 +589,8 @@ m_cfg.WriteToString(wstrWithDeletion); EXPECT_EQ(TString(_T("\n\ -30000\ -FirstName<WINDOWS>\\FirstPathSecondName<WINDOWS>\\SecondPath\ -c:\\Windows\\System32d:\\Moviesx:\\Musics:\\projects\\ch-rw\ -true<WINDOWS>\\media\\chord.wav\ -<WINDOWS>\\\x597D\x8FD0\\ding.wav")), wstrWithDeletion); +30000FirstName<WINDOWS>\\FirstPathSecondName<WINDOWS>\\SecondPathc:\\Windows\\System32d:\\Moviesx:\\Musics:\\projects\\ch-rwtrue<WINDOWS>\\media\\chord.wav<WINDOWS>\\\x597D\x8FD0\\ding.wavFirstName<WINDOWS>\\FirstPath")), + wstrWithDeletion); } /////////////////////////////////////////////////////////////////////////// @@ -599,8 +602,8 @@ m_cfg.WriteToString(wstrWithDeletion); EXPECT_EQ(TString(_T("\n\ -30000FirstName<WINDOWS>\\FirstPath\ -SecondName<WINDOWS>\\SecondPath")), wstrWithDeletion); +30000FirstName<WINDOWS>\\FirstPathSecondName<WINDOWS>\\SecondPathFirstName<WINDOWS>\\FirstPath")), + wstrWithDeletion); } /////////////////////////////////////////////////////////////////////////// @@ -628,6 +631,18 @@ EXPECT_EQ(TString(_T("\\SecondPath")), cfgSubArray.GetAt(1).GetString(_T("Path"))); } +TEST_F(InitializedConfigFixture, ExtractMultipleConfigsWithSingleNode) +{ + TConfigArray cfgSubArray; + + m_cfg.ExtractMultiSubConfigs(_T("CHConfig.Core.SingleObject.Object"), cfgSubArray); + + EXPECT_EQ(1UL, cfgSubArray.GetCount()); + + EXPECT_EQ(TString(_T("FirstName")), cfgSubArray.GetAt(0).GetString(_T("Name"))); + EXPECT_EQ(TString(_T("\\FirstPath")), cfgSubArray.GetAt(0).GetString(_T("Path"))); +} + TEST(TConfigTests, PutSubConfig) { TConfig mainCfg;