diff --git a/include/CLI/Ini.hpp b/include/CLI/Ini.hpp index 9fe18bf3..252a87c7 100644 --- a/include/CLI/Ini.hpp +++ b/include/CLI/Ini.hpp @@ -63,7 +63,7 @@ struct ini_ret_t { }; /// Internal parsing function -std::vector parse_ini(std::istream &input) { +inline std::vector parse_ini(std::istream &input) { std::string name, line; std::string section = "default"; @@ -103,7 +103,7 @@ std::vector parse_ini(std::istream &input) { } /// Parse an INI file, throw an error (ParseError:INIParseError or FileError) on failure -std::vector parse_ini(const std::string &name) { +inline std::vector parse_ini(const std::string &name) { std::ifstream input{name}; if(!input.good()) diff --git a/include/CLI/StringTools.hpp b/include/CLI/StringTools.hpp index d421b555..d5400635 100644 --- a/include/CLI/StringTools.hpp +++ b/include/CLI/StringTools.hpp @@ -16,7 +16,7 @@ namespace detail { // Based on http://stackoverflow.com/questions/236129/split-a-string-in-c ///Split a string by a delim -std::vector split(const std::string &s, char delim) { +inline std::vector split(const std::string &s, char delim) { std::vector elems; // Check to see if emtpy string, give consistent result if(s=="") @@ -61,14 +61,14 @@ std::string rjoin(const T& v, std::string delim = ",") { // Based roughly on http://stackoverflow.com/questions/25829143/c-trim-whitespace-from-a-string /// Trim whitespace from left of string -std::string& ltrim(std::string &str) { +inline std::string& ltrim(std::string &str) { auto it = std::find_if(str.begin(), str.end(), [](char ch){ return !std::isspace(ch , std::locale());}); str.erase(str.begin(), it); return str; } /// Trim anything from left of string -std::string& ltrim(std::string &str, const std::string &filter) { +inline std::string& ltrim(std::string &str, const std::string &filter) { auto it = std::find_if(str.begin(), str.end(), [&filter](char ch){return filter.find(ch) == std::string::npos;}); str.erase(str.begin(), it); return str; @@ -76,42 +76,42 @@ std::string& ltrim(std::string &str, const std::string &filter) { /// Trim whitespace from right of string -std::string& rtrim(std::string &str) { +inline std::string& rtrim(std::string &str) { auto it = std::find_if(str.rbegin(), str.rend(), [](char ch){ return !std::isspace(ch, std::locale());}); str.erase(it.base() , str.end() ); return str; } /// Trim anything from right of string -std::string& rtrim(std::string &str, const std::string &filter) { +inline std::string& rtrim(std::string &str, const std::string &filter) { auto it = std::find_if(str.rbegin(), str.rend(), [&filter](char ch){return filter.find(ch) == std::string::npos;}); str.erase(it.base(), str.end()); return str; } /// Trim whitespace from string -std::string& trim(std::string &str) { +inline std::string& trim(std::string &str) { return ltrim(rtrim(str)); } /// Trim anything from string -std::string& trim(std::string &str, const std::string filter) { +inline std::string& trim(std::string &str, const std::string filter) { return ltrim(rtrim(str, filter), filter); } /// Make a copy of the string and then trim it -std::string trim_copy(const std::string &str) { +inline std::string trim_copy(const std::string &str) { std::string s = str; return trim(s); } /// Make a copy of the string and then trim it, any filter string can be used (any char in string is filtered) -std::string trim_copy(const std::string &str, const std::string &filter) { +inline std::string trim_copy(const std::string &str, const std::string &filter) { std::string s = str; return trim(s, filter); } /// Print a two part "help" string -void format_help(std::stringstream &out, std::string name, std::string description, size_t wid) { +inline void format_help(std::stringstream &out, std::string name, std::string description, size_t wid) { name = " " + name; out << std::setw(wid) << std::left << name; if(description != "") { @@ -145,14 +145,14 @@ inline bool valid_name_string(const std::string &str) { } /// Return a lower case version of a string -std::string inline to_lower(std::string str) { +inline std::string to_lower(std::string str) { std::transform(std::begin(str), std::end(str), std::begin(str), [](const std::string::value_type &x){return std::tolower(x,std::locale());}); return str; } /// Split a string '"one two" "three"' into 'one two', 'three' -std::vector inline split_up(std::string str) { +inline std::vector split_up(std::string str) { std::vector delims = {'\'', '\"'}; auto find_ws = [](char ch){ return std::isspace(ch , std::locale());}; diff --git a/include/CLI/Timer.hpp b/include/CLI/Timer.hpp index c7e9721a..89c4a844 100644 --- a/include/CLI/Timer.hpp +++ b/include/CLI/Timer.hpp @@ -119,6 +119,6 @@ public: } /// This prints out the time if shifted into a std::cout like stream. -std::ostream & operator<< (std::ostream& in, const CLI::Timer& timer) { +inline std::ostream & operator<< (std::ostream& in, const CLI::Timer& timer) { return in << timer.to_string(); } diff --git a/include/CLI/Validators.hpp b/include/CLI/Validators.hpp index e67165d5..9da47eda 100644 --- a/include/CLI/Validators.hpp +++ b/include/CLI/Validators.hpp @@ -24,7 +24,7 @@ namespace CLI { /// @{ /// Check for an existing file -bool ExistingFile(std::string filename) { +inline bool ExistingFile(std::string filename) { struct stat buffer; bool exist = stat(filename.c_str(), &buffer) == 0; bool is_dir = (buffer.st_mode & S_IFDIR) != 0; @@ -40,7 +40,7 @@ bool ExistingFile(std::string filename) { } /// Check for an existing directory -bool ExistingDirectory(std::string filename) { +inline bool ExistingDirectory(std::string filename) { struct stat buffer; bool exist = stat(filename.c_str(), &buffer) == 0; bool is_dir = (buffer.st_mode & S_IFDIR) != 0; @@ -57,7 +57,7 @@ bool ExistingDirectory(std::string filename) { /// Check for a non-existing path -bool NonexistentPath(std::string filename) { +inline bool NonexistentPath(std::string filename) { struct stat buffer; bool exist = stat(filename.c_str(), &buffer) == 0; if(!exist) {