[go: up one dir, main page]

Menu

[r463]: / clp / trunk / src / stlini.h  Maximize  Restore  History

Download this file

43 lines (32 with data), 1.6 kB

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#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