#ifndef _TA_FILE_
#define _TA_FILE_

// Link to AGK libraries
#include "agk.h"

// stuff we need
#include "ta_oops.h"

// get some standard objects we need
#include <stdarg.h>
#include <string>

/////////////////////////////////////////
// CLASS DEFINITION /////////////////////
/////////////////////////////////////////

class ta_file
{
	private:
		// for file processing
		static bool is_bin;
		static char mySet[50][64];
		static char aBlank[2];
		static int myInd;
		static int myCnt;
		static int myFid;
		static char myFname[1024];
		static char myLine[1024];
		static char holdLine[1024];
		static std::string agk_str;

		// for debugging
		static char debLine[2048];

	public:
		ta_file() {};

		// for file processing
		static bool is_open() {return (myFid!=0?true:false);};
		static bool moreFile();
		static bool openFileRead(const char* afile,bool as_binary=false);
		static bool openFileWrite(const char* afile,bool clear=true,bool as_binary=false);
		static void closeFile(void);
		static bool getAndSplitLine(const char* delim,int reqpec,bool no_blank=false);
		static int splitCount();
		static void debugLine(char* tag);
		static void showLastLine(char* tag);

		// read functions
		static const char* getValue();
		static void getValue(signed int& ret);
		static void getValue(unsigned int& ret);
		static void getValue(signed long long& ret);
		static void getValue(unsigned long long& ret);
		static void getValue(signed short& ret);
		static void getValue(unsigned short& ret);
		static void getValue(signed char& ret);
		static void getValue(unsigned char& ret);
		static void getValue(bool& ret);
		static void getValue(float& ret);

		// write functions
		static void putValue(char* val);
		static void putValue(signed int val);
		static void putValue(unsigned int val);
		static void putValue(signed long long val);
		static void putValue(unsigned long long val);
		static void putValue(signed short val);
		static void putValue(unsigned short val);
		static void putValue(signed char val);
		static void putValue(unsigned char val);
		static void putValue(bool val);
		static void putValue(float val);

		// for debug handling
		static void initDebug(const char* game);
		static void writeDebug(const char* fmt, ...);

	private:
		static const char* doAGKstr(char* fix_agk_str);
		static int trim_line();
		static int get_int();
};
#endif
