26 #include "../my_config.h"
62 cellule() : next(NULL), prev(NULL), data(NULL), size(0) {};
63 struct cellule *next, *prev;
70 { make_alloc(size, first, last); };
79 {
detruit(first); copy_from(val);
return *
this; };
81 bool operator < (
const storage & ref)
const
82 {
return difference(ref) < 0; };
83 bool operator == (
const storage & ref)
const
84 {
return difference(ref) == 0; };
85 bool operator > (
const storage & ref)
const
86 {
return difference(ref) > 0; };
87 bool operator <= (
const storage & ref)
const
88 {
return difference(ref) <= 0; };
89 bool operator >= (
const storage & ref)
const
90 {
return difference(ref) >= 0; };
91 bool operator != (
const storage & ref)
const
92 {
return difference(ref) != 0; };
93 unsigned char & operator [](
infinint position);
94 unsigned char operator [](
const infinint & position)
const;
96 void clear(
unsigned char val = 0);
102 iterator() : ref(NULL), cell(NULL), offset(0) {};
107 iterator operator ++ (S_I x)
108 { iterator ret = *
this; skip_plus_one();
return ret; };
109 iterator operator -- (S_I x)
110 { iterator ret = *
this; skip_less_one();
return ret; };
111 iterator & operator ++ ()
112 { skip_plus_one();
return *
this; };
113 iterator & operator -- ()
114 { skip_less_one();
return *
this; };
115 iterator operator + (U_32 s)
const
116 { iterator ret = *
this; ret += s;
return ret; };
117 iterator operator - (U_32 s)
const
118 { iterator ret = *
this; ret -= s;
return ret; };
120 iterator & operator -= (U_32 s);
121 unsigned char &operator *()
const;
126 bool operator == (
const iterator & cmp)
const
127 {
return ref == cmp.ref && cell == cmp.cell && offset == cmp.offset; };
128 bool operator != (
const iterator & cmp)
const
129 {
return ! (*
this == cmp); };
132 static const U_32 OFF_BEGIN = 1;
133 static const U_32 OFF_END = 2;
136 struct cellule *cell;
139 void relative_skip_to(S_32 val);
140 bool points_on_data()
const
141 {
return ref != NULL && cell != NULL && offset < cell->size; };
143 inline void skip_plus_one();
144 inline void skip_less_one();
151 iterator begin()
const
152 { iterator ret; ret.cell = first;
if(ret.cell != NULL) ret.offset = 0;
else ret.offset = iterator::OFF_END; ret.ref =
this;
return ret; };
154 { iterator ret; ret.cell = NULL; ret.offset = iterator::OFF_END; ret.ref =
this;
return ret; };
160 iterator rbegin()
const
161 { iterator ret; ret.cell = last; ret.offset = last != NULL ? last->size-1 : 0; ret.ref =
this;
return ret; };
162 iterator rend()
const
163 { iterator ret; ret.cell = NULL, ret.offset = iterator::OFF_BEGIN; ret.ref =
this;
return ret; };
170 U_I
write(iterator & it,
unsigned char *a, U_I size);
171 U_I read(iterator & it,
unsigned char *a, U_I size)
const;
172 bool write(iterator & it,
unsigned char a)
173 {
return write(it, &a, 1) == 1; };
174 bool read(iterator & it,
unsigned char &a)
const
175 {
return read(it, &a, 1) == 1; };
178 void insert_null_bytes_at_iterator(iterator it, U_I size);
179 void insert_const_bytes_at_iterator(iterator it,
unsigned char a, U_I size);
180 void insert_bytes_at_iterator(iterator it,
unsigned char *a, U_I size);
181 void insert_as_much_as_necessary_const_byte_to_be_as_wider_as(
const storage & ref,
const iterator & it,
unsigned char value);
182 void remove_bytes_at_iterator(iterator it, U_I number);
183 void remove_bytes_at_iterator(iterator it,
infinint number);
185 #ifdef LIBDAR_SPECIAL_ALLOC
189 struct cellule *first, *last;
191 void copy_from(
const storage & ref);
192 S_32 difference(
const storage & ref)
const;
194 void insert_bytes_at_iterator_cmn(iterator it,
bool constant,
unsigned char *a, U_I size);
195 void fusionne(
struct cellule *a_first,
struct cellule *a_last,
struct cellule *b_first,
struct cellule *b_last,
196 struct cellule *&res_first,
struct cellule * & res_last);
202 static void detruit(
struct cellule *c);
203 static void make_alloc(U_32 size,
struct cellule * & begin,
struct cellule * & end);
204 static void make_alloc(
infinint size, cellule * & begin,
struct cellule * & end);
206 friend class storage::iterator;
209 inline void storage::iterator::skip_plus_one()
212 if(++offset >= cell->size)
222 inline void storage::iterator::skip_less_one()
232 offset = cell->size - 1;
are defined here basic integer types that tend to be portable
U_I write(iterator &it, unsigned char *a, U_I size)
write data to the storage at the location pointed to by it
re-definition of new and delete class operatorthis is a set of macro that makes the new and delete op...
arbitrary large storage structure
contains all the excetion class thrown by libdar
switch module to limitint (32 ou 64 bits integers) or infinint
this is the interface class from which all other data transfer classes inherit
the arbitrary large positive integer class
libdar namespace encapsulate all libdar symbols