mirror of
https://github.com/pdf2htmlEX/pdf2htmlEX.git
synced 2024-12-22 13:00:08 +00:00
simplify base64stream
This commit is contained in:
parent
2deef0d6dd
commit
7a9d98b194
@ -7,14 +7,14 @@ using std::ostream;
|
||||
ostream & base64stream::dumpto(ostream & out)
|
||||
{
|
||||
unsigned char buf[3];
|
||||
while(in.read((char*)buf, 3))
|
||||
while(in->read((char*)buf, 3))
|
||||
{
|
||||
out << base64_encoding[(buf[0] & 0xfc)>>2]
|
||||
<< base64_encoding[((buf[0] & 0x03)<<4) | ((buf[1] & 0xf0)>>4)]
|
||||
<< base64_encoding[((buf[1] & 0x0f)<<2) | ((buf[2] & 0xc0)>>6)]
|
||||
<< base64_encoding[(buf[2] & 0x3f)];
|
||||
}
|
||||
auto cnt = in.gcount();
|
||||
auto cnt = in->gcount();
|
||||
if(cnt > 0)
|
||||
{
|
||||
for(int i = cnt; i < 3; ++i)
|
||||
@ -39,7 +39,6 @@ ostream & base64stream::dumpto(ostream & out)
|
||||
|
||||
const char * base64stream::base64_encoding = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
|
||||
|
||||
ostream & operator << (ostream & out, base64stream & bf) { return bf.dumpto(out); }
|
||||
ostream & operator << (ostream & out, base64stream && bf) { return bf.dumpto(out); }
|
||||
ostream & operator << (ostream & out, base64stream bf) { return bf.dumpto(out); }
|
||||
|
||||
} //namespace pdf2htmlEX
|
||||
|
@ -15,17 +15,16 @@ namespace pdf2htmlEX {
|
||||
class base64stream
|
||||
{
|
||||
public:
|
||||
base64stream(std::istream & in) : in(in) { }
|
||||
base64stream(std::istream & in) : in(&in) { }
|
||||
|
||||
std::ostream & dumpto(std::ostream & out);
|
||||
|
||||
private:
|
||||
std::istream & in;
|
||||
std::istream * in;
|
||||
static const char * base64_encoding;
|
||||
};
|
||||
|
||||
std::ostream & operator << (std::ostream & out, base64stream & bf);
|
||||
std::ostream & operator << (std::ostream & out, base64stream && bf);
|
||||
std::ostream & operator << (std::ostream & out, base64stream bf);
|
||||
|
||||
} //namespace pdf2htmlEX
|
||||
#endif //BASE64STREAM_H__
|
||||
|
Loading…
Reference in New Issue
Block a user