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; }
/// <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; }
/// <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; }
public void Write(UInt32 source, int numberOfBits) { EnsureBufferSize(m_bitLength + numberOfBits); NetBitWriter.WriteUInt32(source, numberOfBits, m_data, m_bitLength); m_bitLength += numberOfBits; }
public void Write(UInt32 source) { EnsureBufferSize(m_bitLength + 32); NetBitWriter.WriteUInt32(source, 32, m_data, m_bitLength); m_bitLength += 32; }