mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 07:07:45 +00:00
AK: Add a way to disable the trimming of whitespace in to_*int
This behavior might not always be desirable, and so this patch adds a way to disable it.
This commit is contained in:
parent
8be7bdaac3
commit
3abcfcc178
6 changed files with 74 additions and 61 deletions
|
@ -22,6 +22,11 @@ enum class TrimMode {
|
|||
Both
|
||||
};
|
||||
|
||||
enum class TrimWhitespace {
|
||||
Yes,
|
||||
No,
|
||||
};
|
||||
|
||||
struct MaskSpan {
|
||||
size_t start;
|
||||
size_t length;
|
||||
|
@ -40,11 +45,11 @@ namespace StringUtils {
|
|||
|
||||
bool matches(const StringView& str, const StringView& mask, CaseSensitivity = CaseSensitivity::CaseInsensitive, Vector<MaskSpan>* match_spans = nullptr);
|
||||
template<typename T = int>
|
||||
Optional<T> convert_to_int(const StringView&);
|
||||
Optional<T> convert_to_int(const StringView&, TrimWhitespace = TrimWhitespace::Yes);
|
||||
template<typename T = unsigned>
|
||||
Optional<T> convert_to_uint(const StringView&);
|
||||
Optional<T> convert_to_uint(const StringView&, TrimWhitespace = TrimWhitespace::Yes);
|
||||
template<typename T = unsigned>
|
||||
Optional<T> convert_to_uint_from_hex(const StringView&);
|
||||
Optional<T> convert_to_uint_from_hex(const StringView&, TrimWhitespace = TrimWhitespace::Yes);
|
||||
bool equals_ignoring_case(const StringView&, const StringView&);
|
||||
bool ends_with(const StringView& a, const StringView& b, CaseSensitivity);
|
||||
bool starts_with(const StringView&, const StringView&, CaseSensitivity);
|
||||
|
@ -61,3 +66,4 @@ String to_snakecase(const StringView&);
|
|||
|
||||
using AK::CaseSensitivity;
|
||||
using AK::TrimMode;
|
||||
using AK::TrimWhitespace;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue