
extern "C" { 
#include "../../c/lkf5defs.h"
}

class BufferChar;

class Output
{
protected:
	unsigned int m_nFlags;
	char *m_InputFileName;
	char *m_OutputFileName;

	char *LocalStringCopy (const char *str) const;

public:
	Output (unsigned int flags);
	virtual ~Output ();
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual const char *GetDefaultOutputFilename();

	void SetInputFileName (const char *);
	void SetOutputFileName (const char *);
	const char *GetInputFileName (void) const  { return m_InputFileName; }
	const char *GetOutputFileName (void) const { return m_OutputFileName; }
} ;

class OutputScoringFile : public Output
{
public:
	inline OutputScoringFile (unsigned int flags) : Output (flags)
	{}
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputScoringFile ();
} ;

class OutputPlausEWFile : public Output
{
	bool m_IsErrorFile;
	int  m_ModelYear;

protected:
	OutputPlausEWFile (unsigned int flags, bool iserror);

public:
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputPlausEWFile ();

	void WriteHeader (LKF_CONTEXT *ctx, BufferChar *);
	void WriteFooter (LKF_CONTEXT *ctx, BufferChar *);

	inline void SetModelYear (int m) { m_ModelYear = m; }
	inline int GetModelYear (void) const { return m_ModelYear; }
} ;

class OutputPlausErrorFile : public OutputPlausEWFile
{
public:
	inline OutputPlausErrorFile (unsigned int flags) : OutputPlausEWFile (flags, true)
	{}
	virtual ~OutputPlausErrorFile ();
} ;

class OutputPlausWarningFile : public OutputPlausEWFile
{
public:
	inline OutputPlausWarningFile (unsigned int flags) : OutputPlausEWFile (flags, false) 
	{}
	virtual ~OutputPlausWarningFile ();
} ;

class OutputMeldeDiagFile : public Output
{
	int  m_ModelYear;
public:
	OutputMeldeDiagFile (unsigned int flags);
	virtual ~OutputMeldeDiagFile ();
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);

	inline void SetModelYear (int m) { m_ModelYear = m; }
	inline int GetModelYear (void) const { return m_ModelYear; }
} ;

class OutputPlausNPFile : public Output
{
public:
	inline OutputPlausNPFile (unsigned int flags) : Output (flags)
	{}
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputPlausNPFile ();
} ;

class OutputNPSumFile : public Output
{ /* V10.0 */
public:
	inline OutputNPSumFile (unsigned int flags) : Output (flags)
	{}
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputNPSumFile ();
} ;


class OutputScoringOptimizerFile : public Output
{
public:
	inline OutputScoringOptimizerFile (unsigned int flags) : Output (flags)
	{}
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputScoringOptimizerFile ();

} ;

class OutputScoringCSVFile : public Output
{
	unsigned int m_Count;
	unsigned int *m_FieldNumbers;
public:
	OutputScoringCSVFile (unsigned int count, unsigned int *fieldnumbers, unsigned int flags);
	virtual ~OutputScoringCSVFile ();
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
} ;

#define FLAG_OUTPUT_INTEINSTUFUNG   1
#define FLAG_OUTPUT_INTANALYSE		2
#define FLAG_OUTPUT_SAPSII_DETAILS	4
#define FLAG_OUTPUT_TISS_DETAILS	8
#define FLAG_OUTPUT_TRISS_DETAILS  16
#define FLAG_OUTPUT_AUF_DETAILS	   32
#define FLAG_OUTPUT_HEADLINE	  256

#define FLAG_OUTPUT_ANYDETAIL    (FLAG_OUTPUT_SAPSII_DETAILS | FLAG_OUTPUT_TISS_DETAILS | FLAG_OUTPUT_TRISS_DETAILS | FLAG_OUTPUT_AUF_DETAILS)
#define FLAG_OUTPUT_INTALL		 (FLAG_OUTPUT_ANYDETAIL | FLAG_OUTPUT_INTEINSTUFUNG | FLAG_OUTPUT_INTANALYSE | FLAG_OUTPUT_HEADLINE)

class OutputIntensivScoringFile : public Output
{
public:
	inline OutputIntensivScoringFile (unsigned int flags) : Output (flags)
	{}

	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputIntensivScoringFile ();
} ;

class OutputCheckFile : public Output
{
	unsigned int nType;
public:
	inline OutputCheckFile (unsigned int type, unsigned int flags) : Output (flags)
	{
		nType = type;
	}

	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputCheckFile ();
	
} ;

class OutputStammFile : public Output
{
	char *pFilename;
public:
	OutputStammFile (const char *stammfile, unsigned int flags);
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputStammFile ();

} ;

class OutputProtocolFile : public Output
{
public:
	OutputProtocolFile (unsigned int flags);
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputProtocolFile ();
} ;

#define OUTPUTFILE_CHECKDETAILS		(1<<8)

class OutputSatzartFile : public Output
{
	unsigned int m_ModellJahr;
protected:
	void FillCheckInfo (LKF_CONTEXT *pContext, BufferChar *pBuf, const void *pCheckInfo, const char *sFieldIndex, const char *sErrorIndex);
public:
	OutputSatzartFile (unsigned int modelljahr, unsigned int flags);
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputSatzartFile ();
} ;

#define OUTPUTFLAG_NOMBDS	(1<<8)
#define OUTPUTFLAG_NOINT	(1<<9)
#define OUTPUTFLAG_NOADD	(1<<10)

class OutputDataFile : public Output
{
public:
	OutputDataFile (unsigned int flags);
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputDataFile ();
} ;

class OutputErrorListFile : public Output
{
public:
	OutputErrorListFile (unsigned int flags);
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputErrorListFile ();
} ;

class OutputStatFile : public Output
{
public:
	OutputStatFile (unsigned int flags);
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputStatFile ();
} ;

class OutputTraceFile : public Output
{
public:
	OutputTraceFile (unsigned int flags);
	virtual int FillBuffer (LKF_CONTEXT *ctx, BufferChar *);
	virtual ~OutputTraceFile ();
} ;
