20 #ifndef __BYTEBUFFER_INC__
21 #define __BYTEBUFFER_INC__
28 #include <libbbb/libbbb.h>
57 # define BYTEBUFFER_INCREASE_STEP 256
126 inline bool isValid (
void )
const
127 {
return ( err_ ==
false ); }
133 inline bool isEmpty (
void )
const
134 {
return ( used_ == 0 ); }
140 inline unsigned allocated (
void )
const
147 inline unsigned size (
void )
const
154 inline unsigned count (
void )
const
161 inline unsigned lenght (
void )
const
168 inline void seek ( quint64 loc )
169 { iterator_ = loc;
if ( iterator_ > used_ ) iterator_ = 0; }
175 inline quint64 position (
void )
const
176 {
return iterator_; }
188 bool reinitFromFile ( QFile & file );
194 bool saveToFile ( QFile & file );
200 unsigned getRaw (
unsigned bytes )
202 char * ret = (
char *)reserve( bytes );
203 if ( ret == NULL )
return 0;
218 inline void append (
int new_val )
220 qint64 * loc = (qint64*)reserve(
sizeof(qint64) );
221 if ( loc == NULL )
return;
229 inline void append (
unsigned new_val )
231 quint64 * loc = (quint64*)reserve(
sizeof(quint64) );
232 if ( loc == NULL )
return;
240 inline void append ( quint64 new_val )
242 quint64 * loc = (quint64*)reserve(
sizeof(quint64) );
243 if ( loc == NULL )
return;
251 inline void append ( qint64 new_val )
253 qint64 * loc = (qint64*)reserve(
sizeof(qint64) );
254 if ( loc == NULL )
return;
262 inline void append (
bool new_val )
264 quint64 * loc = (quint64*)reserve(
sizeof(quint64) );
265 if ( loc == NULL )
return;
273 inline void append (
double new_val )
275 double * loc = (
double*)reserve(
sizeof(
double) );
276 if ( loc == NULL )
return;
284 void append (
const QString & new_val );
291 const char * new_val,
293 bool uncounted =
false
311 bool getValue (
bool & out_val, quint64 offset );
322 quint64 getValue (
char * out_val,
int max_buf, quint64 offset );
332 bool getValue ( quint64 offset,
int count,
char * out_val );
343 bool getValue (
char ** out_val, quint64 offset );
350 bool getValue (
double & out_val, quint64 offset );
357 bool getValue (
int & out_val, quint64 offset );
364 bool getValue ( qint64 & out_val, quint64 offset );
373 bool getValue ( QString & out_val, quint64 offset );
380 bool getValue ( quint64 & out_val, quint64 offset );
387 bool getValue (
unsigned & out_val, quint64 offset );
404 inline bool getValue (
int & out_val )
405 {
return getValue( out_val, iterator_ ); }
412 inline bool getValue (
unsigned & out_val )
413 {
return getValue( out_val, iterator_ ); }
420 inline bool getValue ( qint64 & out_val )
421 {
return getValue( out_val, iterator_ ); }
428 inline bool getValue ( quint64 & out_val )
429 {
return getValue( out_val, iterator_ ); }
436 inline bool getValue (
bool & out_val )
437 {
return getValue( out_val, iterator_ ); }
444 inline bool getValue (
double & out_val )
445 {
return getValue( out_val, iterator_ ); }
454 inline bool getValue ( QString & out_val )
455 {
return getValue( out_val, iterator_ ); }
466 inline bool getValue (
char ** out_val )
467 {
return getValue( out_val, iterator_ ); }
478 inline quint64 getValue (
char * out_val,
int max_buf )
479 {
return getValue( out_val, max_buf, iterator_ ); }
489 inline bool getValue (
int count,
char * out_buf )
490 {
return getValue( iterator_, count, out_buf ); }
500 inline bool readUncountedBytes (
int count,
char * out_buf )
501 {
return getValue( iterator_, count, out_buf ); }
516 void * reserve (
unsigned bytes );
522 inline void markError (
void )
523 { Q_ASSERT(
false ); err_ =
true; }
529 inline void markErrorFree (
void )
553 #endif // __BYTEBUFFER_INC__