@Override public void writeUInt32(int fieldNumber, int value, boolean repeated) throws IOException { tail = writeTagAndRawVarInt32( makeTag(fieldNumber, WIRETYPE_VARINT), value, this, tail); }
@Override public void writeBool(int fieldNumber, boolean value, boolean repeated) throws IOException { tail = writeTagAndRawVarInt32( makeTag(fieldNumber, WIRETYPE_VARINT), value ? 1 : 0, this, tail); }
/** * Returns the buffer encoded with the tag and LinkedBuffer (zero-copy) */ public static LinkedBuffer writeTagAndLinkedBuffer(int tag, final LinkedBuffer buffer, final WriteSession session, LinkedBuffer lb) { final int valueLen = buffer.offset - buffer.start; if (valueLen == 0) { // write only the tag and delimiter return writeTagAndRawVarInt32(tag, valueLen, session, lb); } lb = writeTagAndRawVarInt32(tag, valueLen, session, lb); // zero copy lb.next = buffer; final int remaining = lb.buffer.length - lb.offset; // if all filled up, return a fresh buffer. return remaining == 0 ? new LinkedBuffer(session.nextBufferSize, buffer) : new LinkedBuffer(lb, buffer); }
@Override public void writeSInt32(int fieldNumber, int value, boolean repeated) throws IOException { tail = writeTagAndRawVarInt32( makeTag(fieldNumber, WIRETYPE_VARINT), encodeZigZag32(value), this, tail); }
@Override public void writeInt32(int fieldNumber, int value, boolean repeated) throws IOException { if (value < 0) { tail = writeTagAndRawVarInt64( makeTag(fieldNumber, WIRETYPE_VARINT), value, this, tail); } else { tail = writeTagAndRawVarInt32( makeTag(fieldNumber, WIRETYPE_VARINT), value, this, tail); } }
return writeTagAndRawVarInt32(tag, valueLen, session, lb); lb = writeTagAndRawVarInt32(tag, valueLen, session, lb);