librime: utilities.h Source File

| librime 1.2 Rime Input Method Engine, the core library

utilities.h
Go to the documentation of this file.
1//
2// Copyright RIME Developers
3// Distributed under the BSD License
4//
5// 2013-01-30 GONG Chen <chen.sst@gmail.com>
6//
7#ifndef RIME_UTILITIES_H_
8#define RIME_UTILITIES_H_
9
10#include <stdint.h>
11#include <boost/crc.hpp>
12#include <rime/common.h>
13
14namespace rime {
15
16int CompareVersionString(const string& x, const string& y);
17
18 class ChecksumComputer {
19 public:
20 explicit ChecksumComputer(uint32_t initial_remainder = 0);
21 void ProcessFile(const path& file_path);
22 uint32_t Checksum();
23
24 private:
25 boost::crc_32_type crc_;
26 static constexpr size_t buffer_size = 64 * 1024; // 64 KB
27};
28
29 inline uint32_t Checksum(const path& file_path) {
30 ChecksumComputer c;
31 c.ProcessFile(file_path);
32 return c.Checksum();
33}
34
35} // namespace rime
36
37#endif // RIME_UTILITIES_H_
common.h
rime
Definition algebra.cc:12
rime::CompareVersionString
int CompareVersionString(const string &x, const string &y)
Definition utilities.cc:13
rime::Checksum
uint32_t Checksum(const path &file_path)
Definition utilities.h:29
rime::ChecksumComputer
Definition utilities.h:18
rime::ChecksumComputer::Checksum
uint32_t Checksum()
Definition utilities.cc:49
rime::ChecksumComputer::ProcessFile
void ProcessFile(const path &file_path)
Definition utilities.cc:34
rime::ChecksumComputer::ChecksumComputer
ChecksumComputer(uint32_t initial_remainder=0)
Definition utilities.cc:31
rime::path
Definition common.h:84