File Coverage

src/panda/encode/base64.h
Criterion Covered Total %
statement 2 2 100.0
branch n/a
condition n/a
subroutine n/a
pod n/a
total 2 2 100.0


line stmt bran cond sub pod time code
1             #pragma once
2             #include
3             #include
4             #include
5              
6             namespace panda { namespace encode {
7              
8             using std::size_t;
9              
10 8           inline size_t encode_base64_getlen (size_t source_len) { return (source_len + 2) / 3 * 4; }
11 8           inline size_t decode_base64_getlen (size_t source_len) { return source_len * 3 / 4; }
12              
13             size_t encode_base64 (const string_view source, char* dest, bool url_mode = false, bool use_pad = false);
14             size_t decode_base64 (const string_view source, char* dest);
15              
16             inline string encode_base64 (const string_view source, bool url_mode = false, bool use_pad = false) {
17             string ret;
18             char* buf = ret.reserve(encode_base64_getlen(source.length()));
19             auto len = encode_base64(source, buf, url_mode, use_pad);
20             ret.length(len);
21             return ret;
22             }
23              
24             inline string decode_base64 (const string_view source) {
25             string ret;
26             char* buf = ret.reserve(decode_base64_getlen(source.length()));
27             auto len = decode_base64(source, buf);
28             ret.length(len);
29             return ret;
30             }
31              
32             }}