/*
  File: include/ioutils/Interface_INIParser.h
  Description: ini parser interface
  Part of the Mantis project
  (c) 2002 Lycos Inc.

  This file is distributed for the sole purpose of allowing you to write
  software to interface with Sonique 2 and other Mantis programs. It is
  not to be modified or used for any other purpose without written
  authorization.

  If you redistribute this file, it must be in the original package
  complete with all other files provided, including the usage agreement.

  Do not remove this notice.
*/

#ifndef _INTERFACE_INIPARSER_H__
#define _INTERFACE_INIPARSER_H__

#ifdef DEBUG_INCLUDE_ORDER
#pragma message("Including " __FILE__ "\n" )
#endif

#if _MSC_VER > 1000
#pragma once
#endif

// {A74F5ECF-5204-44bb-8F3D-FE2ECD73CA3A}
DEFINE_MID(MID_INI_PARSER, 0xa74f5ecf, 0x5204, 0x44bb, 0x8f, 0x3d, 0xfe, 0x2e, 0xcd, 0x73, 0xca, 0x3a);



class MINIParser : public MGeneric
{
public:
	virtual MRESULT	__stdcall	Load(IOObject* Storage)														= 0;
	virtual MRESULT	__stdcall	Save(IOObject* Storage)														= 0;
	virtual MRESULT	__stdcall	CloseFile()																	= 0;

	virtual MRESULT	__stdcall	GetString(const char* Section, const char* Name, AString& szToHere) const	= 0;
	virtual MRESULT	__stdcall	GetInteger(const char* Section, const char* Name, int32& lToHere) const		= 0;
	virtual MRESULT	__stdcall	GetReal(const char* Section, const char* Name, double& lfToHere) const		= 0;
	virtual MRESULT	__stdcall	GetSections(Array<AString>& SectionNames) const								= 0;
	virtual MRESULT	__stdcall	GetEntries(const char* Section, Array<AString>& EntryNames) const			= 0;

	virtual MRESULT	__stdcall	SetString(const char* Section, const char* Name, const char* Value)			= 0;
	virtual MRESULT	__stdcall	SetInteger(const char* Section, const char* Name, int32 Value)				= 0;
	virtual MRESULT	__stdcall	SetReal(const char* Section, const char* Name, double Value)				= 0;
	virtual MRESULT	__stdcall	RemoveEntry(const char* Section, const char* Name)							= 0;
	virtual MRESULT	__stdcall	RemoveSection(const char* Section)											= 0;

	virtual MRESULT	__stdcall	Flush()																		= 0;
};

enum {
	ERR_INIPARSER_UNABLETOMEMORYMAPFILE,
	ERR_INIPARSER_FILENOTOPEN,
	ERR_INIPARSER_FILEOPENEDREADONLY,
	ERR_INIPARSER_SEEKFAILED,
	ERR_INIPARSER_WRONGTYPE,
	ERR_INIPARSER__NUM
};

#define ERR_INIPARSER__MODULE "INI Parser"

inline MError* GetINIParserErrors(MError* Errors)
{
	Errors[ERR_INIPARSER_UNABLETOMEMORYMAPFILE].Name =	"unable to memory map file";
	Errors[ERR_INIPARSER_FILENOTOPEN].Name =			"file not open";
	Errors[ERR_INIPARSER_FILEOPENEDREADONLY].Name =		"file was opened read only";
	Errors[ERR_INIPARSER_SEEKFAILED].Name =				"file seek failed";
	Errors[ERR_INIPARSER_WRONGTYPE].Name =				"the data requested was of a different type than expected";

	return Errors;
}


#ifdef DEBUG_INCLUDE_ORDER
#pragma message("Done including " __FILE__ "\n" )
#endif

#endif // _INTERFACE_INIPARSER_H__
