HomeForumSourceResearchGuide
Sign in to contribute to source. how it works
Type definition file compress.algorithm.StreamCompression by barry
expand copy to clipboardexpand
/*
 {"description" : "Low-level compression API to compress data using a particular compression algorithm. The compressed data generated by this API does not include any file headers or meta-data, instead producing a raw compressed stream. This data is usually wrapped in a particular file format like zip or gzip."
	}
*/

interface StreamCompression {
	
	/*
	 {"@description" : "Prepare the stream compressor to begin a new compression activity."
		}
	*/
	void compressInit()
	
	/*
	 {"@description" : "Compresses the given chunk of data, returning the compressed version.",
	 	"chunk" : "Raw data chunk to compress.",
		"lastChunk" : "Must be set to true if this is the final chunk of data to be compressed for this stream.",
	 	"@return" : "The compressed data."
		}
	*/
	byte[] compress(byte chunk[], bool lastChunk)
	
	/*
	 {"@description" : "Finish a stream compression activity."
		}
	*/
	void compressEnd()

	/*
	 {"@description" : "Status code returned by decompressStatus() to indicate that the compressed stream continues."}
	*/
const byte DS_CONTINUE = 0x0

	/*
	 {"@description" : "Status code returned by decompressStatus() to indicate that the compressed stream ended somewhere within the most recently issued chunk to decompress()."}
	*/
const byte DS_END = 0x1

	/*
	 {"@description" : "Status code returned by decompressStatus() to indicate that there was a fatal error during decompression and the attempt should be aborted."}
	*/
const byte DS_ERROR = 0x2
	
	/*
	 {"@description" : "Prepare the stream compressor to begin a new decompression activity."
		}
	*/
	void decompressInit()
	
	/*
	 {"@description" : "Decompresses the given chunk of data, returning the decompressed version.",
	 	"chunk" : "Compressed chunk of data to decompress.",
	 	"@return" : "The decompressed data corresponding to this chunk."
		}
	*/
	byte[] decompress(byte chunk[])
	
	/*
	 {"@description" : "Query the status of the current decompression activity.",
	 	"@return" : "This function returns DS_CONTINUE if the stream should continue; DS_END if the end of the compressed data has been reached somewhere within chunk, or DS_ERROR if a fatal error was encountered during decompression."
		}
	*/
	byte decompressStatus()
	
	/*
	 {"@description" : "Finish a stream decompression activity."
		"@return" : "The number of bytes of the final compressed data chunk (pass to decompress()) which were used before the end of the stream was reached. The remaining bytes of the last chunk were not part of this compressed data stream."
		}
	*/
	int decompressEnd()
	}
Revision history
To propose a new revision to this entity, use dana source put -ut your/new/version.dn -n compress.algorithm.StreamCompression -m "reason for update" -u yourUsername
Version 1 (this version) by barry
Notes for this version: Standard Library Initialisation