Scans both the user and global keys and returns a list of all values in both keys. Values in the user key take precedence over those in the global key. @param p_rvValues Where to store information about the values.
| 205 | // @param p_rvValues Where to store information about the values. |
| 206 | // |
| 207 | void UserOverrideableRegKey::GetValues(ValueInfoV& p_rvValues) const |
| 208 | { |
| 209 | ValueInfoV vValues; |
| 210 | |
| 211 | // Get values in user key first, then in global key. |
| 212 | if (!Locked()) { |
| 213 | m_UserKey.GetValues(vValues); |
| 214 | } |
| 215 | if (m_GlobalKey.Valid()) { |
| 216 | m_GlobalKey.GetValues(vValues); |
| 217 | } |
| 218 | |
| 219 | // Sort values in the vector according to their name using stable_sort. |
| 220 | // This way, for values that appear in both keys, the value in the user |
| 221 | // key will be before that of the global key. |
| 222 | const auto compareValueInfos = [](const ValueInfo& p_Value1, const ValueInfo& p_Value2) noexcept { |
| 223 | return ::_wcsicmp(p_Value1.m_ValueName.c_str(), p_Value2.m_ValueName.c_str()) < 0; |
| 224 | }; |
| 225 | std::stable_sort(vValues.begin(), vValues.end(), compareValueInfos); |
| 226 | |
| 227 | // Now remove duplicates, which will remove conflicting values from the global key. |
| 228 | const auto valueInfosEqual = [](const ValueInfo& p_Value1, const ValueInfo& p_Value2) noexcept { |
| 229 | return ::_wcsicmp(p_Value1.m_ValueName.c_str(), p_Value2.m_ValueName.c_str()) == 0; |
| 230 | }; |
| 231 | vValues.erase(std::unique(vValues.begin(), vValues.end(), valueInfosEqual), vValues.end()); |
| 232 | |
| 233 | // Return the resulting values. |
| 234 | if (p_rvValues.empty()) { |
| 235 | p_rvValues = std::move(vValues); |
| 236 | } else { |
| 237 | p_rvValues.insert(p_rvValues.end(), vValues.cbegin(), vValues.cend()); |
| 238 | } |
| 239 | } |
| 240 | |
| 241 | // |
| 242 | // Scans both the user and global keys to find subkeys and returns |