本文整理汇总了C++中StringBuilder::appendLiteral方法的典型用法代码示例。如果您正苦于以下问题:C++ StringBuilder::appendLiteral方法的具体用法?C++ StringBuilder::appendLiteral怎么用?C++ StringBuilder::appendLiteral使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringBuilder
的用法示例。
在下文中一共展示了StringBuilder::appendLiteral方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: appendLangArgumentList
static void appendLangArgumentList(StringBuilder& str, const Vector<AtomicString>& argumentList)
{
unsigned argumentListSize = argumentList.size();
for (unsigned i = 0; i < argumentListSize; ++i) {
str.append('"');
str.append(argumentList[i]);
str.append('"');
if (i != argumentListSize - 1)
str.appendLiteral(", ");
}
}
示例2: getPropertyText
String StylePropertySerializer::getPropertyText(CSSPropertyID propertyID, const String& value, bool isNotFirstDecl) const
{
StringBuilder result;
if (isNotFirstDecl)
result.append(' ');
result.append(getPropertyName(propertyID));
result.appendLiteral(": ");
result.append(value);
result.append(';');
return result.toString();
}
示例3: appendBackgroundRepeatValue
static void appendBackgroundRepeatValue(StringBuilder& builder, const CSSValue& repeatXCSSValue, const CSSValue& repeatYCSSValue)
{
// FIXME: Ensure initial values do not appear in CSS_VALUE_LISTS.
DEFINE_STATIC_REF_WILL_BE_PERSISTENT(CSSPrimitiveValue, initialRepeatValue, (CSSPrimitiveValue::create(CSSValueRepeat)));
const CSSPrimitiveValue& repeatX = repeatXCSSValue.isInitialValue() ? *initialRepeatValue : toCSSPrimitiveValue(repeatXCSSValue);
const CSSPrimitiveValue& repeatY = repeatYCSSValue.isInitialValue() ? *initialRepeatValue : toCSSPrimitiveValue(repeatYCSSValue);
CSSValueID repeatXValueId = repeatX.getValueID();
CSSValueID repeatYValueId = repeatY.getValueID();
if (repeatXValueId == repeatYValueId) {
builder.append(repeatX.cssText());
} else if (repeatXValueId == CSSValueNoRepeat && repeatYValueId == CSSValueRepeat) {
builder.appendLiteral("repeat-y");
} else if (repeatXValueId == CSSValueRepeat && repeatYValueId == CSSValueNoRepeat) {
builder.appendLiteral("repeat-x");
} else {
builder.append(repeatX.cssText());
builder.appendLiteral(" ");
builder.append(repeatY.cssText());
}
}
示例4: paramString
String UnlinkedFunctionExecutable::paramString() const
{
FunctionParameters& parameters = *m_parameters;
StringBuilder builder;
for (size_t pos = 0; pos < parameters.size(); ++pos) {
if (!builder.isEmpty())
builder.appendLiteral(", ");
parameters.at(pos)->toString(builder);
}
return builder.toString();
}
示例5: cssText
String CSSFontFaceRule::cssText() const
{
StringBuilder result;
result.appendLiteral("@font-face { ");
String descs = m_fontFaceRule->properties().asText();
result.append(descs);
if (!descs.isEmpty())
result.append(' ');
result.append('}');
return result.toString();
}
示例6: formatForDebugger
void VisibleSelection::formatForDebugger(char* buffer, unsigned length) const
{
StringBuilder result;
String s;
if (isNone()) {
result.appendLiteral("<none>");
} else {
const int FormatBufferSize = 1024;
char s[FormatBufferSize];
result.appendLiteral("from ");
start().formatForDebugger(s, FormatBufferSize);
result.append(s);
result.appendLiteral(" to ");
end().formatForDebugger(s, FormatBufferSize);
result.append(s);
}
strncpy(buffer, result.toString().utf8().data(), length - 1);
}
示例7: convertToDataURL
void FileReaderLoader::convertToDataURL()
{
StringBuilder builder;
builder.appendLiteral("data:");
if (!m_bytesLoaded) {
m_stringResult = builder.toString();
return;
}
builder.append(m_dataType);
builder.appendLiteral(";base64,");
Vector<char> out;
base64Encode(m_rawData->data(), m_bytesLoaded, out);
out.append('\0');
builder.append(out.data());
m_stringResult = builder.toString();
}
示例8: writeJSON
void InspectorValue::writeJSON(StringBuilder& output) const
{
switch (m_type) {
case Type::Null:
output.appendLiteral("null");
break;
case Type::Boolean:
if (m_value.boolean)
output.appendLiteral("true");
else
output.appendLiteral("false");
break;
case Type::String:
doubleQuoteString(m_value.string, output);
break;
case Type::Double:
case Type::Integer: {
NumberToLStringBuffer buffer;
if (!std::isfinite(m_value.number)) {
output.appendLiteral("null");
return;
}
DecimalNumber decimal = m_value.number;
unsigned length = 0;
if (decimal.bufferLengthForStringDecimal() > WTF::NumberToStringBufferLength) {
// Not enough room for decimal. Use exponential format.
if (decimal.bufferLengthForStringExponential() > WTF::NumberToStringBufferLength) {
// Fallback for an abnormal case if it's too little even for exponential.
output.appendLiteral("NaN");
return;
}
length = decimal.toStringExponential(buffer, WTF::NumberToStringBufferLength);
} else
length = decimal.toStringDecimal(buffer, WTF::NumberToStringBufferLength);
output.append(buffer, length);
break;
}
default:
ASSERT_NOT_REACHED();
}
}
示例9: platformResourceForPath
bool WebInspectorServer::platformResourceForPath(const String& path, Vector<char>& data, String& contentType)
{
// The page list contains an unformated list of pages that can be inspected with a link to open a session.
if (path == "/pagelist.json") {
buildPageList(data, contentType);
return true;
}
// Point the default path to a formatted page that queries the page list and display them.
CString localPath = WebCore::fileSystemRepresentation(inspectorServerFilesPath() + ((path == "/") ? "/inspectorPageIndex.html" : path));
if (localPath.isNull())
return false;
GRefPtr<GFile> file = adoptGRef(g_file_new_for_path(localPath.data()));
GOwnPtr<GError> error;
GRefPtr<GFileInfo> fileInfo = adoptGRef(g_file_query_info(file.get(), G_FILE_ATTRIBUTE_STANDARD_SIZE "," G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, 0, &error.outPtr()));
if (!fileInfo) {
StringBuilder builder;
builder.appendLiteral("<!DOCTYPE html><html><head></head><body>Error: ");
builder.appendNumber(error->code);
builder.appendLiteral(", ");
builder.append(error->message);
builder.appendLiteral(" occurred during fetching webinspector resource files.<br>Make sure you ran make install or have set WEBKIT_INSPECTOR_SERVER_PATH in your environment to point to webinspector folder.</body></html>");
CString cstr = builder.toString().utf8();
data.append(cstr.data(), cstr.length());
contentType = "text/html; charset=utf-8";
g_warning("Error fetching webinspector resource files: %d, %s", error->code, error->message);
return true;
}
GRefPtr<GFileInputStream> inputStream = adoptGRef(g_file_read(file.get(), 0, 0));
if (!inputStream)
return false;
data.grow(g_file_info_get_size(fileInfo.get()));
if (!g_input_stream_read_all(G_INPUT_STREAM(inputStream.get()), data.data(), data.size(), 0, 0, 0))
return false;
contentType = GOwnPtr<gchar>(g_file_info_get_attribute_as_string(fileInfo.get(), G_FILE_ATTRIBUTE_STANDARD_FAST_CONTENT_TYPE)).get();
return true;
}
示例10: didReceiveResponse
void EventSource::didReceiveResponse(unsigned long, const ResourceResponse& response)
{
ASSERT(m_state == CONNECTING);
ASSERT(m_requestInFlight);
m_eventStreamOrigin = SecurityOrigin::create(response.url())->toString();
int statusCode = response.httpStatusCode();
bool mimeTypeIsValid = response.mimeType() == "text/event-stream";
bool responseIsValid = statusCode == 200 && mimeTypeIsValid;
if (responseIsValid) {
const String& charset = response.textEncodingName();
// If we have a charset, the only allowed value is UTF-8 (case-insensitive).
responseIsValid = charset.isEmpty() || equalIgnoringCase(charset, "UTF-8");
if (!responseIsValid) {
StringBuilder message;
message.appendLiteral("EventSource's response has a charset (\"");
message.append(charset);
message.appendLiteral("\") that is not UTF-8. Aborting the connection.");
// FIXME: We are missing the source line.
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message.toString());
}
} else {
// To keep the signal-to-noise ratio low, we only log 200-response with an invalid MIME type.
if (statusCode == 200 && !mimeTypeIsValid) {
StringBuilder message;
message.appendLiteral("EventSource's response has a MIME type (\"");
message.append(response.mimeType());
message.appendLiteral("\") that is not \"text/event-stream\". Aborting the connection.");
// FIXME: We are missing the source line.
scriptExecutionContext()->addConsoleMessage(JSMessageSource, ErrorMessageLevel, message.toString());
}
}
if (responseIsValid) {
m_state = OPEN;
dispatchEvent(Event::create(eventNames().openEvent, false, false));
} else {
m_loader->cancel();
dispatchEvent(Event::create(eventNames().errorEvent, false, false));
}
}
示例11: buildRawString
inline void SecurityOrigin::buildRawString(StringBuilder& builder) const
{
builder.reserveCapacity(m_protocol.length() + m_host.length() + 10);
builder.append(m_protocol);
builder.appendLiteral("://");
builder.append(m_host);
if (m_port) {
builder.append(':');
builder.appendNumber(m_port);
}
}
示例12: mediaText
String MediaQuerySet::mediaText() const
{
StringBuilder text;
bool needComma = false;
for (auto& query : m_queries) {
if (needComma)
text.appendLiteral(", ");
text.append(query.cssText());
needComma = true;
}
return text.toString();
}
示例13: formatForDebugger
void Text::formatForDebugger(char* buffer, unsigned length) const
{
StringBuilder result;
String s;
result.append(nodeName());
s = data();
if (s.length() > 0) {
if (result.length())
result.appendLiteral("; ");
result.appendLiteral("length=");
result.appendNumber(s.length());
result.appendLiteral("; value=\"");
result.append(s);
result.append('"');
}
strncpy(buffer, result.toString().utf8().data(), length - 1);
buffer[length - 1] = '\0';
}
示例14: nodePositionAsStringForTesting
String nodePositionAsStringForTesting(Node* node)
{
StringBuilder result;
Node* parent;
for (Node* n = node; n; n = parent) {
parent = n->parentNode();
if (n != node)
result.appendLiteral(" of ");
if (parent) {
result.appendLiteral("child ");
result.appendNumber(n->nodeIndex());
result.appendLiteral(" {");
result.append(n->nodeName());
result.append('}');
} else
result.appendLiteral("document");
}
return result.toString();
}
示例15: cssText
String CSSStyleRule::cssText() const
{
StringBuilder result;
result.append(selectorText());
result.appendLiteral(" { ");
String decls = m_styleRule->properties().asText();
result.append(decls);
if (!decls.isEmpty())
result.append(' ');
result.append('}');
return result.toString();
}