当前位置: 首页>>代码示例>>C++>>正文


C++ SharedBuffer::append方法代码示例

本文整理汇总了C++中SharedBuffer::append方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedBuffer::append方法的具体用法?C++ SharedBuffer::append怎么用?C++ SharedBuffer::append使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SharedBuffer的用法示例。


在下文中一共展示了SharedBuffer::append方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: generateMHTMLFooter

void MHTMLArchive::generateMHTMLFooter(
    const String& boundary,
    SharedBuffer& outputBuffer)
{
    CString asciiString = String("--" + boundary + "--\r\n").utf8();
    outputBuffer.append(asciiString.data(), asciiString.length());
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:7,代码来源:MHTMLArchive.cpp

示例2: generateMHTMLHeader

void MHTMLArchive::generateMHTMLHeader(
    const String& boundary, const String& title, const String& mimeType,
    SharedBuffer& outputBuffer)
{
    DateComponents now;
    now.setMillisecondsSinceEpochForDateTime(currentTimeMS());
    // TODO(lukasza): Passing individual date/time components seems fragile.
    String dateString = makeRFC2822DateString(
        now.weekDay(), now.monthDay(), now.month(), now.fullYear(),
        now.hour(), now.minute(), now.second(), 0);

    StringBuilder stringBuilder;
    stringBuilder.appendLiteral("From: <Saved by Blink>\r\n");
    stringBuilder.appendLiteral("Subject: ");
    // We replace non ASCII characters with '?' characters to match IE's behavior.
    stringBuilder.append(replaceNonPrintableCharacters(title));
    stringBuilder.appendLiteral("\r\nDate: ");
    stringBuilder.append(dateString);
    stringBuilder.appendLiteral("\r\nMIME-Version: 1.0\r\n");
    stringBuilder.appendLiteral("Content-Type: multipart/related;\r\n");
    stringBuilder.appendLiteral("\ttype=\"");
    stringBuilder.append(mimeType);
    stringBuilder.appendLiteral("\";\r\n");
    stringBuilder.appendLiteral("\tboundary=\"");
    stringBuilder.append(boundary);
    stringBuilder.appendLiteral("\"\r\n\r\n");

    // We use utf8() below instead of ascii() as ascii() replaces CRLFs with ??
    // (we still only have put ASCII characters in it).
    ASSERT(stringBuilder.toString().containsOnlyASCII());
    CString asciiString = stringBuilder.toString().utf8();

    outputBuffer.append(asciiString.data(), asciiString.length());
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:34,代码来源:MHTMLArchive.cpp

示例3: generateMHTMLPart

void MHTMLArchive::generateMHTMLPart(
    const String& boundary,
    EncodingPolicy encodingPolicy,
    const SerializedResource& resource,
    SharedBuffer& outputBuffer)
{
    StringBuilder stringBuilder;
    stringBuilder.append("--" + boundary + "\r\n");
    stringBuilder.appendLiteral("Content-Type: ");
    stringBuilder.append(resource.mimeType);

    const char* contentEncoding = 0;
    if (encodingPolicy == UseBinaryEncoding)
        contentEncoding = binary;
    else if (MIMETypeRegistry::isSupportedJavaScriptMIMEType(resource.mimeType) || MIMETypeRegistry::isSupportedNonImageMIMEType(resource.mimeType))
        contentEncoding = quotedPrintable;
    else
        contentEncoding = base64;

    stringBuilder.appendLiteral("\r\nContent-Transfer-Encoding: ");
    stringBuilder.append(contentEncoding);
    stringBuilder.appendLiteral("\r\nContent-Location: ");
    stringBuilder.append(resource.url);
    stringBuilder.appendLiteral("\r\n\r\n");

    CString asciiString = stringBuilder.toString().utf8();
    outputBuffer.append(asciiString.data(), asciiString.length());

    if (!strcmp(contentEncoding, binary)) {
        const char* data;
        size_t position = 0;
        while (size_t length = resource.data->getSomeData(data, position)) {
            outputBuffer.append(data, length);
            position += length;
        }
    } else {
        // FIXME: ideally we would encode the content as a stream without having to fetch it all.
        const char* data = resource.data->data();
        size_t dataLength = resource.data->size();
        Vector<char> encodedData;
        if (!strcmp(contentEncoding, quotedPrintable)) {
            quotedPrintableEncode(data, dataLength, encodedData);
            outputBuffer.append(encodedData.data(), encodedData.size());
            outputBuffer.append("\r\n", 2);
        } else {
            ASSERT(!strcmp(contentEncoding, base64));
            // We are not specifying insertLFs = true below as it would cut the lines with LFs and MHTML requires CRLFs.
            base64Encode(data, dataLength, encodedData);
            const size_t maximumLineLength = 76;
            size_t index = 0;
            size_t encodedDataLength = encodedData.size();
            do {
                size_t lineLength = std::min(encodedDataLength - index, maximumLineLength);
                outputBuffer.append(encodedData.data() + index, lineLength);
                outputBuffer.append("\r\n", 2);
                index += maximumLineLength;
            } while (index < encodedDataLength);
        }
    }
}
开发者ID:shaoboyan,项目名称:chromium-crosswalk,代码行数:60,代码来源:MHTMLArchive.cpp


注:本文中的SharedBuffer::append方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。