コード例 #1
0
        /// <summary>
        /// Reads 1 to 8 bits into a byte
        /// </summary>
        public byte ReadByte(int numberOfBits)
        {
            Debug.CheckArgument(numberOfBits > 0 && numberOfBits <= 8, "ReadByte(bits) can only read between 1 and 8 bits");
            byte retval = BitWriter.ReadByte(m_data, numberOfBits, m_readPosition);

            m_readPosition += numberOfBits;
            return(retval);
        }
コード例 #2
0
        /// <summary>
        /// Reads a signed byte
        /// </summary>
        public sbyte ReadSByte()
        {
            Debug.CheckArgument(m_bitLength - m_readPosition >= 8, c_readOverflowError);
            byte retval = BitWriter.ReadByte(m_data, 8, m_readPosition);

            m_readPosition += 8;
            return((sbyte)retval);
        }
コード例 #3
0
        /// <summary>
        /// Reads a boolean value (stored as a single bit) written using Write(bool)
        /// </summary>
        public bool ReadBoolean()
        {
            Debug.CheckArgument(m_bitLength - m_readPosition >= 1, c_readOverflowError);
            byte retval = BitWriter.ReadByte(m_data, 1, m_readPosition);

            m_readPosition += 1;
            return(retval > 0 ? true : false);
        }
コード例 #4
0
 /// <summary>
 /// Reads a byte and returns true or false for success
 /// </summary>
 public bool ReadByte(out byte result)
 {
     if (m_bitLength - m_readPosition < 8)
     {
         result = 0;
         return(false);
     }
     result          = BitWriter.ReadByte(m_data, 8, m_readPosition);
     m_readPosition += 8;
     return(true);
 }