本文整理匯總了C++中wtf::String::find方法的典型用法代碼示例。如果您正苦於以下問題:C++ String::find方法的具體用法?C++ String::find怎麽用?C++ String::find使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wtf::String
的用法示例。
在下文中一共展示了String::find方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: spellCheckWord
bool MockSpellCheck::spellCheckWord(const WebString& text, int* misspelledOffset, int* misspelledLength)
{
ASSERT(misspelledOffset);
ASSERT(misspelledLength);
// Initialize this spellchecker.
initializeIfNeeded();
// Reset the result values as our spellchecker does.
*misspelledOffset = 0;
*misspelledLength = 0;
// Convert to a String because we store String instances in
// m_misspelledWords and WebString has no find().
const WTF::String stringText(text.data(), text.length());
// Extract the first possible English word from the given string.
// The given string may include non-ASCII characters or numbers. So, we
// should filter out such characters before start looking up our
// misspelled-word table.
// (This is a simple version of our SpellCheckWordIterator class.)
// If the given string doesn't include any ASCII characters, we can treat the
// string as valid one.
// Unfortunately, This implementation splits a contraction, i.e. "isn't" is
// split into two pieces "isn" and "t". This is OK because webkit tests
// don't have misspelled contractions.
int wordOffset = stringText.find(isASCIIAlpha);
if (wordOffset == -1)
return true;
int wordEnd = stringText.find(isNotASCIIAlpha, wordOffset);
int wordLength = wordEnd == -1 ? stringText.length() - wordOffset : wordEnd - wordOffset;
// Look up our misspelled-word table to check if the extracted word is a
// known misspelled word, and return the offset and the length of the
// extracted word if this word is a known misspelled word.
// (See the comment in MockSpellCheck::initializeIfNeeded() why we use a
// misspelled-word table.)
WTF::String word = stringText.substring(wordOffset, wordLength);
if (!m_misspelledWords.contains(word))
return true;
*misspelledOffset = wordOffset;
*misspelledLength = wordLength;
return false;
}
示例2: onConsoleMessage
static void onConsoleMessage(Ewk_View_Smart_Data*, const char* message, unsigned int lineNumber, const char*)
{
// Tests expect only the filename part of local URIs
WTF::String newMessage = message;
if (!newMessage.isEmpty()) {
const size_t fileProtocol = newMessage.find("file://");
if (fileProtocol != WTF::notFound)
newMessage = newMessage.left(fileProtocol) + urlSuitableForTestResult(newMessage.substring(fileProtocol));
}
// Ignore simple translation-related messages and unnecessary messages
if (newMessage.contains("Localized string") || newMessage.contains("Protocol Error: the message is for non-existing domain 'Profiler'"))
return;
printf("CONSOLE MESSAGE: ");
if (lineNumber)
printf("line %u: ", lineNumber);
printf("%s\n", newMessage.utf8().data());
}