本文整理匯總了C++中wtf::String類的典型用法代碼示例。如果您正苦於以下問題:C++ String類的具體用法?C++ String怎麽用?C++ String使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了String類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。
示例1: ewk_settings_default_user_agent_get
/**
* @internal
*
* Gets the default user agent string.
*
* @return a pointer to an eina_stringshare containing the user agent string
*/
const char* ewk_settings_default_user_agent_get()
{
WTF::String uaVersion = String::number(WEBKIT_MAJOR_VERSION) + '.' + String::number(WEBKIT_MINOR_VERSION) + '+';
WTF::String staticUa = "Mozilla/5.0 (" + _ewk_settings_webkit_platform_get() + "; " + _ewk_settings_webkit_os_version_get() + ") AppleWebKit/" + uaVersion + " (KHTML, like Gecko) Version/5.0 Safari/" + uaVersion;
return eina_stringshare_add(staticUa.utf8().data());
}
示例2: if
PassRefPtr<DocumentFragment> Pasteboard::documentFragment(Frame* frame, PassRefPtr<Range> context, bool allowPlainText, bool& chosePlainText)
{
LOGD("documentFragment");
chosePlainText = false;
String dataFormat = "HTML";
String imageFormat = "IMAGE";
String markup;
KURL srcURL;
markup = android::getHTML();
if(!markup.isEmpty()) {
RefPtr<DocumentFragment> fragment =
createFragmentFromMarkup(frame->document(), markup, srcURL, FragmentScriptingNotAllowed);
if (fragment)
return fragment.release();
}
else if (allowPlainText) {
WTF::String markup = android::getText();//ChromiumBridge::clipboardReadPlainText(buffer);
if (!markup.isEmpty()) {
chosePlainText = true;
RefPtr<DocumentFragment> fragment =
createFragmentFromText(context.get(), markup);
if (fragment)
return fragment.release();
}
}
return 0;
}
開發者ID:johnwpoliver,項目名稱:Samsung-GT-P3113-AOSP-CM-Kernel-and-Ramdisk,代碼行數:30,代碼來源:PasteBoardAndroid.cpp
示例3: adoptPtr
PassOwnPtr<ScheduledAction> ScheduledAction::create(ExecState* exec, DOMWrapperWorld* isolatedWorld, ContentSecurityPolicy* policy)
{
JSValue v = exec->argument(0);
CallData callData;
CallType callType = getCallData(v, callData);
if (callType == CallTypeNone) {
if (policy && !policy->allowEval())
return nullptr;
UString string = v.toString(exec)->value(exec);
if (exec->hadException())
return nullptr;
return adoptPtr(new ScheduledAction(ustringToString(string), isolatedWorld));
}
// WebERA this calculates a unique indification of the called function scheduled in this action.
if (callType == CallTypeJS) {
const SourceCode source = callData.js.functionExecutable->source();
WTF::String url = WebCore::decodeURLEscapeSequences(WTF::String(source.provider()->url().utf8().data()));
uint calledLine = source.firstLine();
return adoptPtr(new ScheduledAction(exec, v, isolatedWorld, url.ascii().data(), calledLine));
}
return adoptPtr(new ScheduledAction(exec, v, isolatedWorld, "<native-function>", -1));
}
示例4: get_textAtOffset
HRESULT AccessibleText::get_textAtOffset(long offset, enum IA2TextBoundaryType boundaryType, long* startOffset, long* endOffset, BSTR* text)
{
if (initialCheck() == E_POINTER)
return E_POINTER;
if (!startOffset || !endOffset || !text)
return E_POINTER;
int textLength = m_object->stringValue().length();
offset = convertSpecialOffset(offset);
if (offset < 0 || offset > textLength)
return E_INVALIDARG;
// Obtain the desired text range
VisiblePosition currentPosition = m_object->visiblePositionForIndex(offset);
VisiblePositionRange textRange;
switch (boundaryType) {
case IA2_TEXT_BOUNDARY_CHAR:
textRange = m_object->visiblePositionRangeForRange(PlainTextRange(offset, 1));
break;
case IA2_TEXT_BOUNDARY_WORD:
textRange = m_object->positionOfRightWord(leftWordPosition(currentPosition.next(), true));
break;
case IA2_TEXT_BOUNDARY_SENTENCE:
textRange = m_object->sentenceForPosition(currentPosition);
break;
case IA2_TEXT_BOUNDARY_PARAGRAPH:
textRange = m_object->paragraphForPosition(currentPosition);
break;
case IA2_TEXT_BOUNDARY_LINE:
textRange = m_object->leftLineVisiblePositionRange(currentPosition);
break;
case IA2_TEXT_BOUNDARY_ALL:
textRange = m_object->visiblePositionRangeForRange(PlainTextRange(0, m_object->text().length()));
break;
default:
return E_INVALIDARG;
break;
}
// Obtain string and offsets associated with text range
*startOffset = textRange.start.deepEquivalent().offsetInContainerNode();
*endOffset = textRange.end.deepEquivalent().offsetInContainerNode();
if (*startOffset == *endOffset)
return S_FALSE;
WTF::String substringText = m_object->text().substring(*startOffset, *endOffset - *startOffset);
*text = BString(substringText).release();
if (substringText.length() && !*text)
return E_OUTOFMEMORY;
if (!*text)
return S_FALSE;
return S_OK;
}
示例5: setValueInternal
void DOMTokenList::setValueInternal(const WTF::String& value)
{
// Clear tokens but not capacity.
m_tokens.shrink(0);
HashSet<AtomicString> addedTokens;
// https://dom.spec.whatwg.org/#ordered%20sets
for (unsigned start = 0; ; ) {
while (start < value.length() && isHTMLSpace(value[start]))
++start;
if (start >= value.length())
break;
unsigned end = start + 1;
while (end < value.length() && !isHTMLSpace(value[end]))
++end;
AtomicString token = value.substring(start, end - start);
if (!addedTokens.contains(token)) {
m_tokens.append(token);
addedTokens.add(token);
}
start = end + 1;
}
m_tokens.shrinkToFit();
m_cachedValue = nullAtom;
}
示例6: ewk_settings_default_user_agent_get
/**
* @internal
*
* Gets the default user agent string.
*
* @return a pointer to an eina_stringshare containing the user agent string
*/
const char* ewk_settings_default_user_agent_get()
{
WTF::String uaVersion = makeString(String::number(WEBKIT_USER_AGENT_MAJOR_VERSION), '.', String::number(WEBKIT_USER_AGENT_MINOR_VERSION), '+');
WTF::String staticUa = makeString("Mozilla/5.0 (", _ewk_settings_webkit_platform_get(), "; ", _ewk_settings_webkit_os_version_get(), ") AppleWebKit/", uaVersion) + makeString(" (KHTML, like Gecko) Version/5.0 Safari/", uaVersion);
return eina_stringshare_add(staticUa.utf8().data());
}
示例7: exceededDatabaseQuota
void ChromeClientBlackBerry::exceededDatabaseQuota(Frame* frame, const WTF::String& name)
{
#if ENABLE(DATABASE)
Document* document = frame->document();
if (!document)
return;
SecurityOrigin* origin = document->securityOrigin();
if (m_webPage->d->m_dumpRenderTree) {
m_webPage->d->m_dumpRenderTree->exceededDatabaseQuota(origin, name);
return;
}
DatabaseTracker& tracker = DatabaseTracker::tracker(document->groupName());
unsigned long long totalUsage = tracker.totalDatabaseUsage();
unsigned long long originUsage = tracker.usageForOrigin(origin);
DatabaseDetails details = tracker.detailsForNameAndOrigin(name, origin);
unsigned long long estimatedSize = details.expectedUsage();
const WTF::String& nameStr = details.displayName();
WTF::String originStr = origin->databaseIdentifier();
unsigned long long quota = m_webPage->client()->databaseQuota(originStr.characters(), originStr.length(),
nameStr.characters(), nameStr.length(), totalUsage, originUsage, estimatedSize);
tracker.setQuota(origin, quota);
#endif
}
示例8: writeString
static void writeString(WTF::Vector<char>& vector, const WTF::String& str)
{
unsigned strLen = str.length();
// Only do work if the string has data.
if (strLen) {
// Determine how much to grow the vector. Use the worst case for utf8 to
// avoid reading the string twice. Add sizeof(unsigned) to hold the
// string length in utf8.
unsigned vectorLen = vector.size() + sizeof(unsigned);
unsigned length = (strLen << 2) + vectorLen;
// Grow the vector. This will change the value of v.size() but we
// remember the original size above.
vector.grow(length);
// Grab the position to write to.
char* data = vector.begin() + vectorLen;
// Write the actual string
int l = SkUTF16_ToUTF8(str.characters(), strLen, data);
ALOGV("Writing string %d %.*s", l, l, data);
// Go back and write the utf8 length. Subtract sizeof(unsigned) from
// data to get the position to write the length.
memcpy(data - sizeof(unsigned), (char*)&l, sizeof(unsigned));
// Shrink the internal state of the vector so we match what was
// actually written.
vector.shrink(vectorLen + l);
} else
vector.append((char*)&strLen, sizeof(unsigned));
}
示例9: sendResponseIfNeeded
void QNetworkReplyHandler::sendResponseIfNeeded()
{
ASSERT(m_replyWrapper && m_replyWrapper->reply() && !wasAborted());
if (m_replyWrapper->reply()->error() && m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).isNull())
return;
ResourceHandleClient* client = m_resourceHandle->client();
if (!client)
return;
WTF::String mimeType = m_replyWrapper->mimeType();
if (mimeType.isEmpty()) {
// let's try to guess from the extension
mimeType = MIMETypeRegistry::getMIMETypeForPath(m_replyWrapper->reply()->url().path());
}
KURL url(m_replyWrapper->reply()->url());
ResourceResponse response(url, mimeType.lower(),
m_replyWrapper->reply()->header(QNetworkRequest::ContentLengthHeader).toLongLong(),
m_replyWrapper->encoding(), String());
if (url.isLocalFile()) {
client->didReceiveResponse(m_resourceHandle, response);
return;
}
// The status code is equal to 0 for protocols not in the HTTP family.
int statusCode = m_replyWrapper->reply()->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
if (url.protocolIsInHTTPFamily()) {
String suggestedFilename = filenameFromHTTPContentDisposition(QString::fromLatin1(m_replyWrapper->reply()->rawHeader("Content-Disposition")));
if (!suggestedFilename.isEmpty())
response.setSuggestedFilename(suggestedFilename);
else {
Vector<String> extensions = MIMETypeRegistry::getExtensionsForMIMEType(mimeType);
if (extensions.isEmpty())
response.setSuggestedFilename(url.lastPathComponent());
else {
// If the suffix doesn't match the MIME type, correct the suffix.
QString filename = url.lastPathComponent();
const String suffix = QMimeDatabase().suffixForFileName(filename);
if (!extensions.contains(suffix)) {
filename.chop(suffix.length());
filename += MIMETypeRegistry::getPreferredExtensionForMIMEType(mimeType);
}
response.setSuggestedFilename(filename);
}
}
response.setHTTPStatusCode(statusCode);
response.setHTTPStatusText(m_replyWrapper->reply()->attribute(QNetworkRequest::HttpReasonPhraseAttribute).toByteArray().constData());
// Add remaining headers.
foreach (const QNetworkReply::RawHeaderPair& pair, m_replyWrapper->reply()->rawHeaderPairs())
response.setHTTPHeaderField(QString::fromLatin1(pair.first), QString::fromLatin1(pair.second));
}
示例10: method
HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method(
/* [retval][out] */ BSTR* result)
{
ASSERT(m_element && isHTMLFormElement(m_element));
WTF::String methodString = toHTMLFormElement(m_element)->method();
*result = BString(methodString.characters(), methodString.length()).release();
return S_OK;
}
示例11: urlSuitableForTestResult
static WTF::String urlSuitableForTestResult(const WTF::String& uriString)
{
if (uriString.isEmpty() || !uriString.startsWith("file://"))
return uriString;
const size_t index = uriString.reverseFind('/');
return (index == WTF::notFound) ? uriString : uriString.substring(index + 1);
}
示例12: innerText
HRESULT STDMETHODCALLTYPE DOMHTMLElement::innerText(
/* [retval][out] */ BSTR* result)
{
ASSERT(m_element && m_element->isHTMLElement());
WTF::String innerTextString = static_cast<HTMLElement*>(m_element)->innerText();
*result = BString(innerTextString.characters(), innerTextString.length()).release();
return S_OK;
}
示例13: method
HRESULT STDMETHODCALLTYPE DOMHTMLFormElement::method(
/* [retval][out] */ BSTR* result)
{
ASSERT(m_element && m_element->hasTagName(formTag));
WTF::String methodString = static_cast<HTMLFormElement*>(m_element)->method();
*result = BString(methodString.characters(), methodString.length()).release();
return S_OK;
}
示例14: ReleaseIconForPageUrl
static void ReleaseIconForPageUrl(JNIEnv* env, jobject obj, jstring url)
{
ALOG_ASSERT(url, "No url given to releaseIconForPageUrl");
WTF::String urlStr = jstringToWtfString(env, url);
ALOGV("Releasing icon for '%s'", urlStr.latin1().data());
WebCore::iconDatabase().releaseIconForPageURL(urlStr);
}
示例15: showGraphicsLayerTree
void showGraphicsLayerTree(const WebCore::GraphicsLayer* layer)
{
if (!layer)
return;
WTF::String output = layer->layerTreeAsText(LayerTreeAsTextDebug);
fprintf(stderr, "%s\n", output.utf8().data());
}