//	Zinc Application Framework - Z_IDATA.HPP
//	COPYRIGHT (C) 1990-1999.  All Rights Reserved.
//	Zinc Software Incorporated.  Pleasant Grove, Utah  USA

#if !defined(Z_IDATA_HPP)
#define Z_IDATA_HPP
#include <z_data.hpp>

// --------------------------------------------------------------------------
// ----- ZafI18nData --------------------------------------------------------
// --------------------------------------------------------------------------

typedef void (*ZafAllocateModule)(void);
typedef void (*ZafFreeModule)(bool);

class ZAF_EXPORT ZafI18nData : public ZafData
{
public:
	// --- General members ---
	virtual ~ZafI18nData(void);
	static const ZafIChar *CountryCodeToZafLocale(int countryCode);
	static const ZafIChar *OSLanguageToZafLanguage(const ZafIChar *osLanguage);
	static const ZafIChar *ZafLocaleToZafLanguage(const ZafIChar *zafLocale);
	static const ZafIChar *ZafLanguageToZafLocale(const ZafIChar *zafLanguage);
	static const ZafIChar *OSI18nName(void);

	// --- Attributes & data access ---
	// get
	static const ZafIChar *I18nName(void);
	// set
	static bool AddStaticModule(ZafFreeModule freeModule, ZafAllocateModule allocateModule = ZAF_NULLF(ZafAllocateModule), ZafClassID category = ID_DEFAULT);
	static ZafError SetI18nName(const ZafIChar *i18nName);
	static ZafError SetI18nName(const ZafIChar *languageName, const ZafIChar *localeName, const ZafIChar *codeSetName);
	static bool SubtractStaticModule(ZafFreeModule freeModule, ZafAllocateModule allocateModule = ZAF_NULLF(ZafAllocateModule));

	// --- Default i18n ---
	static void I18nAllocate(const ZafIChar *i18nName = ZAF_NULLP(ZafIChar));
	static void I18nFree(bool globalRequest = false);
	static const ZafIChar *ResetI18n(const ZafIChar *newName = ZAF_NULLP(ZafIChar));

#if defined(USE_ZAF_PERSISTENCE)
	// --- Persistent members ---
	virtual void Write(ZafDataPersistence &persist);
#endif

	// --- Class identification ---
	static ZafClassID classID;
	static ZafClassNameChar ZAF_FARDATA className[];
	virtual ZafClassID ClassID(void) const { return (classID); }
	virtual ZafClassName ClassName(void) const { return (className); }
	virtual bool IsA(ZafClassID compareID) const;
	virtual bool IsA(ZafClassName compareName) const;

	struct ZafStaticModule
	{
		ZafAllocateModule allocateModule;
		ZafFreeModule freeModule;
		ZafClassID category;
	};

protected:
	// --- General members ---
	ZafI18nData(void);
	ZafI18nData(const ZafI18nData &copy);

#if defined(USE_ZAF_PERSISTENCE)
	// --- Persistent members ---
	ZafI18nData(const ZafIChar *name, ZafDataPersistence &persist);
#endif

private:
	static ZafIChar i18nName[64];

#if defined(ZAF_INDEPENDENT)
// "public privates"  Must be public for initialization.
public: 
#endif
	static ZafStaticModule *staticModule;
};

#if defined(USE_ZAF_PERSISTENCE)
// --- global variable declarations ---
extern ZAF_EXPORT ZafFileSystem *zafI18nStorage;
#endif

#endif // Z_IDATA_HPP

