Beispiel #1
0
bool ArgumentDecoder::decodeInt32(int32_t& result)
{
    if (!alignBufferPosition(sizeof(result), sizeof(result)))
        return false;
    
    result = *reinterpret_cast<uint32_t*>(m_bufferPos);
    m_bufferPos += sizeof(result);
    return true;
}
bool ArgumentDecoder::decode(double& result)
{
    if (!alignBufferPosition(sizeof(result), sizeof(result)))
        return false;
    
    result = *reinterpret_cast_ptr<double*>(m_bufferPos);
    m_bufferPos += sizeof(result);
    return true;
}
Beispiel #3
0
bool ArgumentDecoder::decodeFixedLengthData(uint8_t* data, size_t size, unsigned alignment)
{
    if (!alignBufferPosition(alignment, size))
        return false;

    memcpy(data, m_bufferPos, size);
    m_bufferPos += size;

    return true;
}
Beispiel #4
0
bool ArgumentDecoder::decodeVariableLengthByteArray(DataReference& dataReference)
{
    uint64_t size;
    if (!decode(size))
        return false;
    
    if (!alignBufferPosition(1, size))
        return false;

    uint8_t* data = m_bufferPos;
    m_bufferPos += size;

    dataReference = DataReference(data, size);
    return true;
}
bool ArgumentDecoder::decodeBytes(Vector<uint8_t>& buffer)
{
    uint64_t size;
    if (!decodeUInt64(size))
        return false;

    if (!alignBufferPosition(1, size))
        return false;

    buffer.resize(size);
    if (size > 0)
        memcpy(&buffer[0], m_bufferPos, size);
    m_bufferPos += size;
    return true;
}
bool ArgumentDecoder::decodeBytes(DataReference& dataReference)
{
    uint64_t size;
    if (!decodeUInt64(size))
        return false;
    
    if (!alignBufferPosition(1, size))
        return false;

    uint8_t* data = m_bufferPos;
    m_bufferPos += size;

    dataReference = DataReference(data, size);
    return true;
}
bool ArgumentDecoder::decodeBytes(uint8_t* buffer, size_t bufferSize)
{
    // FIXME: Decoding the size is not strictly necessary here since we know the size upfront.
    uint64_t size;
    if (!decodeUInt64(size))
        return false;

    ASSERT(size == bufferSize);
    if (size != bufferSize)
        return false;

    if (!alignBufferPosition(1, size))
        return false;

    memcpy(buffer, m_bufferPos, size);
    m_bufferPos += size;
    return true;
}