29 #include "../my_config.h" 49 static constexpr U_I OLD_CRC_SIZE = 2;
52 crc(
const crc & ref) =
default;
53 crc(
crc && ref) noexcept =
default;
54 crc & operator = (
const crc & ref) =
default;
55 crc & operator = (
crc && ref) noexcept =
default;
56 virtual ~
crc() =
default;
58 virtual bool operator == (
const crc & ref)
const = 0;
59 bool operator != (
const crc & ref)
const {
return ! (*
this == ref); };
61 virtual void compute(
const infinint & offset,
const char *buffer, U_I length) = 0;
62 virtual void compute(
const char *buffer, U_I length) = 0;
63 virtual void clear() = 0;
65 virtual std::string crc2str()
const = 0;
66 virtual infinint get_size()
const = 0;
67 virtual crc *clone()
const = 0;
83 crc_i(
const crc_i & ref) : size(ref.
size), cyclic(ref.
size) { copy_data_from(ref); pointer = cyclic.begin(); };
85 crc_i & operator = (
const crc_i & ref) { copy_from(ref);
return *
this; };
86 crc_i & operator = (
crc_i && ref) noexcept =
default;
89 bool operator == (
const crc & ref)
const;
91 virtual void compute(
const infinint & offset,
const char *buffer, U_I length)
override;
92 virtual void compute(
const char *buffer, U_I length)
override;
93 virtual void clear()
override;
95 virtual std::string crc2str()
const override;
96 virtual infinint get_size()
const override {
return size; };
99 virtual crc *clone()
const override {
crc *tmp =
new (std::nothrow)
crc_i(*
this);
if(tmp ==
nullptr)
throw Ememory(
"crc");
return tmp; };
107 void copy_from(
const crc_i & ref);
108 void copy_data_from(
const crc_i & ref);
123 crc_n & operator = (
crc_n && ref) noexcept =
default;
124 ~
crc_n() { destroy(); };
126 bool operator == (
const crc & ref)
const;
128 virtual void compute(
const infinint & offset,
const char *buffer, U_I length)
override;
129 virtual void compute(
const char *buffer, U_I length)
override;
130 virtual void clear()
override;
132 virtual std::string crc2str()
const override;
133 virtual infinint get_size()
const override {
return size; };
136 virtual crc *clone()
const override {
crc *tmp =
new (std::nothrow)
crc_n(*
this);
if(tmp ==
nullptr)
throw Ememory(
"crc");
return tmp; };
144 void alloc(U_I width);
145 void copy_from(
const crc_n & ref);
146 void copy_data_from(
const crc_n & ref);
are defined here basic integer types that tend to be portable
crc implementation based on U_I
ancestor class of generic_file
storage cyclic
the checksum storage
storage::iterator pointer
points to the next byte to modify
precursor class of generic_file used to avoid cyclic dependencies with storage and infinint ...
contains a class that permits arbitrary large data storage
crc * create_crc_from_size(infinint width)
generate a CRC object with adhoc width based on a file size
infinint size
size of the checksum
unsigned char * cyclic
the checksum storage (non infinint mode)
exception used when memory has been exhausted
crc implementation based on infinint
arbitrary large storage structure
crc * create_crc_from_file(proto_generic_file &f, bool old=false)
generate a CRC object reading it from file
switch module to limitint (32 ou 64 bits integers) or infinint
U_I size
size of checksum (non infinint mode)
the arbitrary large positive integer class
pure virtual class defining interface of a CRC object
unsigned char * pointer
points to the next byte to modify (non infinint mode)
libdar namespace encapsulate all libdar symbols