Rhino C++ API
8.13
|
#include <opennurbs_base64.h>
Static Public Member Functions | |
static size_t | Decode (const wchar_t *base64_in, void *buffer_out, size_t max_length=UINT_MAX) |
static bool | Encode (const void *buffer_in, size_t num_bytes, ON_wString &base64_out, bool append) |
class ON_CLASS ON_EncodeBase64 { public: ON_EncodeBase64(); virtual ~ON_EncodeBase64();
void Begin();
/ Calling Encode will generate at least / sizeof_buffer/57 and at most (sizeof_buffer+56)/57 / calls to Output(). Every callback to Output() will / have m_output_count = 76. void Encode(const void* buffer, size_t sizeof_buffer);
/ Calling End may generate a single call to Output() / If it does generate a single call to Output(), / then m_output_count will be between 1 and 76. void End(); ///< may generate a single call to Output().
/ With a single exception, when Output() is called, / 57 input bytes have been encoded into 76 output / characters with ASCII codes A-Z, a-z, 0-9, +, /. / m_output_count will be 76 / m_output[0...(m_output_count-1)] will be the base 64 / encoding. / m_output[m_output_count] = 0. / The Output() function can modify the values of m_output[] / and m_output_count anyway it wants. virtual void Output();
/ Total number of bytes passed to Encode(). int m_encode_count;
/ When the virtual Output() is called, there are m_output_count (1 to 76) / characters of base64 encoded output in m_output[]. The remainder of / the m_output[] array is zero. The Output function may modify the / contents of m_output[] any way it sees fit. int m_output_count; char m_output[80];
private: / input waiting to be encoded / At most 56 bytes can be waiting to be processed in m_input[]. unsigned int m_unused2; ///< Here for alignment purposes. Never used by opennurbs. unsigned int m_input_count; unsigned char m_input[64];
void EncodeHelper1(const unsigned char*, char*); void EncodeHelper2(const unsigned char*, char*); void EncodeHelper3(const unsigned char*, char*); void EncodeHelper57(const unsigned char*); };
|
static |
Decode a base64 string. buffer_out must be large enough to accommodate the decoded data. It is safe to use the length of base64_in because this Base64 string will always be about 33% bigger than the data it was created from. Returns the number of bytes written to buffer_out. The function stops when max_length bytes have been decoded. If buffer_out is null, the function simply calculates the exact required buffer size.
|
static |
Encode data to a base64 string. If append is true, the encoded string is appended to base64_out. Otherwise base64_out is replaced with the encoded string. Returns true if ok, false if unable to allocate the output buffer.