Turi Create  4.0
turi::fileio_impl::general_fstream_sink Class Reference

#include <core/storage/fileio/general_fstream_sink.hpp>

Public Member Functions

 general_fstream_sink (std::string file)
 
 general_fstream_sink (std::string file, bool gzip_compressed)
 
 general_fstream_sink (const general_fstream_sink &)=default
 
 general_fstream_sink (general_fstream_sink &&)=default
 
 ~general_fstream_sink ()
 Destructor. Closes the file.
 
bool is_open () const
 
std::streamsize write (const char *c, std::streamsize bufsize)
 
void close ()
 
bool good () const
 
bool bad () const
 
bool fail () const
 
size_t get_bytes_written () const
 

Detailed Description

Implements a general file stream sink device which wraps the union_fstream, and provides automatic gzip decompression capabilities.

The general_fstream_sink is NOT thread-safe.

Definition at line 26 of file general_fstream_sink.hpp.

Constructor & Destructor Documentation

◆ general_fstream_sink() [1/4]

turi::fileio_impl::general_fstream_sink::general_fstream_sink ( std::string  file)
explicit

Constructs a fstream sink which write to a file. This file can be of any protocol supported by the union_fstream, and may also be gzip compressed. Gzip compression detection is automatic based on the file extension. (Whether it ends in .gz)

◆ general_fstream_sink() [2/4]

turi::fileio_impl::general_fstream_sink::general_fstream_sink ( std::string  file,
bool  gzip_compressed 
)

Constructs a fstream sink which writes to a file. This file can be of any protocol supported by the union_fstream, and may also be gzip compressed. Gzip compression detection is not performed, and the gzip_compressed flag is used to enable/disable gzip decompression.

◆ general_fstream_sink() [3/4]

turi::fileio_impl::general_fstream_sink::general_fstream_sink ( const general_fstream_sink )
default

Default copy constructor. copied object shares handles with the original object. Required because boost streams requires devices to be copyable. This should really not be used otherwise.

◆ general_fstream_sink() [4/4]

turi::fileio_impl::general_fstream_sink::general_fstream_sink ( general_fstream_sink &&  )
default

Default move constructor

Member Function Documentation

◆ bad()

bool turi::fileio_impl::general_fstream_sink::bad ( ) const

Returns true if the stream is bad. See std::ios_base

◆ close()

void turi::fileio_impl::general_fstream_sink::close ( )

Closes all file handles

◆ fail()

bool turi::fileio_impl::general_fstream_sink::fail ( ) const

Returns true if a stream operation failed. See std::ios_base

◆ get_bytes_written()

size_t turi::fileio_impl::general_fstream_sink::get_bytes_written ( ) const

Returns the number of physical bytes written so far. This is an estimate, especially if the file is gzip compressed. Returns (size_t)(-1) if there is no file opened.

◆ good()

bool turi::fileio_impl::general_fstream_sink::good ( ) const

Returns true if the stream is good. See std::ios_base

◆ is_open()

bool turi::fileio_impl::general_fstream_sink::is_open ( ) const

Returns true if the file is opened

◆ write()

std::streamsize turi::fileio_impl::general_fstream_sink::write ( const char *  c,
std::streamsize  bufsize 
)

Attempts to write bufsize bytes into the stream from the buffer. Returns the actual number of bytes read. Returns -1 on failure.


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