Public Types | Public Member Functions | Static Private Member Functions | Private Attributes | Static Private Attributes | List of all members
cet::crc32 Class Reference

#include <crc32.h>

Public Types

using uchar = unsigned char
 
using digest_t = std::uint32_t
 

Public Member Functions

constexpr crc32 ()=default
 
constexpr crc32 (char const *mesg)
 
constexpr crc32 (char const mesg)
 
 crc32 (std::string const &mesg)
 
constexpr crc32operator<< (char const *mesg)
 
constexpr crc32operator<< (char const mesg)
 
crc32operator<< (std::string const &mesg)
 
constexpr digest_t digest () const
 

Static Private Member Functions

static constexpr std::uint32_t crc32_xorot ()
 

Private Attributes

digest_t context {0xFFFFFFFFL}
 

Static Private Attributes

static constexpr std::uint32_t crctable [256]
 

Detailed Description

Definition at line 19 of file crc32.h.

Member Typedef Documentation

using cet::crc32::digest_t = std::uint32_t

Definition at line 22 of file crc32.h.

using cet::crc32::uchar = unsigned char

Definition at line 21 of file crc32.h.

Constructor & Destructor Documentation

constexpr cet::crc32::crc32 ( )
default
constexpr cet::crc32::crc32 ( char const *  mesg)
explicit

Definition at line 107 of file crc32.h.

108 {
109  operator<<(mesg);
110 }
constexpr crc32 & operator<<(char const *mesg)
Definition: crc32.h:119
constexpr cet::crc32::crc32 ( char const  mesg)
explicit

Definition at line 112 of file crc32.h.

113 {
114  operator<<(mesg);
115 }
constexpr crc32 & operator<<(char const *mesg)
Definition: crc32.h:119
crc32::crc32 ( std::string const &  mesg)
explicit

Definition at line 50 of file crc32.cc.

51 {
52  operator<<(mesg);
53 }
constexpr crc32 & operator<<(char const *mesg)
Definition: crc32.h:119

Member Function Documentation

static constexpr std::uint32_t cet::crc32::crc32_xorot ( )
inlinestaticprivate

Definition at line 43 of file crc32.h.

44  {
45  return 0xFFFFFFFFL;
46  }
constexpr cet::crc32::digest_t cet::crc32::digest ( ) const

Definition at line 138 of file crc32.h.

139 {
140  return context ^ crc32_xorot();
141 }
static constexpr std::uint32_t crc32_xorot()
Definition: crc32.h:43
digest_t context
Definition: crc32.h:39
constexpr cet::crc32 & cet::crc32::operator<< ( char const *  mesg)

Definition at line 119 of file crc32.h.

120 {
121  unsigned i{};
122  while (mesg[i] != '\0') {
123  operator<<(mesg[i]);
124  ++i;
125  }
126  return *this;
127 }
constexpr crc32 & operator<<(char const *mesg)
Definition: crc32.h:119
constexpr cet::crc32 & cet::crc32::operator<< ( char const  mesg)

Definition at line 130 of file crc32.h.

131 {
132  uchar const ch = mesg;
133  context = crctable[(context ^ ch) & 0xFFL] ^ (context >> 8);
134  return *this;
135 }
unsigned char uchar
Definition: nybbler.cc:11
static constexpr std::uint32_t crctable[256]
Definition: crc32.h:47
digest_t context
Definition: crc32.h:39
crc32 & crc32::operator<< ( std::string const &  mesg)

Definition at line 56 of file crc32.cc.

57 {
58  for (uchar const ch : mesg) {
59  context = crctable[(context ^ ch) & 0xFFL] ^ (context >> 8);
60  }
61  return *this;
62 }
unsigned char uchar
Definition: nybbler.cc:11
static constexpr std::uint32_t crctable[256]
Definition: crc32.h:47
digest_t context
Definition: crc32.h:39

Member Data Documentation

digest_t cet::crc32::context {0xFFFFFFFFL}
private

Definition at line 39 of file crc32.h.

constexpr std::uint32_t cet::crc32::crctable
staticprivate

Definition at line 47 of file crc32.h.


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