/src/qpdf/libqpdf/qpdf/Pl_Base64.hh
Line | Count | Source |
1 | | #ifndef PL_BASE64_HH |
2 | | #define PL_BASE64_HH |
3 | | |
4 | | #include <qpdf/Pipeline.hh> |
5 | | |
6 | | class Pl_Base64 final: public Pipeline |
7 | | { |
8 | | public: |
9 | | enum action_e { a_encode, a_decode }; |
10 | | Pl_Base64(char const* identifier, Pipeline* next, action_e); |
11 | 0 | ~Pl_Base64() final = default; |
12 | | void write(unsigned char const* buf, size_t len) final; |
13 | | void finish() final; |
14 | | |
15 | | static std::string encode(std::string_view data); |
16 | | static std::string decode(std::string_view data); |
17 | | |
18 | | private: |
19 | | void decode_internal(std::string_view data); |
20 | | void encode_internal(std::string_view data); |
21 | | void flush_decode(); |
22 | | void flush_encode(); |
23 | | void reset(); |
24 | | |
25 | | action_e action; |
26 | | unsigned char buf[4]{0, 0, 0, 0}; |
27 | | size_t pos{0}; |
28 | | std::string in_buffer; |
29 | | std::string out_buffer; |
30 | | bool end_of_data{false}; |
31 | | }; |
32 | | |
33 | | #endif // PL_BASE64_HH |