]> git.lyx.org Git - features.git/blob - src/support/checksum.cpp
Revert "Amend 3093789e for cmake build"
[features.git] / src / support / checksum.cpp
1 // -*- C++ -*-
2 /**
3  * \file checksum.cpp
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Yuriy Skalko
8  *
9  * Full author contact details are available in file CREDITS.
10  */
11
12 #include "support/checksum.h"
13 #include "boost/crc.hpp"
14 #include <algorithm>
15
16 namespace lyx {
17
18 namespace support {
19
20 unsigned long checksum(std::string const & s)
21 {
22         boost::crc_32_type crc;
23         crc.process_bytes(s.c_str(), s.size());
24         return crc.checksum();
25 }
26
27 unsigned long checksum(std::ifstream & ifs)
28 {
29         std::istreambuf_iterator<char> beg(ifs);
30         std::istreambuf_iterator<char> end;
31
32         boost::crc_32_type crc;
33         crc = for_each(beg, end, crc);
34         return crc.checksum();
35 }
36
37 unsigned long checksum(char const * beg, char const * end)
38 {
39         boost::crc_32_type crc;
40         crc.process_block(beg, end);
41         return crc.checksum();
42 }
43
44 } // namespace support
45
46 } // namespace lyx