12 #include <boost/crc.hpp> 18 template <
class ret_t,
class crc_t>
19 ret_t
crc(
const std::string& _str)
22 crc.process_bytes(_str.data(), _str.size());
23 return crc.checksum();
26 inline uint32_t
crc32(
const std::string& _str)
28 return crc<uint32_t, boost::crc_32_type>(_str);
31 inline uint64_t
crc64(
const std::string& _str)
33 return crc<uint64_t, crc_optimal_64_t>(_str);
36 template <
class ret_t,
class crc_t>
37 ret_t
crc(std::istream& _stream)
44 _stream.read(buf,
sizeof buf);
45 result.process_bytes(buf, _stream.gcount());
50 return result.checksum();
54 throw std::runtime_error(
"Failed to calculate CRC: file read failed");
58 inline uint32_t
crc32(std::istream& _stream)
60 return crc<uint32_t, boost::crc_32_type>(_stream);
63 inline uint64_t
crc64(std::istream& _stream)
65 return crc<uint64_t, crc_optimal_64_t>(_stream);
uint64_t crc64(const std::string &_str)
Definition: CRC.h:31
uint32_t crc32(const std::string &_str)
Definition: CRC.h:26
ret_t crc(const std::string &_str)
Definition: CRC.h:19
boost::crc_optimal< 64, 0x04C11DB7, 0, 0, false, false > crc_optimal_64_t
Definition: CRC.h:16
Definition: BoostHelper.h:14