Rhino C++ API  8.13
Public Member Functions | List of all members
ON_Base64EncodeStream Class Reference

#include <opennurbs_base64.h>

Public Member Functions

 ON_Base64EncodeStream ()
 
virtual ~ON_Base64EncodeStream ()
 
bool Begin ()
 
void * CallbackContext () const
 
ON_StreamCallbackFunction CallbackFunction () const
 
bool End ()
 
bool In (ON__UINT64 in_buffer_size, const void *in_buffer)
 
ON__UINT32 InCRC () const
 
ON__UINT64 InSize () const
 
virtual bool Out (void *callback_context, ON__UINT32 out_buffer_size, const char *out_buffer)
 
ON__UINT32 OutCRC () const
 
ON__UINT64 OutSize () const
 
bool SetCallback (ON_StreamCallbackFunction callback_function, void *callback_context)
 

Detailed Description

Copyright (c) 1993-2022 Robert McNeel & Associates. All rights reserved. OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert McNeel & Associates.

THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY. ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF MERCHANTABILITY ARE HEREBY DISCLAIMED.

For complete openNURBS copyright information see http://www.opennurbs.org.

Constructor & Destructor Documentation

◆ ON_Base64EncodeStream()

ON_Base64EncodeStream::ON_Base64EncodeStream ( )

◆ ~ON_Base64EncodeStream()

virtual ON_Base64EncodeStream::~ON_Base64EncodeStream ( )
virtual

Member Function Documentation

◆ Begin()

bool ON_Base64EncodeStream::Begin ( )

Description: Call Begin() one time to initialize the base64 encoding calculation. Then call In() one or more times to submit the unencoded stream to the base64 encoding calculation. When you reach the end of the unencoded stream, call End(). Returns: true if successful, false if an error occurred.

◆ CallbackContext()

void* ON_Base64EncodeStream::CallbackContext ( ) const

Returns: Current value of the context pointer passed as the first argument to the base64 encoded stream output handler function.

◆ CallbackFunction()

ON_StreamCallbackFunction ON_Base64EncodeStream::CallbackFunction ( ) const

Returns: Current value of the callback function for handling the base64 encoded stream. If the callback function is null, the the virtual Out() function is used to handle the output stream.

◆ End()

bool ON_Base64EncodeStream::End ( )

Description: After the last call to In(), call End(). Calling End() may generate one call to the output stream handler with the value of out_buffer_size = 4 to 76. Returns: true if successful, false if an error occurred.

◆ In()

bool ON_Base64EncodeStream::In ( ON__UINT64  in_buffer_size,
const void *  in_buffer 
)

Description: Call In() one or more times to base64 encode a stream of bytes. After the last call to In(), call End(). Calling In() will result in at least in_buffer_size/57 and at most (in_buffer_size+56)/57 calls to 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 occurred.

◆ InCRC()

ON__UINT32 ON_Base64EncodeStream::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 base64 encoding 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_Base64EncodeStream::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_Base64EncodeStream::Out ( void *  callback_context,
ON__UINT32  out_buffer_size,
const char *  out_buffer 
)
virtual

Description: If an explicit base 64 encoded stream output handler is not specified ( CallbackFunction() returns null ), then the virtual Out() function is called to handle the base 64 encoded output stream. As the input stream is encoded, one or more calls to Out() will occur.

With a possible exception of the last call to Out(), when Out() is called, 57 input bytes have been encoded into 76 output characters with ASCII codes A-Z, a-z, 0-9, +, /. Parameters: callback_context - [in] context pointer set by calling SetCallback(). Typically the context pointer is not used by a virtual override because the context can be added as member variables of the derived class, but it is available if needed. out_buffer_size - [in] number of non-null characters in out_buffer. out_buffer - [in] A null terminated ASCII string that is a base 64 encoding. out_buffer[0...(out_buffer_size-1)] are ASCII characters with values characters with ASCII codes A-Z, a-z, 0-9, +, / and out_buffer[out_buffer_size] = 0.
Returns: True to continue base 64 encodeing and false to cancel the encoding calculation.

◆ OutCRC()

ON__UINT32 ON_Base64EncodeStream::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_Base64EncodeStream::OutSize ( ) const

Returns: Then the returned value is the total number characters in the output stream. The size is incremented immediately after each call to the output stream handler. If the base64 encoding 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_Base64EncodeStream::SetCallback ( ON_StreamCallbackFunction  callback_function,
void *  callback_context 
)

Description: ON_Base64EncodeStream delivers the base64 encoded stream by calling a base64 encoded stream output handler function. There are two options for specifying the base64 encoded stream output handler function.

  1. Overriding the virtual Out() function.
  2. Providing a callback function. SetCallback() is used to specify a callback function to handle the base64 encoded stream and to specify a context pointer to be passed to either option of the handler. Parameters: callback_function - [in] Function to handle sections of the base64 encoded 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 base64 encoding calculation should continue and false to cancel the base64 encoding calculation. callback_context - [in] This value is passed as the first argument when calling callback_function or the virtual Out() function. Returns: True if successful. Remarks: Once base64 encoding has started, it would be unusual to intentionally change the base64 encoded stream output handler, but you can do this if you need to.