CLI11 2.4.2
Loading...
Searching...
No Matches
StringTools.hpp File Reference
#include <algorithm>
#include <iomanip>
#include <locale>
#include <sstream>
#include <stdexcept>
#include <string>
#include <type_traits>
#include <vector>
#include "Macros.hpp"
#include "impl/StringTools_inl.hpp"

Go to the source code of this file.

Namespaces

namespace  CLI
 
namespace  CLI::enums
 
namespace  CLI::detail
 

Functions

template<typename T , typename = typename std::enable_if<std::is_enum<T>::value>::type>
std::ostream & CLI::enums::operator<< (std::ostream &in, const T &item)
 output streaming for enumerations
 
CLI11_INLINE std::vector< std::string > CLI::detail::split (const std::string &s, char delim)
 Split a string by a delim.
 
template<typename T >
std::string CLI::detail::join (const T &v, std::string delim=",")
 Simple function to join a string.
 
template<typename T , typename Callable , typename = typename std::enable_if<!std::is_constructible<std::string, Callable>::value>::type>
std::string CLI::detail::join (const T &v, Callable func, std::string delim=",")
 Simple function to join a string from processed elements.
 
template<typename T >
std::string CLI::detail::rjoin (const T &v, std::string delim=",")
 Join a string in reverse order.
 
CLI11_INLINE std::string & CLI::detail::ltrim (std::string &str)
 Trim whitespace from left of string.
 
CLI11_INLINE std::string & CLI::detail::ltrim (std::string &str, const std::string &filter)
 Trim anything from left of string.
 
CLI11_INLINE std::string & CLI::detail::rtrim (std::string &str)
 Trim whitespace from right of string.
 
CLI11_INLINE std::string & CLI::detail::rtrim (std::string &str, const std::string &filter)
 Trim anything from right of string.
 
std::string & CLI::detail::trim (std::string &str)
 Trim whitespace from string.
 
std::string & CLI::detail::trim (std::string &str, const std::string filter)
 Trim anything from string.
 
std::string CLI::detail::trim_copy (const std::string &str)
 Make a copy of the string and then trim it.
 
CLI11_INLINE std::string & CLI::detail::remove_quotes (std::string &str)
 remove quotes at the front and back of a string either '"' or '\''
 
CLI11_INLINE void CLI::detail::remove_quotes (std::vector< std::string > &args)
 remove quotes from all elements of a string vector and process escaped components
 
CLI11_INLINE std::string CLI::detail::fix_newlines (const std::string &leader, std::string input)
 
std::string CLI::detail::trim_copy (const std::string &str, const std::string &filter)
 Make a copy of the string and then trim it, any filter string can be used (any char in string is filtered)
 
CLI11_INLINE std::ostream & CLI::detail::format_help (std::ostream &out, std::string name, const std::string &description, std::size_t wid)
 Print a two part "help" string.
 
CLI11_INLINE std::ostream & CLI::detail::format_aliases (std::ostream &out, const std::vector< std::string > &aliases, std::size_t wid)
 Print subcommand aliases.
 
template<typename T >
bool CLI::detail::valid_first_char (T c)
 
template<typename T >
bool CLI::detail::valid_later_char (T c)
 Verify following characters of an option.
 
CLI11_INLINE bool CLI::detail::valid_name_string (const std::string &str)
 Verify an option/subcommand name.
 
bool CLI::detail::valid_alias_name_string (const std::string &str)
 Verify an app name.
 
bool CLI::detail::is_separator (const std::string &str)
 check if a string is a container segment separator (empty or "%%")
 
bool CLI::detail::isalpha (const std::string &str)
 Verify that str consists of letters only.
 
std::string CLI::detail::to_lower (std::string str)
 Return a lower case version of a string.
 
std::string CLI::detail::remove_underscore (std::string str)
 remove underscores from a string
 
CLI11_INLINE std::string CLI::detail::find_and_replace (std::string str, std::string from, std::string to)
 Find and replace a substring with another substring.
 
bool CLI::detail::has_default_flag_values (const std::string &flags)
 check if the flag definitions has possible false flags
 
CLI11_INLINE void CLI::detail::remove_default_flag_values (std::string &flags)
 
CLI11_INLINE std::ptrdiff_t CLI::detail::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.
 
template<typename Callable >
std::string CLI::detail::find_and_modify (std::string str, std::string trigger, Callable modify)
 
CLI11_INLINE std::vector< std::string > CLI::detail::split_up (std::string str, char delimiter='\0')
 
CLI11_INLINE std::string CLI::detail::get_environment_value (const std::string &env_name)
 get the value of an environmental variable or empty string if empty
 
CLI11_INLINE std::size_t CLI::detail::escape_detect (std::string &str, std::size_t offset)
 
CLI11_INLINE bool CLI::detail::has_escapable_character (const std::string &str)
 detect if a string has escapable characters
 
CLI11_INLINE std::string CLI::detail::add_escaped_characters (const std::string &str)
 escape all escapable characters
 
CLI11_INLINE std::string CLI::detail::remove_escaped_characters (const std::string &str)
 replace the escaped characters with their equivalent
 
CLI11_INLINE std::string CLI::detail::binary_escape_string (const std::string &string_to_escape)
 generate a string with all non printable characters escaped to hex codes
 
CLI11_INLINE bool CLI::detail::is_binary_escaped_string (const std::string &escaped_string)
 
CLI11_INLINE std::string CLI::detail::extract_binary_string (const std::string &escaped_string)
 extract an escaped binary_string
 
CLI11_INLINE bool CLI::detail::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
 

Variables

constexpr int CLI::detail::expected_max_vector_size {1 << 29}