Utility Functions.
More...
|
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.
|
|
|
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...
|
|
◆ fileClockToSystemClock()
template<typename T >
std::chrono::system_clock::time_point rose::util::fileClockToSystemClock |
( |
T |
fileTimePoint | ) |
|
Convert a filesystem time to a system clock time point.
- Template Parameters
-
T | The type of the file time point. |
- Parameters
-
fileTimePoint | The value of the file time point. |
- Returns
- std::chrono::system_clock::time_point.
◆ offset()
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
-
C | The type of the container. |
- Parameters
-
container | The container |
skip | the 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
-
T | The underlying type of the metric. |
N | The number of elements in the metric. |
- Parameters
-
strm | The std::ostream to print on. |
metric | The ScreenMetric value. |
- Returns
- The std::stream.
◆ roundTo()
template<typename R , typename V >
constexpr R rose::util::roundTo |
( |
V |
value | ) |
|
Round a value to an unsigned integer and mask to the maximum value of the target type.
- Template Parameters
-
R | return value type, must be an unsigned type |
V | type to round, must be a floating point type |
- Parameters
-
- Returns
- the result of rounding and masking.
◆ roundToFloat()
template<typename T >
float rose::util::roundToFloat |
( |
T |
value, |
|
|
T |
multiplier = 1. |
|
) |
| |
Round a floating point value to an floating point value.
- Template Parameters
-
- Parameters
-
value | the value to round |
multiplier | a multiplier which can change the where the rounding takes place |
- Returns
- the rounded value
◆ roundToInt()
template<typename T >
int rose::util::roundToInt |
( |
T |
value, |
|
|
T |
multiplier = 1. |
|
) |
| |
Round a floating point value to an integer.
- Template Parameters
-
- Parameters
-
value | the value to round |
multiplier | a 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
-
Arg | First argument type |
Args | Rest of the argument types |
- Parameters
-
arg | First argument |
args | Rest of the arguments |
- Returns
- The composited string