Lumiera 0.pre.04~rc.1
»edit your freedom«
Loading...
Searching...
No Matches
util.cpp File Reference

Implementation of widely used helper functions. More...

Go to the source code of this file.

Description

Implementation of widely used helper functions.

The helpers implemented here are typically accessed by including util.hpp, so the reason of pushing down the implementation into a separate translation unit (this one here) is to avoid more heavyweight includes (e.g. boost).

Definition in file util.cpp.

#include "error.hpp"
#include "lib/util.hpp"
#include "lib/format-string.hpp"
#include <boost/algorithm/string.hpp>
#include <functional>
#include <regex>

Namespaces

namespace  util
 
namespace  util::anonymous_namespace{util.cpp}
 

Typedefs

using Cha = string::value_type
 
using ChPredicate = function< bool(Cha)>
 

Functions

ChPredicate operator! (ChPredicate p)
 
ChPredicate isValid (is_alnum() or is_any_of("-_.+$()@"))
 characters to be retained
 
ChPredicate isPunct (is_space() or is_any_of(",;:#*~´`?\\=/&%![]{}<>"))
 punctuation to be replaced by '_'
 
std::string sanitise (string const &org)
 produce an identifier based on the given string.
 
string trim (string const &org)
 remove leading and trailing whitespace
 
bool boolVal (string const &)
 interpret text representation of a boolean value.
 
bool isYes (string const &) noexcept
 check the given text if it can be interpreted as affirmative answer (bool true).
 
bool isNo (string const &) noexcept
 check if the given text is empty or can be interpreted as rejection (bool false)-
 

Variables

regex trueTokens { "\\s*(true|yes|on|1|\\+)\\s*", regex::icase | regex::optimize }
 
regex falseTokens { "\\s*(false|no|off|0|\\-)\\s*", regex::icase | regex::optimize }