config: add Config::_loadFile function to allow loading custom configuration file
This commit is contained in:
parent
13caaab8da
commit
878c379242
|
@ -578,13 +578,30 @@ char* Config::getConfigDirectory()
|
||||||
|
|
||||||
int
|
int
|
||||||
Config::_load()
|
Config::_load()
|
||||||
|
{
|
||||||
|
std::string configFile = _dir + "/" + cfgFile;
|
||||||
|
bool success = Config::_loadFile(configFile.c_str());
|
||||||
|
|
||||||
|
return success;
|
||||||
|
}
|
||||||
|
|
||||||
|
int
|
||||||
|
Config::_loadFile(const char* fname)
|
||||||
{
|
{
|
||||||
signed int pos, eqPos;
|
signed int pos, eqPos;
|
||||||
std::fstream config;
|
std::fstream config;
|
||||||
std::map<std::string, int>::iterator int_i;
|
std::map<std::string, int>::iterator int_i;
|
||||||
std::map<std::string, double>::iterator dbl_i;
|
std::map<std::string, double>::iterator dbl_i;
|
||||||
std::map<std::string, std::string>::iterator str_i;
|
std::map<std::string, std::string>::iterator str_i;
|
||||||
std::string configFile = _dir + "/" + cfgFile;
|
std::string configFile;
|
||||||
|
// if no filename argument was passed, parse the default configuration file
|
||||||
|
if(fname == NULL)
|
||||||
|
{
|
||||||
|
configFile = _dir + "/" + cfgFile;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
configFile = fname;
|
||||||
|
}
|
||||||
std::string line, name, value;
|
std::string line, name, value;
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
|
|
||||||
|
|
|
@ -20,6 +20,7 @@ private:
|
||||||
int _addOption(char, const std::string &, const std::string &, int);
|
int _addOption(char, const std::string &, const std::string &, int);
|
||||||
int _addOption(const std::string &, const std::string &, int);
|
int _addOption(const std::string &, const std::string &, int);
|
||||||
int _load(void);
|
int _load(void);
|
||||||
|
int _loadFile(const char* fname);
|
||||||
int _parseArgs(int, char **);
|
int _parseArgs(int, char **);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
Loading…
Reference in New Issue