////////////////////////////////////////////////////////////////////////////////
// MechWarrior3Reader.h
// reader.zbd parser - todo: does not work yet, incomplete, work in progress
// maybe too difficult to justify the minor gain of functionality?
// Copyright Bjoern Ganster
// Developed since 2007

#ifndef MechWarrior3Reader__H
#define MechWarrior3Reader__H

#include "Archive.h"
#include "XMLTree.h"

#include <iostream>

class MW3ReaderZbdArchive : public MWArchive {
public:
	// Constructor
	MW3ReaderZbdArchive();

	// Destructor
	~MW3ReaderZbdArchive() OVERRIDE;

	// Open file
	bool open(const PathChar* PRJFN, bool readOnly = true) OVERRIDE;

	// Close file
	void close() OVERRIDE;

	// Read bufSize bytes from file numbered index at offset into buf
	bool getFileChunk(size_t index, size_t offset, void* buf, size_t bufSize) OVERRIDE;

	// Export MW3 zreader archive as XML (recursive part)
	void exportMW3ZReaderAsXmlRec(size_t& offset, XMLTreeIterator& xmlIter, int rescursions);

protected:
	MemoryBlock mMb;

	// Read values for a key
	void readValues(size_t& offset, XMLTreeIterator& xmlIter, size_t argCount);

	// Read a list of values
	void readList(size_t& offset, XMLTreeIterator& xmlIter, size_t argNo);
};

#endif
