1 /* This file is part of
2 * ======================================================
4 * LyX, The Document Processor
5 * Copyright 2001 The LyX Team.
7 * ======================================================
16 #include <boost/crc.hpp>
18 #include "support/lyxlib.h"
23 template<typename InputIterator>
25 unsigned long do_crc(InputIterator first, InputIterator last)
27 boost::crc_32_type crc;
28 crc = std::for_each(first, last, crc);
29 return crc.checksum();
35 // And this would be the file interface.
36 unsigned long lyx::sum(string const & file)
38 std::ifstream ifs(file.c_str());
41 #ifdef HAVE_DECL_ISTREAMBUF_ITERATOR
42 // This is a lot faster...
43 std::istreambuf_iterator<char> beg(ifs);
44 std::istreambuf_iterator<char> end;
47 ifs.unsetf(std::ios::skipws);
48 std::istream_iterator<char> beg(ifs);
49 std::istream_iterator<char> end;
52 return do_crc(beg, end);