Пример #1
0
bool parseNumberFromString(const String& string, float& number, bool skip)
{
    if (string.isEmpty())
        return false;
    if (string.is8Bit()) {
        const LChar* ptr = string.characters8();
        const LChar* end = ptr + string.length();
        return genericParseNumber(ptr, end, number, skip) && ptr == end;
    }
    const UChar* ptr = string.characters16();
    const UChar* end = ptr + string.length();
    return genericParseNumber(ptr, end, number, skip) && ptr == end;
}
bool parseNumberFromString(const String& string, float& number, bool skip)
{
    auto upconvertedCharacters = StringView(string).upconvertedCharacters();
    const UChar* ptr = upconvertedCharacters;
    const UChar* end = ptr + string.length();
    return genericParseNumber(ptr, end, number, skip) && ptr == end;
}
Пример #3
0
bool genericParseNumberOrPercentage(const CharType*& ptr, const CharType* end, float& number)
{
    if (genericParseNumber(ptr, end, number, AllowLeadingWhitespace)) {
        if (ptr == end)
            return true;

        bool isPercentage = (*ptr == '%');
        if (isPercentage)
            ptr++;

        skipOptionalSVGSpaces(ptr, end);

        if (isPercentage)
            number /= 100.f;

        return ptr == end;
    }

    return false;
}
Пример #4
0
bool parseNumber(const UChar*& ptr, const UChar* end, float& number, WhitespaceMode mode)
{
    return genericParseNumber(ptr, end, number, mode);
}
Пример #5
0
bool parseNumber(const UChar*& ptr, const UChar* end, float& number, bool skip)
{
    return genericParseNumber(ptr, end, number, skip);
}
Пример #6
0
bool parseSVGNumber(CharType* begin, size_t length, double& number)
{
    const CharType* ptr = begin;
    const CharType* end = ptr + length;
    return genericParseNumber(ptr, end, number, false);
}
Пример #7
0
bool parseNumberFromString(const String& string, float& number, bool skip)
{
    const UChar* ptr = string.characters();
    const UChar* end = ptr + string.length();
    return genericParseNumber(ptr, end, number, skip) && ptr == end;
}