JASSv2
checksum.h
Go to the documentation of this file.
1 /*
2  CHECKSUM.H
3  ----------
4  Copyright (c) 2016 Andrew Trotman
5  Released under the 2-clause BSD license (See:https://en.wikipedia.org/wiki/BSD_licenses)
6 */
13 #pragma once
14 
15 #include <stdint.h>
16 
17 #include <string>
18 
19 namespace JASS
20  {
21  /*
22  CLASS CHECKSUM
23  --------------
24  */
28  class checksum
29  {
30  public:
31  /*
32  CHECKSUM::FLETCHER_16()
33  -----------------------
34  */
45  template <typename TYPE>
46  static uint16_t fletcher_16(TYPE &start, TYPE &end);
47 
48 
49  /*
50  CHECKSUM::FLETCHER_16()
51  -----------------------
52  */
59  static uint16_t fletcher_16(const void *data, size_t length);
60 
61  /*
62  CHECKSUM::FLETCHER_16()
63  -----------------------
64  */
70  static uint16_t fletcher_16(const std::string &string)
71  {
72  return fletcher_16(string.c_str(), string.length());
73  }
74 
75  /*
76  CHECKSUM::FLETCHER_16()
77  -----------------------
78  */
84  static uint16_t fletcher_16(std::istream &stream);
85 
86  /*
87  CHECKSUM::FLETCHER_16_FILE()
88  ----------------------------
89  */
95  static uint16_t fletcher_16_file(const std::string &filename);
96 
97  /*
98  CHECKSUM::UNITTEST()
99  --------------------
100  */
104  static void unittest(void);
105  };
106 
107  }
static void unittest(void)
Unit test this class. Checksums can be verified against:http://www.nitrxgen.net/hashgen/.
Definition: checksum.cpp:104
static uint16_t fletcher_16(const std::string &string)
Compute the Fletcher 16-bit checksum of a string (see the template verison details)..
Definition: checksum.h:70
Holder class for checksums, Cyclic Redundency Checks, and so on.
Definition: checksum.h:28
static uint16_t fletcher_16(TYPE &start, TYPE &end)
Compute the Fletcher 16-bit checksum of 8-bit data. Unlike a "regular" 8-bit checsum, this manages position as well as content.
Definition: checksum.cpp:27
Definition: compress_integer_elias_delta_simd.c:23
static uint16_t fletcher_16_file(const std::string &filename)
Compute the Fletcher 16-bit checksum of a disk file.
Definition: checksum.cpp:94