/// <summary> /// Gets the size of a string if it was to be written to the encoder /// </summary> /// <param name="str">The string to check the size of</param> /// <returns>The size the string would take on the encoder</returns> public int GetStringSize(string str) { if (ProtoRev < 0x0300u) { int len = str.Length; if (len > 0xffff) { len = 0xffff; } return(2 + len); } return(Leb128.SizeUleb128((ulong)str.Length) + str.Length); }
/// <summary> /// Write a Uleb128 length to the encoder /// </summary> /// <param name="val">The Uleb128 length to write</param> public void WriteUleb128(ulong val) { Leb128.WriteUleb128(m_buffer, val); }
/// <summary> /// Gets the size of a raw array if it was to be written to the encoder /// </summary> /// <param name="raw">The raw array to check the size of</param> /// <returns>The size the raw array would take on the encoder</returns> public int GetRawSize(byte[] raw) { return(Leb128.SizeUleb128((ulong)raw.Length) + raw.Length); }
/// <summary> /// Read a Uleb128 length from the buffer. /// </summary> /// <param name="val">The length read</param> /// <returns>True if the length was read</returns> public bool ReadUleb128(out ulong val) { return(Leb128.ReadUleb128(m_stream, out val)); }