예제 #1
0
        public UInt64 ReadUInt64()
        {
            ulong low = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);

            m_readPosition += 32;
            ulong high = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);

            ulong retval = low + (high << 32);

            m_readPosition += 32;
            return(retval);
        }
예제 #2
0
        public bool ReadInt32(out Int32 result)
        {
            if (m_bitLength - m_readPosition < 32)
            {
                result = 0;
                return(false);
            }

            result          = (Int32)NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
            m_readPosition += 32;
            return(true);
        }
예제 #3
0
        public UInt64 PeekUInt64(int numberOfBits)
        {
            ulong retval;

            if (numberOfBits <= 32)
            {
                retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);
            }
            else
            {
                retval  = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);
                retval |= NetBitWriter.ReadUInt32(m_data, numberOfBits - 32, m_readPosition) << 32;
            }
            return(retval);
        }
예제 #4
0
        /// <summary>
        /// Reads the specified number of bits into an Int32 without advancing the read pointer
        /// </summary>
        public Int32 PeekInt32(int numberOfBits)
        {
            uint retval = NetBitWriter.ReadUInt32(m_data, numberOfBits, m_readPosition);

            if (numberOfBits == 32)
            {
                return((int)retval);
            }

            int signBit = 1 << (numberOfBits - 1);

            if ((retval & signBit) == 0)
            {
                return((int)retval);                // positive
            }
            // negative
            unchecked
            {
                uint mask = ((uint)-1) >> (33 - numberOfBits);
                uint tmp  = (retval & mask) + 1;
                return(-((int)tmp));
            }
        }
예제 #5
0
        public UInt32 PeekUInt32()
        {
            uint retval = NetBitWriter.ReadUInt32(m_data, 32, m_readPosition);

            return(retval);
        }