32 #include "../my_config.h"
50 static const U_I OLD_CRC_SIZE = 2;
54 virtual bool operator == (
const crc & ref)
const = 0;
55 bool operator != (
const crc & ref)
const {
return ! (*
this == ref); };
57 virtual void compute(
const infinint & offset,
const char *buffer, U_I length) = 0;
58 virtual void compute(
const char *buffer, U_I length) = 0;
59 virtual void clear() = 0;
60 virtual void dump(generic_file & f)
const = 0;
61 virtual std::string crc2str()
const = 0;
62 virtual infinint get_size()
const = 0;
63 virtual crc *clone()
const = 0;
66 extern crc *create_crc_from_file(generic_file & f,
bool old =
false);
67 extern crc *create_crc_from_size(infinint width);
69 class crc_i :
public crc
72 crc_i(
const infinint & width);
73 crc_i(
const infinint & width, generic_file & f);
74 crc_i(
const crc_i & ref) : size(ref.size), cyclic(ref.size) { copy_data_from(ref); pointer = cyclic.begin(); };
75 const crc_i & operator = (
const crc_i & ref) { copy_from(ref);
return *
this; };
77 bool operator == (
const crc & ref)
const;
79 void compute(
const infinint & offset,
const char *buffer, U_I length);
80 void compute(
const char *buffer, U_I length);
82 void dump(generic_file & f)
const;
83 std::string crc2str()
const;
84 infinint get_size()
const {
return size; };
86 #ifdef LIBDAR_SPECIAL_ALLOC
87 USE_SPECIAL_ALLOC(crc_i);
92 crc *clone()
const {
return new crc_i(*
this); };
97 storage::iterator pointer;
100 void copy_from(
const crc_i & ref);
101 void copy_data_from(
const crc_i & ref);
105 class crc_n :
public crc
110 crc_n(U_I width, generic_file & f);
111 crc_n(
const crc_n & ref) { copy_from(ref); };
112 const crc_n & operator = (
const crc_n & ref);
113 ~crc_n() { destroy(); };
115 bool operator == (
const crc & ref)
const;
117 void compute(
const infinint & offset,
const char *buffer, U_I length);
118 void compute(
const char *buffer, U_I length);
120 void dump(generic_file & f)
const;
121 std::string crc2str()
const;
122 infinint get_size()
const {
return size; };
124 #ifdef LIBDAR_SPECIAL_ALLOC
125 USE_SPECIAL_ALLOC(crc_n);
129 crc *clone()
const {
return new crc_n(*
this); };
134 unsigned char *pointer;
135 unsigned char *cyclic;
137 void alloc(U_I width);
138 void copy_from(
const crc_n & ref);
139 void copy_data_from(
const crc_n & ref);