示例#1
0
        public void WriteAt(Int32 offset, UInt32 source)
        {
            int newBitLength = Math.Max(m_bitLength, offset + 32);

            EnsureBufferSize(newBitLength);
            NetBitWriter.WriteUInt32(source, 32, m_data, offset);
            m_bitLength = newBitLength;
        }
示例#2
0
        /// <summary>
        /// Writes a 32 bit signed integer
        /// </summary>
        public unsafe void Write(Int32 source)
        {
            EnsureBufferSize(m_bitLength + 32);

            // can write fast?
            if (m_bitLength % 8 == 0)
            {
                fixed(byte *numRef = &Data[m_bitLength / 8])
                {
                    *((int *)numRef) = source;
                }
            }
            else
            {
                NetBitWriter.WriteUInt32((UInt32)source, 32, Data, m_bitLength);
            }
            m_bitLength += 32;
        }
示例#3
0
        /// <summary>
        /// Writes a signed integer using 1 to 32 bits
        /// </summary>
        public void Write(Int32 source, int numberOfBits)
        {
            EnsureBufferSize(m_bitLength + numberOfBits);

            if (numberOfBits != 32)
            {
                // make first bit sign
                int signBit = 1 << (numberOfBits - 1);
                if (source < 0)
                {
                    source = (-source - 1) | signBit;
                }
                else
                {
                    source &= (~signBit);
                }
            }

            NetBitWriter.WriteUInt32((uint)source, numberOfBits, m_data, m_bitLength);

            m_bitLength += numberOfBits;
        }
示例#4
0
 public void Write(UInt32 source, int numberOfBits)
 {
     EnsureBufferSize(m_bitLength + numberOfBits);
     NetBitWriter.WriteUInt32(source, numberOfBits, m_data, m_bitLength);
     m_bitLength += numberOfBits;
 }
示例#5
0
 public void Write(UInt32 source)
 {
     EnsureBufferSize(m_bitLength + 32);
     NetBitWriter.WriteUInt32(source, 32, m_data, m_bitLength);
     m_bitLength += 32;
 }