Kōtuku
  • Gallery
  • API
  • Wiki
  • GitHub
    • Audio
    • Config
    • Core
    • Display
    • Document
    • Font
    • HTTP
    • Network
    • Regex
    • SVG
    • Tiri
    • Vector
    • XML
    • XQuery
    • XRandR
      • Audio
      • MP3
      • Sound
      • File
      • MetaClass
      • Module
      • StorageDevice
      • Task
      • Thread
      • Time
      • Compression
      • CompressedStream
      • Config
      • LZMAStream
      • Script
      • Tiri
      • XML
      • XQuery
      • Controller
      • BlurFX
      • ColourFX
      • CompositeFX
      • ConvolveFX
      • DisplacementFX
      • FilterEffect
      • FloodFX
      • ImageFX
      • LightingFX
      • MergeFX
      • MorphologyFX
      • OffsetFX
      • RemapFX
      • SourceFX
      • TurbulenceFX
      • WaveFunctionFX
      • Scintilla
      • Bitmap
      • Clipboard
      • Display
      • Document
      • Font
      • Image
      • Pointer
      • Surface
      • SVG
      • ClientSocket
      • HTTP
      • NetClient
      • NetLookup
      • NetServer
      • NetSocket
      • Proxy
      • Gradient
      • GradientConic
      • GradientContour
      • GradientDiamond
      • GradientDiffusion
      • GradientDistal
      • GradientGouraud
      • GradientLinear
      • GradientMesh
      • GradientRadial
      • GradientVoronoi
      • Vector
      • VectorClip
      • VectorColour
      • VectorEllipse
      • VectorFilter
      • VectorGradient
      • VectorGroup
      • VectorImage
      • VectorPath
      • VectorPattern
      • VectorPolygon
      • VectorRectangle
      • VectorScene
      • VectorShape
      • VectorSpiral
      • VectorText
      • VectorTransition
      • VectorViewport
      • VectorWave
      • Linux Builds
      • Windows Builds
      • Customising Your Build
      • Kōtuku Objects
      • Kōtuku In Depth
      • Kōtuku Design Patterns
      • Coding With AI
      • Regex Manual
      • XML Comparisons
      • Tiri Reference Manual
      • Config API
      • Defer Syntax
      • GUI API
      • HTTP Server API
      • I/O API
      • JSON API
      • OAuth API
      • Options API
      • Proxy Server API
      • Tempus API
      • URL API
      • VFX API
      • Widgets
      • RIPL Reference Manual
      • Origo
      • Flute / Unit Testing
      • Tuku
      • Embedded Document Format
      • TDL Reference Manual
      • TDL Tools
      • Action Reference Manual
      • System Error Codes

CompressedStream Class

Acts as a proxy for decompressing and compressing data streams between objects.

Use the CompressedStream class to compress and decompress data on the fly without the need for a temporary storage area. The default compression algorithm is DEFLATE with gzip header data. It is compatible with common command-line tools such as gzip.

To decompress data, set the Input field with a source object that supports the Read() action, such as a File. Repeatedly reading from the CompressedStream will automatically handle the decompression process. If the decompressed size of the incoming data is defined in the source header, it will be reflected in the Size field.

To compress data, set the Output field with a source object that supports the Write() action, such as a File. Repeatedly writing to the CompressedStream with raw data will automatically handle the compression process for you. Once all of the data has been written, call the Write() action with a null empty Buffer to finalise the stream. In Tiri, call acWrite(nil).

Structure

The CompressedStream class consists of the following fields:

Access
NameTypeComment
 FormatCFThe format of the compressed stream. The default is GZIP.
NameDescription
CF::DEFLATEThe 'deflate' format
CF::GZIPThe 'gzip' format
CF::ZLIBThe 'zlib' format
 InputOBJECTPTRAn input object that will supply data for decompression.

To create a stream that decompresses data from a compressed source, set the Input field with a reference to an object that will provide the source data. It is most common for the source object to be a File type, however any class that supports the Read() action is permitted.

The source object must be in a readable state. The Input field is mutually exclusive to the Output field.

 OutputOBJECTPTRA target object that will receive data compressed by the stream.

To create a stream that compresses data to a target object, set the Output field with an object reference. It is most common for the target object to be a File type, however any class that supports the Write() action is permitted.

The target object must be in a writeable state. The Output field is mutually exclusive to the Input field.

 SizeINT64The uncompressed size of the input source, if known.

The Size field will reflect the uncompressed size of the input source, if this can be determined from the header. In the case of GZIP decompression, the size will not be known until the parser has consumed the header. This means that at least one call to the Read() action is required before the Size is known.

If the size is unknown, a value of -1 is returned.

 TotalOutputINT64A live counter of total bytes that have been output by the stream.

Actions

The following actions are currently supported:

ReadDecompress data from the input stream and write it to the supplied buffer.
ERR acRead(*Object, std::span<int8_t> Buffer, INT *Result)
ParameterDescription
BufferA mutable buffer that will receive the data.
ResultThe Read action will write this parameter with the total number of bytes read into the Buffer.
ResetReset the state of the stream.
ERR acReset(*Object)

Resetting a CompressedStream returns it to the same state as that when first initialised. Note that this does not affect the state of the object referenced via Input or Output, so it may be necessary for the client to reset referenced objects separately.

SeekFor use in decompressing streams only. Seeks to a position within the stream.
ERR acSeek(*Object, DOUBLE Offset, INT Position)
ParameterDescription
OffsetThe desired offset to seek to, relative to the Position parameter.
PositionThe position that defines the starting point for Offset.
WriteCompress raw data in a buffer and write it to the Output object.
ERR acWrite(*Object, std::span<const int8_t> Buffer, INT *Result)
ParameterDescription
BufferA buffer containing the data that will be written to the object.
ResultThis parameter with be updated with the total number of bytes written from the Buffer.
CompressedStream class documentation © Paul Manias © 1996-2026

CF Type

Compression stream formats

NameDescription
CF::DEFLATEThe 'deflate' format
CF::GZIPThe 'gzip' format
CF::ZLIBThe 'zlib' format
CompressedStream module documentation © Paul Manias © 1996-2026