From 801b866b98441dd6476301fb88d7ab63f9db4328 Mon Sep 17 00:00:00 2001 From: vanhofen Date: Fri, 8 Nov 2013 15:06:05 +0100 Subject: [PATCH] libconfigfile: allow configfiles with another delimiter as '=' Origin commit data ------------------ Branch: ni/coolstream Commit: https://github.com/neutrino-images/ni-neutrino/commit/f9515444f0ea839839e507eac6eaac8f51f7f7c4 Author: vanhofen Date: 2013-11-08 (Fri, 08 Nov 2013) Origin message was: ------------------ - libconfigfile: allow configfiles with another delimiter as '=' ------------------ No further description and justification available within origin commit message! ------------------ This commit was generated by Migit --- lib/libconfigfile/configfile.cpp | 16 ++++++++-------- lib/libconfigfile/configfile.h | 8 ++++---- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/libconfigfile/configfile.cpp b/lib/libconfigfile/configfile.cpp index 354d5ec97..651562335 100644 --- a/lib/libconfigfile/configfile.cpp +++ b/lib/libconfigfile/configfile.cpp @@ -51,7 +51,7 @@ void CConfigFile::clear() // // public file operation methods // -bool CConfigFile::loadConfig(const char * const filename) +bool CConfigFile::loadConfig(const char * const filename, char _delimiter) { std::ifstream configFile(filename); @@ -67,7 +67,7 @@ bool CConfigFile::loadConfig(const char * const filename) if (configFile.fail()) break; - std::string::size_type i = s.find('='); + std::string::size_type i = s.find(_delimiter); if (i != std::string::npos) { std::string::size_type j = s.find('#'); @@ -86,12 +86,12 @@ bool CConfigFile::loadConfig(const char * const filename) } } -bool CConfigFile::loadConfig(const std::string & filename) +bool CConfigFile::loadConfig(const std::string & filename, char _delimiter) { - return loadConfig(filename.c_str()); + return loadConfig(filename.c_str(), _delimiter); } -bool CConfigFile::saveConfig(const char * const filename) +bool CConfigFile::saveConfig(const char * const filename, char _delimiter) { std::string tmpname = std::string(filename) + ".tmp"; unlink(tmpname.c_str()); @@ -102,7 +102,7 @@ bool CConfigFile::saveConfig(const char * const filename) std::cout << "[ConfigFile] saving " << filename << std::endl; for (ConfigDataMap::const_iterator it = configData.begin(); it != configData.end(); ++it) { - configFile << it->first << "=" << it->second << std::endl; + configFile << it->first << _delimiter << it->second << std::endl; } configFile.sync(); @@ -123,9 +123,9 @@ bool CConfigFile::saveConfig(const char * const filename) } } -bool CConfigFile::saveConfig(const std::string & filename) +bool CConfigFile::saveConfig(const std::string & filename, char _delimiter) { - return saveConfig(filename.c_str()); + return saveConfig(filename.c_str(), _delimiter); } diff --git a/lib/libconfigfile/configfile.h b/lib/libconfigfile/configfile.h index 5a247a556..6f1e052e7 100644 --- a/lib/libconfigfile/configfile.h +++ b/lib/libconfigfile/configfile.h @@ -50,11 +50,11 @@ class CConfigFile public: CConfigFile(const char p_delimiter, const bool p_saveDefaults = true); - bool loadConfig(const char * const filename); - bool loadConfig(const std::string & filename); + bool loadConfig(const char * const filename, char _delimiter = '='); + bool loadConfig(const std::string & filename, char _delimiter = '='); - bool saveConfig(const char * const filename); - bool saveConfig(const std::string & filename); + bool saveConfig(const char * const filename, char _delimiter = '='); + bool saveConfig(const std::string & filename, char _delimiter = '='); void clear();