-
Notifications
You must be signed in to change notification settings - Fork 6.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
common: do not accept invalid input in VersionHelper and add negative…
… unit tests
- Loading branch information
Showing
8 changed files
with
144 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#define NOMINMAX | ||
#include <winrt/base.h> | ||
#include <winrt/Windows.Foundation.Collections.h> | ||
#include <Windows.h> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#pragma once | ||
|
||
#include <string_view> | ||
#include <string> | ||
#include <algorithm> | ||
|
||
constexpr inline std::string_view default_trim_arg = " \t\r\n"; | ||
|
||
inline std::string_view left_trim(std::string_view s, const std::string_view chars_to_trim = default_trim_arg) | ||
{ | ||
s.remove_prefix(std::min(s.find_first_not_of(chars_to_trim), size(s))); | ||
return s; | ||
} | ||
|
||
inline std::string_view right_trim(std::string_view s, const std::string_view chars_to_trim = default_trim_arg) | ||
{ | ||
s.remove_suffix(std::min(size(s) - s.find_last_not_of(chars_to_trim) - 1, size(s))); | ||
return s; | ||
} | ||
|
||
inline std::string_view trim(std::string_view s, const std::string_view chars_to_trim = default_trim_arg) | ||
{ | ||
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) | ||
{ | ||
for (const char c : chars_to_replace) | ||
{ | ||
std::replace(begin(s), end(s), c, replacement_char); | ||
} | ||
} |