----------------------------------------------------------------------------- Purpose: Insert a subkey at index Input : nIndex - *pSubKey - -----------------------------------------------------------------------------
| 360 | // *pSubKey - |
| 361 | //----------------------------------------------------------------------------- |
| 362 | void KeyValues::InsertSubKey(int nIndex, KeyValues* pSubKey) |
| 363 | { |
| 364 | // Sub key must be valid and not part of another chain |
| 365 | assert(pSubKey && pSubKey->m_pPeer == nullptr); |
| 366 | |
| 367 | if (nIndex == 0) |
| 368 | { |
| 369 | pSubKey->m_pPeer = m_pSub; |
| 370 | m_pSub = pSubKey; |
| 371 | return; |
| 372 | } |
| 373 | else |
| 374 | { |
| 375 | int nCurrentIndex = 0; |
| 376 | for (KeyValues* pIter = GetFirstSubKey(); pIter != nullptr; pIter = pIter->GetNextKey()) |
| 377 | { |
| 378 | ++nCurrentIndex; |
| 379 | if (nCurrentIndex == nIndex) |
| 380 | { |
| 381 | pSubKey->m_pPeer = pIter->m_pPeer; |
| 382 | pIter->m_pPeer = pSubKey; |
| 383 | return; |
| 384 | } |
| 385 | } |
| 386 | // Index is out of range if we get here |
| 387 | assert(0); |
| 388 | return; |
| 389 | } |
| 390 | } |
| 391 | |
| 392 | //----------------------------------------------------------------------------- |
| 393 | // Purpose: Checks if key contains a subkey |
nothing calls this directly
no test coverage detected