mirror of
https://github.com/CLIUtils/CLI11.git
synced 2025-04-29 12:13:52 +00:00
Include missing inlines to allow linking
This commit is contained in:
parent
e772c0e43b
commit
1e627bfcf2
@ -63,7 +63,7 @@ struct ini_ret_t {
|
||||
};
|
||||
|
||||
/// Internal parsing function
|
||||
std::vector<ini_ret_t> parse_ini(std::istream &input) {
|
||||
inline std::vector<ini_ret_t> parse_ini(std::istream &input) {
|
||||
std::string name, line;
|
||||
std::string section = "default";
|
||||
|
||||
@ -103,7 +103,7 @@ std::vector<ini_ret_t> parse_ini(std::istream &input) {
|
||||
}
|
||||
|
||||
/// Parse an INI file, throw an error (ParseError:INIParseError or FileError) on failure
|
||||
std::vector<ini_ret_t> parse_ini(const std::string &name) {
|
||||
inline std::vector<ini_ret_t> parse_ini(const std::string &name) {
|
||||
|
||||
std::ifstream input{name};
|
||||
if(!input.good())
|
||||
|
@ -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<std::string> split(const std::string &s, char delim) {
|
||||
inline std::vector<std::string> split(const std::string &s, char delim) {
|
||||
std::vector<std::string> 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<char>(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<char>(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<std::string> inline split_up(std::string str) {
|
||||
inline std::vector<std::string> split_up(std::string str) {
|
||||
|
||||
std::vector<char> delims = {'\'', '\"'};
|
||||
auto find_ws = [](char ch){ return std::isspace<char>(ch , std::locale());};
|
||||
|
@ -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();
|
||||
}
|
||||
|
@ -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) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user