qxLib
Classes | Functions
base.h File Reference
#include <qx/containers/string/format_string.h>
#include <qx/meta/concepts.h>
#include <qx/math/units/base.inl>

Go to the source code of this file.

Classes

struct  qx::unit< T, unit_t >
 
struct  std::formatter< qx::unit< T, unit_t >, qx::char_type >
 

Functions

template<arithmetic_c T, enumeration_c unit_t>
unit< T, unit_t > qx::normalize_unit (unit< T, unit_t > unit) noexcept
 The function returns the closest value greater than one from the SI for the unit of measurement. More...
 
template<arithmetic_c T, enumeration_c unit_t>
unit< T, unit_t > qx::normalize_unit (T value, unit_t eInitialType) noexcept
 The function returns the closest value greater than one from the SI for the unit of measurement. More...
 
template<arithmetic_c T, enumeration_c unit_t, class char_t >
std::optional< unit< T, unit_t > > qx::unit_from_string (basic_string_view< char_t > svValue) noexcept
 Creates a unit from a string. More...
 

Detailed Description

Author
Khrapov
Date
11.08.2025

Definition in file base.h.

Function Documentation

◆ normalize_unit() [1/2]

template<arithmetic_c T, enumeration_c unit_t>
unit<T, unit_t> qx::normalize_unit ( value,
unit_t  eInitialType 
)
noexcept

The function returns the closest value greater than one from the SI for the unit of measurement.

Template Parameters
T- floating point or integral value type
unit_t- unit type enum
Parameters
value- input unit value
eInitialType- input unit type
Return values
-the closest value greater than one from the SI for the unit of measurement

◆ normalize_unit() [2/2]

template<arithmetic_c T, enumeration_c unit_t>
unit<T, unit_t> qx::normalize_unit ( unit< T, unit_t >  unit)
noexcept

The function returns the closest value greater than one from the SI for the unit of measurement.

Template Parameters
T- floating point or integral value type
unit_t- unit type enum
Parameters
unit- input unit
Return values
-the closest value greater than one from the SI for the unit of measurement

◆ unit_from_string()

template<arithmetic_c T, enumeration_c unit_t, class char_t >
std::optional<unit<T, unit_t> > qx::unit_from_string ( basic_string_view< char_t >  svValue)
noexcept

Creates a unit from a string.

Input examples: 20KiB 20 KiB 20 KiB 20KiB

Template Parameters
T- expected value type
unit_t- unit enum
char_t- input string char type
Parameters
svValue- input string value
Return values
-a unit if created successfully or std::nullopt