16 #ifndef INCLUDED_utility_io_izstream_hh
17 #define INCLUDED_utility_io_izstream_hh
30 #if defined( USE_FILE_PROVIDER )
59 typedef std::istream & (*manipulator)(
izstream & );
60 typedef std::istream & (*std_manipulator)( std::istream & );
73 #if defined( USE_FILE_PROVIDER )
74 ,file_provider_stream( &bad_stream )
84 std::string
const & filename_a,
85 std::ios_base::openmode open_mode = std::ios_base::in
89 #if defined( USE_FILE_PROVIDER )
90 ,file_provider_stream( &bad_stream )
94 open( filename_a, open_mode );
116 #if defined( USE_FILE_PROVIDER )
118 if ( file_provider_stream->good() )
return true;
128 operator std::istream
const &()
const
130 #if defined( USE_FILE_PROVIDER )
132 if ( file_provider_stream->good() ) {
133 return *file_provider_stream;
138 :
static_cast< std::istream
const &
>(
if_stream_ ) );
144 operator std::istream &()
146 #if defined( USE_FILE_PROVIDER )
147 if ( file_provider_stream->good() ) {
148 return *file_provider_stream;
153 :
static_cast< std::istream &
>(
if_stream_ ) );
161 template<
typename T >
194 std::string
const & filename_a,
195 std::ios_base::openmode open_mode = std::ios_base::in
204 #if defined( USE_FILE_PROVIDER )
206 if ( file_provider_stream->good() ) {
207 file_provider_stream->clear();
221 #if defined( USE_FILE_PROVIDER )
223 if ( file_provider_stream->good() ) {
240 #if defined( USE_FILE_PROVIDER )
241 if ( file_provider_stream->good() ) {
242 file_provider_stream->clear();
243 file_provider_stream->seekg( std::ios_base::beg );
244 file_provider_stream->clear();
256 if_stream_.setstate( std::ios_base::failbit );
284 get(
char * str, std::streamsize
const count )
294 get(
char * str, std::streamsize
const count,
char const delim )
304 get( std::string & str, std::streamsize
const count )
306 char * cp =
new char[
count ];
317 get( std::string & str, std::streamsize
const count,
char const delim )
319 char * cp =
new char[
count ];
332 stream().getline( line, count );
342 stream().getline( line, count, delim );
372 stream().read( str, count );
382 char * cp =
new char[
count ];
383 stream().read( cp, count );
395 return stream().readsome( str, count );
404 char * cp =
new char[
count ];
405 std::streamsize
const n_chars =
stream().readsome( cp, count );
437 stream().ignore( count, delim );
480 #if defined( USE_FILE_PROVIDER )
481 if ( file_provider_stream->good() ) {
482 return *file_provider_stream;
487 :
static_cast< std::istream
const &
>(
if_stream_ ) );
496 #if defined( USE_FILE_PROVIDER )
497 if ( file_provider_stream->good() ) {
498 return *file_provider_stream;
503 :
static_cast< std::istream &
>(
if_stream_ ) );
512 #if defined( USE_FILE_PROVIDER )
513 if ( file_provider_stream->good() ) {
514 return *file_provider_stream;
519 :
static_cast< std::istream
const &
>(
if_stream_ ) );
528 #if defined( USE_FILE_PROVIDER )
529 if ( file_provider_stream->good() ) {
530 return *file_provider_stream;
535 :
static_cast< std::istream &
>(
if_stream_ ) );
684 std::string
const &
name,
685 std::ios_base::openmode open_mode);
726 #if defined( USE_FILE_PROVIDER )
727 std::istream *file_provider_stream;
728 std::stringstream bad_stream;
779 #endif // INCLUDED_utility_io_izstream_HH
uLong get_crc() const
returns the uncompressed data crc
std::streambuf * rdbuf() const
Pointer to the stream buffer.
std::istream & stream()
Stream access.
Altered zipstream library header.
izstream & ignore()
Skip over the next character.
std::istream const & stream() const
Stream access.
std::istream &(* std_manipulator)(std::istream &)
static void set_alternative_search_paths(vector1< std::string > alternative_search_paths)
bool compressed() const
Compressed?
izstream & getline(std::string &line, char const delim)
Get the rest of the line.
uLong get_in_size() const
returns the compressed data size
izstream & getline(char *line, std::streamsize const count)
Get the rest of the line.
izstream & putback(char c)
Put the last character read back into the stream and check that passed character is correct...
izstream & ignore(std::streamsize const count)
Skip over the next specified number of characters.
izstream & unget()
Put the last character read back into the stream.
izstream(std::string const &filename_a, std::ios_base::openmode open_mode=std::ios_base::in)
Filename constructor.
izstream & getline(char *line, std::streamsize const count, char const delim)
Get the rest of the line.
Input stream wrapper abstract base class.
long gzip(std::string const &uncompressedfile, bool overwrite)
gzip: file compression
std::istream & skip(izstream &stream)
Skip rest of line and line terminator (manipulator)
bool is_gzip() const
Is stream attached to a gzip file?
std::string filename_
File name.
bool uncompressed() const
Uncompressed?
static vector1< std::string > get_alternative_search_paths()
orstream: Input stream wrapper abstract base class
izstream & ignore(std::streamsize const count, char const delim)
Skip over the next specified number of characters.
bool check_crc() const
CRC of gzip file valid?
std::ifstream if_stream_
File stream.
long get_crc() const
CRC of the uncompressed data (see zipstream documentation)
int peek()
Returns the next character without extracting it.
void close()
Close the ifstream and reset the state.
bool eof() const
End of file?
bool check_crc() const
return crc check result
std::istream & operator>>(T &t)
Stream input.
izstream: Input file stream wrapper for uncompressed and compressed files
bool gzipped() const
gzipped?
void clear()
Clear the stream(s)
izstream & read(char *str, std::streamsize const count)
Read the next specified number of characters.
void open_ifstream(std::string const &name, std::ios_base::openmode open_mode)
Helper function for opening files with alternative search paths.
izstream & getline(izstream &stream, std::string &line)
std::getline( std::istream, std::string ) wrapper
utility::io::izstream forward declarations
long get_in_size() const
Compressed data size.
izstream & getline(izstream &stream, std::string &line, char const delim)
std::getline( std::istream, std::string, char ) wrapper
std::streamsize gcount() const
Get the number of characters read by the last unformatted read.
long gunzip(std::string const &compressedfile, bool overwrite)
gunzip: file decompression
vector1: std::vector with 1-based indexing
bool is_gzip() const
returns true if it is a gzip file
izstream & read(std::string &str, std::streamsize const count)
Read the next specified number of characters.
long get_out_size() const
Uncompressed data size.
izstream()
Default constructor.
std::streamsize readsome(char *str, std::streamsize const count)
Read the next available specified number of characters.
std::string const & filename() const
File name.
rule< Scanner, string_closure::context_t > name
void seek_beg()
Seek to the beginning.
std::istream &(* manipulator)(izstream &)
static vector1< std::string > alternative_search_paths_
Alternative search paths This initialized by the option system -in:path:path Notice that izstream can...
void open(std::string const &filename_a, std::ios_base::openmode open_mode=std::ios_base::in)
Open a file.
izstream & getline(std::string &line)
Get the rest of the line.
zlib_stream::zip_istream * zip_stream_p_
Zip file stream pointer (owning)
basic_zip_istream< char > zip_istream
Compression compression_
Compression state.
std::streamsize readsome(std::string &str, std::streamsize const count)
Read the next available specified number of characters.
uLong get_out_size() const
returns the uncompressed data size
virtual ~izstream()
Destructor.
std::istream const & operator()() const
Stream access.