MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / StrNaturalContains

Function StrNaturalContains

src/string.cpp:496–514  ·  view source on GitHub ↗

* Checks if a string is contained in another string with a locale-aware comparison that is case sensitive. * * @param str The string to search in. * @param value The string to search for. * @return True if a match was found. */

Source from the content-addressed store, hash-verified

494 * @return True if a match was found.
495 */
496[[nodiscard]] bool StrNaturalContains(std::string_view str, std::string_view value)
497{
498#ifdef WITH_ICU_I18N
499 int res_u = ICUStringContains(str, value, false);
500 if (res_u >= 0) return res_u > 0;
501#endif /* WITH_ICU_I18N */
502
503#if defined(_WIN32) && !defined(STRGEN) && !defined(SETTINGSGEN)
504 int res = Win32StringContains(str, value, false);
505 if (res >= 0) return res > 0;
506#endif
507
508#if defined(WITH_COCOA) && !defined(STRGEN) && !defined(SETTINGSGEN)
509 int res = MacOSStringContains(str, value, false);
510 if (res >= 0) return res > 0;
511#endif
512
513 return str.find(value) != std::string_view::npos;
514}
515
516/**
517 * Checks if a string is contained in another string with a locale-aware comparison that is case insensitive.

Callers 1

AddLineMethod · 0.85

Calls 4

ICUStringContainsFunction · 0.85
Win32StringContainsFunction · 0.85
MacOSStringContainsFunction · 0.85
findMethod · 0.45

Tested by

no test coverage detected