27#include <boost/algorithm/string.hpp>
30using boost::algorithm::trim_right_copy_if;
31using boost::algorithm::is_any_of;
32using boost::algorithm::is_alnum;
33using boost::algorithm::is_space;
38using std::regex_match;
47 using Cha = string::value_type;
59 string res (trim_right_copy_if(org, !
isValid ));
60 string::iterator j = res.begin();
61 string::const_iterator i = org.begin();
62 string::const_iterator e = i + (res.length());
65 while ( i != e and !
isValid (*i) ) ++i;
66 while ( i != e and
isValid (*i) ) *(j++) = *(i++);
71 while ( i != e and
isPunct (*i));
74 res.erase(j,res.end());
87 return boost::algorithm::trim_copy (org);
94 regex
trueTokens {
"\\s*(true|yes|on|1|\\+)\\s*", regex::icase | regex::optimize };
95 regex
falseTokens{
"\\s*(false|no|off|0|\\-)\\s*", regex::icase | regex::optimize };
101 if (regex_match (textForm, trueTokens))
return true;
102 if (regex_match (textForm, falseTokens))
return false;
108 isYes (
string const& textForm)
noexcept
110 return regex_match (textForm, trueTokens);
115 isNo (
string const& textForm)
noexcept
117 return isnil (textForm)
118 or regex_match (textForm, falseTokens);
A front-end for using printf-style formatting.
Lumiera error handling (C++ interface).
LumieraError< LERR_(INVALID)> Invalid
bool isNo(string const &textForm) noexcept
check if the given text is empty or can be interpreted as rejection (bool false)-
std::string sanitise(std::string const &)
produce an identifier based on the given string.
ChPredicate isValid(is_alnum() or is_any_of("-_.+$()@"))
characters to be retained
ChPredicate operator!(ChPredicate p)
ChPredicate isPunct(is_space() or is_any_of(",;:#*~´`?\\=/&%![]{}<>"))
punctuation to be replaced by '_'
string trim(string const &org)
remove leading and trailing whitespace
bool boolVal(string const &textForm)
interpret text representation of a boolean value.
bool isYes(string const &textForm) noexcept
check the given text if it can be interpreted as affirmative answer (bool true).
function< bool(Cha)> ChPredicate
bool isnil(lib::time::Duration const &dur)
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...