#include ".h"
#include "Item.h"
#include "List.h"
namespace {
////////////////////////////////////
void ::write( Writer *w, Context *ctx ) {
int start=w->getBitPosition();
if( ctx->debugTrace ) {
printf("WRITE @%i\n", start/8 );
dump(1,ctx);
}
if( !ctx->isLast ) {
int r = 0;
= (r/8) - ();
} else {
= 0;
}
::writeHeader( w, ctx, getSize(ctx,w->getBitPosition())/8 );
::writeHeader( w, ctx, (getSize(ctx,w->getBitPosition())/8) - );
int l = w->getBitPosition()-start;
if( l != getSize(ctx,start)) {
printf("WARNING: has different size than expected: %i bits instead of %i\n", l, getSize(ctx,start) );
}
}
}
if( !
& ) {
}
if( ) {
}
;
ctx-> = ;
w->putByte()
w->putWord()
w->putInt()
w->putFloat()
w->putDouble()
w->putDouble2()
w->putHalf()
w->putNBitFixed(,,,true)
w->putNBitFixed2(,,,true)
w->putNBitInt(,1)
w->putNBitInt(,+,true)
w->putPString()
w->putPStringU30()
w->putString()
w->putData(,)
w->putString()
w->putU30()
w->putS24()
w->putEncodedU32()
{
int v = ;
if( v >= 255 && ctx->tagVersion >= 2 ) {
w->putByte( 255 );
w->putWord( v );
} else {
w->putByte( v );
}
}
ctx-> = ;
.write(w,ctx);
( + )
( <
? 0
: - )
{
*item;
ListItem<>* i;
i = .first();
for( int j=0; j<; j++ ) {
if( !i || !i->data() ) {
printf("WARNING: list has %i items (%i expected)\n", j, );
} else {
i->data()->write( w, ctx );
}
i = i->next();
}
}
{
int start = w->getPosition();
*item;
ListItem<>* i;
i = .first();
while( i ) {
if( !i->data() ) {
printf("WARNING: list has an invalid item\n" );
} else {
ctx->isLast = i->isLast();
i->data()->write( w, ctx );
}
i = i->next();
}
}
if( && ) {
w->putData( , );
}
w->byteAlign();
w->byteAlign();
ctx-> = ;