20 explicit IniFile (
const std::string& name);
35 const std::string&
File ()
const
39 void File (
const std::string& filename);
42 size_t GetString (
char *value,
size_t len,
const std::string& key,
const std::string& section,
const std::string& defval = std::string())
const;
45 std::string
GetString (
const std::string& key,
const std::string& section,
const std::string& defval = std::string ())
const;
48 int GetInt (
const std::string& key,
const std::string& section,
int defval=0)
const;
51 double GetDouble (
const std::string& key,
const std::string& section,
double defval=0.)
const;
54 bool GetBool (
const std::string& key,
const std::string& section,
bool defval=
false)
const;
57 bool HasKey (
const std::string& key,
const std::string& section)
const;
60 bool PutString (
const std::string& key,
const std::string& value,
const std::string& section);
63 bool PutInt (
const std::string& key,
long value,
const std::string& section);
66 bool PutBool (
const std::string& key,
bool value,
const std::string& section);
69 bool PutDouble (
const std::string& key,
double value,
const std::string& section,
int dec = 2);
72 bool DeleteKey (
const std::string& key,
const std::string& section);
78 bool CopySection (
const IniFile& from_file,
const std::string& from_sect,
const std::string& to_sect=std::string());
84 int GetKeys (
char *
buffer,
size_t sz,
const std::string& section);
87 size_t GetKeys (std::deque<std::string>& keys,
const std::string& section);
93 size_t GetSections (std::deque<std::string>& sections);
97 COLORREF GetColor (const std::string& key, const std::string& section, COLORREF defval = RGB (0, 0, 0)) const;
100 HFONT GetFont (
const std::string& key,
const std::string& section, HFONT defval = NULL)
const;
103 bool PutColor (
const std::string& key, COLORREF value,
const std::string& section);
106 bool PutFont (
const std::string& key, HFONT font,
const std::string& section);
111 std::string filename;
Operations on INI files.
Definition ini.h:17
double GetDouble(const std::string &key, const std::string §ion, double defval=0.) const
Return a floating point value.
Definition ini.cpp:271
const std::string & File() const
Return file name associated with this object.
Definition ini.h:35
bool PutBool(const std::string &key, bool value, const std::string §ion)
Write a boolean key.
Definition ini.cpp:519
bool PutDouble(const std::string &key, double value, const std::string §ion, int dec=2)
Write a floating point value key.
Definition ini.cpp:296
IniFile & operator=(const IniFile &)
Assignment operator.
Definition ini.cpp:235
bool DeleteSection(const std::string §ion)
Delete an entire section.
Definition ini.cpp:649
size_t GetSections(char *sects, size_t sz)
Return the names of all sections in the INI file.
Definition ini.cpp:786
bool HasKey(const std::string &key, const std::string §ion) const
Check for key existence.
Definition ini.cpp:249
bool HasSection(const std::string §ion)
Return true if profile contains a non empty section with the given name.
Definition ini.cpp:628
int GetKeys(char *buffer, size_t sz, const std::string §ion)
Retrieve names of all keys in a section.
Definition ini.cpp:662
bool PutInt(const std::string &key, long value, const std::string §ion)
Write an integer key.
Definition ini.cpp:283
int GetInt(const std::string &key, const std::string §ion, int defval=0) const
Return an integer key.
Definition ini.cpp:260
~IniFile()
Destructor.
Definition ini.cpp:199
bool PutString(const std::string &key, const std::string &value, const std::string §ion)
Write a string key.
Definition ini.cpp:768
bool GetBool(const std::string &key, const std::string §ion, bool defval=false) const
Return a boolean key.
Definition ini.cpp:499
bool DeleteKey(const std::string &key, const std::string §ion)
Delete a key.
Definition ini.cpp:641
bool CopySection(const IniFile &from_file, const std::string &from_sect, const std::string &to_sect=std::string())
Copy all keys from one section to another.
Definition ini.cpp:537
size_t GetString(char *value, size_t len, const std::string &key, const std::string §ion, const std::string &defval=std::string()) const
Get a string key.
Definition ini.cpp:720
IniFile()
Default constructor uses a temporary file.
Definition ini.cpp:181
A simple buffer for caching values returned by Windows API.
Definition winutf8.h:160