bool IDBKeyData::decode(KeyedDecoder& decoder, IDBKeyData& result)
{
    if (!decoder.decodeBool("null", result.m_isNull))
        return false;

    if (result.m_isNull)
        return true;

    auto enumFunction = [](int64_t value) {
        return value == KeyType::Max
            || value == KeyType::Invalid
            || value == KeyType::Array
            || value == KeyType::String
            || value == KeyType::Date
            || value == KeyType::Number
            || value == KeyType::Min;
    };
    if (!decoder.decodeEnum("m_type", result.m_type, enumFunction))
        return false;

    if (result.m_type == KeyType::Invalid)
        return true;

    if (result.m_type == KeyType::Max)
        return true;

    if (result.m_type == KeyType::Min)
        return true;

    if (result.m_type == KeyType::String)
        return decoder.decodeString("string", result.m_stringValue);

    if (result.m_type == KeyType::Number || result.m_type == KeyType::Date)
        return decoder.decodeDouble("number", result.m_numberValue);

    ASSERT(result.m_type == KeyType::Array);

    auto arrayFunction = [](KeyedDecoder& decoder, IDBKeyData& result) {
        return decode(decoder, result);
    };
    
    result.m_arrayValue.clear();
    return decoder.decodeObjects("array", result.m_arrayValue, arrayFunction);
}
Example #2
0
PassRefPtr<FormData> FormData::decode(KeyedDecoder& decoder)
{
    RefPtr<FormData> data = FormData::create();

    if (!decoder.decodeBool("alwaysStream", data->m_alwaysStream))
        return nullptr;

    if (!decoder.decodeBytes("boundary", data->m_boundary))
        return nullptr;

    if (!decoder.decodeObjects("elements", data->m_elements, [](KeyedDecoder& decoder, FormDataElement& element) {
        return decodeElement(decoder, element);
    }))
        return nullptr;

    if (!decoder.decodeInt64("identifier", data->m_identifier))
        return nullptr;

    return data.release();
}
Example #3
0
bool IDBKeyPath::decode(KeyedDecoder& decoder, IDBKeyPath& result)
{
    auto enumFunction = [](int64_t value) {
        return value == NullType || value == StringType || value == ArrayType;
    };

    if (!decoder.decodeVerifiedEnum("type", result.m_type, enumFunction))
        return false;

    if (result.m_type == NullType)
        return true;

    if (result.m_type == StringType)
        return decoder.decodeString("string", result.m_string);

    ASSERT(result.m_type == ArrayType);

    auto arrayFunction = [](KeyedDecoder& decoder, String& result) {
        return decoder.decodeString("string", result);
    };

    return decoder.decodeObjects("array", result.m_array, arrayFunction);
}