Util/StringUtil: add StringStartsWith()
Replaces GLib's g_str_has_prefix().
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
#include "ASCII.hxx"
|
||||
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
|
||||
const char *
|
||||
strchug_fast(const char *p)
|
||||
@@ -32,6 +33,13 @@ strchug_fast(const char *p)
|
||||
return p;
|
||||
}
|
||||
|
||||
bool
|
||||
StringStartsWith(const char *haystack, const char *needle)
|
||||
{
|
||||
const size_t length = strlen(needle);
|
||||
return memcmp(haystack, needle, length) == 0;
|
||||
}
|
||||
|
||||
bool
|
||||
string_array_contains(const char *const* haystack, const char *needle)
|
||||
{
|
||||
|
@@ -40,6 +40,10 @@ strchug_fast(char *p)
|
||||
return const_cast<char *>(strchug_fast((const char *)p));
|
||||
}
|
||||
|
||||
gcc_pure
|
||||
bool
|
||||
StringStartsWith(const char *haystack, const char *needle);
|
||||
|
||||
/**
|
||||
* Checks whether a string array contains the specified string.
|
||||
*
|
||||
|
Reference in New Issue
Block a user