29 #include "../my_config.h"
65 cellule() : next(NULL), prev(NULL), data(NULL), size(0) {};
66 struct cellule *next, *prev;
73 { make_alloc(size, first, last); };
82 {
detruit(first); copy_from(val);
return *
this; };
84 bool operator < (
const storage & ref)
const
85 {
return difference(ref) < 0; };
86 bool operator == (
const storage & ref)
const
87 {
return difference(ref) == 0; };
88 bool operator > (
const storage & ref)
const
89 {
return difference(ref) > 0; };
90 bool operator <= (
const storage & ref)
const
91 {
return difference(ref) <= 0; };
92 bool operator >= (
const storage & ref)
const
93 {
return difference(ref) >= 0; };
94 bool operator != (
const storage & ref)
const
95 {
return difference(ref) != 0; };
96 unsigned char & operator [](
infinint position);
97 unsigned char operator [](
const infinint & position)
const;
99 void clear(
unsigned char val = 0);
105 iterator() : ref(NULL), cell(NULL), offset(0) {};
110 iterator operator ++ (S_I x)
111 { iterator ret = *
this; skip_plus_one();
return ret; };
112 iterator operator -- (S_I x)
113 { iterator ret = *
this; skip_less_one();
return ret; };
114 iterator & operator ++ ()
115 { skip_plus_one();
return *
this; };
116 iterator & operator -- ()
117 { skip_less_one();
return *
this; };
118 iterator operator + (U_32 s)
const
119 { iterator ret = *
this; ret += s;
return ret; };
120 iterator operator - (U_32 s)
const
121 { iterator ret = *
this; ret -= s;
return ret; };
123 iterator & operator -= (U_32 s);
124 unsigned char &operator *()
const;
129 bool operator == (
const iterator & cmp)
const
130 {
return ref == cmp.ref && cell == cmp.cell && offset == cmp.offset; };
131 bool operator != (
const iterator & cmp)
const
132 {
return ! (*
this == cmp); };
135 static const U_32 OFF_BEGIN = 1;
136 static const U_32 OFF_END = 2;
139 struct cellule *cell;
142 void relative_skip_to(S_32 val);
143 bool points_on_data()
const
144 {
return ref != NULL && cell != NULL && offset < cell->size; };
146 inline void skip_plus_one();
147 inline void skip_less_one();
154 iterator begin()
const
155 { iterator ret; ret.cell = first;
if(ret.cell != NULL) ret.offset = 0;
else ret.offset = iterator::OFF_END; ret.ref =
this;
return ret; };
157 { iterator ret; ret.cell = NULL; ret.offset = iterator::OFF_END; ret.ref =
this;
return ret; };
163 iterator rbegin()
const
164 { iterator ret; ret.cell = last; ret.offset = last != NULL ? last->size-1 : 0; ret.ref =
this;
return ret; };
165 iterator rend()
const
166 { iterator ret; ret.cell = NULL, ret.offset = iterator::OFF_BEGIN; ret.ref =
this;
return ret; };
173 U_I
write(iterator & it,
unsigned char *a, U_I size);
174 U_I read(iterator & it,
unsigned char *a, U_I size)
const;
175 bool write(iterator & it,
unsigned char a)
176 {
return write(it, &a, 1) == 1; };
177 bool read(iterator & it,
unsigned char &a)
const
178 {
return read(it, &a, 1) == 1; };
181 void insert_null_bytes_at_iterator(iterator it, U_I size);
182 void insert_const_bytes_at_iterator(iterator it,
unsigned char a, U_I size);
183 void insert_bytes_at_iterator(iterator it,
unsigned char *a, U_I size);
184 void insert_as_much_as_necessary_const_byte_to_be_as_wider_as(
const storage & ref,
const iterator & it,
unsigned char value);
185 void remove_bytes_at_iterator(iterator it, U_I number);
186 void remove_bytes_at_iterator(iterator it,
infinint number);
188 #ifdef LIBDAR_SPECIAL_ALLOC
192 struct cellule *first, *last;
194 void copy_from(
const storage & ref);
195 S_32 difference(
const storage & ref)
const;
197 void insert_bytes_at_iterator_cmn(iterator it,
bool constant,
unsigned char *a, U_I size);
198 void fusionne(
struct cellule *a_first,
struct cellule *a_last,
struct cellule *b_first,
struct cellule *b_last,
199 struct cellule *&res_first,
struct cellule * & res_last);
205 static void detruit(
struct cellule *c);
206 static void make_alloc(U_32 size,
struct cellule * & begin,
struct cellule * & end);
207 static void make_alloc(
infinint size, cellule * & begin,
struct cellule * & end);
209 friend class storage::iterator;
212 inline void storage::iterator::skip_plus_one()
215 if(++offset >= cell->size)
225 inline void storage::iterator::skip_less_one()
235 offset = cell->size - 1;