MCPcopy Create free account
hub / github.com/NazaraEngine/NazaraEngine / FindLast

Method FindLast

src/Nazara/Core/String.cpp:967–1002  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

965 */
966
967 std::size_t String::FindLast(char character, std::intmax_t start, UInt32 flags) const
968 {
969 if (character == '\0' || m_sharedString->size == 0)
970 return npos;
971
972 if (start < 0)
973 start = std::max<std::size_t>(m_sharedString->size + start, 0);
974
975 std::size_t pos = static_cast<std::size_t>(start);
976 if (pos >= m_sharedString->size)
977 return npos;
978
979 char* ptr = &m_sharedString->string[m_sharedString->size-1];
980
981 if (flags & CaseInsensitive)
982 {
983 character = Detail::ToLower(character);
984 do
985 {
986 if (Detail::ToLower(*ptr) == character)
987 return ptr - m_sharedString->string.get();
988 }
989 while (ptr-- != m_sharedString->string.get());
990 }
991 else
992 {
993 do
994 {
995 if (*ptr == character)
996 return ptr - m_sharedString->string.get();
997 }
998 while (ptr-- != m_sharedString->string.get());
999 }
1000
1001 return npos;
1002 }
1003
1004 /*!
1005 * \brief Finds the last index of the "C string" in the string

Callers 2

LoadMethod · 0.80
String.cppFile · 0.80

Calls 2

ToLowerFunction · 0.85
GetConstBufferMethod · 0.80

Tested by

no test coverage detected