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

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

// First attempt.
#include <z_stdcom.hpp>

// --------------------------------------------------------------------------
// ----- ZafFormatData ------------------------------------------------------
// --------------------------------------------------------------------------

struct ZAF_EXPORT parentArgs;
#define ZAF_FORMAT_LENGTH		64

class ZAF_EXPORT ZafFormatData : public ZafData
{
public:
	// --- General members ---
	virtual ~ZafFormatData(void);

#if defined(USE_ZAF_PERSISTENCE)
	// --- Persistence ---
	ZafFormatData(const ZafIChar *name, ZafDataPersistence &persist);
	virtual void Write(ZafDataPersistence &persist);
#endif

	// --- Attributes & data access ---
	// get
	virtual int FormattedText(ZafIChar *buffer, int maxLength, const ZafIChar *format = 0) const = 0;

	// --- 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;

	// Printing and Scanning functions
	
	static void SetSprintf(ZafIChar fmtCH, objectFormat format);
	static int sprintf(ZafIChar *dst, const ZafIChar *format, ...);

	static void SetSscanf(ZafIChar fmtCH, objectParse parse);
	static int sscanf(const ZafIChar *dst, const ZafIChar *format, ...);
	
protected:
	friend class ZafStandardArg;

	// --- General members ---
	ZafFormatData(void);
	ZafFormatData(const ZafFormatData &copy);

	// printf support
	const ZafIChar *ParseFormat(ZafIChar *format, const ZafIChar *formatArray) const;
	int Sprintf(ZafIChar *buffer, int maxLength, const ZafIChar *format) const;
	int Sscanf(const ZafIChar *buffer, const ZafIChar *format);

	// Printing and Scanning functions
	static int _vsprintf(ZafIChar *buffer, const ZafIChar *format, va_list *argList);
	static int _vsscanf(const ZafIChar *buffer, const ZafIChar *format, va_list *argList);

#if defined(ZAF_MOTIF)
public:
#endif

	static struct FormatTable
	{
		ZafIChar fmtCH;
		objectFormat Format;
	} formatTable[40];

#if defined(ZAF_INDEPENDENT)
// Must be public for initialization;
public:
#endif
	static int formatTableEntries;

	static struct ParseTable
	{
		ZafIChar fmtCH;
		objectParse Parse;
	} parseTable[40];
	static int parseTableEntries;

};

#endif // Z_FDATA_HPP

