Пример #1
0
size32_t CThorContiguousRowBuffer::readVStr(ARowBuilder & target, size32_t offset, size32_t fixedSize)
{
    size32_t size = sizeVStr();
    byte * self = target.ensureCapacity(fixedSize + size, NULL);
    doRead(size, self+offset);
    return size;
}
Пример #2
0
size32_t CThorStreamDeserializerSource::readUtf8(ARowBuilder & target, size32_t offset, size32_t fixedSize, size32_t len)
{
    //The len is the number of utf characters, size depends on which characters are included.
    size32_t totalSize = 0;
    loop
    {
        if (len == 0)
            return totalSize;

        size32_t available;
        const byte * cur = doPeek(1, available);

        size32_t copyLen;
        for (copyLen = 0; copyLen < available;)
        {
            copyLen += readUtf8Size(cur+copyLen);   // This function only accesses the first byte
            if (--len == 0)
                break;
        }

        byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL);
        doRead(copyLen, self+offset+totalSize);
        totalSize += copyLen;
    }
}
Пример #3
0
size32_t CThorStreamDeserializerSource::readVUni(ARowBuilder & target, size32_t offset, size32_t fixedSize)
{
    size32_t totalSize = 0;
    bool done = false;
    loop
    {
        size32_t available;
        const byte * cur = doPeek(2, available);

        size32_t copyLen = 0;
        for (copyLen = 0; copyLen+1 < available; copyLen+=2)
        {
            if (cur[copyLen] == 0 && cur[copyLen+1] == 0)
            {
                copyLen += 2;
                done = true;
                break;
            }
        }

        byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL);
        doRead(copyLen, self+offset+totalSize);
        totalSize += copyLen;
        if (done)
            return totalSize;
    }
}
Пример #4
0
size32_t CThorContiguousRowBuffer::readUtf8(ARowBuilder & target, size32_t offset, size32_t fixedSize, size32_t len)
{
    if (len == 0)
        return 0;

    size32_t size = sizeUtf8(len);
    byte * self = target.ensureCapacity(fixedSize + size, NULL);
    doRead(size, self+offset);
    return size;
}
Пример #5
0
size32_t CThorStreamDeserializerSource::readVStr(ARowBuilder & target, size32_t offset, size32_t fixedSize)
{
    size32_t totalSize = 0;
    loop
    {
        size32_t available;
        const byte * cur = doPeek(1, available);

        const byte * end = static_cast<const byte *>(memchr(cur, 0, available));
        size32_t copyLen = end ? (end+1) - cur : available;

        byte * self = target.ensureCapacity(fixedSize + totalSize + copyLen, NULL);
        doRead(copyLen, self+offset+totalSize);
        totalSize += copyLen;
        if (end)
            return totalSize;
    }
}
Пример #6
0
 virtual size32_t transform(ARowBuilder & rowBuilder, const void * src) override
 {
     unsigned size = recordSize.getRecordSize(src);
     memcpy(rowBuilder.ensureCapacity(size, NULL), src, size);
     return size;
 }