#include <z_file.hpp>

class SubTable
{
public:

	SubTable(ZafUInt16 initialValue, ZafUInt8 position, bool isUni);

	void AddMapping(ZafUInt16 value, ZafUInt8 position);

	void WriteData(ZafFile *file);
protected:
	bool isUni;
	ZafUInt16 mapping[256];
	ZafUInt8 minValue;
	ZafUInt8 maxValue;
};

struct ZafLeadinEntry
{
	ZafUInt8 minValue, maxValue;
};

class Mapping
{
public:
	Mapping();

	void AddMapping(ZafUInt16 codeMap, ZafUInt16 uniMap);
	void AddLeadin(ZafUInt8 leadByte);
//	void ChangeMapping(ZafUInt16 codeMap, ZafUInt16 uniMap);
	int PageNum(ZafUInt16 value);

	void Save(ZafFileSystem	*fileSystem);
	void SetUnicode(bool isUni);
protected:
	SubTable *localToUnicode[256];
	SubTable *unicodeToLocal[256];

	ZafLeadinEntry leadin[20];
	int noOfLeadins;

	ZafIChar *toLocal;
	ZafIChar *localTo;
	ZafNumberID numID;
	ZafStringID strngID;
	bool isUni;
};


