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

Go to the source code of this file.

Classes

struct  qx::unit< T, unit_t >
 

Functions

template<arithmetic_c T, unit_enum_c unit_t>
constexpr 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, unit_enum_c unit_t>
constexpr 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, unit_enum_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...
 
template<arithmetic_c T, unit_enum_c unit_t, class char_t >
std::optional< unit< T, unit_t > > qx::unit_from_string (const char_t *pszValue) noexcept
 Creates a unit from a string. More...
 
template<unit_enum_c unit_t, class char_t = char_type>
constexpr std::optional< basic_string_view< char_t > > qx::get_unit_suffix (unit_t eUnit) noexcept
 Get a unit suffix if exists. More...
 

Detailed Description

Author
Khrapov
Date
11.08.2025

Definition in file base.h.

Function Documentation

◆ get_unit_suffix()

template<unit_enum_c unit_t, class char_t = char_type>
constexpr std::optional<basic_string_view<char_t> > qx::get_unit_suffix ( unit_t  eUnit)
constexprnoexcept

Get a unit suffix if exists.

Template Parameters
unit_t- unit enum
char_t- result string view char type
Parameters
eUnit- unit to search
Return values
-unit suffix

◆ normalize_unit() [1/2]

template<arithmetic_c T, unit_enum_c unit_t>
constexpr unit<T, unit_t> qx::normalize_unit ( value,
unit_t  eInitialType 
)
constexprnoexcept

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, unit_enum_c unit_t>
constexpr unit<T, unit_t> qx::normalize_unit ( unit< T, unit_t >  unit)
constexprnoexcept

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() [1/2]

template<arithmetic_c T, unit_enum_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

◆ unit_from_string() [2/2]

template<arithmetic_c T, unit_enum_c unit_t, class char_t >
std::optional<unit<T, unit_t> > qx::unit_from_string ( const char_t *  pszValue)
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
pszValue- input string value
Return values
-a unit if created successfully or std::nullopt