本文整理匯總了C++中wtf::String::remove方法的典型用法代碼示例。如果您正苦於以下問題:C++ String::remove方法的具體用法?C++ String::remove怎麽用?C++ String::remove使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類wtf::String
的用法示例。
在下文中一共展示了String::remove方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: resolveMimeType
const string WebResponse::resolveMimeType(const string& url, const string& old_mime)
{
// Use "text/html" as a default (matching the behaviour of the Apache
// HTTP stack -- see guessMimeType() in LoadListener.java).
string mimeType = old_mime.length() ? old_mime : "text/html";
// Try to guess a better MIME type from the URL. We call
// getMIMETypeForExtension rather than getMIMETypeForPath because the
// latter defaults to "application/octet-stream" on failure.
WebCore::KURL kurl(WebCore::ParsedURLString, url.c_str());
WTF::String path = kurl.path();
size_t extensionPos = path.reverseFind('.');
if (extensionPos != WTF::notFound) {
// We found a file extension.
path.remove(0, extensionPos + 1);
// TODO: Should use content-disposition instead of url if it is there
WTF::String mime = WebCore::MIMETypeRegistry::getMIMETypeForExtension(path);
if (!mime.isEmpty()) {
// Great, we found a MIME type.
mimeType = std::string(mime.utf8().data(), mime.length());
}
}
return mimeType;
}