void LogSequence2::save(std::ostream & out)
{
	CRC8 crch;
	CRC32 crcd;
	unsigned char data[9];
	unsigned int len;

	// Write type
	uint8_t type = TYPE_SEQLOG;
	crch.writeData(out, &type, sizeof(uint8_t));

	// Write numbits
	crch.writeData(out, &numbits, sizeof(numbits));

	// Write numentries
	len=csd::VByte::encode(data, numentries);
	crch.writeData(out, data, len);

	// Write Header CRC
	crch.writeCRC(out);

	// Write data
	size_t numbytes = numBytesFor(numbits, numentries);
	crcd.writeData(out, (unsigned char*)&array[0], numbytes);

	// Write Data CRC
	crcd.writeCRC(out);
}
Exemple #2
0
void CSD_PFC::save(ostream &out)
{
	CRC8 crch;
	CRC32 crcd;
	unsigned char buf[27]; // 9 bytes per VByte (max) * 3 values.

	// Save type
	crch.writeData(out, (unsigned char *)&type, sizeof(type));

	// Save sizes
	uint8_t pos = 0;
	pos += VByte::encode(&buf[pos], numstrings);
	pos += VByte::encode(&buf[pos], bytes);
	pos += VByte::encode(&buf[pos], blocksize);

	crch.writeData(out, buf, pos);
	crch.writeCRC(out);

	// Write block pointers
	if(!blocks) {
		hdt::LogSequence2 log;
		log.save(out);
	} else {
		blocks->save(out);
	}

	// Write packed data
	if(text) {
		crcd.writeData(out, text, bytes);
	} else {
		assert(numstrings==0);
		assert(bytes==0);
	}
	crcd.writeCRC(out);
}