1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 22:57:44 +00:00

AK: Move the wildcard-matching implementation to StringUtils

Provide wrappers in the String and StringView classes, and add some tests.
This commit is contained in:
howar6hill 2020-02-26 15:25:24 +08:00 committed by Andreas Kling
parent 2a30a020c1
commit 055344f346
16 changed files with 147 additions and 62 deletions

View file

@ -29,6 +29,7 @@
#include <AK/Forward.h>
#include <AK/RefPtr.h>
#include <AK/StringImpl.h>
#include <AK/StringUtils.h>
#include <AK/StringView.h>
#include <AK/Traits.h>
@ -108,13 +109,8 @@ public:
{
}
enum class CaseSensitivity {
CaseInsensitive,
CaseSensitive,
};
static String repeated(char, size_t count);
bool matches(const StringView& pattern, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;
bool matches(const StringView& mask, CaseSensitivity = CaseSensitivity::CaseInsensitive) const;
// FIXME: These should be shared between String and StringView somehow!
int to_int(bool& ok) const;
@ -244,7 +240,6 @@ public:
}
private:
bool match_helper(const StringView& mask) const;
RefPtr<StringImpl> m_impl;
};