Scans both the user and global keys to find subkeys and returns a list of all such subkeys. Subkeys in the user key take precedence over those in the global key. @param p_rvSubkeys Where to store information about the subkeys.
| 246 | // @param p_rvSubkeys Where to store information about the subkeys. |
| 247 | // |
| 248 | void UserOverrideableRegKey::GetSubKeys(SubkeyInfoV& p_rvSubkeys) const |
| 249 | { |
| 250 | // This is pretty much the same thing as GetValues. |
| 251 | SubkeyInfoV vSubkeys; |
| 252 | |
| 253 | if (!Locked()) { |
| 254 | m_UserKey.GetSubKeys(vSubkeys); |
| 255 | } |
| 256 | if (m_GlobalKey.Valid()) { |
| 257 | m_GlobalKey.GetSubKeys(vSubkeys); |
| 258 | } |
| 259 | |
| 260 | const auto compareSubkeyInfos = [](const SubkeyInfo& p_Subkey1, const SubkeyInfo& p_Subkey2) noexcept { |
| 261 | return ::_wcsicmp(p_Subkey1.m_KeyName.c_str(), p_Subkey2.m_KeyName.c_str()) < 0; |
| 262 | }; |
| 263 | std::stable_sort(vSubkeys.begin(), vSubkeys.end(), compareSubkeyInfos); |
| 264 | |
| 265 | const auto subkeyInfosEqual = [](const SubkeyInfo& p_Subkey1, const SubkeyInfo& p_Subkey2) noexcept { |
| 266 | return ::_wcsicmp(p_Subkey1.m_KeyName.c_str(), p_Subkey2.m_KeyName.c_str()) == 0; |
| 267 | }; |
| 268 | vSubkeys.erase(std::unique(vSubkeys.begin(), vSubkeys.end(), subkeyInfosEqual), vSubkeys.end()); |
| 269 | |
| 270 | if (p_rvSubkeys.empty()) { |
| 271 | p_rvSubkeys = std::move(vSubkeys); |
| 272 | } else { |
| 273 | p_rvSubkeys.insert(p_rvSubkeys.end(), vSubkeys.cbegin(), vSubkeys.cend()); |
| 274 | } |
| 275 | } |
| 276 | |
| 277 | // |
| 278 | // Tries to save a DWORD value in the registry key. |