/// <summary> /// Write variable encoded 32-bit unsigned integer /// </summary> public void WriteVarUInt32(uint value) { if (position + IntegerHelper.MaxBytesVarInt32 > length) { EndOfStream(IntegerHelper.MaxBytesVarInt32); } position = IntegerHelper.EncodeVarUInt32(buffer, value, position); }
/// <summary> /// Write variable encoded 64-bit unsigned integer /// </summary> public void WriteVarUInt64(ulong value) { if (position + IntegerHelper.MaxBytesVarInt64 > length) { EndOfStream(IntegerHelper.MaxBytesVarInt64); } position = IntegerHelper.EncodeVarUInt64(buffer, value, position); }
/// <summary> /// Write variable encoded 16-bit unsigned integer /// </summary> public void WriteVarUInt16(ushort value) { if (position + IntegerHelper.MaxBytesVarInt16 > length) { EndOfStream(IntegerHelper.MaxBytesVarInt16); } position = IntegerHelper.EncodeVarUInt16(buffer, value, position); }
/// <summary> /// Read variable encoded 64-bit unsigned integer /// </summary> /// <exception cref="EndOfStreamException"/> public ulong ReadVarUInt64() { if (position > end - IntegerHelper.MaxBytesVarInt64) { return(DecodeVarUInt64Checked()); } return(IntegerHelper.DecodeVarUInt64(buffer, ref position)); }
/// <summary> /// Read variable encoded 32-bit unsigned integer /// </summary> /// <exception cref="EndOfStreamException"/> public uint ReadVarUInt32() { if (position > end - IntegerHelper.MaxBytesVarInt32) { return((uint)DecodeVarUInt64Checked()); } return(IntegerHelper.DecodeVarUInt32(buffer, ref position)); }
/// <summary> /// Read variable encoded 16-bit unsigned integer /// </summary> /// <exception cref="EndOfStreamException"/> public ushort ReadVarUInt16() { if (position > end - IntegerHelper.MaxBytesVarInt16) { return((ushort)DecodeVarUInt64Checked()); } return(IntegerHelper.DecodeVarUInt16(buffer, ref position)); }
/// <summary> /// Write variable encoded 32-bit unsigned integer /// </summary> public void WriteVarUInt32(uint value) { if (position + IntegerHelper.MaxBytesVarInt32 > end) { EndOfStream(IntegerHelper.MaxBytesVarInt32); } position = IntegerHelper.EncodeVarUInt32(data, value, position); }