1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
#include "qpbufbase.ih"
#include <iostream>
// returns true if the buffer must be flushed, otherwise return false
//
bool QPBufBase::decode()
{
// read d_in character by character
// if the character != '=' then store the character in the buffer
// otherwise if the next char is \n then store \n, otherwise
// convert the character from the next two hex-value representing
// characters, otherwise (at EOF) return false.
while (true)
{
int b0 = d_in.get(); // get a character
if (b0 == '=') // found a '=' char
{
b0 = d_in.get(); // get the next char
if (b0 == '\n') // =\n means soft line break
continue; // and so not a real \n
int b1 = d_in.get(); // get 2nd of 2 hex chars
// convert to real char
b0 = (s_hexChars.find(b0) << 4) + s_hexChars.find(b1);
}
if (!d_in)
return false;
d_buffer.push_back(b0);
if (d_buffer.size() > 100) // flush if the buffer is full
return true;
}
}
|