![]() |
Rosetta Utilities
2015.09
|
izstream: Input file stream wrapper for uncompressed and compressed files More...
#include <izstream.hh>
Public Member Functions | |
izstream () | |
Default constructor. More... | |
izstream (std::string const &filename_a, std::ios_base::openmode open_mode=std::ios_base::in) | |
Filename constructor. More... | |
virtual | ~izstream () |
Destructor. More... | |
operator bool () const | |
bool conversion More... | |
operator std::istream const & () const | |
Stream conversion. More... | |
operator std::istream & () | |
Stream conversion. More... | |
template<typename T > | |
std::istream & | operator>> (T &t) |
Stream input. More... | |
std::istream & | operator>> (manipulator m) |
Stream manipulator input. More... | |
std::istream & | operator>> (std_manipulator m) |
Stream manipulator input. More... | |
void | open (std::string const &filename_a, std::ios_base::openmode open_mode=std::ios_base::in) |
Open a file. More... | |
void | clear () |
Clear the stream(s) More... | |
void | close () |
Close the ifstream and reset the state. More... | |
void | seek_beg () |
Seek to the beginning. More... | |
int | get () |
Get the next character. More... | |
izstream & | get (char &c) |
Get the next character. More... | |
izstream & | get (char *str, std::streamsize const count) |
Get the next specified number of characters. More... | |
izstream & | get (char *str, std::streamsize const count, char const delim) |
Get the next specified number of characters. More... | |
izstream & | get (std::string &str, std::streamsize const count) |
Get the next specified number of characters. More... | |
izstream & | get (std::string &str, std::streamsize const count, char const delim) |
Get the next specified number of characters. More... | |
izstream & | getline (char *line, std::streamsize const count) |
Get the rest of the line. More... | |
izstream & | getline (char *line, std::streamsize const count, char const delim) |
Get the rest of the line. More... | |
izstream & | getline (std::string &line) |
Get the rest of the line. More... | |
izstream & | getline (std::string &line, char const delim) |
Get the rest of the line. More... | |
izstream & | read (char *str, std::streamsize const count) |
Read the next specified number of characters. More... | |
izstream & | read (std::string &str, std::streamsize const count) |
Read the next specified number of characters. More... | |
std::streamsize | readsome (char *str, std::streamsize const count) |
Read the next available specified number of characters. More... | |
std::streamsize | readsome (std::string &str, std::streamsize const count) |
Read the next available specified number of characters. More... | |
izstream & | ignore () |
Skip over the next character. More... | |
izstream & | ignore (std::streamsize const count) |
Skip over the next specified number of characters. More... | |
izstream & | ignore (std::streamsize const count, char const delim) |
Skip over the next specified number of characters. More... | |
int | peek () |
Returns the next character without extracting it. More... | |
izstream & | unget () |
Put the last character read back into the stream. More... | |
izstream & | putback (char c) |
Put the last character read back into the stream and check that passed character is correct. More... | |
std::istream const & | operator() () const |
Stream access. More... | |
std::istream & | operator() () |
Stream access. More... | |
std::istream const & | stream () const |
Stream access. More... | |
std::istream & | stream () |
Stream access. More... | |
std::streambuf * | rdbuf () const |
Pointer to the stream buffer. More... | |
std::string const & | filename () const |
File name. More... | |
std::streamsize | gcount () const |
Get the number of characters read by the last unformatted read. More... | |
bool | good () const |
Good? More... | |
bool | eof () const |
End of file? More... | |
bool | fail () const |
Fail? More... | |
bool | bad () const |
Bad? More... | |
bool | compressed () const |
Compressed? More... | |
bool | uncompressed () const |
Uncompressed? More... | |
bool | gzipped () const |
gzipped? More... | |
![]() | |
virtual | ~irstream () |
Destructor. More... | |
template<typename T > | |
irstream & | operator>> (T &t) |
Stream input. More... | |
Static Public Member Functions | |
static void | set_alternative_search_paths (vector1< std::string > alternative_search_paths) |
static vector1< std::string > | get_alternative_search_paths () |
Private Types | |
enum | Compression { NONE, UNCOMPRESSED, GZIP } |
typedef std::istream &(* | manipulator )(izstream &) |
typedef std::istream &(* | std_manipulator )(std::istream &) |
Private Member Functions | |
bool | is_gzip () const |
Is stream attached to a gzip file? More... | |
bool | check_crc () const |
CRC of gzip file valid? More... | |
long | get_crc () const |
CRC of the uncompressed data (see zipstream documentation) More... | |
long | get_in_size () const |
Compressed data size. More... | |
long | get_out_size () const |
Uncompressed data size. More... | |
void | open_ifstream (std::string const &name, std::ios_base::openmode open_mode) |
Helper function for opening files with alternative search paths. More... | |
Private Attributes | |
Compression | compression_ |
Compression state. More... | |
std::ifstream | if_stream_ |
File stream. More... | |
std::string | filename_ |
File name. More... | |
zlib_stream::zip_istream * | zip_stream_p_ |
Zip file stream pointer (owning) More... | |
Static Private Attributes | |
static vector1< std::string > | alternative_search_paths_ |
Alternative search paths This initialized by the option system -in:path:path Notice that izstream cannot access the option system (because the utility library comes before the basic library), so setting the alternate search paths is it the responsibility of core::init::init() More... | |
Friends | |
long | utility::file::gzip (std::string const &uncompressedfile, bool overwrite) |
long | utility::file::gunzip (std::string const &compressedfile, bool overwrite) |
Additional Inherited Members | |
![]() | |
typedef std::istream &(* | std_manipulator )(std::istream &) |
![]() | |
irstream () | |
Default constructor. More... | |
izstream: Input file stream wrapper for uncompressed and compressed files
|
private |
|
private |
|
inline |
Default constructor.
|
inlineexplicit |
Filename constructor.
References open().
|
inlinevirtual |
Destructor.
References if_stream_, and zip_stream_p_.
|
inlinevirtual |
|
inlineprivate |
CRC of gzip file valid?
References zip_stream_p_.
|
inlinevirtual |
Clear the stream(s)
Implements utility::io::irstream.
References if_stream_, and zip_stream_p_.
Referenced by basic::database::open().
|
inline |
Close the ifstream and reset the state.
References compression_, filename_, if_stream_, NONE, and zip_stream_p_.
Referenced by utility::exit(), utility::file_contents(), basic::database::open(), open(), basic::sampling::orientations::QuaternionGridManager::request_by_name(), numeric::interpolation::spline_from_file(), and basic::options::start_files().
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inline |
File name.
References filename_.
|
inline |
Get the number of characters read by the last unformatted read.
References stream().
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinestatic |
References alternative_search_paths_.
Referenced by basic::resource_manager::locator::FileStream::FileStream().
|
inlineprivate |
CRC of the uncompressed data (see zipstream documentation)
References zip_stream_p_.
|
inlineprivate |
Compressed data size.
References zip_stream_p_.
|
inlineprivate |
Uncompressed data size.
References zip_stream_p_.
|
inlinevirtual |
Get the rest of the line.
Implements utility::io::irstream.
References stream().
Referenced by basic::options::start_files().
|
inlinevirtual |
|
inlinevirtual |
Get the rest of the line.
Implements utility::io::irstream.
References utility::io::getline(), and stream().
|
inlinevirtual |
Get the rest of the line.
Implements utility::io::irstream.
References utility::io::getline(), and stream().
|
inlinevirtual |
Good?
Implements utility::io::irstream.
References stream().
Referenced by basic::database::open(), and basic::options::start_files().
|
inlinevirtual |
|
inlinevirtual |
Skip over the next character.
Implements utility::io::irstream.
References stream().
Referenced by utility::io::skip().
|
inlinevirtual |
Skip over the next specified number of characters.
Implements utility::io::irstream.
References stream().
|
inlinevirtual |
Skip over the next specified number of characters.
Implements utility::io::irstream.
References stream().
|
inlineprivate |
Is stream attached to a gzip file?
References zip_stream_p_.
void utility::io::izstream::open | ( | std::string const & | filename_a, |
std::ios_base::openmode | open_mode = std::ios_base::in |
||
) |
Open a file.
References utility::io::oc::cerr, close(), compression_, utility::file::file_extension(), utility::SingletonBase< Inline_File_Provider >::get_instance(), utility::Inline_File_Provider::get_istream(), GZIP, if_stream_, NONE, open_ifstream(), utility::file::trytry_ifstream_open(), UNCOMPRESSED, and zip_stream_p_.
Referenced by izstream(), basic::database::open(), basic::resource_manager::locator::FileStream::open(), and numeric::interpolation::spline_from_file().
|
private |
Helper function for opening files with alternative search paths.
References alternative_search_paths_, filename_, if_stream_, name, platform::file::PATH_SEPARATOR(), and utility::file::trytry_ifstream_open().
Referenced by open().
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
|
inline |
Stream input.
References stream().
|
inline |
Stream manipulator input.
|
inlinevirtual |
Stream manipulator input.
Implements utility::io::irstream.
|
inlinevirtual |
Returns the next character without extracting it.
Implements utility::io::irstream.
References stream().
|
inlinevirtual |
Put the last character read back into the stream and check that passed character is correct.
Implements utility::io::irstream.
References stream().
|
inlinevirtual |
|
inlinevirtual |
Read the next specified number of characters.
Implements utility::io::irstream.
References stream().
|
inlinevirtual |
Read the next specified number of characters.
Implements utility::io::irstream.
References stream().
|
inlinevirtual |
Read the next available specified number of characters.
Implements utility::io::irstream.
References stream().
|
inlinevirtual |
Read the next available specified number of characters.
Implements utility::io::irstream.
References stream().
|
inlinevirtual |
|
inlinestatic |
References alternative_search_paths_.
|
inlinevirtual |
Stream access.
Implements utility::io::irstream.
References if_stream_, and zip_stream_p_.
Referenced by bad(), eof(), fail(), gcount(), get(), getline(), good(), ignore(), operator>>(), peek(), putback(), rdbuf(), read(), readsome(), and unget().
|
inlinevirtual |
|
inlinevirtual |
|
inlinevirtual |
Put the last character read back into the stream.
Implements utility::io::irstream.
References stream().
|
friend |
|
friend |
|
staticprivate |
Alternative search paths This initialized by the option system -in:path:path Notice that izstream cannot access the option system (because the utility library comes before the basic library), so setting the alternate search paths is it the responsibility of core::init::init()
Referenced by get_alternative_search_paths(), open_ifstream(), and set_alternative_search_paths().
|
private |
Compression state.
Referenced by close(), compressed(), gzipped(), open(), and uncompressed().
|
private |
File name.
Referenced by close(), filename(), and open_ifstream().
|
private |
File stream.
Referenced by clear(), close(), open(), open_ifstream(), operator bool(), operator std::istream &(), operator std::istream const &(), operator()(), seek_beg(), stream(), and ~izstream().
|
private |
Zip file stream pointer (owning)
Referenced by check_crc(), clear(), close(), get_crc(), get_in_size(), get_out_size(), is_gzip(), open(), operator bool(), operator std::istream &(), operator std::istream const &(), operator()(), seek_beg(), stream(), and ~izstream().