@Override
        public LinkedBuffer writeVarInt64(long value,
                final WriteSession session, final LinkedBuffer lb) throws IOException
        {
            while (true)
            {
                session.size++;
                if (lb.offset == lb.buffer.length)
                {
                    // flush and reset
                    lb.offset = session.flush(lb.buffer, lb.start, lb.offset - lb.start);
                }

                if ((value & ~0x7FL) == 0)
                {
                    lb.buffer[lb.offset++] = (byte) value;
                    return lb;
                }

                lb.buffer[lb.offset++] = (byte) (((int) value & 0x7F) | 0x80);
                value >>>= 7;
            }
        }
The flexible output for outputs that use {@link WriteSession}.

@author David Yu
@created Sep 20, 2010
protostuff-api/src/main/java/io/protostuff/WriteSink.java