4 #include <boost/iostreams/categories.hpp>
5 #include <boost/iostreams/positioning.hpp>
6 #include <boost/iostreams/read.hpp>
7 #include <boost/shared_ptr.hpp>
13 template<
class ifstream>
18 boost::iostreams::input,
19 boost::iostreams::device_tag,
20 boost::iostreams::closable_tag
26 {
open(std::vector<std::string>(1, filename)); }
32 {
open(std::vector<std::string>(1, filename)); }
35 open(
const std::vector<std::string>& filenames)
40 if (filenames.empty())
42 _ifstream.reset(
new ifstream(filenames.front()));
53 boost::iostreams::stream_offset
54 get_current_file_index()
63 get_current_filename()
66 const auto i = get_current_file_index();
71 read(
char*
const s,
const std::streamsize n)
75 const auto size = boost::iostreams::read(*
_ifstream, s, n);
106 template<
class ifstream>
107 class join :
public boost::iostreams::stream<join_source<ifstream>> {
110 typedef boost::iostreams::stream<source>
base;
121 void open(
const std::vector<std::string>& filenames) { (**this).open(filenames); }
join_source(const std::string &filename)
join(const std::vector< std::string > &filenames)
join_source< ifstream > source
void open(const std::vector< std::string > &filenames)
std::vector< std::string > _filenames
join(const std::string &filename)
boost::iostreams::stream< source > base
void open(const std::vector< std::string > &filenames)
std::streamsize read(char *const s, const std::streamsize n)
boost::shared_ptr< ifstream > _ifstream
void open(const std::string &filename)
join_source(const std::vector< std::string > &filenames)
std::size_t _current_file_index
void open(const std::string &filename)