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


C++ StringBuilder::appendNumber方法代码示例

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


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

示例1: appendServerMapMousePosition

static void appendServerMapMousePosition(StringBuilder& url, Event* event)
{
    ASSERT(event);
    if (!is<MouseEvent>(*event))
        return;

    ASSERT(event->target());
    Node* target = event->target()->toNode();
    ASSERT(target);
    if (!is<HTMLImageElement>(*target))
        return;

    HTMLImageElement& imageElement = downcast<HTMLImageElement>(*target);
    if (!imageElement.isServerMap())
        return;

    if (!is<RenderImage>(imageElement.renderer()))
        return;
    auto& renderer = downcast<RenderImage>(*imageElement.renderer());

    // FIXME: This should probably pass true for useTransforms.
    FloatPoint absolutePosition = renderer.absoluteToLocal(FloatPoint(downcast<MouseEvent>(*event).pageX(), downcast<MouseEvent>(*event).pageY()));
    int x = absolutePosition.x();
    int y = absolutePosition.y();
    url.append('?');
    url.appendNumber(x);
    url.append(',');
    url.appendNumber(y);
}
开发者ID:houzhenggang,项目名称:webkit,代码行数:29,代码来源:HTMLAnchorElement.cpp

示例2: dump

void Option::dump(StringBuilder& builder) const
{
    switch (type()) {
    case Options::Type::boolType:
        builder.append(m_entry.boolVal ? "true" : "false");
        break;
    case Options::Type::unsignedType:
        builder.appendNumber(m_entry.unsignedVal);
        break;
    case Options::Type::doubleType:
        builder.appendNumber(m_entry.doubleVal);
        break;
    case Options::Type::int32Type:
        builder.appendNumber(m_entry.int32Val);
        break;
    case Options::Type::optionRangeType:
        builder.append(m_entry.optionRangeVal.rangeString());
        break;
    case Options::Type::optionStringType: {
        const char* option = m_entry.optionStringVal;
        if (!option)
            option = "";
        builder.append('"');
        builder.append(option);
        builder.append('"');
        break;
    }
    case Options::Type::gcLogLevelType: {
        builder.append(GCLogging::levelAsString(m_entry.gcLogLevelVal));
        break;
    }
    }
}
开发者ID:nickooms,项目名称:webkit,代码行数:33,代码来源:Options.cpp

示例3: appendServerMapMousePosition

static void appendServerMapMousePosition(StringBuilder& url, Event* event)
{
    if (!event->isMouseEvent())
        return;

    ASSERT(event->target());
    Node* target = event->target()->toNode();
    ASSERT(target);
    if (!isHTMLImageElement(*target))
        return;

    HTMLImageElement& imageElement = toHTMLImageElement(*target);
    if (!imageElement.isServerMap())
        return;

    if (!imageElement.renderer() || !imageElement.renderer()->isRenderImage())
        return;
    RenderImage* renderer = toRenderImage(imageElement.renderer());

    // FIXME: This should probably pass true for useTransforms.
    FloatPoint absolutePosition = renderer->absoluteToLocal(FloatPoint(toMouseEvent(event)->pageX(), toMouseEvent(event)->pageY()));
    int x = absolutePosition.x();
    int y = absolutePosition.y();
    url.append('?');
    url.appendNumber(x);
    url.append(',');
    url.appendNumber(y);
}
开发者ID:eth-srl,项目名称:BlinkER,代码行数:28,代码来源:HTMLAnchorElement.cpp

示例4: serializedAsCSSComponentValue

String Color::serializedAsCSSComponentValue() const
{
    StringBuilder result;
    result.reserveCapacity(32);
    bool colorHasAlpha = hasAlpha();
    if (colorHasAlpha)
        result.appendLiteral("rgba(");
    else
        result.appendLiteral("rgb(");

    result.appendNumber(static_cast<unsigned char>(red()));
    result.appendLiteral(", ");

    result.appendNumber(static_cast<unsigned char>(green()));
    result.appendLiteral(", ");

    result.appendNumber(static_cast<unsigned char>(blue()));
    if (colorHasAlpha) {
        result.appendLiteral(", ");

        NumberToStringBuffer buffer;
        const char* alphaString = numberToFixedPrecisionString(alpha() / 255.0f, 6, buffer, true);
        result.append(alphaString, strlen(alphaString));
    }

    result.append(')');
    return result.toString();
}
开发者ID:335969568,项目名称:Blink-1,代码行数:28,代码来源:Color.cpp

示例5: serialized

String Color::serialized() const
{
    if (!hasAlpha()) {
        StringBuilder builder;
        builder.reserveCapacity(7);
        builder.append('#');
        appendByteAsHex(red(), builder, Lowercase);
        appendByteAsHex(green(), builder, Lowercase);
        appendByteAsHex(blue(), builder, Lowercase);
        return builder.toString();
    }

    StringBuilder result;
    result.reserveCapacity(28);

    result.appendLiteral("rgba(");
    result.appendNumber(red());
    result.appendLiteral(", ");
    result.appendNumber(green());
    result.appendLiteral(", ");
    result.appendNumber(blue());
    result.appendLiteral(", ");

    if (!alpha())
        result.append('0');
    else {
        result.append(Decimal::fromDouble(alpha() / 255.0).toString());
    }

    result.append(')');
    return result.toString();
}
开发者ID:335969568,项目名称:Blink-1,代码行数:32,代码来源:Color.cpp

示例6: appendServerMapMousePosition

static void appendServerMapMousePosition(StringBuilder& url, Event& event)
{
    if (!is<MouseEvent>(event))
        return;
    auto& mouseEvent = downcast<MouseEvent>(event);

    ASSERT(mouseEvent.target());
    auto* target = mouseEvent.target()->toNode();
    ASSERT(target);
    if (!is<HTMLImageElement>(*target))
        return;

    auto& imageElement = downcast<HTMLImageElement>(*target);
    if (!imageElement.isServerMap())
        return;

    auto* renderer = imageElement.renderer();
    if (!is<RenderImage>(renderer))
        return;

    // FIXME: This should probably pass UseTransforms in the MapCoordinatesFlags.
    auto absolutePosition = downcast<RenderImage>(*renderer).absoluteToLocal(FloatPoint(mouseEvent.pageX(), mouseEvent.pageY()));
    url.append('?');
    url.appendNumber(std::lround(absolutePosition.x()));
    url.append(',');
    url.appendNumber(std::lround(absolutePosition.y()));
}
开发者ID:ollie314,项目名称:webkit,代码行数:27,代码来源:HTMLAnchorElement.cpp

示例7: makeRFC2822DateString

// See http://tools.ietf.org/html/rfc2822#section-3.3 for more information.
String makeRFC2822DateString(unsigned dayOfWeek, unsigned day, unsigned month, unsigned year, unsigned hours, unsigned minutes, unsigned seconds, int utcOffset)
{
    StringBuilder stringBuilder;
    stringBuilder.append(weekdayName[dayOfWeek]);
    stringBuilder.appendLiteral(", ");
    stringBuilder.appendNumber(day);
    stringBuilder.append(' ');
    stringBuilder.append(monthName[month]);
    stringBuilder.append(' ');
    stringBuilder.appendNumber(year);
    stringBuilder.append(' ');

    stringBuilder.append(twoDigitStringFromNumber(hours));
    stringBuilder.append(':');
    stringBuilder.append(twoDigitStringFromNumber(minutes));
    stringBuilder.append(':');
    stringBuilder.append(twoDigitStringFromNumber(seconds));
    stringBuilder.append(' ');

    stringBuilder.append(utcOffset > 0 ? '+' : '-');
    int absoluteUTCOffset = abs(utcOffset);
    stringBuilder.append(twoDigitStringFromNumber(absoluteUTCOffset / 60));
    stringBuilder.append(twoDigitStringFromNumber(absoluteUTCOffset % 60));

    return stringBuilder.toString();
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_external_chromium_org_third_party_WebKit,代码行数:27,代码来源:DateMath.cpp

示例8: resultForDialogSubmit

String ImageInputType::resultForDialogSubmit() const
{
    StringBuilder result;
    result.appendNumber(m_clickLocation.x());
    result.append(",");
    result.appendNumber(m_clickLocation.y());
    return result.toString();
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:8,代码来源:ImageInputType.cpp

示例9: createImageBuffer

void HTMLCanvasElement::createImageBuffer() const
{
    ASSERT(!m_imageBuffer);

    m_hasCreatedImageBuffer = true;
    m_didClearImageBuffer = true;

    FloatSize logicalSize = size();
    FloatSize deviceSize = convertLogicalToDevice(logicalSize);
    if (!deviceSize.isExpressibleAsIntSize())
        return;

    if (deviceSize.width() * deviceSize.height() > MaxCanvasArea) {
        StringBuilder stringBuilder;
        stringBuilder.appendLiteral("Canvas area exceeds the maximum limit (width * height > ");
        stringBuilder.appendNumber(MaxCanvasArea);
        stringBuilder.appendLiteral(").");
        document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, stringBuilder.toString());
        return;
    }

    // Make sure we don't use more pixel memory than the system can support.
    size_t requestedPixelMemory = 4 * width() * height();
    if (activePixelMemory + requestedPixelMemory > maxActivePixelMemory()) {
        StringBuilder stringBuilder;
        stringBuilder.appendLiteral("Total canvas memory use exceeds the maximum limit (");
        stringBuilder.appendNumber(maxActivePixelMemory() / 1024 / 1024);
        stringBuilder.appendLiteral(" MB).");
        document().addConsoleMessage(MessageSource::JS, MessageLevel::Warning, stringBuilder.toString());
        return;
    }

    IntSize bufferSize(deviceSize.width(), deviceSize.height());
    if (!bufferSize.width() || !bufferSize.height())
        return;

    RenderingMode renderingMode = shouldAccelerate(bufferSize) ? Accelerated : Unaccelerated;

    setImageBuffer(ImageBuffer::create(size(), renderingMode));
    if (!m_imageBuffer)
        return;
    m_imageBuffer->context().setShadowsIgnoreTransforms(true);
    m_imageBuffer->context().setImageInterpolationQuality(DefaultInterpolationQuality);
    if (document().settings() && !document().settings()->antialiased2dCanvasEnabled())
        m_imageBuffer->context().setShouldAntialias(false);
    m_imageBuffer->context().setStrokeThickness(1);
    m_contextStateSaver = std::make_unique<GraphicsContextStateSaver>(m_imageBuffer->context());

    JSC::JSLockHolder lock(scriptExecutionContext()->vm());
    scriptExecutionContext()->vm().heap.reportExtraMemoryAllocated(memoryCost());

#if USE(IOSURFACE_CANVAS_BACKING_STORE) || ENABLE(ACCELERATED_2D_CANVAS)
    if (m_context && m_context->is2d())
        // Recalculate compositing requirements if acceleration state changed.
        const_cast<HTMLCanvasElement*>(this)->setNeedsStyleRecalc(SyntheticStyleChange);
#endif
}
开发者ID:srinivas-kakarla,项目名称:WebKitForWayland,代码行数:57,代码来源:HTMLCanvasElement.cpp

示例10: valueAsString

String SVGRect::valueAsString() const
{
    StringBuilder builder;
    builder.appendNumber(x());
    builder.append(' ');
    builder.appendNumber(y());
    builder.append(' ');
    builder.appendNumber(width());
    builder.append(' ');
    builder.appendNumber(height());
    return builder.toString();
}
开发者ID:dstockwell,项目名称:blink,代码行数:12,代码来源:SVGRect.cpp

示例11: imageTitle

static String imageTitle(const String& filename, const IntSize& size)
{
    StringBuilder result;
    result.append(filename);
    result.appendLiteral(" (");
    // FIXME: Localize numbers. Safari/OSX shows localized numbers with group
    // separaters. For example, "1,920x1,080".
    result.appendNumber(size.width());
    result.append(static_cast<UChar>(0xD7)); // U+00D7 (multiplication sign)
    result.appendNumber(size.height());
    result.append(')');
    return result.toString();
}
开发者ID:JulienIsorce,项目名称:ChromiumGStreamerBackend,代码行数:13,代码来源:ImageDocument.cpp

示例12: customCSSText

String CSSCubicBezierTimingFunctionValue::customCSSText() const
{
    StringBuilder builder;
    builder.appendLiteral("cubic-bezier(");
    builder.appendNumber(m_x1);
    builder.appendLiteral(", ");
    builder.appendNumber(m_y1);
    builder.appendLiteral(", ");
    builder.appendNumber(m_x2);
    builder.appendLiteral(", ");
    builder.appendNumber(m_y2);
    builder.append(')');    
    return builder.toString();
}
开发者ID:Comcast,项目名称:WebKitForWayland,代码行数:14,代码来源:CSSTimingFunctionValue.cpp

示例13: onMemoryDump

void Resource::onMemoryDump(WebMemoryDumpLevelOfDetail levelOfDetail, WebProcessMemoryDump* memoryDump) const
{
    static const size_t kMaxURLReportLength = 128;
    static const int kMaxResourceClientToShowInMemoryInfra = 10;

    const String dumpName = getMemoryDumpName();
    WebMemoryAllocatorDump* dump = memoryDump->createMemoryAllocatorDump(dumpName);
    dump->addScalar("encoded_size", "bytes", m_encodedSize);
    if (canDelete()) {
        dump->addScalar("dead_size", "bytes", m_encodedSize);
    } else {
        dump->addScalar("live_size", "bytes", m_encodedSize);
    }

    if (m_data) {
        dump->addScalar("purgeable_size", "bytes", isPurgeable() && !wasPurged() ? encodedSize() + overheadSize() : 0);
        m_data->onMemoryDump(dumpName, memoryDump);
    }

    if (levelOfDetail == WebMemoryDumpLevelOfDetail::Detailed) {
        String urlToReport = url().string();
        if (urlToReport.length() > kMaxURLReportLength) {
            urlToReport.truncate(kMaxURLReportLength);
            urlToReport = urlToReport + "...";
        }
        dump->addString("url", "", urlToReport);

        dump->addString("reason_not_deletable", "", reasonNotDeletable());

        Vector<String> clientNames;
        ResourceClientWalker<ResourceClient> walker(m_clients);
        while (ResourceClient* client = walker.next())
            clientNames.append(client->debugName());
        ResourceClientWalker<ResourceClient> walker2(m_clientsAwaitingCallback);
        while (ResourceClient* client = walker2.next())
            clientNames.append("(awaiting) " + client->debugName());
        ResourceClientWalker<ResourceClient> walker3(m_finishedClients);
        while (ResourceClient* client = walker3.next())
            clientNames.append("(finished) " + client->debugName());
        std::sort(clientNames.begin(), clientNames.end(), codePointCompareLessThan);

        StringBuilder builder;
        for (size_t i = 0; i < clientNames.size() && i < kMaxResourceClientToShowInMemoryInfra; ++i) {
            if (i > 0)
                builder.append(" / ");
            builder.append(clientNames[i]);
        }
        if (clientNames.size() > kMaxResourceClientToShowInMemoryInfra) {
            builder.append(" / and ");
            builder.appendNumber(clientNames.size() - kMaxResourceClientToShowInMemoryInfra);
            builder.append(" more");
        }
        dump->addString("ResourceClient", "", builder.toString());
    }

    const String overheadName = dumpName + "/metadata";
    WebMemoryAllocatorDump* overheadDump = memoryDump->createMemoryAllocatorDump(overheadName);
    overheadDump->addScalar("size", "bytes", overheadSize());
    memoryDump->addSuballocation(overheadDump->guid(), String(WTF::Partitions::kAllocatedObjectPoolName));
}
开发者ID:golden628,项目名称:ChromiumGStreamerBackend,代码行数:60,代码来源:Resource.cpp

示例14: valueAsString

String SVGTransform::valueAsString() const
{
    double arguments[6];
    size_t argumentCount = 0;
    switch (m_transformType) {
    case SVG_TRANSFORM_UNKNOWN:
        return emptyString();
    case SVG_TRANSFORM_MATRIX: {
        arguments[argumentCount++] = m_matrix.a();
        arguments[argumentCount++] = m_matrix.b();
        arguments[argumentCount++] = m_matrix.c();
        arguments[argumentCount++] = m_matrix.d();
        arguments[argumentCount++] = m_matrix.e();
        arguments[argumentCount++] = m_matrix.f();
        break;
    }
    case SVG_TRANSFORM_TRANSLATE: {
        arguments[argumentCount++] = m_matrix.e();
        arguments[argumentCount++] = m_matrix.f();
        break;
    }
    case SVG_TRANSFORM_SCALE: {
        arguments[argumentCount++] = m_matrix.a();
        arguments[argumentCount++] = m_matrix.d();
        break;
    }
    case SVG_TRANSFORM_ROTATE: {
        arguments[argumentCount++] = m_angle;

        double angleInRad = deg2rad(m_angle);
        double cosAngle = cos(angleInRad);
        double sinAngle = sin(angleInRad);
        float cx = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix.e() * (1 - cosAngle) - m_matrix.f() * sinAngle) / (1 - cosAngle) / 2 : 0);
        float cy = narrowPrecisionToFloat(cosAngle != 1 ? (m_matrix.e() * sinAngle / (1 - cosAngle) + m_matrix.f()) / 2 : 0);
        if (cx || cy) {
            arguments[argumentCount++] = cx;
            arguments[argumentCount++] = cy;
        }
        break;
    }
    case SVG_TRANSFORM_SKEWX:
        arguments[argumentCount++] = m_angle;
        break;
    case SVG_TRANSFORM_SKEWY:
        arguments[argumentCount++] = m_angle;
        break;
    }
    ASSERT(argumentCount <= WTF_ARRAY_LENGTH(arguments));

    StringBuilder builder;
    builder.append(transformTypePrefixForParsing(m_transformType));

    for (size_t i = 0; i < argumentCount; ++i) {
        if (i)
            builder.append(' ');
        builder.appendNumber(arguments[i]);
    }
    builder.append(')');
    return builder.toString();
}
开发者ID:astojilj,项目名称:chromium-crosswalk,代码行数:60,代码来源:SVGTransform.cpp

示例15: nodePosition

static String nodePosition(Node* node)
{
    StringBuilder result;

    Element* body = node->document()->body();
    Node* parent;
    for (Node* n = node; n; n = parent) {
        parent = n->parentOrHostNode();
        if (n != node)
            result.appendLiteral(" of ");
        if (parent) {
            if (body && n == body) {
                // We don't care what offset body may be in the document.
                result.appendLiteral("body");
                break;
            }
            if (n->isShadowRoot()) {
                result.append('{');
                result.append(getTagName(n));
                result.append('}');
            } else {
                result.appendLiteral("child ");
                result.appendNumber(n->nodeIndex());
                result.appendLiteral(" {");
                result.append(getTagName(n));
                result.append('}');
            }
        } else
            result.appendLiteral("document");
    }

    return result.toString();
}
开发者ID:dog-god,项目名称:iptv,代码行数:33,代码来源:RenderTreeAsText.cpp


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