#include <opennurbs_compress.h>
|
| ON_CompressStream () |
|
virtual | ~ON_CompressStream () |
|
bool | Begin () |
| Call Begin() one time to initialize the compression calculation. Then call In() one or more times to submit the uncompressed stream to the compression calculation. When you reach the end of the uncompressed stream, call End(). More...
|
|
void * | CallbackContext () const |
|
ON_StreamCallbackFunction | CallbackFunction () const |
|
bool | End () |
| After the last call to In(), call End(). Calling End() may generate zero or more calls to the output stream handler. More...
|
|
bool | In (ON__UINT64 in_buffer_size, const void *in_buffer) |
| Call In() one or more times to compress a stream of uncompressed bytes. After the last call to In(), call End(). Calling In() may generate zero or more calls to the output stream handler. More...
|
|
ON__UINT32 | InCRC () const |
|
ON__UINT64 | InSize () const |
|
virtual bool | Out (void *callback_context, ON__UINT32 out_buffer_size, const void *out_buffer) |
| If an explicit compressed stream output handler is not specified ( CallbackFunction() returns null ), then the virtual Out() function is called to handle the compressed output stream. As the input stream is compressed, one or more calls to Out() will occur. More...
|
|
ON__UINT32 | OutCRC () const |
|
ON__UINT64 | OutSize () const |
|
bool | SetCallback (ON_StreamCallbackFunction callback_function, void *callback_context) |
| ON_CompressStream delivers the compressed stream by calling a compressed stream output handler function. There are two options for specifying the compressed stream output handler function. More...
|
|
◆ ON_CompressStream()
ON_CompressStream::ON_CompressStream |
( |
| ) |
|
◆ ~ON_CompressStream()
virtual ON_CompressStream::~ON_CompressStream |
( |
| ) |
|
|
virtual |
◆ Begin()
bool ON_CompressStream::Begin |
( |
| ) |
|
Call Begin() one time to initialize the compression calculation. Then call In() one or more times to submit the uncompressed stream to the compression calculation. When you reach the end of the uncompressed stream, call End().
- Returns
- true if successful, false if an error occured.
◆ CallbackContext()
void* ON_CompressStream::CallbackContext |
( |
| ) |
const |
- Returns
- Current value of the context pointer passed as the first argument to the compressed stream output handler function.
◆ CallbackFunction()
ON_StreamCallbackFunction ON_CompressStream::CallbackFunction |
( |
| ) |
const |
- Returns
- Current value of the callback function for handling the compressed stream. If the callback function is null, the the virtual Out() function is used to handle
◆ End()
bool ON_CompressStream::End |
( |
| ) |
|
After the last call to In(), call End(). Calling End() may generate zero or more calls to the output stream handler.
- Returns
- true if successful, false if an error occured.
◆ In()
bool ON_CompressStream::In |
( |
ON__UINT64 |
in_buffer_size, |
|
|
const void * |
in_buffer |
|
) |
| |
Call In() one or more times to compress a stream of uncompressed bytes. After the last call to In(), call End(). Calling In() may generate zero or more calls to the output stream handler.
- Parameters
-
in_buffer_size | [in] number of bytes in in_buffer |
in_buffer | [in] |
- Returns
- true if successful, false if an error occured.
◆ InCRC()
ON__UINT32 ON_CompressStream::InCRC |
( |
| ) |
const |
- Returns
- Then the returned value is the 32-bit crc of the input stream. The crc is updated every time In() is called before any calls are made to the output stream handler. If the compression calculation is finished ( End() has been called ), then the returned value is the 32-bit crc of the entire input stream.
◆ InSize()
ON__UINT64 ON_CompressStream::InSize |
( |
| ) |
const |
- Returns
- Then the returned value is the total number bytes in the input stream. The size is updated every time In() is called before any calls are made to the output stream handler. If the calculation is finished ( End() has been called ), then the returned value is the total number of bytes in the entire input stream.
◆ Out()
virtual bool ON_CompressStream::Out |
( |
void * |
callback_context, |
|
|
ON__UINT32 |
out_buffer_size, |
|
|
const void * |
out_buffer |
|
) |
| |
|
virtual |
If an explicit compressed stream output handler is not specified ( CallbackFunction() returns null ), then the virtual Out() function is called to handle the compressed output stream. As the input stream is compressed, one or more calls to Out() will occur.
- Returns
- True to continue compressing and false to cancel the compression calculation.
In general, it is probably going to be easier to test and debug your code if you ignore the callback_context parameter and add a member variable to your derived class to make additional information accessable to your Out function.
◆ OutCRC()
ON__UINT32 ON_CompressStream::OutCRC |
( |
| ) |
const |
- Returns
- Then the returned value is the 32bit crc of the output stream. The crc is updated immediately after each call to the output stream handler. If the calculation is finished ( End() has been called ), then the returned value is the 32-bit crc of the entire output stream.
◆ OutSize()
ON__UINT64 ON_CompressStream::OutSize |
( |
| ) |
const |
- Returns
- Then the returned value is the total number bytes in the output stream. The size is incremented immediately after each call to the output stream handler. If the compression calculation is finished ( End() has been called ), then the returned value is the total number of bytes in the entire output stream.
◆ SetCallback()
bool ON_CompressStream::SetCallback |
( |
ON_StreamCallbackFunction |
callback_function, |
|
|
void * |
callback_context |
|
) |
| |
ON_CompressStream delivers the compressed stream by calling a compressed stream output handler function. There are two options for specifying the compressed stream output handler function.
- Overriding the virtual Out() function.
- Providing a callback function. SetCallback() is used to specify a callback function to handle the compressed stream and to specify a context pointer to be passed to either option of the handler.
- Parameters
-
callback_function | [in] Function to call with sections of the compressed stream. If callback_function is null, then the virtual Out() function will be called. When callback_function is specified, it must return true if the compression calculation should continue and false to cancel the compression calculation. |
callback_context | [in] This value is passed as the first argument when calling callback_function or the virutal Out() function. |
- Returns
- True if successful.
Once compression has started, it would be unusual to intentionally change the compressed stream output handler, but you can do this if you need to.