srecord  1.65.0
adler16.h
Go to the documentation of this file.
1 //
2 // srecord - Manipulate EPROM load files
3 // Copyright (C) 2009-2011 Peter Miller
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU Lesser General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or (at
8 // your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 // General Public License for more details.
14 //
15 // You should have received a copy of the GNU Lesser General Public License
16 // along with this program. If not, see <http://www.gnu.org/licenses/>.
17 //
18 
19 #ifndef SRECORD_ADLER16_H
20 #define SRECORD_ADLER16_H
21 
22 #include <cstddef>
23 
24 namespace srecord
25 {
26 
27 /**
28  * The adler16 class is used to represent the running value of a 16-bit
29  * Adler checksum of series of bytes. (Using an algorith analogous to
30  * Adler-32, but using mod 251 instead of 65521).
31  */
32 class adler16
33 {
34 public:
35  /**
36  * The destructor.
37  */
38  virtual ~adler16();
39 
40  /**
41  * The default constructor.
42  */
44 
45  /**
46  * The copy constructor.
47  */
48  adler16(const adler16 &);
49 
50  /**
51  * The assignment operator.
52  */
54 
55  /**
56  * The get method is used to obtain the running value of the checksum.
57  */
58  unsigned short get() const;
59 
60  /**
61  * The next method is used to advance the state by one byte.
62  */
63  void next(unsigned char);
64 
65  /**
66  * The nextbuf method is used to advance the state by a series of bytes.
67  */
68  void nextbuf(const void *, size_t);
69 
70 private:
71  /**
72  * The sum_a instance variable is used to remember the sum of bytes
73  * scanned.
74  */
75  unsigned char sum_a;
76 
77  /**
78  * The sum_b instance variable is used to remember the sum of the
79  * sum of bytes scanned.
80  */
81  unsigned char sum_b;
82 };
83 
84 };
85 
86 // vim: set ts=8 sw=4 et :
87 #endif // SRECORD_ADLER16_H
The adler16 class is used to represent the running value of a 16-bit Adler checksum of series of byte...
Definition: adler16.h:33
adler16()
The default constructor.
void nextbuf(const void *, size_t)
The nextbuf method is used to advance the state by a series of bytes.
adler16 & operator=(const adler16 &)
The assignment operator.
adler16(const adler16 &)
The copy constructor.
virtual ~adler16()
The destructor.
void next(unsigned char)
The next method is used to advance the state by one byte.
unsigned short get() const
The get method is used to obtain the running value of the checksum.