SHORE API
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
shore::istreams Class Reference

Manages an array of input streams. More...

Inheritance diagram for shore::istreams:
shore::streams_base

Public Member Functions

 istreams ()
 Default constructor.
 
 istreams (const std::string &fn)
 Construct and open a file.
 
 istreams (const std::vector< std::string > &fn)
 Construct and open files.
 
template<class Iter >
 istreams (Iter f_beg, Iter f_end)
 
std::istream & open_file (const std::string &fnam)
 Open a file interpreting special file names and automatically select decompression method.
 
std::istream & open_file (const std::string &fnam, const Codec c)
 Open a file interpreting special file names and forcing a specific decompression method.
 
template<class Iter >
void open_files (Iter f_beg, Iter f_end)
 Open files interpreting special file names and automatically select decompression method.
 
std::istream & open_normalfile (const std::string &fn, const Codec c=CODEC_PLAIN)
 Open a file with name fn.
 
std::istream & push_back (std::istream &stream, const std::string &name=std::string(), const Codec c=CODEC_PLAIN)
 Add a stream.
 
std::istream & open_pipe (const std::string &command, const bool tolerant=false, const Codec c=CODEC_PLAIN)
 Open a pipe.
 
void add_codec (const size_t index, const Codec c)
 Setup decompression type for the given stream.
 
void read_error_check (const int index, const std::string &label=std::string())
 Check one of the streams for read errors.
 
void read_error_check_rdbuf (const int index, const std::string &label=std::string())
 Check one of the streams for read errors after os<<is.rdbuf().
 
void close_all ()
 Close all streams. The file informations and size() remain unaltered.
 
void close_stream (const std::istream *const s)
 Close the stream that corresponds to the pointer s.
 
void close_stream (const size_t i)
 Close one of the streams.
 
void close_stream (const int i)
 Close one of the streams.
 
void use_mmap (const bool b)
 
size_t size () const
 Get the number of opened streams.
 
std::istream & operator[] (size_t n)
 Get one of the streams.
 
std::istream & front ()
 Get the first of the streams.
 
std::istream & back ()
 Get the last of the streams.
 
uint64_t get_streamsize (const size_t i) const
 Get the size of one of the streams.
 
const std::string & get_streamname (const size_t i) const
 Get the (file) name of one of the streams.
 
bool is_raw_seekable (const size_t i) const
 
bool is_stream_seekable (const size_t i) const
 

Static Public Member Functions

static bool has_magic (std::istream *const in, const int m1, const int m2)
 Check if file starts with a given 2-byte magic number.
 
static bool has_gzip_magic (std::istream *const in)
 Check if file starts with a GZIP magic number.
 
static bool has_xz_magic (std::istream *const in)
 Check if file starts with an XZ magic number.
 
static bool is_gzip (const std::string &fn)
 Check if file is a GZIP file.
 
static bool is_xz (const std::string &fn)
 Check if file is an XZ file.
 
static Codec get_codec (const std::string &fn)
 Get the compresssion codec for a file name.
 
static uint64_t uncompressed_file_size (const std::string &fn)
 Get the uncompressed size of a (compressed or uncompressed) file.
 
static void read_error_check (std::istream &s, const std::string &stream_name, const std::string &label=std::string())
 Check istream for errors.
 
static void read_error_eof_check (std::istream &s, const std::string &stream_name, const std::string &label=std::string())
 Check istream for errors or unexpected EOF.
 
static void read_error_check_rdbuf (std::istream &s, const std::string &stream_name, const std::string &label=std::string())
 Check istream s for errors after an os<<s.rdbuf().
 
static void save_stream_to_string (std::string &res, std::istream &s, const std::string &streamname)
 Save entire istream contents to a std::string.
 
static void save_stream_to_string (std::string &res, const std::string &s)
 Save entire istream contents to a std::string.
 

Additional Inherited Members

- Public Types inherited from shore::streams_base
enum  Codec { CODEC_PLAIN, CODEC_GZIP, CODEC_XZ }
 Supported compression codecs.
 
enum  RandomAccessGranularity { GRANULARITY_FAST, GRANULARITY_MEDIUM, GRANULARITY_SLOW }
 Presets for compression block sizes.
 
- Static Public Attributes inherited from shore::streams_base
static const int BLOCKSIZE_PRESET_VALUES [3]
 
static const std::string COMPRESSION_FILEEXTS [3]
 Recognized compression file name extensions.
 

Detailed Description

Manages an array of input streams.


The documentation for this class was generated from the following file: