#ifndef _STLINI_H
#define _STLINI_H 1
#include <map>
#include <string>
// change this if you expect to have huge lines in your INI files...
// note that this is the max size of a single line, NOT the max number of lines
#define MAX_INI_LINE 500
namespace StlIni {
struct StlIniCompareStringNoCase
{
bool operator()(const std::string& x, const std::string& y) const;
};
// return true or false depending on whether the first string is less than the second
inline bool StlIniCompareStringNoCase::operator()(const std::string& x, const std::string& y) const
{
return (strcasecmp(x.c_str(), y.c_str()) < 0) ? true : false;
}
// these typedefs just make the code a bit more readable
typedef std::map<std::string, std::string, StlIniCompareStringNoCase > INISection;
typedef std::map<std::string, INISection , StlIniCompareStringNoCase > INIFile;
std::string GetIniSetting(INIFile &theINI, const char *pszSection, const char *pszKey, const char *pszDefaultVal="");
std::string GetIniKeys(INIFile &theINI, const char *pszSection, const char *pszDefaultVal="");
std::string GetIniSectionsByKey(INIFile &theINI, const char *key, const char *pszDefaultVal="");
void PutIniSetting(INIFile &theINI, const char *pszSection, const char *pszKey=NULL, const char *pszValue="");
void RemoveIniSetting(INIFile &theINI, const char *pszSection, const char *pszKey);
void SaveIni(INIFile &theINI, const char *pszFilename);
INIFile LoadIni(const char *pszFilename);
void LoadIncludedIni(INIFile &theINI, const char *filename);
void readIniContents(INIFile &theINI, const char *filename);
void DumpIni(INIFile &ini);
}
#endif // _STLINI_H