23 #ifndef GUL14_SUBSTRING_CHECKS_H_
24 #define GUL14_SUBSTRING_CHECKS_H_
53 return haystack.find(needle) != string_view::npos;
70 return haystack.find(needle) != string_view::npos;
87 const auto hsl = str.length();
88 const auto sl = suffix.length();
90 return hsl >= sl && str.compare(hsl - sl, sl, suffix) == 0;
106 return !str.empty() && str.back() == c;
123 const auto hsl = str.length();
124 const auto hl = prefix.length();
126 return hsl >= hl &&
string_view{ str.data(), hl }.compare(prefix) == 0;
142 return !str.empty() && str.front() == c;
167 if (str1.size() != str2.size())
171 auto it1 = str1.cbegin();
172 auto it2 = str2.cbegin();
174 while (it1 != str1.cend())
209 auto const haysize = haystack.size();
210 auto const needlesize = needle.size();
211 if (haysize < needlesize)
213 for (std::size_t i = 0; i <= haysize - needlesize; ++i) {
219 if (j == std::size_t(-1)) {
222 haystack.remove_prefix(1);
244 while (not haystack.empty()) {
247 haystack.remove_prefix(1);
269 while (not str.empty()) {
274 str.remove_suffix(1);
275 suffix.remove_suffix(1);
277 return suffix.empty();
315 while (not str.empty()) {
320 str.remove_prefix(1);
321 prefix.remove_prefix(1);
323 return prefix.empty();
Declarations of lowercase_ascii(), lowercase_ascii_inplace(), uppercase_ascii(), and uppercase_ascii_...
constexpr char lowercase_ascii(char c) noexcept
Return the ASCII lowercase equivalent of the given character (or the unchanged character,...
Definition: case_ascii.h:48
constexpr bool equals_nocase(string_view str1, string_view str2) noexcept
Determine whether a string is equal to another one, making no distinction between upper and lower cas...
Definition: substring_checks.h:165
constexpr bool ends_with(string_view str, string_view suffix) noexcept
Determine whether a string ends with another string.
Definition: substring_checks.h:85
constexpr bool contains_nocase(string_view haystack, string_view needle) noexcept
Determine whether a string contains another string.
Definition: substring_checks.h:207
constexpr bool starts_with_nocase(string_view str, string_view prefix) noexcept
Determine whether a string starts with another string.
Definition: substring_checks.h:313
constexpr bool ends_with_nocase(string_view str, string_view suffix) noexcept
Determine whether a string ends with another string.
Definition: substring_checks.h:267
constexpr bool starts_with(string_view str, string_view prefix) noexcept
Determine whether a string starts with another string.
Definition: substring_checks.h:121
constexpr bool contains(string_view haystack, string_view needle) noexcept
Determine whether a string contains another string.
Definition: substring_checks.h:51
Definition of macros used internally by GUL.
Namespace gul14 contains all functions and classes of the General Utility Library.
Definition: doxygen.h:26
Provides a gul14::string_view that is fully compatible with C++17's std::string_view.