/// <summary> /// Creates a new stream using arithmetic compression on the provided <paramref name="stream"/>. /// </summary> /// <param name="stream">Underlying stream to compress or decompress.</param> /// <param name="mode">Compression mode (compress or decompress).</param> /// <param name="leaveOpen">Whether to leave the underlying stream open on dispose.</param> public ArithmeticStream(Stream stream, CompressionMode mode, bool leaveOpen) { _stream = mode == CompressionMode.Compress ? new BitStreamWriter(stream) : new BitStreamReader(stream) as BitStream; _mode = mode; _leaveOpen = leaveOpen; if (mode == CompressionMode.Decompress) { _coder.DecodeStart(_stream.ReadBoolean); } }
/// <summary> /// Initializes a new instance of the <see cref="OneOddSock.IO.BitBinaryWriter"/> class /// with the underlying <paramref name="stream"/> and default encoding (UTF8). /// </summary> public BitBinaryWriter(BitStream stream) : this(stream, Encoding.UTF8) { }
/// <summary> /// Initializes a new instance of the <see cref="OneOddSock.IO.BitBinaryWriter"/> class /// with the underlying <paramref name="stream"/> and <paramref name="encoding"/>. /// </summary> public BitBinaryWriter(BitStream stream, Encoding encoding) : base(stream, encoding) { _stream = stream; }
/// <summary> /// Initializes a new instance of the <see cref="OneOddSock.IO.BitBinaryReader"/> class. /// </summary> public BitBinaryReader(BitStream input) : this(input, Encoding.UTF8) { }
/// <summary> /// Initializes a new instance of the <see cref="OneOddSock.IO.BitBinaryReader"/> class. /// </summary> public BitBinaryReader(BitStream input, Encoding encoding) : base(input, encoding) { _reader = input; }