public bool ReadString(ref string val) { ulong v; if (Leb128.ReadUleb128(m_buffer, ref m_count, out v) == 0) { return(false); } var len = (int)v; if (m_buffer.Length < m_count + len) { return(false); } val = Encoding.UTF8.GetString(m_buffer, m_count, len); m_count += len; return(true); }
public bool ReadRaw(ref byte[] val) { ulong v; if (Leb128.ReadUleb128(m_buffer, ref m_count, out v) == 0) { return(false); } var len = (int)v; if (m_buffer.Length < m_count + len) { return(false); } val = new byte[len]; Array.Copy(m_buffer, m_count, val, 0, len); m_count += len; return(true); }
public void WriteUleb128(ulong val) { Leb128.WriteUleb128(m_buffer, val); }
public int GetStringSize(string str) { return(Leb128.SizeUleb128((ulong)str.Length) + str.Length); }
public int GetRawSize(byte[] raw) { return(Leb128.SizeUleb128((ulong)raw.Length) + raw.Length); }
public bool ReadUleb128(out ulong val) { return(Leb128.ReadUleb128(m_buffer, ref m_count, out val) != 0); }