Exemplo n.º 1
0
 /// <summary>
 /// Reads the specified number of bytes
 /// </summary>
 public byte[] ReadBytes(int numberOfBytes)
 {
     byte[] retval = new byte[numberOfBytes];
     NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, retval, 0);
     m_readPosition += (8 * numberOfBytes);
     return(retval);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Reads the specified number of bytes and returns true for success
        /// </summary>
        public bool ReadBytes(int numberOfBytes, out byte[] result)
        {
            if (m_bitLength - m_readPosition + 7 < (numberOfBytes * 8))
            {
                result = null;
                return(false);
            }

            result = new byte[numberOfBytes];
            NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, result, 0);
            m_readPosition += (8 * numberOfBytes);
            return(true);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reads the specified number of bits into a preallocated array
        /// </summary>
        /// <param name="into">The destination array</param>
        /// <param name="offset">The offset where to start writing in the destination array</param>
        /// <param name="numberOfBits">The number of bits to read</param>
        public void ReadBits(byte[] into, int offset, int numberOfBits)
        {
            int numberOfWholeBytes = numberOfBits / 8;
            int extraBits          = numberOfBits - (numberOfWholeBytes * 8);

            NetBitWriter.ReadBytes(m_data, numberOfWholeBytes, m_readPosition, into, offset);
            m_readPosition += (8 * numberOfWholeBytes);

            if (extraBits > 0)
            {
                into[offset + numberOfWholeBytes] = ReadByte(extraBits);
            }
        }
Exemplo n.º 4
0
 /// <summary>
 /// Reads the specified number of bytes without advancing the read pointer
 /// </summary>
 public void PeekBytes(byte[] into, int offset, int numberOfBytes)
 {
     NetBitWriter.ReadBytes(m_data, numberOfBytes, m_readPosition, into, offset);
 }