Use read_file_mapping in TextFileReader
This commit is contained in:
parent
87501931f6
commit
220e6d18da
2 changed files with 11 additions and 5 deletions
|
@ -18,16 +18,19 @@
|
|||
|
||||
#include "text_file_reader.h"
|
||||
|
||||
#include <libaegisub/io.h>
|
||||
#include <libaegisub/file_mapping.h>
|
||||
#include <libaegisub/util.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/trim.hpp>
|
||||
#include <boost/interprocess/streams/bufferstream.hpp>
|
||||
|
||||
TextFileReader::TextFileReader(agi::fs::path const& filename, std::string encoding, bool trim)
|
||||
: file(agi::io::Open(filename, true))
|
||||
: file(agi::util::make_unique<agi::read_file_mapping>(filename))
|
||||
, stream(agi::util::make_unique<boost::interprocess::bufferstream>(file->read(0, file->size()), file->size()))
|
||||
, trim(trim)
|
||||
, iter(agi::line_iterator<std::string>(*file, encoding))
|
||||
, iter(agi::line_iterator<std::string>(*stream, encoding))
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -14,17 +14,20 @@
|
|||
//
|
||||
// Aegisub Project http://www.aegisub.org/
|
||||
|
||||
#include <fstream>
|
||||
#include <iosfwd>
|
||||
#include <memory>
|
||||
#include <string>
|
||||
|
||||
#include <libaegisub/fs_fwd.h>
|
||||
#include <libaegisub/line_iterator.h>
|
||||
|
||||
namespace agi { class read_file_mapping; }
|
||||
|
||||
/// @class TextFileReader
|
||||
/// @brief A line-based text file reader
|
||||
class TextFileReader {
|
||||
std::unique_ptr<std::ifstream> file;
|
||||
std::unique_ptr<agi::read_file_mapping> file;
|
||||
std::unique_ptr<std::istream> stream;
|
||||
bool trim;
|
||||
agi::line_iterator<std::string> iter;
|
||||
|
||||
|
|
Loading…
Reference in a new issue