Fleet  0.0.9
Inference in the LOT
Enumerations | Functions | Variables
CLI::detail Namespace Reference

Enumerations

enum  enabler
 Simple empty scoped class. More...
 

Functions

std::vector< std::string > split (const std::string &s, char delim)
 Split a string by a delim. More...
 
template<typename T >
std::string join (const T &v, std::string delim=",")
 Simple function to join a string. More...
 
template<typename T >
std::string rjoin (const T &v, std::string delim=",")
 Join a string in reverse order. More...
 
std::string & ltrim (std::string &str)
 Trim whitespace from left of string. More...
 
std::string & ltrim (std::string &str, const std::string &filter)
 Trim anything from left of string. More...
 
std::string & rtrim (std::string &str)
 Trim whitespace from right of string. More...
 
std::string & rtrim (std::string &str, const std::string &filter)
 Trim anything from right of string. More...
 
std::string & trim (std::string &str)
 Trim whitespace from string. More...
 
std::string & trim (std::string &str, const std::string filter)
 Trim anything from string. More...
 
std::string trim_copy (const std::string &str)
 Make a copy of the string and then trim it. More...
 
std::string 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) More...
 
void format_help (std::stringstream &out, std::string name, std::string description, size_t wid)
 Print a two part "help" string. More...
 
template<typename T >
bool valid_first_char (T c)
 Verify the first character of an option. More...
 
template<typename T >
bool valid_later_char (T c)
 Verify following characters of an option. More...
 
bool valid_name_string (const std::string &str)
 Verify an option name. More...
 
std::string to_lower (std::string str)
 Return a lower case version of a string. More...
 
std::vector< std::string > split_up (std::string str)
 Split a string '"one two" "three"' into 'one two', 'three'. More...
 
std::string fix_newlines (std::string leader, std::string input)
 
template<typename T , enable_if_t< std::is_integral< T >::value &&std::is_signed< T >::value, detail::enabler > = detail::dummy>
constexpr const char * type_name ()
 This one should not be used, since vector types print the internal type. More...
 
template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_signed< T >::value)||std::is_enum< T >::value, detail::enabler > = detail::dummy>
bool lexical_cast (std::string input, T &output)
 Signed integers / enums. More...
 
bool split_short (const std::string &current, std::string &name, std::string &rest)
 
bool split_long (const std::string &current, std::string &name, std::string &value)
 
std::vector< std::string > split_names (std::string current)
 
std::tuple< std::vector< std::string >, std::vector< std::string >, std::string > get_names (const std::vector< std::string > &input)
 Get a vector of short names, one of long names, and a single name. More...
 

Variables

constexpr enabler dummy = {}
 An instance to use in EnableIf. More...
 

Enumeration Type Documentation

◆ enabler

enum CLI::detail::enabler
strong

Simple empty scoped class.

Function Documentation

◆ fix_newlines()

std::string CLI::detail::fix_newlines ( std::string  leader,
std::string  input 
)
inline

Add a leader to the beginning of all new lines (nothing is added at the start of the first line). "; " would be for ini files

Can't use Regex, or this would be a subs.

◆ format_help()

void CLI::detail::format_help ( std::stringstream &  out,
std::string  name,
std::string  description,
size_t  wid 
)
inline

Print a two part "help" string.

◆ get_names()

std::tuple<std::vector<std::string>, std::vector<std::string>, std::string> CLI::detail::get_names ( const std::vector< std::string > &  input)
inline

Get a vector of short names, one of long names, and a single name.

◆ join()

template<typename T >
std::string CLI::detail::join ( const T &  v,
std::string  delim = "," 
)

Simple function to join a string.

◆ lexical_cast()

template<typename T , enable_if_t<(std::is_integral< T >::value &&std::is_signed< T >::value)||std::is_enum< T >::value, detail::enabler > = detail::dummy>
bool CLI::detail::lexical_cast ( std::string  input,
T &  output 
)

Signed integers / enums.

Non-string parsable.

String and similar.

Floats.

Unsigned integers.

◆ ltrim() [1/2]

std::string& CLI::detail::ltrim ( std::string &  str)
inline

Trim whitespace from left of string.

◆ ltrim() [2/2]

std::string& CLI::detail::ltrim ( std::string &  str,
const std::string &  filter 
)
inline

Trim anything from left of string.

◆ rjoin()

template<typename T >
std::string CLI::detail::rjoin ( const T &  v,
std::string  delim = "," 
)

Join a string in reverse order.

◆ rtrim() [1/2]

std::string& CLI::detail::rtrim ( std::string &  str)
inline

Trim whitespace from right of string.

◆ rtrim() [2/2]

std::string& CLI::detail::rtrim ( std::string &  str,
const std::string &  filter 
)
inline

Trim anything from right of string.

◆ split()

std::vector<std::string> CLI::detail::split ( const std::string &  s,
char  delim 
)
inline

Split a string by a delim.

◆ split_long()

bool CLI::detail::split_long ( const std::string &  current,
std::string &  name,
std::string &  value 
)
inline

◆ split_names()

std::vector<std::string> CLI::detail::split_names ( std::string  current)
inline

◆ split_short()

bool CLI::detail::split_short ( const std::string &  current,
std::string &  name,
std::string &  rest 
)
inline

◆ split_up()

std::vector<std::string> CLI::detail::split_up ( std::string  str)
inline

Split a string '"one two" "three"' into 'one two', 'three'.

◆ to_lower()

std::string CLI::detail::to_lower ( std::string  str)
inline

Return a lower case version of a string.

◆ trim() [1/2]

std::string& CLI::detail::trim ( std::string &  str)
inline

Trim whitespace from string.

◆ trim() [2/2]

std::string& CLI::detail::trim ( std::string &  str,
const std::string  filter 
)
inline

Trim anything from string.

◆ trim_copy() [1/2]

std::string CLI::detail::trim_copy ( const std::string &  str)
inline

Make a copy of the string and then trim it.

◆ trim_copy() [2/2]

std::string CLI::detail::trim_copy ( const std::string &  str,
const std::string &  filter 
)
inline

Make a copy of the string and then trim it, any filter string can be used (any char in string is filtered)

◆ type_name()

template<typename T , enable_if_t< std::is_integral< T >::value &&std::is_signed< T >::value, detail::enabler > = detail::dummy>
constexpr const char * CLI::detail::type_name ( )

This one should not be used, since vector types print the internal type.

Was going to be based on http://stackoverflow.com/questions/1055452/c-get-name-of-type-in-template But this is cleaner and works better in this case

◆ valid_first_char()

template<typename T >
bool CLI::detail::valid_first_char ( c)

Verify the first character of an option.

◆ valid_later_char()

template<typename T >
bool CLI::detail::valid_later_char ( c)

Verify following characters of an option.

◆ valid_name_string()

bool CLI::detail::valid_name_string ( const std::string &  str)
inline

Verify an option name.

Variable Documentation

◆ dummy

constexpr enabler CLI::detail::dummy = {}

An instance to use in EnableIf.