mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-04 10:16:24 +02:00
[Updating] Add versioning to UpdateState.json (#12744)
- fix "Check for updates" hang if UpdateState.json was deleted while the page is open
This commit is contained in:
@@ -22,28 +22,34 @@ struct default_trim_arg<wchar_t>
|
||||
};
|
||||
|
||||
template<typename CharT>
|
||||
inline std::basic_string_view<CharT> left_trim(std::basic_string_view<CharT> s, const std::basic_string_view<CharT> chars_to_trim = default_trim_arg<CharT>::value)
|
||||
inline std::basic_string_view<CharT> left_trim(std::basic_string_view<CharT> s,
|
||||
const std::basic_string_view<CharT> chars_to_trim = default_trim_arg<CharT>::value)
|
||||
{
|
||||
s.remove_prefix(std::min<size_t>(s.find_first_not_of(chars_to_trim), size(s)));
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename CharT>
|
||||
inline std::basic_string_view<CharT> right_trim(std::basic_string_view<CharT> s, const std::basic_string_view<CharT> chars_to_trim = default_trim_arg<CharT>::value)
|
||||
inline std::basic_string_view<CharT> right_trim(std::basic_string_view<CharT> s,
|
||||
const std::basic_string_view<CharT> chars_to_trim = default_trim_arg<CharT>::value)
|
||||
{
|
||||
s.remove_suffix(std::min<size_t>(size(s) - s.find_last_not_of(chars_to_trim) - 1, size(s)));
|
||||
return s;
|
||||
}
|
||||
|
||||
template<typename CharT>
|
||||
inline std::basic_string_view<CharT> trim(std::basic_string_view<CharT> s, const std::basic_string_view<CharT> chars_to_trim = default_trim_arg<CharT>::value)
|
||||
inline std::basic_string_view<CharT> trim(std::basic_string_view<CharT> s,
|
||||
const std::basic_string_view<CharT> chars_to_trim = default_trim_arg<CharT>::value)
|
||||
{
|
||||
return left_trim(right_trim(s, chars_to_trim), chars_to_trim);
|
||||
}
|
||||
|
||||
inline void replace_chars(std::string& s, const std::string_view chars_to_replace, const char replacement_char)
|
||||
template<typename CharT>
|
||||
inline void replace_chars(std::basic_string<CharT>& s,
|
||||
const std::basic_string_view<CharT> chars_to_replace,
|
||||
const CharT replacement_char)
|
||||
{
|
||||
for (const char c : chars_to_replace)
|
||||
for (const CharT c : chars_to_replace)
|
||||
{
|
||||
std::replace(begin(s), end(s), c, replacement_char);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user