Files
source/Utils/INIReader.h
T
Wanne 067a3a5899 Bugfix: Memory Leak in CIniReader::ReadString (by Arynn)
Fixed an array off by one issue in game setting structure (by Arynn)

git-svn-id: https://ja2svn.mooo.com/source/ja2/trunk/GameSource/ja2_v1.13/Build@2869 3b4a5df2-a311-0410-b5c6-a8a6f20db521
2009-05-19 06:24:06 +00:00

57 lines
2.4 KiB
C++

#ifndef INIREADER_H
#define INIREADER_H
#include <Windows.h>
#include <Types.h>
#include <stack>
#include <string>
// Kaiden: This will read any value out of
// an INI file as long as the correct type is specified.
// Methods should be fairly self explainatory
//
// Note: readers without valid range parameters will be removed to "encourage" developers to specify
// valid ranges. Consider carefully what those values should be.
//
// Queue of error messages. They are queued because screen is not ready for I/O yet.
extern std::stack<std::string> iniErrorMessages;
class CIniReader
{
public:
CIniReader(const STR8 szFileName);
CIniReader(const STR8 szFileName, BOOLEAN Force_Custom_Data_Path); // force path for nonexisting INI files
// Warning: the following function will be removed
int ReadInteger(const STR8 szSection, const STR8 szKey, int iDefaultValue);
int ReadInteger(const STR8 szSection, const STR8 szKey, int defaultValue, int minValue, int maxValue);
//void testReadUINT32(void);//various limit tests of UINT and double/float handling
//front end functions that control type interpretation and range control, each calls internal ReadUINT
UINT32 ReadUINT32(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue);
UINT16 ReadUINT16(const STR8 szSection, const STR8 szKey, UINT16 defaultValue, UINT16 minValue, UINT16 maxValue);
UINT8 ReadUINT8 (const STR8 szSection, const STR8 szKey, UINT8 defaultValue, UINT8 minValue, UINT8 maxValue);
// Warning: the following function will be removed
//double ReadDouble(const STR8 szSection, const STR8 szKey, double fltDefaultValue);
// Read_reals
DOUBLE ReadDouble(const STR8 szSection, const STR8 szKey, DOUBLE defaultValue, DOUBLE minValue, DOUBLE maxValue);
FLOAT ReadFloat (const STR8 szSection, const STR8 szKey, FLOAT defaultValue, FLOAT minValue, FLOAT maxValue);
BOOLEAN ReadBoolean(const STR8 szSection, const STR8 szKey, BOOLEAN bolDefaultValue);
void ReadString(const STR8 szSection, const STR8 szKey, const STR8 szDefaultValue, STR8 input_buffer, size_t buffer_size);
BOOLEAN Is_CIniReader_File_Found(void) {return (CIniReader_File_Found);}
private:
char m_szFileName[MAX_PATH];
BOOLEAN CIniReader_File_Found;
UINT32 ReadUINT(const STR8 szSection, const STR8 szKey, UINT32 defaultValue, UINT32 minValue, UINT32 maxValue);
};
#endif//INIREADER_H