5#ifndef FLUTTER_FML_BASE32_H_
6#define FLUTTER_FML_BASE32_H_
11#include "flutter/fml/logging.h"
15template <
int from_length,
int to_length,
int buffer_length>
21 lower_free_bits_ -= from_length;
22 buffer_ |= (
bits << lower_free_bits_);
28 buffer_ = (buffer_ << to_length) & kMask;
29 lower_free_bits_ += to_length;
33 int Peek()
const {
return (buffer_ >> (buffer_length - to_length)); }
35 bool CanAppend()
const {
return lower_free_bits_ >= from_length; }
39 static_assert(buffer_length >= 2 * from_length);
40 static_assert(buffer_length >= 2 * to_length);
41 static_assert(buffer_length <
sizeof(
int) * 8);
43 static constexpr int kMask = (1 << buffer_length) - 1;
46 int lower_free_bits_ = buffer_length;
52std::pair<bool, std::string>
Base32Encode(std::string_view input);
53std::pair<bool, std::string>
Base32Decode(
const std::string& input);
int BitsAvailable() const
#define FML_DCHECK(condition)
std::pair< bool, std::string > Base32Decode(const std::string &input)
std::pair< bool, std::string > Base32Encode(std::string_view input)