diff options
author | Kenneth Heafield <github@kheafield.com> | 2013-01-23 00:23:35 +0400 |
---|---|---|
committer | Kenneth Heafield <github@kheafield.com> | 2013-01-23 00:23:35 +0400 |
commit | e2fc3062315ab5039abb27c594a88fb87adfd5c8 (patch) | |
tree | 6a15ae47c533ad2a3b46fa5c0a07928c1d1bf3ff /util/file_piece.hh | |
parent | fcf75fae18c618877a6c0e7d8ebcfcaf833f5e27 (diff) |
KenLM 58da33: compiler warnings, correctly handle bare K, kill HAVE_BOOST
Diffstat (limited to 'util/file_piece.hh')
-rw-r--r-- | util/file_piece.hh | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/util/file_piece.hh b/util/file_piece.hh index 533109769..c07c60119 100644 --- a/util/file_piece.hh +++ b/util/file_piece.hh @@ -9,6 +9,7 @@ #include "util/string_piece.hh" #include <cstddef> +#include <iosfwd> #include <string> #include <stdint.h> @@ -31,6 +32,13 @@ class FilePiece { // Takes ownership of fd. name is used for messages. explicit FilePiece(int fd, const char *name = NULL, std::ostream *show_progress = NULL, std::size_t min_buffer = 1048576); + /* Read from an istream. Don't use this if you can avoid it. Raw fd IO is + * much faster. But sometimes you just have an istream like Boost's HTTP + * server and want to parse it the same way. + * name is just used for messages and FileName(). + */ + explicit FilePiece(std::istream &stream, const char *name = NULL, std::size_t min_buffer = 1048576); + ~FilePiece(); char get() { @@ -71,6 +79,8 @@ class FilePiece { const std::string &FileName() const { return file_name_; } private: + void InitializeNoRead(const char *name, std::size_t min_buffer); + // Calls InitializeNoRead, so don't call both. void Initialize(const char *name, std::ostream *show_progress, std::size_t min_buffer); template <class T> T ReadNumber(); |