binpac: Adding an interface to manually control the buffering for generated

parsers.

This consists of two parts:

    1. The generated Flow classes expose their flow buffers via a new
       method flow_buffer().

    2. Flow buffers get two new methods:

        // Interface for delayed parsing. Sometimes BinPAC doesn't get the
        // buffering right and then one can use these to feed parts
        // individually and assemble them internally. After calling
        // FinishBuffer(), one can send the uppper-layer flow an FlowEOF()
        // to trigger parsing.
        void BufferData(const_byteptr data, const_byteptr end);
        void FinishBuffer();
This commit is contained in:
Robin Sommer 2013-07-24 18:32:09 -07:00 committed by Tim Wojtulewicz
parent ce2b56751b
commit 61cc83affa
3 changed files with 23 additions and 2 deletions

View file

@ -137,6 +137,19 @@ void FlowBuffer::NewFrame(int frame_length, bool chunked)
MarkOrCopyFrame();
}
void FlowBuffer::BufferData(const_byteptr data, const_byteptr end)
{
mode_ = FRAME_MODE;
frame_length_ += (end - data);
MarkOrCopyFrame();
NewData(data, end);
}
void FlowBuffer::FinishBuffer()
{
message_complete_ = true;
}
void FlowBuffer::GrowFrame(int length)
{
BINPAC_ASSERT(frame_length_ >= 0);