31template <typename T, typename = typename std::enable_if<std::is_enum<T>::value>::type>
32std::ostream &
operator<<(std::ostream &in,
const T &item) {
34 return in << static_cast<typename std::underlying_type<T>::type>(item);
40using enums::operator<<;
51template <
typename T> std::string
join(
const T &
v, std::string
delim =
",") {
53 auto beg = std::begin(
v);
54 auto end = std::end(
v);
66 typename =
typename std::enable_if<!std::is_constructible<std::string, Callable>::value>::type>
69 auto beg = std::begin(
v);
70 auto end = std::end(
v);
73 auto nloc =
s.tellp();
84template <
typename T> std::string
rjoin(
const T &
v, std::string
delim =
",") {
139format_help(std::ostream &
out, std::string name,
const std::string &description, std::size_t
wid);
147 return ((
c !=
'-') && (
static_cast<unsigned char>(
c) > 33));
155 return ((
c !=
'=') && (
c !=
':') && (
c !=
'{') && ((
static_cast<unsigned char>(
c) > 32) ||
c ==
'\t'));
163 static const std::string
badChars(std::string(
"\n") +
'\0');
164 return (
str.find_first_of(
badChars) == std::string::npos);
169 static const std::string
sep(
"%%");
175 return std::all_of(
str.begin(),
str.end(), [](
char c) { return std::isalpha(c, std::locale()); });
180 std::transform(std::begin(
str), std::end(
str), std::begin(
str), [](
const std::string::value_type &
x) {
181 return std::tolower(
x, std::locale());
188 str.erase(std::remove(std::begin(
str), std::end(
str),
'_'), std::end(
str));
197 return (
flags.find_first_of(
"{!") != std::string::npos);
204 const std::vector<std::string>
names,
266#include "impl/StringTools_inl.hpp"
#define CLI11_INLINE
Definition Macros.hpp:129
CLI11_INLINE std::string fix_newlines(const std::string &leader, std::string input)
auto checked_to_string(T &&value) -> decltype(to_string(std::forward< T >(value)))
special template overload
Definition TypeTools.hpp:349
CLI11_INLINE bool is_binary_escaped_string(const std::string &escaped_string)
CLI11_INLINE void remove_default_flag_values(std::string &flags)
bool valid_first_char(T c)
Definition StringTools.hpp:146
CLI11_INLINE std::string find_and_replace(std::string str, std::string from, std::string to)
Find and replace a substring with another substring.
CLI11_INLINE std::string add_escaped_characters(const std::string &str)
escape all escapable characters
CLI11_INLINE std::vector< std::string > split(const std::string &s, char delim)
Split a string by a delim.
std::string remove_underscore(std::string str)
remove underscores from a string
Definition StringTools.hpp:187
bool is_separator(const std::string &str)
check if a string is a container segment separator (empty or "%%")
Definition StringTools.hpp:168
std::string find_and_modify(std::string str, std::string trigger, Callable modify)
Definition StringTools.hpp:210
std::string trim_copy(const std::string &str)
Make a copy of the string and then trim it.
Definition StringTools.hpp:115
CLI11_INLINE std::string & ltrim(std::string &str)
Trim whitespace from left of string.
std::string & trim(std::string &str)
Trim whitespace from string.
Definition StringTools.hpp:109
CLI11_INLINE std::size_t close_sequence(const std::string &str, std::size_t start, char closure_char)
bool valid_later_char(T c)
Verify following characters of an option.
Definition StringTools.hpp:151
CLI11_INLINE std::string binary_escape_string(const std::string &string_to_escape)
generate a string with all non printable characters escaped to hex codes
CLI11_INLINE std::size_t escape_detect(std::string &str, std::size_t offset)
CLI11_INLINE std::vector< std::string > split_up(std::string str, char delimiter='\0')
constexpr int expected_max_vector_size
Definition StringTools.hpp:45
std::string join(const T &v, std::string delim=",")
Simple function to join a string.
Definition StringTools.hpp:51
CLI11_INLINE std::string & remove_quotes(std::string &str)
remove quotes at the front and back of a string either '"' or '\''
CLI11_INLINE std::ostream & format_aliases(std::ostream &out, const std::vector< std::string > &aliases, std::size_t wid)
Print subcommand aliases.
CLI11_INLINE std::ostream & format_help(std::ostream &out, std::string name, const std::string &description, std::size_t wid)
Print a two part "help" string.
bool valid_alias_name_string(const std::string &str)
Verify an app name.
Definition StringTools.hpp:162
bool isalpha(const std::string &str)
Verify that str consists of letters only.
Definition StringTools.hpp:174
CLI11_INLINE std::ptrdiff_t find_member(std::string name, const std::vector< std::string > names, bool ignore_case=false, bool ignore_underscore=false)
Check if a string is a member of a list of strings and optionally ignore case or ignore underscores.
CLI11_INLINE bool has_escapable_character(const std::string &str)
detect if a string has escapable characters
CLI11_INLINE std::string get_environment_value(const std::string &env_name)
get the value of an environmental variable or empty string if empty
CLI11_INLINE bool process_quoted_string(std::string &str, char string_char='\"', char literal_char = '\'')
process a quoted string, remove the quotes and if appropriate handle escaped characters
CLI11_INLINE bool valid_name_string(const std::string &str)
Verify an option/subcommand name.
CLI11_INLINE std::string remove_escaped_characters(const std::string &str)
replace the escaped characters with their equivalent
std::string to_lower(std::string str)
Return a lower case version of a string.
Definition StringTools.hpp:179
bool has_default_flag_values(const std::string &flags)
check if the flag definitions has possible false flags
Definition StringTools.hpp:196
CLI11_INLINE std::string & rtrim(std::string &str)
Trim whitespace from right of string.
std::string rjoin(const T &v, std::string delim=",")
Join a string in reverse order.
Definition StringTools.hpp:84
CLI11_INLINE std::string extract_binary_string(const std::string &escaped_string)
extract an escaped binary_string
std::ostream & operator<<(std::ostream &in, const T &item)
output streaming for enumerations
Definition StringTools.hpp:32
std::string ignore_case(std::string item)
Helper function to allow ignore_case to be passed to IsMember or Transform.
Definition Validators.hpp:693
std::string ignore_underscore(std::string item)
Helper function to allow ignore_underscore to be passed to IsMember or Transform.
Definition Validators.hpp:696