download BitStream.cs
Language: C#
LOC: 44
Project Info
mcs
Server: Mono
Type: svn
...s\class\ByteFX.Data\Common\
   BitStream.cs
   Connection.cs
   ConnectionString.cs
   DBConnectionString.cs
   DBParametersEditor.cs
   Field.cs
   HuffmanTree.cs
   Inflater.cs
   MultiHostStream.cs
   NamedPipeStream.cs
   Platform.cs
   Security.cs
   SqlCommandEditorDlg.cs
   SqlCommandEditorDlg.resx
   SqlCommandTextEditor.cs
   StreamCreator.cs
   StringUtility.cs
   Version.cs

using System;
using System.IO;

namespace ByteFX.Data.Common
{
	/// <summary>
	/// Summary description for BitStream.
	/// </summary>
	public class BitStream : MemoryStream
	{
		private byte[]	_input;
		private int		_start;
		private int		_end;
		private int		_bitindex;
		private uint	_bitbuffer;
		private int		_bits_in_buffer;

		public BitStream(byte[] input, int index, int len)
		{
			_bitindex = 0;
			_bitbuffer = 0;
			_bits_in_buffer = 0;
			_input = input;
			_start = index;
			_end = _start + len;
		}

		public int GetBits(int numbits)
		{
			return 0;
		}

		public int PeekBits(int numbits)
		{
			int val=0;

			int index=_start;
			while (numbits > 0)
			{
				val = (val << 8) | _input[index++];
				numbits -= 8;
			}

			while (_bits_in_buffer < numbits)
			{
				if (_start == _end)
					throw new Exception("Out of bits");
				byte b = _input[_start++];
			}
			return 0;
		}
	}
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us