Move duplicated 'trim' function to BSPF.

Remove unused methods from Settings.
This commit is contained in:
Stephen Anthony 2020-12-20 20:05:41 -03:30
parent 11241b9871
commit ac09bcd032
3 changed files with 10 additions and 25 deletions

View File

@ -303,6 +303,14 @@ namespace BSPF
} }
} }
// Trim leading and trailing whitespace from a string
inline string trim(const string& str)
{
string::size_type first = str.find_first_not_of(' ');
return (first == string::npos) ? EmptyString :
str.substr(first, str.find_last_not_of(' ')-first+1);
}
// C++11 way to get local time // C++11 way to get local time
// Equivalent to the C-style localtime() function, but is thread-safe // Equivalent to the C-style localtime() function, but is thread-safe
inline std::tm localTime() inline std::tm localTime()

View File

@ -18,15 +18,6 @@
#include "KeyValueRepositoryConfigfile.hxx" #include "KeyValueRepositoryConfigfile.hxx"
#include "Logger.hxx" #include "Logger.hxx"
namespace {
string trim(const string& str)
{
string::size_type first = str.find_first_not_of(' ');
return (first == string::npos) ? EmptyString :
str.substr(first, str.find_last_not_of(' ')-first+1);
}
}
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
KeyValueRepositoryConfigfile::KeyValueRepositoryConfigfile(const FilesystemNode& file) KeyValueRepositoryConfigfile::KeyValueRepositoryConfigfile(const FilesystemNode& file)
: myFile{file} : myFile{file}
@ -67,8 +58,8 @@ std::map<string, Variant> KeyValueRepositoryConfigfile::load()
continue; continue;
// Split the line into key/value pairs and trim any whitespace // Split the line into key/value pairs and trim any whitespace
key = trim(line.substr(0, equalPos)); key = BSPF::trim(line.substr(0, equalPos));
value = trim(line.substr(equalPos + 1, line.length() - key.length() - 1)); value = BSPF::trim(line.substr(equalPos + 1, line.length() - key.length() - 1));
// Skip absent key // Skip absent key
if(key.length() == 0) if(key.length() == 0)

View File

@ -116,20 +116,6 @@ class Settings
void setPermanent(const string& key, const Variant& value); void setPermanent(const string& key, const Variant& value);
void setTemporary(const string& key, const Variant& value); void setTemporary(const string& key, const Variant& value);
// Trim leading and following whitespace from a string
static string trim(const string& str)
{
string::size_type first = str.find_first_not_of(' ');
return (first == string::npos) ? EmptyString :
str.substr(first, str.find_last_not_of(' ')-first+1);
}
// FIXME - Rework so that these aren't needed; hence no commenting added
const Options& getPermanentSettings() const
{ return myPermanentSettings; }
const Options& getTemporarySettings() const
{ return myTemporarySettings; }
private: private:
/** /**
This method must be called *after* settings have been fully loaded This method must be called *after* settings have been fully loaded