29 #include "../my_config.h" 44 class crc :
public on_pool
47 static const U_I OLD_CRC_SIZE = 2;
49 virtual ~crc() throw(Ebug) {};
51 virtual bool operator == (
const crc & ref)
const = 0;
52 bool operator != (
const crc & ref)
const {
return ! (*
this == ref); };
54 virtual void compute(
const infinint & offset,
const char *buffer, U_I length) = 0;
55 virtual void compute(
const char *buffer, U_I length) = 0;
56 virtual void clear() = 0;
57 virtual void dump(generic_file & f)
const = 0;
58 virtual std::string crc2str()
const = 0;
59 virtual infinint get_size()
const = 0;
60 virtual crc *clone()
const = 0;
63 extern crc *create_crc_from_file(generic_file & f, memory_pool *pool,
bool old =
false);
64 extern crc *create_crc_from_size(infinint width, memory_pool *pool);
66 class crc_i :
public crc
69 crc_i(
const infinint & width);
70 crc_i(
const infinint & width, generic_file & f);
71 crc_i(
const crc_i & ref) : size(ref.size), cyclic(ref.size) { copy_data_from(ref); pointer = cyclic.begin(); };
72 const crc_i & operator = (
const crc_i & ref) { copy_from(ref);
return *
this; };
74 bool operator == (
const crc & ref)
const;
76 void compute(
const infinint & offset,
const char *buffer, U_I length);
77 void compute(
const char *buffer, U_I length);
79 void dump(generic_file & f)
const;
80 std::string crc2str()
const;
81 infinint get_size()
const {
return size; };
84 crc *clone()
const {
return new (get_pool()) crc_i(*
this); };
89 storage::iterator pointer;
92 void copy_from(
const crc_i & ref);
93 void copy_data_from(
const crc_i & ref);
97 class crc_n :
public crc
102 crc_n(U_I width, generic_file & f);
103 crc_n(
const crc_n & ref) { copy_from(ref); };
104 const crc_n & operator = (
const crc_n & ref);
105 ~crc_n() { destroy(); };
107 bool operator == (
const crc & ref)
const;
109 void compute(
const infinint & offset,
const char *buffer, U_I length);
110 void compute(
const char *buffer, U_I length);
112 void dump(generic_file & f)
const;
113 std::string crc2str()
const;
114 infinint get_size()
const {
return size; };
117 crc *clone()
const {
return new (get_pool()) crc_n(*
this); };
122 unsigned char *pointer;
123 unsigned char *cyclic;
125 void alloc(U_I width);
126 void copy_from(
const crc_n & ref);
127 void copy_data_from(
const crc_n & ref);
are defined here basic integer types that tend to be portable
contains a class that permits arbitrary large data storage
switch module to limitint (32 ou 64 bits integers) or infinint
this is the base class of object that can be allocated on a memory pool
libdar namespace encapsulate all libdar symbols