SMILE
v2.5
Schwarzschild Modelling Interactive expLoratory Environment
|
Utility class for handling an INI file. More...
#include <configfile.h>
Public Member Functions | |
CConfigFile (const std::string &fileName) | |
open an INI file with the given name; if it exists, read its contents on initialization | |
CConfigFile (const std::string &iniSection, const int numParams, const char *const *params) | |
alternative way of parsing a list of parameters given in the form "name=value" and attribute them to the given section of a non-existent ini file (useful for mimicking the ini file with command-line arguments) | |
~CConfigFile () | |
destroy the class and write unsaved data back to INI file, if it was modified | |
std::string | getValueString (const std::string &key, const std::string &defaultValue="") const |
return a string value from the INI file | |
int | getValueInt (const std::string &key, int defaultValue=0) const |
overloaded for convenience, return an integer value | |
double | getValueDouble (const std::string &key, double defaultValue=0) const |
overloaded for convenience, return a floating-point value | |
bool | getValueBool (const std::string &key, bool defaultValue=false) const |
overloaded for convenience, return a boolean value | |
void | setValue (const std::string &key, int value) |
set an integer value | |
void | setValue (const std::string &key, unsigned int value) |
set an unsigned integer value | |
void | setValue (const std::string &key, double value) |
set a floating-point value | |
void | setValue (const std::string &key, double value, unsigned int width) |
set a floating-point value with a given precision (rather, width of the string representation) | |
void | setValue (const std::string &key, const std::string &value) |
set a string value | |
void | setValue (const std::string &key, const char *value) |
set a string value (overloaded) | |
void | setValue (const std::string &key, bool value) |
set a boolean value | |
void | listGroups (std::vector< std::string > *list) const |
return a list of all sections in the INI file | |
Private Attributes | |
void * | pImpl |
implementation-specific data | |
Utility class for handling an INI file.
Provides high-level interface for reading and writing values of various types, while isolating the details of the implementation in an internal pointer. Currently, there are two such implementations – based on Qt QSettings class (used in SMILE up to version 2.4), and a simple hand-made class which deals with text files directly. Data values are addressed by a case-insensitive key string which combines section and key name: Section/Key.