bool StringArray::contains (StringRef stringToLookFor, bool ignoreCase) const
{
return indexOf (stringToLookFor, ignoreCase) >= 0;
}
int StringArray::indexOf (StringRef stringToLookFor, bool ignoreCase, int i) const
{
if (i < 0)
i = 0;
auto numElements = size();
if (ignoreCase)
{
for (; i < numElements; ++i)
if (strings.getReference(i).equalsIgnoreCase (stringToLookFor))
It’s worth mentioning that the StringArray searching functionality isn’t covered in the StringArray related unit tests (in juce_String.cpp → grep for beginTest ("StringArray");).
That being said, would you consider adding an API with this concept: containsSubstring (caseSensitiveOrNot) ? Looking at all of the contained strings for a substring is my current need, which I worked around by doing (and created a standalone function to accomplish):
for (const auto& s : myStrings)
if (s.containsIgnoreCase (substringToLookFor))
return true;
return false;