62 #ifndef ABSL_STRINGS_INTERNAL_MEMUTIL_H_ 63 #define ABSL_STRINGS_INTERNAL_MEMUTIL_H_ 72 namespace strings_internal {
74 inline char*
memcat(
char* dest,
size_t destlen,
const char* src,
76 return reinterpret_cast<char*
>(memcpy(dest + destlen, src, srclen));
80 char*
memdup(
const char* s,
size_t slen);
81 char*
memrchr(
const char* s,
int c,
size_t slen);
82 size_t memspn(
const char* s,
size_t slen,
const char* accept);
83 size_t memcspn(
const char* s,
size_t slen,
const char* reject);
84 char*
mempbrk(
const char* s,
size_t slen,
const char* accept);
87 template <
bool case_sensitive>
89 const char* needle,
size_t neelen) {
93 const char* hayend = haystack + haylen;
94 const char* needlestart = needle;
95 const char* needleend = needlestart + neelen;
97 for (; haystack < hayend; ++haystack) {
98 char hay = case_sensitive
101 char nee = case_sensitive
105 if (++needle == needleend) {
106 return haystack + 1 - neelen;
108 }
else if (needle != needlestart) {
110 haystack -= needle - needlestart;
111 needle = needlestart;
118 inline const char*
memstr(
const char* phaystack,
size_t haylen,
119 const char* pneedle) {
120 return int_memmatch<true>(phaystack, haylen, pneedle, strlen(pneedle));
123 inline const char*
memcasestr(
const char* phaystack,
size_t haylen,
124 const char* pneedle) {
125 return int_memmatch<false>(phaystack, haylen, pneedle, strlen(pneedle));
128 inline const char*
memmem(
const char* phaystack,
size_t haylen,
129 const char* pneedle,
size_t needlelen) {
130 return int_memmatch<true>(phaystack, haylen, pneedle, needlelen);
133 inline const char*
memcasemem(
const char* phaystack,
size_t haylen,
134 const char* pneedle,
size_t needlelen) {
135 return int_memmatch<false>(phaystack, haylen, pneedle, needlelen);
140 const char*
memmatch(
const char* phaystack,
size_t haylen,
const char* pneedle,
146 #endif // ABSL_STRINGS_INTERNAL_MEMUTIL_H_ char * memcat(char *dest, size_t destlen, const char *src, size_t srclen)
size_t memspn(const char *s, size_t slen, const char *accept)
const char * memmem(const char *phaystack, size_t haylen, const char *pneedle, size_t needlelen)
const char * memstr(const char *phaystack, size_t haylen, const char *pneedle)
char * memrchr(const char *s, int c, size_t slen)
const char * int_memmatch(const char *haystack, size_t haylen, const char *needle, size_t neelen)
char * memdup(const char *s, size_t slen)
char * mempbrk(const char *s, size_t slen, const char *accept)
size_t memcspn(const char *s, size_t slen, const char *reject)
const char * memcasestr(const char *phaystack, size_t haylen, const char *pneedle)
const char * memmatch(const char *phaystack, size_t haylen, const char *pneedle, size_t neelen)
char ascii_tolower(unsigned char c)
const char * memcasemem(const char *phaystack, size_t haylen, const char *pneedle, size_t needlelen)
int memcasecmp(const char *s1, const char *s2, size_t len)