Rosetta  2018.48
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Static Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
utility::io::izstream Class Reference

izstream: Input file stream wrapper for uncompressed and compressed files More...

#include <izstream.hh>

Inheritance diagram for utility::io::izstream:
Inheritance graph
[legend]

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...
 
 ~izstream () override
 Destructor. More...
 
 operator bool () const override
 bool conversion More...
 
 operator std::istream const & () const override
 Stream conversion. More...
 
 operator std::istream & () override
 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) override
 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 () override
 Clear the stream(s) More...
 
void close ()
 Close the ifstream and reset the state. More...
 
void seek_beg () override
 Seek to the beginning. More...
 
int get () override
 Get the next character. More...
 
izstreamget (char &c) override
 Get the next character. More...
 
izstreamget (char *str, std::streamsize const count) override
 Get the next specified number of characters. More...
 
izstreamget (char *str, std::streamsize const count, char const delim) override
 Get the next specified number of characters. More...
 
izstreamget (std::string &str, std::streamsize const count) override
 Get the next specified number of characters. More...
 
izstreamget (std::string &str, std::streamsize const count, char const delim) override
 Get the next specified number of characters. More...
 
izstreamgetline (char *line, std::streamsize const count) override
 Get the rest of the line. More...
 
izstreamgetline (char *line, std::streamsize const count, char const delim) override
 Get the rest of the line. More...
 
izstreamgetline (std::string &line) override
 Get the rest of the line. More...
 
izstreamgetline (std::string &line, char const delim) override
 Get the rest of the line. More...
 
izstreamread (char *str, std::streamsize const count) override
 Read the next specified number of characters. More...
 
izstreamread (std::string &str, std::streamsize const count) override
 Read the next specified number of characters. More...
 
std::streamsize readsome (char *str, std::streamsize const count) override
 Read the next available specified number of characters. More...
 
std::streamsize readsome (std::string &str, std::streamsize const count) override
 Read the next available specified number of characters. More...
 
izstreamignore () override
 Skip over the next character. More...
 
izstreamignore (std::streamsize const count) override
 Skip over the next specified number of characters. More...
 
izstreamignore (std::streamsize const count, char const delim) override
 Skip over the next specified number of characters. More...
 
int peek () override
 Returns the next character without extracting it. More...
 
izstreamunget () override
 Put the last character read back into the stream. More...
 
izstreamputback (char c) override
 Put the last character read back into the stream and check that passed character is correct. More...
 
std::istream const & operator() () const override
 Stream access. More...
 
std::istream & operator() () override
 Stream access. More...
 
std::istream const & stream () const override
 Stream access. More...
 
std::istream & stream () override
 Stream access. More...
 
std::streambuf * rdbuf () const override
 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 override
 Good? More...
 
bool eof () const override
 End of file? More...
 
bool fail () const override
 Fail? More...
 
bool bad () const override
 Bad? More...
 
bool compressed () const override
 Compressed? More...
 
bool uncompressed () const override
 Uncompressed? More...
 
bool gzipped () const override
 gzipped? More...
 
- Public Member Functions inherited from utility::io::irstream
virtual ~irstream ()
 Destructor. More...
 
template<typename T >
irstreamoperator>> (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_istreamzip_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

- Protected Types inherited from utility::io::irstream
typedef std::istream &(* std_manipulator )(std::istream &)
 
- Protected Member Functions inherited from utility::io::irstream
 irstream ()=default
 Default constructor. More...
 

Detailed Description

izstream: Input file stream wrapper for uncompressed and compressed files

Member Typedef Documentation

typedef std::istream&(* utility::io::izstream::manipulator)(izstream &)
private
typedef std::istream&(* utility::io::izstream::std_manipulator)(std::istream &)
private

Member Enumeration Documentation

Enumerator
NONE 
UNCOMPRESSED 
GZIP 

Constructor & Destructor Documentation

utility::io::izstream::izstream ( )
inline

Default constructor.

utility::io::izstream::izstream ( std::string const &  filename_a,
std::ios_base::openmode  open_mode = std::ios_base::in 
)
inlineexplicit

Filename constructor.

References open().

utility::io::izstream::~izstream ( )
inlineoverride

Destructor.

References if_stream_, and zip_stream_p_.

Member Function Documentation

bool utility::io::izstream::bad ( ) const
inlineoverridevirtual

Bad?

Implements utility::io::irstream.

References stream().

bool utility::io::izstream::check_crc ( ) const
inlineprivate
void utility::io::izstream::clear ( )
inlineoverridevirtual

Clear the stream(s)

Implements utility::io::irstream.

References if_stream_, and zip_stream_p_.

Referenced by basic::database::open().

void utility::io::izstream::close ( )
inline
bool utility::io::izstream::compressed ( ) const
inlineoverridevirtual

Compressed?

Implements utility::io::irstream.

References compression_, and GZIP.

bool utility::io::izstream::eof ( ) const
inlineoverridevirtual

End of file?

Implements utility::io::irstream.

References stream().

Referenced by main(), and read_rama_map_file().

bool utility::io::izstream::fail ( ) const
inlineoverridevirtual

Fail?

Implements utility::io::irstream.

References stream().

Referenced by APDBCMover::read_in_insert_loop_info().

std::string const& utility::io::izstream::filename ( ) const
inline

File name.

References filename_.

std::streamsize utility::io::izstream::gcount ( ) const
inline

Get the number of characters read by the last unformatted read.

References stream().

int utility::io::izstream::get ( )
inlineoverridevirtual

Get the next character.

Implements utility::io::irstream.

References stream().

izstream& utility::io::izstream::get ( char &  c)
inlineoverridevirtual

Get the next character.

Implements utility::io::irstream.

References stream().

izstream& utility::io::izstream::get ( char *  str,
std::streamsize const  count 
)
inlineoverridevirtual

Get the next specified number of characters.

Implements utility::io::irstream.

References clean_pdb_keep_ligand::count, and stream().

izstream& utility::io::izstream::get ( char *  str,
std::streamsize const  count,
char const  delim 
)
inlineoverridevirtual

Get the next specified number of characters.

Implements utility::io::irstream.

References clean_pdb_keep_ligand::count, and stream().

izstream& utility::io::izstream::get ( std::string &  str,
std::streamsize const  count 
)
inlineoverridevirtual

Get the next specified number of characters.

Implements utility::io::irstream.

References clean_pdb_keep_ligand::count, basic::options::OptionKeys::cp::cp, and stream().

izstream& utility::io::izstream::get ( std::string &  str,
std::streamsize const  count,
char const  delim 
)
inlineoverridevirtual

Get the next specified number of characters.

Implements utility::io::irstream.

References clean_pdb_keep_ligand::count, basic::options::OptionKeys::cp::cp, and stream().

static vector1< std::string > utility::io::izstream::get_alternative_search_paths ( )
inlinestatic
long utility::io::izstream::get_crc ( ) const
inlineprivate

CRC of the uncompressed data (see zipstream documentation)

References zlib_stream::basic_zip_istreambase< Elem, Tr, ElemA, ByteT, ByteAT >::get_crc(), and zip_stream_p_.

long utility::io::izstream::get_in_size ( ) const
inlineprivate
long utility::io::izstream::get_out_size ( ) const
inlineprivate
izstream& utility::io::izstream::getline ( char *  line,
std::streamsize const  count 
)
inlineoverridevirtual

Get the rest of the line.

Implements utility::io::irstream.

References stream().

Referenced by main(), read_rama_map_file(), and basic::options::start_files().

izstream& utility::io::izstream::getline ( char *  line,
std::streamsize const  count,
char const  delim 
)
inlineoverridevirtual

Get the rest of the line.

Implements utility::io::irstream.

References stream().

izstream& utility::io::izstream::getline ( std::string &  line)
inlineoverridevirtual

Get the rest of the line.

Implements utility::io::irstream.

References utility::io::getline(), and stream().

izstream& utility::io::izstream::getline ( std::string &  line,
char const  delim 
)
inlineoverridevirtual

Get the rest of the line.

Implements utility::io::irstream.

References utility::io::getline(), and stream().

bool utility::io::izstream::good ( ) const
inlineoverridevirtual
bool utility::io::izstream::gzipped ( ) const
inlineoverridevirtual

gzipped?

Implements utility::io::irstream.

References compression_, and GZIP.

izstream& utility::io::izstream::ignore ( )
inlineoverridevirtual

Skip over the next character.

Implements utility::io::irstream.

References stream().

Referenced by utility::io::skip().

izstream& utility::io::izstream::ignore ( std::streamsize const  count)
inlineoverridevirtual

Skip over the next specified number of characters.

Implements utility::io::irstream.

References stream().

izstream& utility::io::izstream::ignore ( std::streamsize const  count,
char const  delim 
)
inlineoverridevirtual

Skip over the next specified number of characters.

Implements utility::io::irstream.

References stream().

bool utility::io::izstream::is_gzip ( ) const
inlineprivate
void utility::io::izstream::open ( std::string const &  filename_a,
std::ios_base::openmode  open_mode = std::ios_base::in 
)
void utility::io::izstream::open_ifstream ( std::string const &  name,
std::ios_base::openmode  open_mode 
)
private

Helper function for opening files with alternative search paths.

References alternative_search_paths_, filename_, if_stream_, basic::options::OptionKeys::in::in, name, platform::file::PATH_SEPARATOR(), and utility::file::trytry_ifstream_open().

Referenced by open().

utility::io::izstream::operator bool ( ) const
inlineoverridevirtual

bool conversion

Implements utility::io::irstream.

References if_stream_, and zip_stream_p_.

utility::io::izstream::operator std::istream & ( )
inlineoverridevirtual

Stream conversion.

Implements utility::io::irstream.

References if_stream_, and zip_stream_p_.

utility::io::izstream::operator std::istream const & ( ) const
inlineoverridevirtual

Stream conversion.

Implements utility::io::irstream.

References if_stream_, and zip_stream_p_.

std::istream const& utility::io::izstream::operator() ( ) const
inlineoverridevirtual

Stream access.

Implements utility::io::irstream.

References if_stream_, and zip_stream_p_.

std::istream& utility::io::izstream::operator() ( )
inlineoverridevirtual

Stream access.

Implements utility::io::irstream.

References if_stream_, and zip_stream_p_.

template<typename T >
std::istream& utility::io::izstream::operator>> ( T &  t)
inline

Stream input.

References stream(), and basic::options::OptionKeys::in::file::t.

std::istream& utility::io::izstream::operator>> ( manipulator  m)
inline

Stream manipulator input.

References test.T110_Numeric::m.

std::istream& utility::io::izstream::operator>> ( std_manipulator  m)
inlineoverridevirtual

Stream manipulator input.

Implements utility::io::irstream.

References test.T110_Numeric::m.

int utility::io::izstream::peek ( )
inlineoverridevirtual

Returns the next character without extracting it.

Implements utility::io::irstream.

References stream().

izstream& utility::io::izstream::putback ( char  c)
inlineoverridevirtual

Put the last character read back into the stream and check that passed character is correct.

Implements utility::io::irstream.

References stream().

std::streambuf* utility::io::izstream::rdbuf ( ) const
inlineoverridevirtual

Pointer to the stream buffer.

Implements utility::io::irstream.

References stream().

izstream& utility::io::izstream::read ( char *  str,
std::streamsize const  count 
)
inlineoverridevirtual

Read the next specified number of characters.

Implements utility::io::irstream.

References stream().

Referenced by numeric::read_tensor_from_file().

izstream& utility::io::izstream::read ( std::string &  str,
std::streamsize const  count 
)
inlineoverridevirtual

Read the next specified number of characters.

Implements utility::io::irstream.

References clean_pdb_keep_ligand::count, basic::options::OptionKeys::cp::cp, and stream().

std::streamsize utility::io::izstream::readsome ( char *  str,
std::streamsize const  count 
)
inlineoverridevirtual

Read the next available specified number of characters.

Implements utility::io::irstream.

References stream().

std::streamsize utility::io::izstream::readsome ( std::string &  str,
std::streamsize const  count 
)
inlineoverridevirtual

Read the next available specified number of characters.

Implements utility::io::irstream.

References clean_pdb_keep_ligand::count, basic::options::OptionKeys::cp::cp, and stream().

void utility::io::izstream::seek_beg ( )
inlineoverridevirtual
static void utility::io::izstream::set_alternative_search_paths ( vector1< std::string >  alternative_search_paths)
inlinestatic
std::istream const& utility::io::izstream::stream ( ) const
inlineoverridevirtual
std::istream& utility::io::izstream::stream ( )
inlineoverridevirtual

Stream access.

Implements utility::io::irstream.

References if_stream_, and zip_stream_p_.

bool utility::io::izstream::uncompressed ( ) const
inlineoverridevirtual

Uncompressed?

Implements utility::io::irstream.

References compression_, and UNCOMPRESSED.

izstream& utility::io::izstream::unget ( )
inlineoverridevirtual

Put the last character read back into the stream.

Implements utility::io::irstream.

References stream().

Friends And Related Function Documentation

long utility::file::gunzip ( std::string const &  compressedfile,
bool  overwrite 
)
friend
long utility::file::gzip ( std::string const &  uncompressedfile,
bool  overwrite 
)
friend

Member Data Documentation

vector1< std::string > utility::io::izstream::alternative_search_paths_
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().

Compression utility::io::izstream::compression_
private

Compression state.

Referenced by close(), compressed(), gzipped(), open(), and uncompressed().

std::string utility::io::izstream::filename_
private

File name.

Referenced by close(), filename(), and open_ifstream().

std::ifstream utility::io::izstream::if_stream_
private
zlib_stream::zip_istream* utility::io::izstream::zip_stream_p_
private

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