Rose
Classes | Typedefs | Functions
rose::util Namespace Reference

Utility Functions. More...

Classes

struct  FontMetrics
 The size metrics that pertain to a particular font. More...
 
struct  iterator_pair
 A pair of iterators which may be used as first and last in the sequence [first . More...
 
class  ReverseContainerView
 Provide a reverse view of a standard container type. More...
 

Typedefs

template<class C >
using iterator_t = decltype(std::begin(std::declval< C & >()))
 An iterator type definition.
 
using DebugTuple = std::optional< std::tuple< const std::string_view, unsigned int > >
 A type to encode the location of an error: file name and line number.
 

Functions

template<typename T >
constexpr T deg2rad (T deg)
 
template<typename T >
constexpr T rad2deg (T rad)
 
template<typename T >
int roundToInt (T value, T multiplier=1.)
 Round a floating point value to an integer. More...
 
template<typename T >
float roundToFloat (T value, T multiplier=1.)
 Round a floating point value to an floating point value. More...
 
template<typename R , typename V >
constexpr R roundTo (V value)
 Round a value to an unsigned integer and mask to the maximum value of the target type. More...
 
template<typename T >
std::string fmtNumber (T value, int precision)
 
template<class C >
iterator_pair< iterator_t< C > > offset (C &container, size_t skip)
 Crate an iterator_pair to generate an offset sequence. More...
 
template<typename T , size_t N>
std::ostream & printScreenMetric (std::ostream &strm, const std::array< T, N > &metric)
 A function to print ScreenMetric values. More...
 
template<typename T >
std::chrono::system_clock::time_point fileClockToSystemClock (T fileTimePoint)
 Convert a filesystem time to a system clock time point. More...
 
template<typename Arg , typename... Args>
std::string StringCompositor (Arg &&arg, Args &&... args)
 Composite a pack of arguments that are streamable to a string. More...
 

Detailed Description

Utility Functions.

Function Documentation

◆ fileClockToSystemClock()

template<typename T >
std::chrono::system_clock::time_point rose::util::fileClockToSystemClock ( fileTimePoint)

Convert a filesystem time to a system clock time point.

Template Parameters
TThe type of the file time point.
Parameters
fileTimePointThe value of the file time point.
Returns
std::chrono::system_clock::time_point.

◆ offset()

template<class C >
iterator_pair<iterator_t<C> > rose::util::offset ( C &  container,
size_t  skip 
)

Crate an iterator_pair to generate an offset sequence.

The returned iterator pair will form a sequence over the container of [first+skip ... last)

Template Parameters
CThe type of the container.
Parameters
containerThe container
skipthe offset
Returns
An iterator_pair<iterator_t<C>>

◆ printScreenMetric()

template<typename T , size_t N>
std::ostream& rose::util::printScreenMetric ( std::ostream &  strm,
const std::array< T, N > &  metric 
)

A function to print ScreenMetric values.

Template Parameters
TThe underlying type of the metric.
NThe number of elements in the metric.
Parameters
strmThe std::ostream to print on.
metricThe ScreenMetric value.
Returns
The std::stream.

◆ roundTo()

template<typename R , typename V >
constexpr R rose::util::roundTo ( value)

Round a value to an unsigned integer and mask to the maximum value of the target type.

Template Parameters
Rreturn value type, must be an unsigned type
Vtype to round, must be a floating point type
Parameters
valuethe value to round
Returns
the result of rounding and masking.

◆ roundToFloat()

template<typename T >
float rose::util::roundToFloat ( value,
multiplier = 1. 
)

Round a floating point value to an floating point value.

Template Parameters
Tthe floating point type
Parameters
valuethe value to round
multipliera multiplier which can change the where the rounding takes place
Returns
the rounded value

◆ roundToInt()

template<typename T >
int rose::util::roundToInt ( value,
multiplier = 1. 
)

Round a floating point value to an integer.

Template Parameters
Tthe floating point type
Parameters
valuethe value to round
multipliera multiplier which can change the where the rounding takes place
Returns
the integer part of the value after rounding

◆ StringCompositor()

template<typename Arg , typename... Args>
std::string rose::util::StringCompositor ( Arg &&  arg,
Args &&...  args 
)

Composite a pack of arguments that are streamable to a string.

Template Parameters
ArgFirst argument type
ArgsRest of the argument types
Parameters
argFirst argument
argsRest of the arguments
Returns
The composited string