Added initializer

This commit is contained in:
Robert Osfield 2016-06-22 12:03:10 +01:00
parent f2704e0bf3
commit 1d7f75c490
2 changed files with 18 additions and 13 deletions

View File

@ -46,6 +46,14 @@ namespace osgDB
int stepcount;
} base64_encodestate;
inline void base64_init_encodestate(base64_encodestate* state_in)
{
state_in->step = step_A;
state_in->result = 0;
state_in->stepcount = 0;
}
typedef struct
{
base64_decodestep step;
@ -61,9 +69,11 @@ namespace osgDB
class OSGDB_EXPORT Base64encoder
{
public:
Base64encoder(int buffersize_in = BUFFERSIZE)
: _buffersize(buffersize_in)
{}
Base64encoder(int buffersize_in = BUFFERSIZE):
_buffersize(buffersize_in)
{
base64_init_encodestate(&_state);
}
int encode(char value_in);
@ -83,9 +93,11 @@ namespace osgDB
class OSGDB_EXPORT Base64decoder
{
public:
Base64decoder(int buffersize_in = BUFFERSIZE)
: _buffersize(buffersize_in)
{}
Base64decoder(int buffersize_in = BUFFERSIZE):
_buffersize(buffersize_in)
{
base64_init_decodestate(&_state);
}
int decode(char value_in);

View File

@ -99,13 +99,6 @@ namespace osgDB
return plainchar - plaintext_out;
}
void base64_init_encodestate(base64_encodestate* state_in)
{
state_in->step = step_A;
state_in->result = 0;
state_in->stepcount = 0;
}
char base64_encode_value(char value_in)
{
static const char* encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";