@@ -36,7 +36,7 @@ namespace base64 {
36
36
using tokenizers::Error;
37
37
using tokenizers::Result;
38
38
39
- Result<std::string> decode (const std::string_view& input);
39
+ Result<std::string> decode (const std::string_view & input);
40
40
41
41
namespace detail {
42
42
@@ -68,12 +68,9 @@ inline Error validate(uint32_t v) {
68
68
return Error::Ok;
69
69
}
70
70
71
- inline Error decode (const std::string_view& input, std::string& output) {
72
- TK_CHECK_OR_RETURN_ERROR (
73
- input.size () == 4 ,
74
- Base64DecodeFailure,
75
- " input length must be 4, got %zu" ,
76
- input.size ());
71
+ inline Error decode (const std::string_view &input, std::string &output) {
72
+ TK_CHECK_OR_RETURN_ERROR (input.size () == 4 , Base64DecodeFailure,
73
+ " input length must be 4, got %zu" , input.size ());
77
74
78
75
uint32_t val = 0 ;
79
76
@@ -103,14 +100,10 @@ inline Error decode(const std::string_view& input, std::string& output) {
103
100
return Error::Ok;
104
101
}
105
102
106
- inline Error decode_1_padding (
107
- const std::string_view& input,
108
- std::string& output) {
109
- TK_CHECK_OR_RETURN_ERROR (
110
- input.size () == 3 ,
111
- Base64DecodeFailure,
112
- " input length must be 3, got %zu" ,
113
- input.size ());
103
+ inline Error decode_1_padding (const std::string_view &input,
104
+ std::string &output) {
105
+ TK_CHECK_OR_RETURN_ERROR (input.size () == 3 , Base64DecodeFailure,
106
+ " input length must be 3, got %zu" , input.size ());
114
107
115
108
uint32_t val = 0 ;
116
109
@@ -134,14 +127,10 @@ inline Error decode_1_padding(
134
127
return Error::Ok;
135
128
}
136
129
137
- inline Error decode_2_padding (
138
- const std::string_view& input,
139
- std::string& output) {
140
- TK_CHECK_OR_RETURN_ERROR (
141
- input.size () == 2 ,
142
- Base64DecodeFailure,
143
- " input length must be 2, got %zu" ,
144
- input.size ());
130
+ inline Error decode_2_padding (const std::string_view &input,
131
+ std::string &output) {
132
+ TK_CHECK_OR_RETURN_ERROR (input.size () == 2 , Base64DecodeFailure,
133
+ " input length must be 2, got %zu" , input.size ());
145
134
146
135
uint32_t val = 0 ;
147
136
@@ -161,13 +150,12 @@ inline Error decode_2_padding(
161
150
162
151
} // namespace detail
163
152
164
- inline tokenizers::Result<std::string> decode (const std::string_view& input) {
153
+ inline tokenizers::Result<std::string> decode (const std::string_view & input) {
165
154
TK_CHECK_OR_RETURN_ERROR (!input.empty (), Base64DecodeFailure, " empty input" );
166
155
167
156
// Faster than `input.size() % 4`.
168
157
TK_CHECK_OR_RETURN_ERROR (
169
- (input.size () & 3 ) == 0 && input.size () >= 4 ,
170
- Base64DecodeFailure,
158
+ (input.size () & 3 ) == 0 && input.size () >= 4 , Base64DecodeFailure,
171
159
" input length must be larger than 4 and is multiple of 4, got %zu" ,
172
160
input.size ());
173
161
0 commit comments