Flutter Engine
fml::BitConverter< from_length, to_length, buffer_length > Class Template Reference

#include <base32.h>

Public Member Functions

void Append (int bits)
 
int Extract ()
 
int Peek () const
 
int BitsAvailable () const
 
bool CanAppend () const
 
bool CanExtract () const
 

Detailed Description

template<int from_length, int to_length, int buffer_length>
class fml::BitConverter< from_length, to_length, buffer_length >

Definition at line 16 of file base32.h.

Member Function Documentation

◆ Append()

template<int from_length, int to_length, int buffer_length>
void fml::BitConverter< from_length, to_length, buffer_length >::Append ( int  bits)
inline

Definition at line 18 of file base32.h.

References fml::BitConverter< from_length, to_length, buffer_length >::CanAppend(), and FML_DCHECK.

Referenced by fml::Base32Decode(), and fml::Base32Encode().

18  {
19  FML_DCHECK(bits < (1 << from_length));
21  lower_free_bits_ -= from_length;
22  buffer_ |= (bits << lower_free_bits_);
23  }
#define FML_DCHECK(condition)
Definition: logging.h:86
bool CanAppend() const
Definition: base32.h:35

◆ BitsAvailable()

template<int from_length, int to_length, int buffer_length>
int fml::BitConverter< from_length, to_length, buffer_length >::BitsAvailable ( ) const
inline

Definition at line 34 of file base32.h.

Referenced by fml::Base32Encode(), and fml::BitConverter< from_length, to_length, buffer_length >::CanExtract().

34 { return buffer_length - lower_free_bits_; }

◆ CanAppend()

template<int from_length, int to_length, int buffer_length>
bool fml::BitConverter< from_length, to_length, buffer_length >::CanAppend ( ) const
inline

Definition at line 35 of file base32.h.

Referenced by fml::BitConverter< from_length, to_length, buffer_length >::Append(), and fml::Base32Encode().

35 { return lower_free_bits_ >= from_length; }

◆ CanExtract()

template<int from_length, int to_length, int buffer_length>
bool fml::BitConverter< from_length, to_length, buffer_length >::CanExtract ( ) const
inline

◆ Extract()

template<int from_length, int to_length, int buffer_length>
int fml::BitConverter< from_length, to_length, buffer_length >::Extract ( )
inline

Definition at line 25 of file base32.h.

References fml::BitConverter< from_length, to_length, buffer_length >::CanExtract(), FML_DCHECK, and fml::BitConverter< from_length, to_length, buffer_length >::Peek().

Referenced by fml::Base32Decode(), and fml::Base32Encode().

25  {
27  int result = Peek();
28  buffer_ = (buffer_ << to_length) & mask_;
29  lower_free_bits_ += to_length;
30  return result;
31  }
bool CanExtract() const
Definition: base32.h:36
#define FML_DCHECK(condition)
Definition: logging.h:86
int Peek() const
Definition: base32.h:33

◆ Peek()

template<int from_length, int to_length, int buffer_length>
int fml::BitConverter< from_length, to_length, buffer_length >::Peek ( ) const
inline

Definition at line 33 of file base32.h.

Referenced by fml::Base32Decode(), fml::Base32Encode(), and fml::BitConverter< from_length, to_length, buffer_length >::Extract().

33 { return (buffer_ >> (buffer_length - to_length)); }

The documentation for this class was generated from the following file: