16
16
17
17
#include < err.h>
18
18
#include < string.h>
19
+ #include < stdint.h>
19
20
20
21
namespace util { class FilePiece ; }
21
22
@@ -25,25 +26,17 @@ class ARPAInputException : public util::Exception {
25
26
public:
26
27
explicit ARPAInputException (const StringPiece &message) throw();
27
28
explicit ARPAInputException (const StringPiece &message, const StringPiece &line) throw();
28
- virtual ~ARPAInputException () throw () {}
29
-
30
- const char *what () const throw() { return what_.c_str (); }
31
-
32
- private:
33
- std::string what_;
29
+ virtual ~ARPAInputException () throw ();
34
30
};
35
31
36
- class ARPAOutputException : public std :: exception {
32
+ class ARPAOutputException : public util ::ErrnoException {
37
33
public:
38
34
ARPAOutputException (const char *prefix, const std::string &file_name) throw ();
39
- virtual ~ARPAOutputException () throw () {}
40
-
41
- const char *what () const throw() { return what_.c_str (); }
35
+ virtual ~ARPAOutputException () throw ();
42
36
43
37
const std::string &File () const throw() { return file_name_; }
44
38
45
39
private:
46
- std::string what_;
47
40
const std::string file_name_;
48
41
};
49
42
@@ -52,7 +45,7 @@ size_t SizeNeededForCounts(const std::vector<uint64_t> &number);
52
45
53
46
/* Writes an ARPA file. This has to be seekable so the counts can be written
54
47
* at the end. Hence, I just have it own a std::fstream instead of accepting
55
- * a separately held std::ostream.
48
+ * a separately held std::ostream. TODO: use the fast one from estimation.
56
49
*/
57
50
class ARPAOutput : boost::noncopyable {
58
51
public:
@@ -92,10 +85,10 @@ class ARPAOutput : boost::noncopyable {
92
85
};
93
86
94
87
95
- template <class Output > void ReadNGrams (util::FilePiece &in, unsigned int length, size_t number, Output &out) {
88
+ template <class Output > void ReadNGrams (util::FilePiece &in, unsigned int length, uint64_t number, Output &out) {
96
89
ReadNGramHeader (in, length);
97
90
out.BeginLength (length);
98
- for (size_t i = 0 ; i < number; ++i) {
91
+ for (uint64_t i = 0 ; i < number; ++i) {
99
92
StringPiece line = in.ReadLine ();
100
93
util::TokenIter<util::SingleCharacter> tabber (line, ' \t ' );
101
94
if (!tabber) throw ARPAInputException (" blank line" , line);
0 commit comments