inline void push()

in src/filtration/filtratorimpl.h [148:206]


    inline void push(PacketInfo& info)
    {
        Filtrator* filtrator = static_cast<Filtrator*>(this);
        assert(info.dlen != 0);

        while(info.dlen) // loop over data in packet
        {
            if(msg_len) // we are on-stream and we are looking to some message
            {
                if(to_be_copied)
                {
                    // hdr_len != 0, readout a part of header of current message
                    if(to_be_copied > info.dlen) // got new part of header (not the all!)
                    {
                        //TRACE("got new part of header (not the all!)");
                        collection.push(info, info.dlen);
                        to_be_copied -= info.dlen;
                        msg_len -= info.dlen;
                        info.dlen = 0; // return from while
                    }
                    else // hdr_len <= dlen, current message will be complete, also we have some additional data
                    {
                        //TRACE("current message will be complete, also we have some additional data");
                        collection.push(info, to_be_copied);
                        info.dlen -= to_be_copied;
                        info.data += to_be_copied;

                        msg_len -= to_be_copied;
                        to_be_copied = 0;

                        collection.skip_first(Filtrator::lengthOfFirstSkipedPart());
                        collection.complete(info); // push complete message to queue
                    }
                }
                else
                {
                    // message header is readout, discard the unused tail of message
                    if(msg_len >= info.dlen) // discard whole new packet
                    {
                        //TRACE("discard whole new packet");
                        msg_len -= info.dlen;
                        return; //info.dlen = 0;  // return from while
                    }
                    else // discard only a part of packet payload related to current message
                    {
                        //TRACE("discard only a part of packet payload related to current message");
                        info.dlen -= msg_len;
                        info.data += msg_len;
                        msg_len = 0;
                        filtrator->find_message(info); // <- optimization
                    }
                }
            }
            else // msg_len == 0, no one message is on reading, try to find next message
            {
                filtrator->find_message(info);
            }
        }
    }