#ifndef ABSL_STRINGS_MATCH_H_
#define ABSL_STRINGS_MATCH_H_
#include <cstring>
#include "absl/strings/string_view.h"
namespace absl {
ABSL_NAMESPACE_BEGIN
inline bool StrContains(absl::string_view haystack,
absl::string_view needle) noexcept {
return haystack.find(needle, 0) != haystack.npos;
}
inline bool StrContains(absl::string_view haystack, char needle) noexcept {
return haystack.find(needle) != haystack.npos;
}
inline bool StartsWith(absl::string_view text,
absl::string_view prefix) noexcept {
return prefix.empty() ||
(text.size() >= prefix.size() &&
memcmp(text.data(), prefix.data(), prefix.size()) == 0);
}
inline bool EndsWith(absl::string_view text,
absl::string_view suffix) noexcept {
return suffix.empty() ||
(text.size() >= suffix.size() &&
memcmp(text.data() + (text.size() - suffix.size()), suffix.data(),
suffix.size()) == 0);
}
bool StrContainsIgnoreCase(absl::string_view haystack,
absl::string_view needle) noexcept;
bool StrContainsIgnoreCase(absl::string_view haystack,
char needle) noexcept;
bool EqualsIgnoreCase(absl::string_view piece1,
absl::string_view piece2) noexcept;
bool StartsWithIgnoreCase(absl::string_view text,
absl::string_view prefix) noexcept;
bool EndsWithIgnoreCase(absl::string_view text,
absl::string_view suffix) noexcept;
absl::string_view FindLongestCommonPrefix(absl::string_view a,
absl::string_view b);
absl::string_view FindLongestCommonSuffix(absl::string_view a,
absl::string_view b);
ABSL_NAMESPACE_END
}
#endif