Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    LZ4Stream Class

    Namespace: Stride.Core.LZ4
    Assembly: Stride.Core.Serialization.dll

    Block compression stream. Allows to use LZ4 for stream compression.

    System.Object → System.MarshalByRefObject → System.IO.Stream → NativeStream → LZ4Stream
    Derived from LZ4Stream:

    public class LZ4Stream : NativeStream, IDisposable
    Name Description
    Constructors
    LZ4Stream(Stream, CompressionMode, Boolean, Int64, Int64, Boolean, Int32)

    Initializes a new instance of the LZ4Stream class.

    Properties
    CanRead

    When overridden in a derived class, gets a value indicating whether the current stream supports reading.

    CanSeek

    When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

    CanWrite

    When overridden in a derived class, gets a value indicating whether the current stream supports writing.

    Length

    When overridden in a derived class, gets the length in bytes of the stream.

    Position

    The position in the uncompressed stream.

    Methods
    Dispose(Boolean)

    Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

    Flush()

    When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

    Read(Byte[], Int32, Int32)

    When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

    Read(IntPtr, Int32)

    Reads a block of bytes from the stream and writes the data in a given buffer.

    ReadByte()

    Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

    Reset()

    Reset the stream to its initial position and state

    Seek(Int64, SeekOrigin)

    When overridden in a derived class, sets the position within the current stream.

    SetLength(Int64)

    When overridden in a derived class, sets the length of the current stream.

    Write(Byte[], Int32, Int32)

    When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

    Write(IntPtr, Int32)

    Writes a block of bytes to this stream using data from a buffer.

    WriteByte(Byte)

    Writes a byte to the current position in the stream and advances the position within the stream by one byte.

    | Improve this Doc View Source

    Constructors


    LZ4Stream(Stream, CompressionMode, Boolean, Int64, Int64, Boolean, Int32)

    Initializes a new instance of the LZ4Stream class.

    public LZ4Stream(Stream innerStream, CompressionMode compressionMode, bool highCompression = false, long uncompressedSize = -1L, long compressedSize = -1L, bool disposeInnerStream = false, int blockSize = 1048576)
    Parameters
    Type Name Description
    System.IO.Stream innerStream

    The inner stream.

    System.IO.Compression.CompressionMode compressionMode

    The compression mode.

    System.Boolean highCompression

    if set to true [high compression].

    System.Int64 uncompressedSize

    The size of the stream uncompressed

    System.Int64 compressedSize
    System.Boolean disposeInnerStream

    if set to true innerStream is disposed during called to Dispose(Boolean)

    System.Int32 blockSize

    Size of the block.

    | Improve this Doc View Source

    Properties


    CanRead

    When overridden in a derived class, gets a value indicating whether the current stream supports reading.

    public override bool CanRead { get; }
    Property Value
    Type Description
    System.Boolean

    true if the stream supports reading; otherwise, false.

    Overrides
    System.IO.Stream.CanRead

    CanSeek

    When overridden in a derived class, gets a value indicating whether the current stream supports seeking.

    public override bool CanSeek { get; }
    Property Value
    Type Description
    System.Boolean

    true if the stream supports seeking; otherwise, false.

    Overrides
    System.IO.Stream.CanSeek

    CanWrite

    When overridden in a derived class, gets a value indicating whether the current stream supports writing.

    public override bool CanWrite { get; }
    Property Value
    Type Description
    System.Boolean

    true if the stream supports writing; otherwise, false.

    Overrides
    System.IO.Stream.CanWrite

    Length

    When overridden in a derived class, gets the length in bytes of the stream.

    public override long Length { get; }
    Property Value
    Type Description
    System.Int64

    A long value representing the length of the stream in bytes.

    Overrides
    System.IO.Stream.Length

    Position

    The position in the uncompressed stream.

    public override long Position { get; set; }
    Property Value
    Type Description
    System.Int64

    The current position within the stream.

    Overrides
    System.IO.Stream.Position
    | Improve this Doc View Source

    Methods


    Dispose(Boolean)

    Releases the unmanaged resources used by the System.IO.Stream and optionally releases the managed resources.

    protected override void Dispose(bool disposing)
    Parameters
    Type Name Description
    System.Boolean disposing

    true to release both managed and unmanaged resources; false to release only unmanaged resources.

    Overrides
    System.IO.Stream.Dispose(System.Boolean)

    Flush()

    When overridden in a derived class, clears all buffers for this stream and causes any buffered data to be written to the underlying device.

    public override void Flush()
    Overrides
    System.IO.Stream.Flush()

    Read(Byte[], Int32, Int32)

    When overridden in a derived class, reads a sequence of bytes from the current stream and advances the position within the stream by the number of bytes read.

    public override int Read(byte[] buffer, int offset, int count)
    Parameters
    Type Name Description
    System.Byte[] buffer

    An array of bytes. When this method returns, the buffer contains the specified byte array with the values between offset and (offset + count - 1) replaced by the bytes read from the current source.

    System.Int32 offset

    The zero-based byte offset in buffer at which to begin storing the data read from the current stream.

    System.Int32 count

    The maximum number of bytes to be read from the current stream.

    Returns
    Type Description
    System.Int32

    The total number of bytes read into the buffer. This can be less than the number of bytes requested if that many bytes are not currently available, or zero (0) if the end of the stream has been reached.

    Overrides
    System.IO.Stream.Read(System.Byte[], System.Int32, System.Int32)

    Read(IntPtr, Int32)

    Reads a block of bytes from the stream and writes the data in a given buffer.

    public override int Read(IntPtr buffer, int count)
    Parameters
    Type Name Description
    System.IntPtr buffer

    When this method returns, contains the specified buffer with the values between 0 and (count - 1) replaced by the bytes read from the current source.

    System.Int32 count

    The maximum number of bytes to read.

    Returns
    Type Description
    System.Int32

    The total number of bytes read into the buffer. This might be less than the number of bytes requested if that number of bytes are not currently available, or zero if the end of the stream is reached.

    Overrides
    NativeStream.Read(IntPtr, Int32)
    Exceptions
    Type Condition
    System.ArgumentNullException

    array is null.


    ReadByte()

    Reads a byte from the stream and advances the position within the stream by one byte, or returns -1 if at the end of the stream.

    public override int ReadByte()
    Returns
    Type Description
    System.Int32

    The unsigned byte cast to an Int32, or -1 if at the end of the stream.

    Overrides
    System.IO.Stream.ReadByte()

    Reset()

    Reset the stream to its initial position and state

    public void Reset()

    Seek(Int64, SeekOrigin)

    When overridden in a derived class, sets the position within the current stream.

    public override long Seek(long offset, SeekOrigin origin)
    Parameters
    Type Name Description
    System.Int64 offset

    A byte offset relative to the origin parameter.

    System.IO.SeekOrigin origin

    A value of type System.IO.SeekOrigin indicating the reference point used to obtain the new position.

    Returns
    Type Description
    System.Int64

    The new position within the current stream.

    Overrides
    System.IO.Stream.Seek(System.Int64, System.IO.SeekOrigin)

    SetLength(Int64)

    When overridden in a derived class, sets the length of the current stream.

    public override void SetLength(long value)
    Parameters
    Type Name Description
    System.Int64 value

    The desired length of the current stream in bytes.

    Overrides
    System.IO.Stream.SetLength(System.Int64)

    Write(Byte[], Int32, Int32)

    When overridden in a derived class, writes a sequence of bytes to the current stream and advances the current position within this stream by the number of bytes written.

    public override void Write(byte[] buffer, int offset, int count)
    Parameters
    Type Name Description
    System.Byte[] buffer

    An array of bytes. This method copies count bytes from buffer to the current stream.

    System.Int32 offset

    The zero-based byte offset in buffer at which to begin copying bytes to the current stream.

    System.Int32 count

    The number of bytes to be written to the current stream.

    Overrides
    System.IO.Stream.Write(System.Byte[], System.Int32, System.Int32)

    Write(IntPtr, Int32)

    Writes a block of bytes to this stream using data from a buffer.

    public override void Write(IntPtr buffer, int count)
    Parameters
    Type Name Description
    System.IntPtr buffer

    The buffer containing data to write to the stream.

    System.Int32 count

    The number of bytes to be written to the current stream.

    Overrides
    NativeStream.Write(IntPtr, Int32)

    WriteByte(Byte)

    Writes a byte to the current position in the stream and advances the position within the stream by one byte.

    public override void WriteByte(byte value)
    Parameters
    Type Name Description
    System.Byte value

    The byte to write to the stream.

    Overrides
    System.IO.Stream.WriteByte(System.Byte)

    Inherited Members

    NativeStream.NativeStreamBufferSize
    NativeStream.nativeStreamBuffer
    NativeStream.ReadUInt16()
    NativeStream.ReadUInt32()
    NativeStream.ReadUInt64()
    NativeStream.Write(UInt16)
    NativeStream.Write(UInt32)
    NativeStream.Write(UInt64)
    System.IO.Stream.Null
    System.IO.Stream.BeginRead(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
    System.IO.Stream.BeginWrite(System.Byte[], System.Int32, System.Int32, System.AsyncCallback, System.Object)
    System.IO.Stream.Close()
    System.IO.Stream.CopyTo(System.IO.Stream)
    System.IO.Stream.CopyTo(System.IO.Stream, System.Int32)
    System.IO.Stream.CopyToAsync(System.IO.Stream)
    System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32)
    System.IO.Stream.CopyToAsync(System.IO.Stream, System.Int32, System.Threading.CancellationToken)
    System.IO.Stream.CreateWaitHandle()
    System.IO.Stream.Dispose()
    System.IO.Stream.EndRead(System.IAsyncResult)
    System.IO.Stream.EndWrite(System.IAsyncResult)
    System.IO.Stream.FlushAsync()
    System.IO.Stream.FlushAsync(System.Threading.CancellationToken)
    System.IO.Stream.ObjectInvariant()
    System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32)
    System.IO.Stream.ReadAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
    System.IO.Stream.Synchronized(System.IO.Stream)
    System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32)
    System.IO.Stream.WriteAsync(System.Byte[], System.Int32, System.Int32, System.Threading.CancellationToken)
    System.IO.Stream.CanTimeout
    System.IO.Stream.ReadTimeout
    System.IO.Stream.WriteTimeout
    System.MarshalByRefObject.GetLifetimeService()
    System.MarshalByRefObject.InitializeLifetimeService()
    System.MarshalByRefObject.MemberwiseClone(System.Boolean)

    Extension Methods

    SocketExtensions.ReadAllAsync(Stream, Byte[], Int32, Int32)
    SocketExtensions.WriteInt32Async(Stream, Int32)
    SocketExtensions.ReadInt32Async(Stream)
    SocketExtensions.WriteInt16Async(Stream, Int16)
    SocketExtensions.ReadInt16Async(Stream)
    SocketExtensions.Write7BitEncodedInt(Stream, Int32)
    SocketExtensions.Read7BitEncodedInt(Stream)
    SocketExtensions.WriteStringAsync(Stream, String)
    SocketExtensions.ReadStringAsync(Stream)
    SocketExtensions.WriteGuidAsync(Stream, Guid)
    SocketExtensions.ReadGuidAsync(Stream)
    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    NativeStreamExtensions.ToNativeStream(Stream)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation