37 #ifndef GENERIC_FILE_HPP
38 #define GENERIC_FILE_HPP
40 #include "../my_config.h"
80 generic_file(
gf_mode m) { rw = m; terminated = no_read_ahead =
false; enable_crc(
false); checksum =
nullptr; };
106 bool operator != (
generic_file & ref) {
return ! (*
this == ref); };
126 virtual U_I
read(
char *a, U_I size)
override;
129 virtual void write(
const char *a, U_I size)
override;
134 void write(
const std::string & arg);
143 enum skippability { skip_backward, skip_forward };
151 virtual bool skippable(skippability direction,
const infinint & amount) = 0;
158 virtual bool skip(
const infinint & pos) = 0;
168 virtual bool truncatable(
const infinint & pos)
const = 0;
183 virtual void truncate(
const infinint & pos);
218 const infinint & me_read_ahead,
219 const infinint & you_read_ahead,
220 const infinint & crc_size,
236 const infinint & me_read_ahead,
237 const infinint & you_read_ahead,
238 const infinint & crc_size,
240 infinint & err_offset);
248 bool crc_status()
const {
return active_read == &generic_file::read_crc; };
265 void set_mode(
gf_mode x) { rw = x; };
335 void (
generic_file::* active_write)(
const char *a, U_I size);
337 void enable_crc(
bool mode);
339 U_I read_crc(
char *a, U_I size);
340 void write_crc(
const char *a, U_I size);
342 void nullifyptr() noexcept { checksum =
nullptr; };
generic modes to open file
virtual void inherited_write(const char *a, U_I size)=0
implementation of the write() operation
are defined here basic integer types that tend to be portable
virtual void truncate(const infinint &pos)
truncate file at the given offset
virtual void write(const char *a, U_I size) override
write data to the generic_file inherited from proto_generic_file
class crc definition, used to handle Cyclic Redundancy Checks
bool diff(generic_file &f, const infinint &me_read_ahead, const infinint &you_read_ahead, const infinint &crc_size, crc *&value)
compares the contents with the object in argument
ancestor class of generic_file
generic_file(const generic_file &ref)
copy constructor
bool operator==(generic_file &ref)
void flush_read()
be ready to read at current position, reseting all pending data for reading, cached and in compressio...
virtual bool truncatable(const infinint &pos) const =0
whether the implementation is able to truncate to the given position
virtual bool skip(const infinint &pos)=0
skip at the absolute position
precursor class of generic_file used to avoid cyclic dependencies with storage and infinint ...
void ignore_read_ahead(bool mode)
virtual void inherited_flush_read()=0
reset internal engine, flush caches in order to read the data at current position ...
gf_mode
generic_file openning modes
S_I read_back(char &a)
skip back one char, read on char and skip back one char
~generic_file() noexcept(false)
virtual destructor,
virtual bool skip_relative(S_I x)=0
skip relatively to the current position
bool is_terminated() const
crc * get_crc()
get CRC of the transfered date since last reset
virtual void inherited_sync_write()=0
write down any pending data
generic_file & operator=(const generic_file &ref)
assignment operator
void read_ahead(const infinint &amount)
generic_file(generic_file &&ref) noexcept
move constructor
generic_file(gf_mode m)
main constructor
virtual U_I read(char *a, U_I size) override
read data from the generic_file inherited from proto_generic_file
virtual void inherited_terminate()=0
destructor-like call, except that it is allowed to throw exceptions
gf_mode get_mode() const
retreive the openning mode for this object
switch module to limitint (32 ou 64 bits integers) or infinint
virtual void inherited_truncate(const infinint &pos)=0
truncate file at the give offset
virtual U_I inherited_read(char *a, U_I size)=0
implementation of read() operation
bool crc_status() const
to known whether CRC calculation is activated or not
virtual void inherited_read_ahead(const infinint &amount)=0
tells the object that several calls to read() will follow to probably obtain at least the given amoun...
virtual infinint get_position() const =0
get the current read/write position
this is the interface class from which all other data transfer classes inherit
virtual void copy_to(generic_file &ref)
copy all data from current position to the object in argument
void sync_write()
write any pending data
void reset_crc(const infinint &width)
reset CRC on read or writen data
the arbitrary large positive integer class
pure virtual class defining interface of a CRC object
virtual bool skip_to_eof()=0
skip to the end of file
void terminate()
destructor-like call, except that it is allowed to throw exceptions
libdar namespace encapsulate all libdar symbols
virtual bool skippable(skippability direction, const infinint &amount)=0
whether the implementation is able to skip
S_I read_forward(char &a)
read one char