util/StringAPI: add StringToken(), StringIsEqualIgnoreCase(), StringCollate()
This commit is contained in:
@@ -94,6 +94,12 @@ StringFindLast(char *haystack, char needle) noexcept
|
|||||||
return strrchr(haystack, needle);
|
return strrchr(haystack, needle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline char *
|
||||||
|
StringToken(char *str, const char *delim) noexcept
|
||||||
|
{
|
||||||
|
return strtok(str, delim);
|
||||||
|
}
|
||||||
|
|
||||||
gcc_nonnull_all
|
gcc_nonnull_all
|
||||||
static inline void
|
static inline void
|
||||||
UnsafeCopyString(char *dest, const char *src) noexcept
|
UnsafeCopyString(char *dest, const char *src) noexcept
|
||||||
@@ -134,6 +140,27 @@ StringIsEqual(const char *a, const char *b, size_t length) noexcept
|
|||||||
return strncmp(a, b, length) == 0;
|
return strncmp(a, b, length) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gcc_pure gcc_nonnull_all
|
||||||
|
static inline bool
|
||||||
|
StringIsEqualIgnoreCase(const char *a, const char *b) noexcept
|
||||||
|
{
|
||||||
|
return strcasecmp(a, b) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
gcc_pure gcc_nonnull_all
|
||||||
|
static inline bool
|
||||||
|
StringIsEqualIgnoreCase(const char *a, const char *b, size_t size) noexcept
|
||||||
|
{
|
||||||
|
return strncasecmp(a, b, size) == 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
gcc_pure gcc_nonnull_all
|
||||||
|
static inline int
|
||||||
|
StringCollate(const char *a, const char *b) noexcept
|
||||||
|
{
|
||||||
|
return strcoll(a, b);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy the string to a new allocation. The return value must be
|
* Copy the string to a new allocation. The return value must be
|
||||||
* freed with free().
|
* freed with free().
|
||||||
|
Reference in New Issue
Block a user