libUTL++
CRC32.h
1 #pragma once
2 
4 
5 #include <libutl/Object.h>
6 
8 
9 UTL_NS_BEGIN;
10 
12 
23 
25 class CRC32 : public Object
26 {
28 
29 public:
30  virtual int compare(const Object& rhs) const;
31 
32  virtual void copy(const Object& rhs);
33 
34  virtual void serialize(Stream& stream, uint_t io, uint_t mode = ser_default);
35 
36  virtual String toString() const;
37 
39  void add(byte_t ch);
40 
42  void
44  {
45  _crc = uint32_t_max;
46  }
47 
49  uint_t
50  get() const
51  {
52  return ~_crc;
53  }
54 
55 private:
56  void
57  init()
58  {
59  clear();
60  }
61  void
62  deInit()
63  {
64  }
65 
66 private:
67  uint32_t _crc;
68  static const uint32_t table[256];
69 };
70 
72 
73 UTL_NS_END;
String toString(const FwdIt &begin, const FwdIt &end, const String &sep, bool key=false)
Obtain a string representation of a sequence (via Object::toString()).
void serialize(bool &b, Stream &stream, uint_t io, uint_t mode=ser_default)
Serialize a boolean.
void deInit()
De-initialize UTL++.
default representation (via getSerializeMode())
Definition: util.h:75
#define UTL_CLASS_DECL(DC, BC)
Declaration of standard UTL++ functionality for a non-template class.
Definition: macros.h:688
unsigned char byte_t
Unsigned character.
Definition: types.h:31
const uint32_t uint32_t_max
Maximum uint32_t value.
Character string.
Definition: String.h:31
unsigned int uint32_t
Unsigned 32-bit integer.
Definition: types.h:115
void copy(T *dest, const T *src, size_t len)
Copy one array of objects to another.
Definition: util_inl.h:690
void clear()
Clear/reset the CRC-32 code.
Definition: CRC32.h:43
unsigned int uint_t
Unsigned integer.
Definition: types.h:59
Stream I/O abstraction.
Definition: Stream.h:68
Generate CRC-32 checksums.
Definition: CRC32.h:25
Root of UTL++ class hierarchy.
Definition: Object.h:52
int compare(bool lhs, bool rhs)
Compare two boolean values.
void init()
Initialize UTL++.