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

Namespaces

namespace  anonymous_namespace{access-casted-o.hpp}
 
namespace  anonymous_namespace{access-casted.hpp}
 
namespace  anonymous_namespace{format-obj.hpp}
 
namespace  anonymous_namespace{format-string.cpp}
 
namespace  anonymous_namespace{format-string.hpp}
 
namespace  anonymous_namespace{format-util.hpp}
 
namespace  anonymous_namespace{util-coll.hpp}
 
namespace  anonymous_namespace{util-tuple.hpp}
 
namespace  anonymous_namespace{util.cpp}
 
namespace  parse
 
namespace  test
 

Typedefs

typedef unsigned char uchar
 
using Rat = boost::rational< int64_t >
 
using Cha = string::value_type
 
using ChPredicate = function< bool(Cha)>
 

Classes

class  _Fmt
 A front-end for using printf-style formatting. More...
 
struct  AccessCasted
 Helper template to access a given value, possibly converted or casted in a safe way. More...
 
struct  AccessCasted_O
 
class  Cloneable
 Types marked with this mix-in may be duplicated by copy-construction, yet may not be moved or transferred any further after creation. More...
 
struct  IDiv
 helper to treat int or long division uniformly More...
 
struct  IDiv< int >
 
struct  IDiv< llong >
 
struct  IDiv< long >
 
class  IosSavepoint
 RAII helper to capture and restore output stream format settings. More...
 
class  MoveAssign
 Types marked with this mix-in may be moved and move-assigned. More...
 
class  MoveOnly
 Types marked with this mix-in may be moved but not copied. More...
 
class  NoInstance
 Not meant to be instantiated in any way. More...
 
class  NonAssign
 Types marked with this mix-in may be created and moved liberally at construction, while any further assignment to object instances is prohibited thereafter. More...
 
class  NonCopyable
 Any copy and copy construction prohibited. More...
 
struct  NullAccessor
 
struct  RegexSearchIter
 wrapped regex iterator to allow usage in foreach loops More...
 
struct  StringConv
 failsafe invocation of custom string conversion. More...
 
struct  StringConv< bool >
 
struct  StringConv< double >
 explicit specialisation to control precision of double values. More...
 
struct  StringConv< float >
 
struct  StringConv< fs::path, void >
 specialisation: render filesystem path as double quoted string More...
 
struct  StringConv< lib::meta::Num< i > >
 
struct  StringConv< lib::time::FSecs, void >
 specialisation: render fractional seconds (for diagnostics) More...
 
struct  StringConv< SP, show_SmartPointer< SP > >
 
struct  StringConv< std::array< T, N > >
 convenient pretty-printer for std::array instances More...
 
struct  StringConv< std::tuple< TYPES... > >
 
struct  StringConv< X *, lib::meta::disable_if< std::__or_< std::is_same< std::remove_cv_t< X >, char >, std::is_same< std::remove_cv_t< X >, void > > > >
 specialisation to allow rendering pointers to string-convertible types. More...
 
struct  StringConv< X, enable_LexicalConversion< X > >
 
struct  StringConv< X, lib::meta::enable_CustomStringConversion< X > >
 

Functions

template<typename F >
string showFloatingPoint (F val, size_t precision) noexcept
 
string showDouble (double) noexcept
 pretty-print a double in (rounded) fixed-point format
 
string showFloat (float val) noexcept
 
string showDecimal (double) noexcept
 show maximum reproducible decimal representation
 
string showDecimal (float val) noexcept
 
string showDecimal (f128 val) noexcept
 
string showComplete (double) noexcept
 show enough decimal digits to represent every distinct value
 
string showComplete (float val) noexcept
 
string showComplete (f128 val) noexcept
 
string showSize (size_t val) noexcept
 
ostream & showAdr (std::ostream &, void const *addr)
 preconfigured format for pretty-printing of addresses
 
string showAdr (void const *addr) noexcept
 pretty-print an address as hex-suffix
 
string showHash (size_t hash, uint showBytes=8) noexcept
 renders the size_t in hex, optionally only trailing bytes
 
std::string showHashLSB (size_t hash) noexcept
 
template<typename TY >
std::string toString (TY const &val) noexcept
 get some string representation of any object, reliably.
 
template<typename TY >
std::string typedString (TY const &val) noexcept
 indicate type and possibly a (custom) conversion to string
 
std::ostream & operator<< (std::ostream &os, _Fmt const &fmt)
 send the formatted buffer directly to the output stream.
 
 LUMIERA_ERROR_DEFINE (FORMAT_SYNTAX, "Syntax error in format string for boost::format")
 
 LUMIERA_ERROR_DECLARE (FORMAT_SYNTAX)
 "Syntax error in format string for boost::format"
 
bool operator== (_Fmt const &left, _Fmt const &right)
 
bool operator== (_Fmt const &fmt, string const &str)
 
bool operator== (_Fmt const &fmt, CStr const cString)
 
bool operator== (string const &str, _Fmt const &fmt)
 
bool operator== (CStr const cString, _Fmt const &fmt)
 
template<class CON , typename... ELMS>
CON collectStr (ELMS const &...elms)
 convert a sequence of elements to string
 
template<typename... ELMS>
vector< string > stringify (ELMS const &...elms)
 standard setup: convert to string into a vector
 
template<class IT >
auto stringify (IT &&src)
 convert to string as transforming step in a pipeline
 
template<class COLL >
string join (COLL &&coll, string const &delim=", ")
 enumerate a collection's contents, separated by delimiter.
 
template<class X >
string join (std::initializer_list< X > const &&ili, string const &delim=", ")
 
template<typename... ARGS>
string joinArgList (ARGS const &...args)
 shortcut: List in parentheses, separated by comma, using temporary vector
 
template<typename... ARGS>
string joinDash (ARGS const &...args)
 shortcut: join directly with dashes
 
template<typename... ARGS>
string joinDot (ARGS const &...args)
 shortcut: join directly with dots
 
template<class COLL >
string toStringParen (COLL &&coll)
 one-argument variant that can be forward declared...
 
template<class COLL >
string toStringBracket (COLL &&coll)
 
template<class OBJ >
OBJ * unConst (const OBJ *o)
 shortcut to save some typing when having to define const and non-const variants of member functions
 
template<class OBJ >
OBJ & unConst (OBJ const &)
 
std::string showBool (bool yes) noexcept
 human readable display of boolean values
 
template<typename X >
lib::meta::disable_if< std::is_pointer< X >, std::string > showAdr (X &elm) noexcept
 
template<typename X >
std::string showPtr (X *ptr=nullptr)
 diagnostics helper for explicitly indicating pointers
 
template<typename SP >
std::string showSmartPtr (SP const &smPtr, std::string label="smP")
 
bool can_represent_Product (int64_t a, int64_t b)
 
bool can_represent_Product (Rat a, Rat b)
 
bool can_represent_Sum (Rat a, Rat b)
 
int64_t reQuant (int64_t num, int64_t den, int64_t u)
 Re-Quantise a number into a new grid, truncating to the next lower grid point.
 
Rat reQuant (Rat src, int64_t u)
 re-Quantise a rational number to a (typically smaller) denominator.
 
template<typename STR >
std::optional< smatch > matchAtStart (STR &&toParse, regex const &regex)
 Helper algorithm to perform a search but require the match to start at the beginning of the string or sequence, while accepting trailing content.
 
template<typename STR >
size_t leadingWhitespace (STR &&toParse)
 
template<class COLL >
std::string toStringBracket (COLL &&coll)
 
std::string sanitise (string const &org)
 produce an identifier based on the given string.
 
bool isnil (lib::time::Duration const &dur)
 
template<typename COLL , typename = enable_if< treat_as_STL_Container<COLL>>>
auto first (COLL const &coll)
 access the first element of a STL-like container.
 
template<typename COLL , typename = enable_if< can_direct_access_Last<COLL>>>
auto last (COLL const &coll)
 access the last element of a STL-like container.
 
template<typename IT , typename = enable_if<treat_as_LumieraIterator<IT>>>
auto first (IT ii)
 extract the first element yielded by an Lumiera Forward Iterator.
 
template<class IT >
auto max (IT &&elms)
 
template<class CON >
auto max (CON const &elms)
 
template<class IT >
auto min (IT &&elms)
 
template<class CON >
auto min (CON const &elms)
 
template<typename IT , typename FUN >
bool and_all (IT i, IT end, FUN predicate)
 All quantification: check if all elements of a collection satisfy the given predicate.
 
template<typename IT , typename FUN >
bool has_any (IT i, IT end, FUN predicate)
 Existential quantification: check if any element of a collection satisfies the given predicate.
 
template<typename Container , typename FUN >
disable_if< can_IterForEach< Container >, FUN > for_each (Container const &coll, FUN doIt)
 operate on all elements of a STL container.
 
template<typename IT , typename FUN >
enable_if< can_IterForEach< IT >, FUN > for_each (IT const &ii, FUN doIt)
 operate on a Lumiera Forward Iterator until exhaustion.
 
template<typename Container , typename FUN >
enable_if< can_STL_ForEach< Container >, bool > and_all (Container const &coll, FUN predicate)
 
template<typename IT , typename FUN >
enable_if< can_IterForEach< IT >, bool > and_all (IT const &ii, FUN predicate)
 
template<typename Container , typename FUN >
enable_if< can_STL_ForEach< Container >, bool > has_any (Container const &coll, FUN predicate)
 
template<typename IT , typename FUN >
enable_if< can_IterForEach< IT >, bool > has_any (IT const &ii, FUN predicate)
 
template<typename CON , typename FUN , typename P1 , typename... ARGS>
void for_each (CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
 Accept binding for arbitrary function arguments.
 
template<typename CON , typename FUN , typename P1 , typename... ARGS>
bool and_all (CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
 Accept binding for arbitrary function arguments.
 
template<typename CON , typename FUN , typename P1 , typename... ARGS>
bool has_any (CON const &elements, FUN function, P1 &&bind1, ARGS &&...args)
 Accept binding for arbitrary function arguments.
 
template<typename N >
constexpr bool isPow2 (N n)
 
template<typename I >
IDiv< I > iDiv (I num, I den)
 
template<typename I >
floordiv (I num, I den)
 floor function for integer arithmetics.
 
template<typename I >
IDiv< I > floorwrap (I num, I den)
 scale wrapping operation.
 
bool almostEqual (double d1, double d2, unsigned int ulp=2)
 epsilon comparison of doubles.
 
template<typename I >
constexpr int ilog2 (I num)
 Integral binary logarithm (disregarding fractional part)
 
template<size_t N, class SEQ >
auto seqTuple (SEQ &&iter)
 Unpack an iterator to build a fixed-size std::tuple of references.
 
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 '_'
 
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)-
 
template<class NUM >
constexpr int sgn (NUM n)
 
template<class N1 , class N2 >
constexpr N1 min (N1 n1, N2 n2)
 
template<class N1 , class N2 >
constexpr N1 max (N1 n1, N2 n2)
 
template<typename NUM >
constexpr NUM noneg (NUM val)
 cut a numeric value to be >=0
 
template<typename NUM , typename NB >
constexpr NUM limited (NB lowerBound, NUM val, NB upperBound)
 force a numeric to be within bounds, inclusively
 
template<typename NUM , typename NB >
constexpr bool isLimited (NB lowerBound, NUM val, NB upperBound)
 
template<typename UN , typename N2 >
constexpr UN positiveDiff (N2 newVal, UN refVal)
 
uint uNum (CStr charPtr)
 positive integral number from textual representation
 
int sNum (CStr charPtr)
 
template<class OBJ >
uint uNum (OBJ const &spec)
 
template<class OBJ >
int sNum (OBJ const &spec)
 
template<class CONT >
bool isnil (const CONT &container)
 a family of util functions providing a "no value whatsoever" test.
 
template<class CONT >
bool isnil (const CONT *pContainer)
 
template<class CONT >
bool isnil (CONT *pContainer)
 
bool isnil (CStr charPtr)
 
bool startsWith (string const &str, string const &prefix)
 check if string starts with a given prefix
 
bool startsWith (string const &str, CStr prefix)
 
bool endsWith (string const &str, string const &suffix)
 check if string ends with the given suffix
 
bool endsWith (string const &str, CStr suffix)
 
void removePrefix (string &str, string const &prefix)
 
void removeSuffix (string &str, string const &suffix)
 
template<typename MAP >
bool contains (MAP &map, typename MAP::key_type const &key)
 shortcut for containment test on a map
 
template<typename T , class CMP , class ALO >
bool contains (std::set< T, CMP, ALO > const &set, T const &val)
 shortcut for set value containment test
 
template<typename T >
bool contains (std::string const &str, const T &val)
 shortcut for string value containment test
 
template<typename SEQ >
bool contains (SEQ const &cont, typename SEQ::const_reference val)
 shortcut for brute-force containment test in any sequential container
 
template<class IT >
bool linearSearch (IT iter, typename IT::value_type const &val)
 use (and exhaust) a »Lumiera Forward Iterator« for linear search
 
template<typename MAP >
MAP::mapped_type getValue_or_default (MAP &map, typename MAP::key_type const &key, typename MAP::mapped_type defaultVal)
 fetch value from a Map, or return a default if not found
 
template<typename MAP >
MAP::mapped_type const & access_or_default (MAP &map, typename MAP::key_type const &key, typename MAP::mapped_type const &refDefault)
 expose a reference to a map entry, with fall-back to some default object
 
template<typename SEQ >
SEQ::iterator removeall (SEQ &coll, typename SEQ::value_type const &val)
 shortcut for removing all copies of an Element in any sequential collection
 
template<class SET , typename FUN >
bool remove_if (SET &set, FUN test)
 remove all elements fulfilling a given predicate from a (sorted) set.
 
template<class X >
const void * getAdr (X &x)
 extract address but strip any type info
 
template<class X >
const void * getAdr (X *x)
 
template<class X >
size_t addrID (X const &x)
 generate an unique numeric ID based on the referred entity
 
template<typename X >
size_t slotNr (X const &x)
 the addressable memory »slot« — platform dependent.
 
template<class A , class B >
bool isSameAdr (A const &a, B const &b)
 compare plain object address identity, disregarding type.
 
template<class A , class B >
bool isSameObject (A const &a, B const &b)
 compare plain object identity, based directly on the referee's memory identities.
 
template<typename A , typename B >
bool isCloseBy (A &&a, B &&b, size_t consideredNearby=50)
 determine heuristically if two objects are located „close to each other“ in memory.
 

Typedef Documentation

◆ uchar

typedef unsigned char uchar

Definition at line 133 of file format-string.hpp.

◆ Rat

using Rat = boost::rational<int64_t>

Definition at line 73 of file rational.hpp.

◆ Cha

using Cha = string::value_type

Definition at line 47 of file util.cpp.

◆ ChPredicate

using ChPredicate = function<bool(Cha)>

Definition at line 48 of file util.cpp.

Function Documentation

◆ showFloatingPoint()

template<typename F >
string showFloatingPoint ( val,
size_t  precision 
)
noexcept

Definition at line 343 of file format-obj.cpp.

Referenced by showComplete(), showComplete(), showComplete(), showDecimal(), showDecimal(), showDecimal(), showDouble(), and showFloat().

+ Here is the caller graph for this function:

◆ showDouble()

std::string showDouble ( double  val)
noexcept

pretty-print a double in (rounded) fixed-point format

Returns
fixed point string representation, never empty
Note
we set an explicit precision, since this is a diagnostic facility
Remarks
typically do not want to see all digits, but, for test code, we do want a predictable string representation of simple fractional values like 0.1 (which can not be represented as binary floats)

Definition at line 360 of file format-obj.cpp.

References showFloatingPoint().

Referenced by StringConv< double >::invoke().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showFloat()

std::string showFloat ( float  val)
noexcept

Definition at line 361 of file format-obj.cpp.

References showFloatingPoint().

Referenced by StringConv< float >::invoke().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showDecimal() [1/3]

std::string showDecimal ( double  val)
noexcept

show maximum reproducible decimal representation

Definition at line 363 of file format-obj.cpp.

References showFloatingPoint().

Referenced by lib::stat::anonymous_namespace{csv.hpp}::format4Csv(), and DataCSV_test::verify_CSV_Format().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showDecimal() [2/3]

std::string showDecimal ( float  val)
noexcept

Definition at line 364 of file format-obj.cpp.

References showFloatingPoint().

+ Here is the call graph for this function:

◆ showDecimal() [3/3]

std::string showDecimal ( f128  val)
noexcept

Definition at line 365 of file format-obj.cpp.

References showFloatingPoint().

+ Here is the call graph for this function:

◆ showComplete() [1/3]

std::string showComplete ( double  val)
noexcept

show enough decimal digits to represent every distinct value

Definition at line 367 of file format-obj.cpp.

References showFloatingPoint().

Referenced by DataCSV_test::verify_CSV_Format().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showComplete() [2/3]

std::string showComplete ( float  val)
noexcept

Definition at line 368 of file format-obj.cpp.

References showFloatingPoint().

+ Here is the call graph for this function:

◆ showComplete() [3/3]

std::string showComplete ( f128  val)
noexcept

Definition at line 369 of file format-obj.cpp.

References showFloatingPoint().

+ Here is the call graph for this function:

◆ showSize()

std::string showSize ( size_t  val)
noexcept

Definition at line 373 of file format-obj.cpp.

Referenced by BlockFlow< CONF >::___sanityCheckAlloc(), ExtentFamily< T, siz >::___sanityCheckAllocSize(), and FamilyMember< TY >::operator string().

+ Here is the caller graph for this function:

◆ showAdr() [1/3]

std::ostream & showAdr ( ostream &  stream,
void const *  addr 
)

preconfigured format for pretty-printing of addresses

Note
show only the trailing X bytes of any address
Examples
/Werk/devel/lumi/src/lib/test/test-helper.hpp.

Definition at line 385 of file format-obj.cpp.

References showAdr().

Referenced by ActivityDetector::buildActivationTap(), ActivityDetector::buildGateWatcher(), RandomChainCalcFunctor< maxFan >::diagnostic(), ActivityDetector::insertActivationTap(), NullDisplayer::put(), showAdr(), showAdr(), showAdr(), Activity::showData(), showPtr(), showSmartPtr(), lib::test::showVariadicTypes(), and ActivityDetector::watchGate().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showAdr() [2/3]

std::string showAdr ( void const *  addr)
noexcept

pretty-print an address as hex-suffix

Definition at line 400 of file format-obj.cpp.

References showAdr().

+ Here is the call graph for this function:

◆ showHash()

std::string showHash ( size_t  hash,
uint  showBytes 
)
noexcept

renders the size_t in hex, optionally only trailing bytes

Definition at line 411 of file format-obj.cpp.

References hash, and limited().

Referenced by SpecialJobFun::SpecialExecutor< FUN >::diagnostic(), TempDir::establishNewDirectory(), TempDir::establishNewFile(), ConfMan::procSpec(), lib::diff::renderCompact(), and showHashLSB().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showHashLSB()

std::string showHashLSB ( size_t  hash)
inlinenoexcept

Definition at line 89 of file format-obj.hpp.

References hash, and showHash().

+ Here is the call graph for this function:

◆ toString()

template<typename TY >
std::string toString ( TY const &  val)
inlinenoexcept

get some string representation of any object, reliably.

A custom string conversion operator is invoked, if applicable, while all lexically convertible types (numbers etc) are treated by boost::lexical_cast. For double or float values, hard wired rounding to a fixed number of digits will be performed, to yield a predictable display of printed unit-test results.

Remarks
while the actual parameter is passed by const-ref, cv-qualifiactions and references are stripped from the type
Note
Deliberately there is no magic detection/support for pointers. This function must not be overloaded (to avoid ambiguities in more elaborate template instantiations).
Remarks
Since 10/2023 an attempt was made to solve this problem down in StringConf<TY>, yet this solution might be brittle. If you want pointers to be indicated (with address), consider using util::showPtr explicitly.
Examples
/Werk/devel/lumi/src/lib/test/test-helper.hpp.

Definition at line 191 of file format-obj.hpp.

References StringConv< X, COND >::invoke(), and toString().

Referenced by UtilIdentity_test::Boo::Boo(), _Pragma(), ActivityDetector::ActivityProbe::activation(), ActivityMatch::afterSeqIncrement(), EventMatch::argPos(), ActivityMatch::beforeSeqIncrement(), ActivityDetector::buildMockJob(), FormatHelper_test::check2String(), Record< VAL >::child(), Rational_test::demonstrate_basics(), util::anonymous_namespace{format-util.hpp}::do_stringify(), TupleElementDisplayer< TY, BASE, TUP, idx >::dump(), lib::stat::anonymous_namespace{csv.hpp}::format4Csv(), ActivityDetector::incrementSeq(), PathArray< chunk_size >::indexOf(), ActivityDetector::ActivityProbe::notify(), MementoTie< SIG, MEM >::operator std::string(), Tracker< TY >::operator string(), ActivityDetector::DiagnosticFun< RET, ARGS >::operator()(), PathArray< chunk_size >::operator[](), steam::control::test::protocolled(), EventMatch::refineSerach_matchArgument(), ActivityMatch::seq(), Activity::showData(), lib::test::showVariadicTypes(), UICoord::Builder::tab(), toString(), DataCSV_test::verify_CSV_Format(), IterExplorer_test::verify_FilterChanges(), Rational_test::verify_limits(), IterExplorer_test::verify_reduceVal(), Rational_test::verify_requant(), BranchCase_test::verifyCopyAssignment(), EventLog::verifyEvent(), ActivityDetector_test::verifyMockInvocation(), ActivityDetector::verifySeqIncrement(), and Nexus::wasInvoked().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ typedString()

template<typename TY >
std::string typedString ( TY const &  val)
inlinenoexcept

indicate type and possibly a (custom) conversion to string

Returns
human readable type name '|' string representation. or just the type, when no string representation available

Definition at line 205 of file format-obj.hpp.

References StringConv< X, COND >::invoke().

Referenced by Variant< TYPES >::Buff< TY >::operator string().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator<<()

std::ostream & operator<< ( std::ostream &  os,
_Fmt const &  fmt 
)

send the formatted buffer directly to the output stream.

Note
this is more efficient than creating a string and outputting that, because boost::format internally uses a string-stream to generate the formatted representation, relying on the C++ output framework

Definition at line 238 of file format-string.cpp.

◆ LUMIERA_ERROR_DEFINE()

LUMIERA_ERROR_DEFINE ( FORMAT_SYNTAX  ,
"Syntax error in format string for boost::format"   
)

◆ LUMIERA_ERROR_DECLARE()

LUMIERA_ERROR_DECLARE ( FORMAT_SYNTAX  )

"Syntax error in format string for boost::format"

◆ operator==() [1/5]

bool operator== ( _Fmt const &  left,
_Fmt const &  right 
)
inline

Definition at line 464 of file format-string.hpp.

◆ operator==() [2/5]

bool operator== ( _Fmt const &  fmt,
string const &  str 
)
inline

Definition at line 470 of file format-string.hpp.

◆ operator==() [3/5]

bool operator== ( _Fmt const &  fmt,
CStr const  cString 
)
inline

Definition at line 476 of file format-string.hpp.

◆ operator==() [4/5]

bool operator== ( string const &  str,
_Fmt const &  fmt 
)
inline

Definition at line 482 of file format-string.hpp.

◆ operator==() [5/5]

bool operator== ( CStr const  cString,
_Fmt const &  fmt 
)
inline

Definition at line 488 of file format-string.hpp.

◆ collectStr()

template<class CON , typename... ELMS>
CON collectStr ( ELMS const &...  elms)
inline

convert a sequence of elements to string

Parameters
elmssequence of arbitrary elements
Template Parameters
CONthe container type to collect the results
Returns
a collection of type CON, initialised by the string representation of the given elements

Definition at line 112 of file format-util.hpp.

References collectStr().

Referenced by collectStr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stringify() [1/2]

template<typename... ELMS>
vector< string > stringify ( ELMS const &...  elms)
inline

standard setup: convert to string into a vector

Definition at line 122 of file format-util.hpp.

References stringify().

Referenced by PlaceholderCommand< ARGS >::capture(), FormatHelper_test::checkStringify(), join(), joinArgList(), joinDash(), joinDot(), stringify(), and stringify().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ stringify() [2/2]

template<class IT >
auto stringify ( IT &&  src)
inline

convert to string as transforming step in a pipeline

Parameters
srca "Lumiera Forward Iterator" with arbitrary result type
Returns
a "Lumiera Forward Iterator" with string elements
See also
FormatHelper_test::checkStringify()

Definition at line 134 of file format-util.hpp.

References stringify(), and lib::transformIterator().

+ Here is the call graph for this function:

◆ join() [1/2]

template<class COLL >
string join ( COLL &&  coll,
string const &  delim = ", " 
)
inline

enumerate a collection's contents, separated by delimiter.

Parameters
collsomething that is standard- or Lumiera-iterable
Note
Lumiera-iterator is copied when given by ref, otherwise moved, while in all other cases the source container is taken by const&
Returns
all contents converted to string and joined into a single string, with separators interspersed.
Remarks
based ostringstream; additionally, we use our failsafe string conversion, which in turn invokes custom string conversion, or lexical_cast as appropriate.
alternatively, the boost::join library function could be used, which works on arbitrary sequences, which incurs some additional weight (both in terms of header include and debug code size). And failures on template substitution tend to be hard to understand, since this generic sequence concept is just so danm absolutely generic (In fact that was the reason why I gave up and just rolled our own join utility)

Definition at line 194 of file format-util.hpp.

References join(), and stringify().

Referenced by FlowDiagnostic< CONF >::allEpochs(), EventMatch::argMatch(), BusTerm_test::attachNewBusTerm(), PlaceholderCommand< ARGS >::capture(), BusTerm_test::captureStateMark(), Statistic_test::check_wightedLinearRegression(), FormatHelper_test::checkStringJoin(), BusTerm_test::clearStates(), BusTerm_test::commandInvocation(), lib::diff::test::anonymous_namespace{diff-tree-application-simple-test.cpp}::contents(), lib::diff::test::anonymous_namespace{diff-tree-application-simple-test.cpp}::contents(), lib::diff::test::anonymous_namespace{diff-tree-mutation-listener-test.cpp}::contents(), TestTracking_test::demonstrate_checkAllocator(), Statistic_test::demonstrate_DataSpan(), IterExplorer_test::demonstrate_LayeredEvaluation(), TestTracking_test::demonstrate_logObject(), AbstractTangible_test::invokeCommand(), join(), join(), joinArgList(), joinDash(), joinDot(), lumiera_get_plugin_path_default(), AbstractTangible_test::markState(), steam::engine::test::anonymous_namespace{job-planning-pipeline-test.cpp}::materialise(), lib::iter::test::anonymous_namespace{iter-chain-search-test.cpp}::materialise(), lib::test::anonymous_namespace{iter-explorer-test.cpp}::materialise(), lib::test::anonymous_namespace{iter-zip-test.cpp}::materialise(), AbstractTangible_test::mutate(), AbstractTangible_test::notify(), Record< VAL >::operator std::string(), LocationRule::operator string(), ActivityDetector::operator string(), MaterialisedDiffBuffer::operator string(), BusTerm_test::pushDiff(), EventMatch::refineSerach_matchArguments(), SegL::renderContent(), lib::diff::anonymous_namespace{test-mutation-target.hpp}::renderRecord(), AbstractTangible_test::revealer(), util::test::show(), ActivityDetector::showLog(), toStringBracket(), toStringParen(), IterExplorer_test::verify_aggregatingGroupItration(), IterExplorer_test::verify_effuse(), IterExplorer_test::verify_elementGroupingOperation(), LateBindInstance_test::verify_forwarding(), AbstractTangible_test::verify_mockManipulation(), MockSupport_test::verify_MockPrerequisites(), TextTemplate_test::verify_parsing(), and BusTerm_test::verifyNotifications().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ join() [2/2]

template<class X >
string join ( std::initializer_list< X > const &&  ili,
string const &  delim = ", " 
)
inline

Definition at line 214 of file format-util.hpp.

References join().

+ Here is the call graph for this function:

◆ joinArgList()

template<typename... ARGS>
string joinArgList ( ARGS const &...  args)
inline

shortcut: List in parentheses, separated by comma, using temporary vector

Definition at line 224 of file format-util.hpp.

References join(), and stringify().

+ Here is the call graph for this function:

◆ joinDash()

template<typename... ARGS>
string joinDash ( ARGS const &...  args)
inline

shortcut: join directly with dashes

Definition at line 232 of file format-util.hpp.

References join(), joinDash(), and stringify().

Referenced by joinDash(), and lib::launchDetached().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ joinDot()

template<typename... ARGS>
string joinDot ( ARGS const &...  args)
inline

shortcut: join directly with dots

Definition at line 240 of file format-util.hpp.

References join(), and stringify().

+ Here is the call graph for this function:

◆ toStringParen()

template<class COLL >
string toStringParen ( COLL &&  coll)
inline

one-argument variant that can be forward declared...

Definition at line 250 of file format-util.hpp.

References join().

+ Here is the call graph for this function:

◆ toStringBracket() [1/2]

template<class COLL >
string toStringBracket ( COLL &&  coll)
inline

Definition at line 257 of file format-util.hpp.

References join().

Referenced by StringConv< std::array< T, N > >::invoke(), and Several< I >::operator std::string().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unConst() [1/2]

template<class OBJ >
OBJ * unConst ( const OBJ *  o)
inline

shortcut to save some typing when having to define const and non-const variants of member functions

Remarks
the »social contract« when using this function is that the programmer has to ensure effective const correctness!

Definition at line 358 of file util.hpp.

References unConst().

Referenced by CheckedCore< COR >::_rawCore(), ScopedPtrVect< T >::allPtrs(), MockJob::isNopJob(), JobTicket::isValid(), VerbPack< REC, RET, arg_storage >::operator string(), IterStateCore< IT >::srcIter(), unConst(), unConst(), ProductCore< ITUP >::yield(), StepDown::yield(), and CountDown::yield().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ unConst() [2/2]

template<class OBJ >
OBJ & unConst ( OBJ const &  ro)
inline

Definition at line 365 of file util.hpp.

References unConst().

+ Here is the call graph for this function:

◆ showBool()

std::string showBool ( bool  yes)
inlinenoexcept

human readable display of boolean values

Returns
"`true`" or "`false`"

Definition at line 446 of file meta/util.hpp.

References lib::meta::BOOL_FALSE_STR, and lib::meta::BOOL_TRUE_STR.

Referenced by StringConv< bool >::invoke().

+ Here is the caller graph for this function:

◆ showAdr() [3/3]

template<typename X >
lib::meta::disable_if< std::is_pointer< X >, std::string > showAdr ( X &  elm)
inlinenoexcept

Definition at line 476 of file meta/util.hpp.

References showAdr().

+ Here is the call graph for this function:

◆ showPtr()

template<typename X >
std::string showPtr ( X *  ptr = nullptr)
inline

diagnostics helper for explicitly indicating pointers

Definition at line 485 of file meta/util.hpp.

References StringConv< X, COND >::invoke(), and showAdr().

Referenced by Activity::showData().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ showSmartPtr()

template<typename SP >
std::string showSmartPtr ( SP const &  smPtr,
std::string  label = "smP" 
)
inline

Definition at line 493 of file meta/util.hpp.

References StringConv< X, COND >::invoke(), and showAdr().

Referenced by _Fmt::Converter< SP, lib::meta::enable_if< _shall_show_smartWrapper< SP > > >::dump(), and StringConv< SP, show_SmartPointer< SP > >::invoke().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ can_represent_Product() [1/2]

bool can_represent_Product ( int64_t  a,
int64_t  b 
)
inline

Definition at line 80 of file rational.hpp.

References can_represent_Product(), and ilog2().

Referenced by can_represent_Product(), can_represent_Product(), can_represent_Sum(), and ZoomWindow::scaleSafe().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ can_represent_Product() [2/2]

bool can_represent_Product ( Rat  a,
Rat  b 
)
inline

Definition at line 88 of file rational.hpp.

References can_represent_Product().

+ Here is the call graph for this function:

◆ can_represent_Sum()

bool can_represent_Sum ( Rat  a,
Rat  b 
)
inline

Definition at line 95 of file rational.hpp.

References can_represent_Product().

Referenced by ZoomWindow::addSafe(), and Rational_test::verify_limits().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reQuant() [1/2]

int64_t reQuant ( int64_t  num,
int64_t  den,
int64_t  u 
)
inline

Re-Quantise a number into a new grid, truncating to the next lower grid point.

Remarks
Grid-aligned values can be interpreted as rational numbers (integer fractions), where the quantiser corresponds to the denominator and the numerator counts the number of grid steps. To work both around precision problems and the danger of integer wrap-around, the integer division is performed on the old value and then the re-quantisation done on the remainder, using 128bit floating point for maximum precision. This operation can also be used to re-form a fraction to be cast in terms of the new quantiser; this introduces a tiny error, but typically allows for safe or simplified calculations.
Parameters
numthe count in old grid-steps (#den) or the numerator
denthe old quantiser or the denominator of a fraction
uthe new quantiser or the new denominator to use
Returns
the adjusted numerator, so that the fraction with u will be almost the same than dividing #num by #den

Definition at line 120 of file rational.hpp.

References iDiv(), and reQuant().

Referenced by lib::time::__framerate_approximation(), lib::time::anonymous_namespace{time.cpp}::build_time_from(), lib::time::anonymous_namespace{quantiser.cpp}::calculate_quantisation(), ZoomWindow::optimiseMetric(), ZoomWindow::parabolicAnchorRule(), reQuant(), reQuant(), ZoomWindow_test::safeguard_toxic_zoomFactor(), and Rational_test::verify_requant().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ reQuant() [2/2]

Rat reQuant ( Rat  src,
int64_t  u 
)
inline

re-Quantise a rational number to a (typically smaller) denominator.

Parameters
uthe new denominator to use
Warning
this is a lossy operation and possibly introduces an error of up to 1/u
Remarks
Rational numbers with large numerators can be »poisonous«, causing numeric overflow when used, even just additively. This function can thus be used to _"sanitise"_ a number, and thus accept a small error while preventing overflow.
Note
using extended-precision floating point to get close to the quantiser even for large denominator. Some platforms fall back to double, leading to extended error bounds

Definition at line 150 of file rational.hpp.

References reQuant().

+ Here is the call graph for this function:

◆ matchAtStart()

template<typename STR >
std::optional< smatch > matchAtStart ( STR &&  toParse,
regex const &  regex 
)

Helper algorithm to perform a search but require the match to start at the beginning of the string or sequence, while accepting trailing content.

Parameters
toParsea string, string-view or something that can be converted to string.
Returns
a std::optional with the match result (std::smatch).

Definition at line 71 of file regex.hpp.

Referenced by util::parse::buildConnex().

+ Here is the caller graph for this function:

◆ leadingWhitespace()

template<typename STR >
size_t leadingWhitespace ( STR &&  toParse)
Returns
number of leading whitespace characters

Definition at line 83 of file regex.hpp.

Referenced by util::parse::buildConnex(), and util::parse::toStringConnex().

+ Here is the caller graph for this function:

◆ toStringBracket() [2/2]

template<class COLL >
std::string toStringBracket ( COLL &&  coll)
inline

Definition at line 257 of file format-util.hpp.

References join().

Referenced by StringConv< std::array< T, N > >::invoke(), and Several< I >::operator std::string().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sanitise()

string sanitise ( string const &  org)

produce an identifier based on the given string.

remove non-standard-chars, reduce sequences of punctuation and whitespace to single underscores. The sanitised string will start with an alphanumeric character.

Example Conversions
   "Word"                             --> "Word"
   "a Sentence"                       --> "a_Sentence"
   "trailing Withespace  \t \n"       --> "trailing_Withespace"
   "with    a   lot  \nof Whitespace" --> "with_a_lot_of_Whitespace"
   "@with\".\'much ($punctuation)[]!" --> "@with.much_($punctuation)"
   "§&Ω%€  leading garbage"           --> "leading_garbage"
   "mixed    Ω   garbage"             --> "mixed_garbage"
   "Bääääh!!"                         --> "Bh"
See also
UtilSanitizedIdentifier_test
lib::meta::sanitisedSymbol()

Definition at line 57 of file util.cpp.

References isPunct(), isValid(), and sanitise().

Referenced by steam::asset::anonymous_namespace{media.cpp}::extractName(), lib::query::normaliseID(), UtilSanitizedIdentifier_test::run(), sanitise(), and lib::meta::sanitisedFullTypeName().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isnil() [1/5]

bool isnil ( lib::time::Duration const &  dur)
inline

Definition at line 860 of file timevalue.hpp.

References isnil().

Referenced by util::anonymous_namespace{util-coll.hpp}::__ensure_nonempty(), FormatHelper_test::checkPrefixSuffix(), FormatHelper_test::checkStringify(), TimeGridBasics_test::createGrid_simplified(), NodeGraphAttachment::empty(), ZoomWindow::ensureNonEmpty(), isnil(), isnil(), isnil(), isnil(), isnil(), isNo(), EventMatch::operator bool(), UtilFloordiv_test::run(), and UtilTuple_test::verify_unpackIterator().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ first() [1/2]

template<typename COLL , typename = enable_if< treat_as_STL_Container<COLL>>>
auto first ( COLL const &  coll)
inline

access the first element of a STL-like container.

Note
the container is taken by const& and the const is stripped before access.

Definition at line 102 of file util-coll.hpp.

References first(), and lib::meta::unwrap().

Referenced by first(), first(), and UtilCollection_test::verify_accessFirstLast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ last()

template<typename COLL , typename = enable_if< can_direct_access_Last<COLL>>>
auto last ( COLL const &  coll)
inline

access the last element of a STL-like container.

Note
the container is taken by const& and the const is stripped before access.

Definition at line 117 of file util-coll.hpp.

References last(), and lib::meta::unwrap().

Referenced by last(), and UtilCollection_test::verify_accessFirstLast().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ first() [2/2]

template<typename IT , typename = enable_if<treat_as_LumieraIterator<IT>>>
auto first ( IT  ii)
inline

extract the first element yielded by an Lumiera Forward Iterator.

Warning
the iterator is modified.

Definition at line 132 of file util-coll.hpp.

References first().

+ Here is the call graph for this function:

◆ max() [1/3]

template<class IT >
auto max ( IT &&  elms)
inline

Definition at line 160 of file util-coll.hpp.

References max().

Referenced by lib::time::__framerate_approximation(), util::parse::accept_repeated(), util::parse::accept_repeated(), BlockFlow< CONF >::announceAdditionalFlow(), Strategy< CONF >::averageEpochs(), Activity::constrainedStart(), Config::getDefaultComputationCapacity(), Strategy< CONF >::initialEpochCnt(), limited(), max(), max(), max(), RandomDraw< POL >::minVal(), stage::draw::rects_overlap(), Syntax< PAR >::repeat(), util::parse::repeatedConnex(), and UtilCollection_test::verify_Min_Max().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ max() [2/3]

template<class CON >
auto max ( CON const &  elms)
inline

Definition at line 172 of file util-coll.hpp.

References max().

+ Here is the call graph for this function:

◆ min() [1/3]

template<class IT >
auto min ( IT &&  elms)
inline

Definition at line 185 of file util-coll.hpp.

References min().

Referenced by util::parse::accept_repeated(), util::parse::accept_repeated(), Activity::constrainedDeath(), Worker< CONF >::contentionWait(), WorkForce< CONF >::incScale(), limited(), RandomDraw< POL >::maxVal(), min(), min(), min(), stage::draw::rects_overlap(), Syntax< PAR >::repeat(), util::parse::repeatedConnex(), SeveralBuilder< I, E, POL >::shiftStorage(), NodeLink_test::trigger_node_port_invocation(), and UtilCollection_test::verify_Min_Max().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ min() [2/3]

template<class CON >
auto min ( CON const &  elms)
inline

Definition at line 197 of file util-coll.hpp.

References min().

+ Here is the call graph for this function:

◆ and_all() [1/4]

template<typename IT , typename FUN >
bool and_all ( IT  i,
IT  end,
FUN  predicate 
)
inline

All quantification: check if all elements of a collection satisfy the given predicate.

Actually a short-circuit evaluation is performed.

Definition at line 69 of file util-foreach.hpp.

References and_all().

Referenced by and_all(), and_all(), and_all(), and_all(), UtilForeach_test::check_existence_quant(), UtilForeach_test::check_foreach_bind(), UtilForeach_test::check_foreach_bind_const(), UtilForeach_test::check_foreach_lambda(), UtilForeach_test::check_foreach_memFun(), UtilForeach_test::check_foreach_plain(), UtilForeach_test::check_invoke_on_each(), UtilForeach_test::check_ref_argument_bind(), and JobTicket::isValid().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has_any() [1/4]

template<typename IT , typename FUN >
bool has_any ( IT  i,
IT  end,
FUN  predicate 
)
inline

Existential quantification: check if any element of a collection satisfies the given predicate.

Actually, a short-circuit evaluation is performed.

Definition at line 85 of file util-foreach.hpp.

References has_any().

Referenced by UtilForeach_test::check_existence_quant(), UtilForeach_test::check_foreach_bind(), UtilForeach_test::check_foreach_bind_const(), UtilForeach_test::check_foreach_lambda(), UtilForeach_test::check_foreach_memFun(), UtilForeach_test::check_foreach_plain(), UtilForeach_test::check_invoke_on_each(), UtilForeach_test::check_ref_argument_bind(), has_any(), has_any(), has_any(), has_any(), DockArea::hasPanel(), and PanelManager::hasPanel().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ for_each() [1/3]

template<typename Container , typename FUN >
disable_if< can_IterForEach< Container >, FUN > for_each ( Container const &  coll,
FUN  doIt 
)
inline

operate on all elements of a STL container.

Note
the container is taken by const& and the const is stripped before iteration.
Todo:
reconsider if using rvalue references covers the "inline iteration" use case sufficiently, so that we can get rid of the unwrapping and thus get back to strict const correctness.
Note
this case is the default and kicks in unless we detect a Lumiera iterator. The handling is different for and_all

Definition at line 113 of file util-foreach.hpp.

References for_each(), and lib::meta::unwrap().

Referenced by UtilForeach_test::check_foreach_bind(), UtilForeach_test::check_foreach_bind_const(), UtilForeach_test::check_foreach_lambda(), UtilForeach_test::check_foreach_memFun(), UtilForeach_test::check_foreach_plain(), UtilForeach_test::check_invoke_on_each(), UtilForeach_test::check_ref_argument_bind(), UtilForeach_test::check_wrapped_container_passing(), ElementTracker< ELM >::clear(), DefsRegistry::dump(), for_each(), for_each(), and for_each().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ for_each() [2/3]

template<typename IT , typename FUN >
enable_if< can_IterForEach< IT >, FUN > for_each ( IT const &  ii,
FUN  doIt 
)
inline

operate on a Lumiera Forward Iterator until exhaustion.

Definition at line 129 of file util-foreach.hpp.

References for_each().

+ Here is the call graph for this function:

◆ and_all() [2/4]

template<typename Container , typename FUN >
enable_if< can_STL_ForEach< Container >, bool > and_all ( Container const &  coll,
FUN  predicate 
)
inline

Definition at line 142 of file util-foreach.hpp.

References and_all(), and lib::meta::unwrap().

+ Here is the call graph for this function:

◆ and_all() [3/4]

template<typename IT , typename FUN >
enable_if< can_IterForEach< IT >, bool > and_all ( IT const &  ii,
FUN  predicate 
)
inline

Definition at line 157 of file util-foreach.hpp.

References and_all().

+ Here is the call graph for this function:

◆ has_any() [2/4]

template<typename Container , typename FUN >
enable_if< can_STL_ForEach< Container >, bool > has_any ( Container const &  coll,
FUN  predicate 
)
inline

Definition at line 169 of file util-foreach.hpp.

References has_any(), and lib::meta::unwrap().

+ Here is the call graph for this function:

◆ has_any() [3/4]

template<typename IT , typename FUN >
enable_if< can_IterForEach< IT >, bool > has_any ( IT const &  ii,
FUN  predicate 
)
inline

Definition at line 184 of file util-foreach.hpp.

References has_any().

+ Here is the call graph for this function:

◆ for_each() [3/3]

template<typename CON , typename FUN , typename P1 , typename... ARGS>
void for_each ( CON const &  elements,
FUN  function,
P1 &&  bind1,
ARGS &&...  args 
)
inline

Accept binding for arbitrary function arguments.

Note
obviously one of those arguments must be a placeholder

Definition at line 199 of file util-foreach.hpp.

References for_each().

+ Here is the call graph for this function:

◆ and_all() [4/4]

template<typename CON , typename FUN , typename P1 , typename... ARGS>
bool and_all ( CON const &  elements,
FUN  function,
P1 &&  bind1,
ARGS &&...  args 
)
inline

Accept binding for arbitrary function arguments.

Note
obviously one of those arguments must be a placeholder

Definition at line 212 of file util-foreach.hpp.

References and_all().

+ Here is the call graph for this function:

◆ has_any() [4/4]

template<typename CON , typename FUN , typename P1 , typename... ARGS>
bool has_any ( CON const &  elements,
FUN  function,
P1 &&  bind1,
ARGS &&...  args 
)
inline

Accept binding for arbitrary function arguments.

Note
obviously one of those arguments must be a placeholder

Definition at line 225 of file util-foreach.hpp.

References has_any().

+ Here is the call graph for this function:

◆ isPow2()

template<typename N >
constexpr bool isPow2 ( n)
inlineconstexpr

Definition at line 34 of file util-quant.hpp.

References isPow2().

Referenced by isPow2().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ iDiv()

template<typename I >
IDiv< I > iDiv ( num,
den 
)
inline
Parameters
densupport type inference and auto typing...

Definition at line 82 of file util-quant.hpp.

Referenced by ZoomWindow::calcPixelsForDurationAtScale(), reQuant(), and ZoomWindow::scaleSafe().

+ Here is the caller graph for this function:

◆ floordiv()

template<typename I >
I floordiv ( num,
den 
)
inline

floor function for integer arithmetics.

Unlike the built-in integer division, this function always rounds towards the next smaller integer, even for negative numbers.

Warning
floor on doubles performs way better
See also
UtilFloordiv_test

Definition at line 97 of file util-quant.hpp.

References floordiv(), IDiv< I >::quot, and IDiv< I >::rem.

Referenced by lib::time::anonymous_namespace{quantiser.cpp}::calculate_quantisation(), floordiv(), FixedFrameQuantiser::grid_aligned(), UtilFloordiv_test::runPerformanceTest(), UtilFloordiv_test::verifyBehaviour(), and UtilFloordiv_test::verifyIntegerTypes().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ floorwrap()

template<typename I >
IDiv< I > floorwrap ( num,
den 
)
inline

scale wrapping operation.

Quantises the numerator value into the scale given by the denominator. Unlike the built-in integer division, this function always rounds towards the next smaller integer and also relates the remainder (=modulo) to this next lower scale grid point.

Returns
quotient and remainder packed into a struct
See also
UtilFloorwarp_test

Definition at line 119 of file util-quant.hpp.

References floorwrap(), IDiv< I >::quot, and IDiv< I >::rem.

Referenced by floorwrap(), and UtilFloorwrap_test::showWrap().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ almostEqual()

bool almostEqual ( double  d1,
double  d2,
unsigned int  ulp = 2 
)
inline

epsilon comparison of doubles.

Remarks
Floating point calculations are only accurate up to a certain degree, and we need to adjust for the magnitude of the involved numbers, since floating point numbers are scaled by the exponent. Moreover, we need to be careful with very small numbers (close to zero), where calculating the difference could yield coarse grained 'subnormal' values.
Parameters
ulpnumber of grid steps to allow for difference (default = 2). Here, a 'grid step' is the smallest difference to 1.0 which can be represented in floating point ('units in the last place')
Warning
don't use this for comparison against zero, rather use an absolute epsilon then.
See also
https://randomascii.wordpress.com/2012/02/25/comparing-floating-point-numbers-2012-edition/
http://en.cppreference.com/w/cpp/types/numeric_limits/epsilon
https://en.wikipedia.org/wiki/Unit_in_the_last_place
Todo:
3/2024 seems we have solved this problem several times meanwhile /////////////////////////////////TICKET #1360 sort out floating-point rounding and precision

Definition at line 150 of file util-quant.hpp.

References almostEqual().

Referenced by almostEqual().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ ilog2()

template<typename I >
constexpr int ilog2 ( num)
inlineconstexpr

Integral binary logarithm (disregarding fractional part)

Returns
index of the largest bit set in num; -1 for num==0
Todo:
C++20 will provide std::bit_width(i) — run a microbenchmark!
Remarks
The implementation uses an unrolled loop to break down the given number in a logarithmic search, subtracting away the larger powers of 2 first. Explained 10/2021 by user «ToddLehman» in this stackoverflow.
Note
Microbenchmarks indicate that this function and std::ilogb(double) perform in the same order of magnitude (which is surprising). This function gets slightly faster for smaller data types. The naive bitshift-count implementation is always significantly slower (8 times for int64_t, 1.6 times for int8_t)
See also
Rational_test::verify_intLog2()
ZoomWindow_test

Definition at line 178 of file util-quant.hpp.

Referenced by lib::time::__framerate_approximation(), ZoomWindow::addSafe(), can_represent_Product(), ZoomWindow::optimiseMetric(), ZoomWindow_test::safeguard_toxic_zoomFactor(), ZoomWindow::scaleSafe(), stage::model::anonymous_namespace{zoom-window.hpp}::toxicDegree(), and Rational_test::verify_intLog2().

+ Here is the caller graph for this function:

◆ seqTuple()

template<size_t N, class SEQ >
auto seqTuple ( SEQ &&  iter)

Unpack an iterator to build a fixed-size std::tuple of references.

Template Parameters
N(mandatory) defines the number of elements to unpack; can be zero
Parameters
iteranything compliant to the Lumiera Forward Iterator protocol
Warning
since the implementation uses std::tie (*iter), a reference is stored, which may lead to strange and dangerous behaviour if the given iterator exposes a reference to mutable internal state (e.g. "state core"). Moreover, it is assumed the iterator yields enough values to fill the new tuple, and this is not checked; an empty or exhausted iterator might throw, or yield otherwise undefined behaviour.

Definition at line 80 of file util-tuple.hpp.

References seqTuple().

Referenced by seqTuple().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ operator!()

ChPredicate operator! ( ChPredicate  p)

Definition at line 49 of file util.cpp.

◆ isValid()

ChPredicate isValid ( is_alnum() or is_any_of("-_.+$()@")  )

characters to be retained

Referenced by sanitise().

+ Here is the caller graph for this function:

◆ isPunct()

ChPredicate isPunct ( is_space() or is_any_of(",;:#*~´`?\\=/&%![]{}<>")  )

punctuation to be replaced by '_'

Referenced by sanitise().

+ Here is the caller graph for this function:

◆ trim()

string trim ( string const &  org)

remove leading and trailing whitespace

Remarks
this function just forwards to boost::algorithm::trim_copy. Use this call when boost header inclusion is an issue, otherwise a direct invocation is likely to perform better, due to inlining.
Returns
a trimmed copy (default locale)

Definition at line 85 of file util.cpp.

References trim().

Referenced by Record< VAL >::extractKey(), Record< VAL >::extractVal(), and trim().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ boolVal()

bool boolVal ( string const &  )

interpret text representation of a boolean value.

Remarks
this function detects the relevant token rather strict....
  • yields true for the tokens "true", "True", "TRUE", "yes", "Yes", "YES", "1", "+"
  • yields false for the tokens "false", "False", "FALSE", "no", "No, "NO", "0", "-"
  • leading and trailing whitespace is ignored
Exceptions
lumiera::error::Invalidfor any other text content

Definition at line 99 of file util.cpp.

Referenced by lib::stat::parseAs(), and UtilParseBool_test::run().

+ Here is the caller graph for this function:

◆ isYes()

bool isYes ( string const &  )
noexcept

check the given text if it can be interpreted as affirmative answer (bool true).

Remarks
this function just fishes for the known true tokens and interprets all other content as false, including empty strings. Never throws.

Definition at line 108 of file util.cpp.

References isYes().

Referenced by isYes(), and UtilParseBool_test::run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isNo()

bool isNo ( string const &  )
noexcept

check if the given text is empty or can be interpreted as rejection (bool false)-

Remarks
this function fishes for the known false tokens; any other non-empty content counts as not no.

Definition at line 115 of file util.cpp.

References isnil().

+ Here is the call graph for this function:

◆ sgn()

template<class NUM >
constexpr int sgn ( NUM  n)
inlineconstexpr

Definition at line 61 of file util.hpp.

References sgn().

Referenced by sgn().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ min() [3/3]

template<class N1 , class N2 >
constexpr N1 min ( N1  n1,
N2  n2 
)
inlineconstexpr

Definition at line 68 of file util.hpp.

References min().

+ Here is the call graph for this function:

◆ max() [3/3]

template<class N1 , class N2 >
constexpr N1 max ( N1  n1,
N2  n2 
)
inlineconstexpr

Definition at line 75 of file util.hpp.

References max().

+ Here is the call graph for this function:

◆ noneg()

template<typename NUM >
constexpr NUM noneg ( NUM  val)
inlineconstexpr

cut a numeric value to be >=0

Definition at line 83 of file util.hpp.

References noneg().

Referenced by noneg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ limited()

template<typename NUM , typename NB >
constexpr NUM limited ( NB  lowerBound,
NUM  val,
NB  upperBound 
)
inlineconstexpr

force a numeric to be within bounds, inclusively

Definition at line 91 of file util.hpp.

References limited(), max(), and min().

Referenced by WorkForce< CONF >::activate(), ZoomWindow::adaptWindowToPixels(), limited(), BreakingPoint< CONF >::maybeAdaptScaleEmpirically(), ZoomWindow::nudgeVisiblePos(), ZoomWindow::parabolicAnchorRule(), RandomDraw< POL >::probability(), showHash(), sNum(), NodeLink_test::trigger_node_port_invocation(), and uNum().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isLimited()

template<typename NUM , typename NB >
constexpr bool isLimited ( NB  lowerBound,
NUM  val,
NB  upperBound 
)
inlineconstexpr

Definition at line 99 of file util.hpp.

References isLimited().

Referenced by isLimited().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ positiveDiff()

template<typename UN , typename N2 >
constexpr UN positiveDiff ( N2  newVal,
UN  refVal 
)
inlineconstexpr

Definition at line 107 of file util.hpp.

References positiveDiff().

Referenced by positiveDiff().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uNum() [1/2]

uint uNum ( CStr  charPtr)
inline

positive integral number from textual representation

Returns
always a number, 0 in case of unparseable text, limited to 0 <= num <= LUMIERA_MAX_ORDINAL_NUMBER

Definition at line 117 of file util.hpp.

References limited(), LUMIERA_MAX_ORDINAL_NUMBER, and uNum().

Referenced by uNum(), and uNum().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sNum() [1/2]

int sNum ( CStr  charPtr)
inline

Definition at line 125 of file util.hpp.

References limited(), and LUMIERA_MAX_ORDINAL_NUMBER.

Referenced by sNum().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ uNum() [2/2]

template<class OBJ >
uint uNum ( OBJ const &  spec)
inline

Definition at line 134 of file util.hpp.

References cStr(), and uNum().

+ Here is the call graph for this function:

◆ sNum() [2/2]

template<class OBJ >
int sNum ( OBJ const &  spec)
inline

Definition at line 141 of file util.hpp.

References cStr(), and sNum().

+ Here is the call graph for this function:

◆ isnil() [2/5]

template<class CONT >
bool isnil ( const CONT &  container)
inline

a family of util functions providing a "no value whatsoever" test.

Works on strings and all STL containers, includes NULL test for pointers

Definition at line 154 of file util.hpp.

References isnil().

+ Here is the call graph for this function:

◆ isnil() [3/5]

template<class CONT >
bool isnil ( const CONT *  pContainer)
inline

Definition at line 161 of file util.hpp.

References isnil().

+ Here is the call graph for this function:

◆ isnil() [4/5]

template<class CONT >
bool isnil ( CONT *  pContainer)
inline

Definition at line 168 of file util.hpp.

References isnil().

+ Here is the call graph for this function:

◆ isnil() [5/5]

bool isnil ( CStr  charPtr)
inline

Definition at line 174 of file util.hpp.

References isnil().

+ Here is the call graph for this function:

◆ startsWith() [1/2]

bool startsWith ( string const &  str,
string const &  prefix 
)
inline

check if string starts with a given prefix

Definition at line 185 of file util.hpp.

References startsWith().

Referenced by FormatHelper_test::checkPrefixSuffix(), FileSupport_test::homedirectoryExpansion(), GenNode::isNamed(), DispatcherLoop::processCommands(), removePrefix(), startsWith(), and startsWith().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ startsWith() [2/2]

bool startsWith ( string const &  str,
CStr  prefix 
)
inline

Definition at line 191 of file util.hpp.

References startsWith().

+ Here is the call graph for this function:

◆ endsWith() [1/2]

bool endsWith ( string const &  str,
string const &  suffix 
)
inline

check if string ends with the given suffix

Definition at line 198 of file util.hpp.

Referenced by FormatHelper_test::checkPrefixSuffix(), endsWith(), FileSupport_test::homedirectoryExpansion(), and removeSuffix().

+ Here is the caller graph for this function:

◆ endsWith() [2/2]

bool endsWith ( string const &  str,
CStr  suffix 
)
inline

Definition at line 207 of file util.hpp.

References endsWith().

+ Here is the call graph for this function:

◆ removePrefix()

void removePrefix ( string &  str,
string const &  prefix 
)
inline

Definition at line 213 of file util.hpp.

References removePrefix(), and startsWith().

Referenced by FormatHelper_test::checkPrefixSuffix(), and removePrefix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeSuffix()

void removeSuffix ( string &  str,
string const &  suffix 
)
inline

Definition at line 220 of file util.hpp.

References endsWith(), and removeSuffix().

Referenced by FormatHelper_test::checkPrefixSuffix(), and removeSuffix().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ contains() [1/4]

template<typename MAP >
bool contains ( MAP &  map,
typename MAP::key_type const &  key 
)
inline

◆ contains() [2/4]

template<typename T , class CMP , class ALO >
bool contains ( std::set< T, CMP, ALO > const &  set,
T const &  val 
)
inline

shortcut for set value containment test

Definition at line 238 of file util.hpp.

References contains().

+ Here is the call graph for this function:

◆ contains() [3/4]

template<typename T >
bool contains ( std::string const &  str,
const T &  val 
)
inline

shortcut for string value containment test

Definition at line 246 of file util.hpp.

References contains().

+ Here is the call graph for this function:

◆ contains() [4/4]

template<typename SEQ >
bool contains ( SEQ const &  cont,
typename SEQ::const_reference  val 
)
inline

shortcut for brute-force containment test in any sequential container

Definition at line 255 of file util.hpp.

References contains(), and std::find().

+ Here is the call graph for this function:

◆ linearSearch()

template<class IT >
bool linearSearch ( IT  iter,
typename IT::value_type const &  val 
)
inline

use (and exhaust) a »Lumiera Forward Iterator« for linear search

Definition at line 266 of file util.hpp.

References std::find().

Referenced by FakeCanvas::testContains().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getValue_or_default()

template<typename MAP >
MAP::mapped_type getValue_or_default ( MAP &  map,
typename MAP::key_type const &  key,
typename MAP::mapped_type  defaultVal 
)
inline

fetch value from a Map, or return a default if not found

Definition at line 275 of file util.hpp.

References getValue_or_default().

Referenced by getValue_or_default().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ access_or_default()

template<typename MAP >
MAP::mapped_type const & access_or_default ( MAP &  map,
typename MAP::key_type const &  key,
typename MAP::mapped_type const &  refDefault 
)
inline

expose a reference to a map entry, with fall-back to some default object

Note
exposing a const reference; especially the default needs to reside somewhere at a safe storage location.
See also
lib::NullValue

Definition at line 292 of file util.hpp.

References access_or_default().

Referenced by access_or_default().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ removeall()

template<typename SEQ >
SEQ::iterator removeall ( SEQ &  coll,
typename SEQ::value_type const &  val 
)
inline

shortcut for removing all copies of an Element in any sequential collection

Definition at line 306 of file util.hpp.

References std::remove(), and removeall().

Referenced by TrackBody::rehook(), TrackBody::remove(), and removeall().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ remove_if()

template<class SET , typename FUN >
bool remove_if ( SET &  set,
FUN  test 
)

remove all elements fulfilling a given predicate from a (sorted) set.

Returns
true if anything has been removed.

Definition at line 319 of file util.hpp.

References remove_if().

Referenced by DefsRegistry::forget(), remove_if(), and RemoveFromSet_test::test_remove().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdr() [1/2]

template<class X >
const void * getAdr ( X &  x)
inline

extract address but strip any type info

Definition at line 377 of file util.hpp.

References getAdr().

Referenced by addrID(), getAdr(), getAdr(), isSameAdr(), and UtilIdentity_test::verify_getAdr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getAdr() [2/2]

template<class X >
const void * getAdr ( X *  x)
inline

Definition at line 383 of file util.hpp.

References getAdr().

+ Here is the call graph for this function:

◆ addrID()

template<class X >
size_t addrID ( X const &  x)
inline

generate an unique numeric ID based on the referred entity

Definition at line 391 of file util.hpp.

References getAdr().

Referenced by SeveralBuilder_test::check_ElementStorage(), slotNr(), and UtilIdentity_test::verify_addrID().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ slotNr()

template<typename X >
size_t slotNr ( X const &  x)
inline

the addressable memory »slot« — platform dependent.

Definition at line 400 of file util.hpp.

References addrID().

Referenced by isCloseBy().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSameAdr()

template<class A , class B >
bool isSameAdr ( A const &  a,
B const &  b 
)
inline

compare plain object address identity, disregarding type.

Note
the pointee is compared when passing pointer(s)

Definition at line 411 of file util.hpp.

References getAdr(), and isSameAdr().

Referenced by TrackingHeapBlockProvider::detachBuffer(), isSameAdr(), TestFrame::operator=(), and UtilIdentity_test::verify_isSameAdr().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isSameObject()

template<class A , class B >
bool isSameObject ( A const &  a,
B const &  b 
)
inline

compare plain object identity, based directly on the referee's memory identities.

Definition at line 421 of file util.hpp.

References isSameObject().

Referenced by PortBuilder< POL, DAT, WAB >::connectLeadPort(), ParamAgentBuilder< POL, DAT, SPEC >::delegateLeadPort(), FlowDiagnostic< CONF >::find(), MockJob::isNopJob(), isSameObject(), LazyInit< PAR >::operator=(), LazyInit< PAR >::operator=(), Sub< i >::operator=(), Tracker::operator=(), Tracker::operator=(), steam::mobject::session::test::anonymous_namespace{session-element-tracker-test.cpp}::operator==(), AccessCasted_test::run(), VerbVisitorDispatch_test::verify_copy_and_equality(), UtilIdentity_test::verify_isSameObject(), MockSupport_test::verify_MockSegmentation(), and JobTicket::verifyInstance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isCloseBy()

template<typename A , typename B >
bool isCloseBy ( A &&  a,
B &&  b,
size_t  consideredNearby = 50 
)
inline

determine heuristically if two objects are located „close to each other“ in memory.

Remarks
can be used to find out about heap versus stack allocation
Warning
relies on platform and implementation-defined observable behaviour

Definition at line 434 of file util.hpp.

References slotNr().

Referenced by LazyInit_test::verify_inlineStorage().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: