本文整理汇总了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());
}