DuxReiNummariae 1.1.0-alpha.19
Simple and powerful budgeting application
Loading...
Searching...
No Matches
drn::foundation Namespace Reference

Namespaces

namespace  detail
namespace  internal

Classes

struct  Clonable
 Interface for creating polymorphic deep-copyable objects. More...
class  Error
 Represents an error condition with an associated message and optional supplementary data. More...
struct  LocaleAware
 A flag to indicate that the operation should be aware of the users' locale. More...
class  ObserverPtr
 A smart pointer for observing another pointer. This means that it preforms no memory management on the lifetime of the observed pointer. This functionally acts as a marker for other developers that this pointer's does not need to be managed nor can it be accidentally deleted. More...
class  Percentage
 Represents a percentage value for use in mathematical calculations or user interfaces. More...
class  QtPtr
 A smart pointer class ensuring the Qt reference counting for automatic memory management. QtPtr is a template-based smart pointer class that ensures Qt's reference counting manages the lifetime of a dynamically allocated object. When the parent owning an object is destroyed or reset, the managed object is automatically deleted. Additionally, when the observed object is destructed, the object observing will turn null. More...
struct  RequireClonable
 Abstract base class requiring derived classes to implement deep-copy functionality. More...
class  ScopeExecutor
 Provides a RAII way to execute a bit of code upon the destruction of the object. More...
struct  SpaceCurrency
 A flag to indicate that the operation should space the currency. More...
class  StrongTypeDef
class  StrongTypeDef< WeakType >
 Creates a strong type that behaves like its underlying weak type form. This is useful for cases where only the type needs to be differentiated, but all behaviour is identical. More...
struct  TruncateZeros
 A flag to indicate that the operation should truncate implied zeros. More...
class  TypeIndexMap
 A generic map container of typed-keys to their values. More...
class  UniqueQtPtr
 A representation of a Qt object that is not handled by the usual Qt memory pattern. When the Qt object derives from a QObject, its deletion is handled on the event loop else it’s deleted immediately upon destruction. More...
struct  WithCurrency
 A flag to indicate that the operation should be done using the currency code. More...

Typedefs

using PartialDays = std::chrono::duration<double, std::ratio<86400>>
 A duration type representing partial (fractional) days.
using TaggedBoolean = StrongTypeDef<bool>
 A type to represent any tagged Boolean type.

Functions

template<typename AsType, typename ObservedType>
AsType & as (ObserverPtr< ObservedType > observer)
 Safely casts an observed base type to a specific derived type.
template<typename HaystackType, typename NeedleType>
requires std::is_same_v<typename HaystackType::value_type, NeedleType>
bool contains (const HaystackType &haystack, const NeedleType &needle)
 Determines whether a specific element exists within a given collection.
DRN_FOUNDATION_EXPORT std::chrono::days daysBetween (const ::QDate &from, const ::QDate &to) noexcept
 Calculates the difference in days between two dates.
DRN_FOUNDATION_EXPORT::QDate firstOfMonth (const ::QDate &date) noexcept
 Calculates the first day of the month for a given date.
DRN_FOUNDATION_EXPORT::QDate halfOfMonth (const ::QDate &date) noexcept
 Calculates the midpoint of the month for a given date.
template<typename IsType, typename ObservedType>
bool is (const ObserverPtr< ObservedType > &observer) noexcept
 Safely determines if a base type is of a specific derived type.
template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, bool > isSet (const FlagType flag, const FlagType mask) noexcept
 Checks whether a specific flag is set within a given mask. This determines if a specified flag is active based on the provided mask. It is typically used to evaluate configuration or state flags where binary flags are combined using bitwise operations.
DRN_FOUNDATION_EXPORT::QDate lastOfMonth (const ::QDate &date) noexcept
 Calculates the last day of the month for a given date.
template<typename ObjectType, typename BaseType, typename ... ObjectArgTypes>
requires internal::IsQtParentableObject<ObjectType>
QtPtr< BaseType > makeBaseQtPtr (ObjectArgTypes &&... objectArgs)
 Creates an object using the Qt memory pattern. Guarantees the object is of a Qt type that can participate in the Qt memory management and is owned by a parent.
template<typename ObjectType, typename BaseType, typename ... ObjectArgTypes>
requires internal::IsQtType<ObjectType> && internal::IsQtType<BaseType>
UniqueQtPtr< BaseType > makeBaseUniqueQtPtr (ObjectArgTypes &&... objectArgs)
 Creates a Qt object that is not handled by the Qt memory pattern.
template<typename QtPtrType>
requires internal::IsQtParentableObject<QtPtrType> && std::is_pointer_v<QtPtrType>
QtPtrType makeOrphan (QtPtrType ptr)
 Detaches the given Qt pointer from its parent, setting its parent to nullptr.
template<typename ObjectType, typename ... ObjectArgTypes>
requires internal::IsQtParentableObject<ObjectType>
QtPtr< ObjectType > makeQtPtr (ObjectArgTypes &&... objectArgs)
 Creates an object using the Qt memory pattern. Guarantees the object is of a Qt type that can participate in the Qt memory management and is owned by a parent.
template<typename ObjectType, typename ... ObjectArgTypes>
requires internal::IsQtType<ObjectType>
UniqueQtPtr< ObjectType > makeUniqueQtPtr (ObjectArgTypes &&... objectArgs)
 Creates a Qt object that is not handled by the Qt memory pattern.
DRN_FOUNDATION_EXPORT std::chrono::months monthsBetween (const ::QDate &from, const ::QDate &to) noexcept
 Calculates the number of complete months between two dates.
DRN_FOUNDATION_EXPORT::QString obfuscate (const ::QString &input)
 Obfuscates a given string. Useful to obfuscate sensitive information in strings while still showing enough characters to be potentially recognizable. This is particularly useful in logging, debugging, or displaying sensitive data like secrets or passwords without revealing the full value.
DRN_FOUNDATION_EXPORT std::optional<::QString > obfuscate (const std::optional<::QString > &input)
 Obfuscates a given string. Useful to obfuscate sensitive information in strings while still showing enough characters to be potentially recognizable. This is particularly useful in logging, debugging, or displaying sensitive data like secrets or passwords without revealing the full value.
template<typename ObservedType, typename ObservedPtrType>
bool operator!= (const ObservedType *lhs, const ObserverPtr< ObservedPtrType > &rhs)
 Inequality operator test to determine if a smart pointer is observing a specific naked pointer.
template<typename KeyType, typename ValueType>
bool operator!= (const TypeIndexMap< KeyType, ValueType > &lhs, const TypeIndexMap< KeyType, ValueType > &rhs)
 Determines if two type-indexed maps are /not/ identical.
template<typename ObservedType>
bool operator!= (std::nullptr_t, const ObserverPtr< ObservedType > &rhs)
 Inequality operator test to determine a pointer that is being observed is null.
template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, FlagType > operator& (const FlagType lhs, const FlagType rhs) noexcept
 Computes the logical AND operation of two flags. This is used to evaluate the intersection of two flags, where a flag is enabled only if it is set in both operands. It simplifies the handling of bitwise operations when working with flags.
DRN_FOUNDATION_EXPORT::QDebug operator<< (::QDebug out, const Percentage &p)
 Full object Qt stream insertion operator.
DRN_FOUNDATION_EXPORT::QDebug operator<< (::QDebug out, const std::chrono::days &val)
DRN_FOUNDATION_EXPORT::QDebug operator<< (::QDebug out, const std::chrono::hours &val)
DRN_FOUNDATION_EXPORT::QDebug operator<< (::QDebug out, const std::chrono::milliseconds &val)
DRN_FOUNDATION_EXPORT::QDebug operator<< (::QDebug out, const std::chrono::months &val)
DRN_FOUNDATION_EXPORT::QDebug operator<< (::QDebug out, const std::chrono::seconds &val)
template<typename ValueType>
::QDebug operator<< (::QDebug out, const std::optional< ValueType > &opt)
template<typename ObservedType>
std::ostream & operator<< (std::ostream &o, const ObserverPtr< ObservedType > &observer)
 Stream insertion operator for outputting the contests of the smart pointer. When the smart pointer is observing another pointer, the object pointed to will have its stream insertion operator used. When the smart pointer is null, the stream will be populated with "<nullptr>".
DRN_FOUNDATION_EXPORT std::ostream & operator<< (std::ostream &out, const Percentage &p)
 Full object stream insertion operator.
template<typename KeyType, typename ValueType>
std::ostream & operator<< (std::ostream &out, const TypeIndexMap< KeyType, ValueType > &data)
 Full object standard output stream insertion operator.
DRN_FOUNDATION_EXPORT std::strong_ordering operator<=> (const ::QDate &lhs, const ::QDate &rhs) noexcept
DRN_FOUNDATION_EXPORT std::strong_ordering operator<=> (const ::QString &lhs, const ::QString &rhs) noexcept
DRN_FOUNDATION_EXPORT std::strong_ordering operator<=> (const pecunia::Money &lhs, const pecunia::Money &rhs) noexcept
template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, bool > operator== (const FlagType lhs, const FlagType rhs) noexcept
 Compares two flag values and determines if they are equal.
template<typename ObservedType, typename ObservedPtrType>
bool operator== (const ObservedType *lhs, const ObserverPtr< ObservedPtrType > &rhs)
 Equality operator test to determine if a smart pointer is observing a specific naked pointer.
template<typename ObservedType, typename ObservedPtrType>
bool operator== (const ObservedType *lhs, const QtPtr< ObservedPtrType > &rhs)
template<typename KeyType, typename ValueType>
bool operator== (const TypeIndexMap< KeyType, ValueType > &lhs, const TypeIndexMap< KeyType, ValueType > &rhs)
 Determines if two type-indexed maps are identical.
template<typename ObservedType>
bool operator== (std::nullptr_t, const ObserverPtr< ObservedType > &rhs)
 Equality operator test to determine a pointer that is being observed is null.
template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, FlagType > operator| (const FlagType lhs, const FlagType rhs) noexcept
 Combines two sets of flags using a logical OR operation. This operation can be used to create a new flag set that contains all flags present in at least one of the inputs.
DRN_FOUNDATION_EXPORT::QString presentationText (const ::QDate &value)
 Converts a given object into a human-readable presentation text.
DRN_FOUNDATION_EXPORT::QString presentationText (const ::qint8 &value)
 Converts a signed 8-bit integer value into a string representation.
DRN_FOUNDATION_EXPORT::QString presentationText (const ::quint8 &value)
 Converts a unsigned 8-bit numeric value into a human-readable presentation text.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::Currency &code)
 Converts a supplied currency object into a human-readable presentation text.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::Currency &code, const SpaceCurrency &shouldBeSpaced)
 Converts a supplied currency object into a human-readable presentation text with optional spacing. This method formats the given currency object into a string representation that is suitable for display purposes. It accounts for optional spacing based on the provided parameters, making it adaptable for different localization needs.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::FloatingPoint &value)
 Converts a floating-point number into a human-readable presentation text for display in GUI elements.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::Money &money)
 Converts a supplied money object into its human-readable presentation text.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::Money &money, const LocaleAware &isLocaleAware, const WithCurrency &shouldAddCurrency)
 Converts a supplied money object into its human-readable presentation text.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::Money &money, const LocaleAware &isLocaleAware, const WithCurrency &shouldAddCurrency, const SpaceCurrency &shouldBeSpaced, const TruncateZeros &shouldTruncate)
 Converts the given money object into a human-readable presentation text based on various formatting options.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::Money &money, const WithCurrency &shouldAddCurrency)
 Converts a supplied money object into its human-readable presentation text.
DRN_FOUNDATION_EXPORT::QString presentationText (const pecunia::Money &money, const WithCurrency &shouldAddCurrency, const SpaceCurrency &shouldBeSpaced)
 Converts a supplied money object into its human-readable presentation text.
DRN_FOUNDATION_EXPORT::QString presentationText (const Percentage &p)
 Generates a text representation for a percentage value.
template<typename ValueType>
::QString presentationText (const std::optional< ValueType > &opt)
 Converts a value to a human-readable text representation.
template<typename ValueType>
ValueType valueOrDefault (const std::optional< ValueType > &opt) noexcept
 A convenience function to retrieve a value from an optional.
template<typename ExceptionType, typename ValueType, typename ... ExceptionArgs>
ValueType valueOrThrow (const std::optional< ValueType > &value, ExceptionArgs ... args)
 A convenience function to retrieve a value from an optional when it's present. When a value is not present, an exception is thrown.

Variables

constexpr PartialDays daysInMonth {daysInYear.count() / monthsInYear.count()}
 The average number of days per month, accounting for leap years, in a standard Gregorian calendar year.
constexpr std::chrono::days daysInWeek {7}
 The total number of days in a standard Gregorian calendar year.
constexpr PartialDays daysInYear {365.2425}
 The average number of days per year, accounting for leap years, in a standard Gregorian calendar year.
constexpr long displayDigits {3}
 The number digits after the decimal for displaying floating-point numbers to the user.
constexpr std::chrono::hours hoursInDay {24}
 The total number of hours in a day.
constexpr std::chrono::hours hoursInWeek {hoursInDay.count() * daysInWeek.count()}
 The total number of hours in a standard Gregorian calendar year.
constexpr std::chrono::months monthsInYear {12}
 The total number of months in a standard Gregorian calendar year.

Typedef Documentation

◆ PartialDays

using drn::foundation::PartialDays = std::chrono::duration<double, std::ratio<86400>>

A duration type representing partial (fractional) days.

This type alias defines a std::chrono::duration that can represent fractional days. The ratio represents the number of seconds in a day (24 hours * 60 minutes * 60 seconds = 86400 seconds).

PartialDays days{2.5}; // Represents two and a half days
std::chrono::duration< double, std::ratio< 86400 > > PartialDays
A duration type representing partial (fractional) days.
Definition CalendarTime.hpp:46
Note
The underlying representation uses double for storing the number of days, allowing for precise fractional day values.

◆ TaggedBoolean

A type to represent any tagged Boolean type.

Function Documentation

◆ as()

template<typename AsType, typename ObservedType>
AsType & drn::foundation::as ( ObserverPtr< ObservedType > observer)
nodiscard

Safely casts an observed base type to a specific derived type.

Exceptions
std::bad_castThrown if the base type cannot be cast to the specified derived type.
Template Parameters
AsTypeThe derived type to cast the observed instance into.
ObservedTypeThe base type being observed.
Parameters
observerThe instance to cast to a derived type.
Returns
The instance cast as the derived type supplied.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ contains()

template<typename HaystackType, typename NeedleType>
requires std::is_same_v<typename HaystackType::value_type, NeedleType>
bool drn::foundation::contains ( const HaystackType & haystack,
const NeedleType & needle )
nodiscard

Determines whether a specific element exists within a given collection.

This method checks whether the provided collection (referred to as the "haystack") contains the specified element (referred to as the "needle"). It is designed to standardise and simplify the process of locating elements within collections, providing a utility function that can be reused across various scenarios.

Template Parameters
HaystackTypeThe type of the collection that contains the data.
NeedleTypeThe type of the element to be searched for.
Parameters
haystackThe collection in which to search for the element.
needleThe element to search for within the collection.
Returns
True if the needle is found within the haystack; false otherwise.

◆ daysBetween()

DRN_FOUNDATION_EXPORT std::chrono::days drn::foundation::daysBetween ( const ::QDate & from,
const ::QDate & to )
nodiscardnoexcept

Calculates the difference in days between two dates.

This function is useful for determining the number of days between two points in time, which can be used for scheduling, event planning, or calculating durations for reports or metrics.

Precondition
The from input date must be valid.
The to input date must be valid.
Parameters
fromThe starting date for the calculation.
toThe ending date for the calculation.
Returns
The number of days between the two dates. This will be negative if the to date is earlier than the from date.

◆ firstOfMonth()

DRN_FOUNDATION_EXPORT::QDate drn::foundation::firstOfMonth ( const ::QDate & date)
nodiscardnoexcept

Calculates the first day of the month for a given date.

This function is useful when operations require aligning a date to the start of its month, such as calculating monthly periods, budgeting, or generating reports.

Precondition
The input date must be valid.
Parameters
dateThe input date from which the first day of the month is derived.
Returns
A new date set to the first day of the same month and year as the provided input date.

◆ halfOfMonth()

DRN_FOUNDATION_EXPORT::QDate drn::foundation::halfOfMonth ( const ::QDate & date)
nodiscardnoexcept

Calculates the midpoint of the month for a given date.

This function is useful when operations require determining a date approximately halfway through the month, such as splitting periods into early/late segments, creating mid-month reports, or sending out reminders.

Precondition
The input date must be valid.
Parameters
dateThe input date from which the midpoint of the month is derived.
Returns
A new date set to a day approximately halfway through the same month and year as the provided input date.

◆ is()

template<typename IsType, typename ObservedType>
bool drn::foundation::is ( const ObserverPtr< ObservedType > & observer)
nodiscardnoexcept

Safely determines if a base type is of a specific derived type.

Template Parameters
IsTypeThe derived type to check if it is being observed.
ObservedTypeThe base type being observed.
Parameters
observerThe instance whose derived type is desired to test.
Returns
True when the non-null instance is of the derived type, false otherwise.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isSet()

template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, bool > drn::foundation::isSet ( const FlagType flag,
const FlagType mask )
nodiscardnoexcept

Checks whether a specific flag is set within a given mask. This determines if a specified flag is active based on the provided mask. It is typically used to evaluate configuration or state flags where binary flags are combined using bitwise operations.

Precondition
The FlagType must be registered with the enumeration flag system.
Template Parameters
FlagTypeThe type of enumeration that describes the possible flags.
Parameters
flagThe specific flag to check.
maskThe mask against which the flag is evaluated.
Returns
true if the flag is set within the provided mask, otherwise false.

◆ lastOfMonth()

DRN_FOUNDATION_EXPORT::QDate drn::foundation::lastOfMonth ( const ::QDate & date)
nodiscardnoexcept

Calculates the last day of the month for a given date.

This function is useful in scenarios where date alignment to the end of the month is required, such as calculating monthly report deadlines, financial summaries, or creating recurring schedules.

Precondition
The input date must be valid.
Parameters
dateThe input date from which the last day of the month is derived.
Returns
A new date set to the last day of the same month and year as the provided input date.

◆ makeBaseQtPtr()

template<typename ObjectType, typename BaseType, typename ... ObjectArgTypes>
requires internal::IsQtParentableObject<ObjectType>
QtPtr< BaseType > drn::foundation::makeBaseQtPtr ( ObjectArgTypes &&... objectArgs)

Creates an object using the Qt memory pattern. Guarantees the object is of a Qt type that can participate in the Qt memory management and is owned by a parent.

Template Parameters
ObjectTypeThe type of the object to create.
BaseTypeThe base type of the object being created.
ObjectArgTypesThe argument types for the object constructor to invoke.
Parameters
objectArgsThe values of to use in the object creation.
Returns
The Qt object that is created on the heap.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeBaseUniqueQtPtr()

template<typename ObjectType, typename BaseType, typename ... ObjectArgTypes>
requires internal::IsQtType<ObjectType> && internal::IsQtType<BaseType>
UniqueQtPtr< BaseType > drn::foundation::makeBaseUniqueQtPtr ( ObjectArgTypes &&... objectArgs)

Creates a Qt object that is not handled by the Qt memory pattern.

Template Parameters
ObjectTypeThe type of the object to create.
BaseTypeThe base type of the object being created.
ObjectArgTypesThe argument types for the object constructor to invoke.
Parameters
objectArgsThe values of to use in the object creation.
Returns
The Qt object that is created on the heap.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeOrphan()

template<typename QtPtrType>
requires internal::IsQtParentableObject<QtPtrType> && std::is_pointer_v<QtPtrType>
QtPtrType drn::foundation::makeOrphan ( QtPtrType ptr)

Detaches the given Qt pointer from its parent, setting its parent to nullptr.

Precondition
The pointer to orphan cannot be null.
Template Parameters
QtPtrTypeThe type of the object to remove the parent.
Parameters
ptrThe Qt pointer to be de-parented.
Returns
The same Qt pointer passed in, but with its parent set to nullptr.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeQtPtr()

template<typename ObjectType, typename ... ObjectArgTypes>
requires internal::IsQtParentableObject<ObjectType>
QtPtr< ObjectType > drn::foundation::makeQtPtr ( ObjectArgTypes &&... objectArgs)

Creates an object using the Qt memory pattern. Guarantees the object is of a Qt type that can participate in the Qt memory management and is owned by a parent.

Template Parameters
ObjectTypeThe type of the object to create.
ObjectArgTypesThe argument types for the object constructor to invoke.
Parameters
objectArgsThe values of to use in the object creation.
Returns
The Qt object that is created on the heap.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ makeUniqueQtPtr()

template<typename ObjectType, typename ... ObjectArgTypes>
requires internal::IsQtType<ObjectType>
UniqueQtPtr< ObjectType > drn::foundation::makeUniqueQtPtr ( ObjectArgTypes &&... objectArgs)

Creates a Qt object that is not handled by the Qt memory pattern.

Template Parameters
ObjectTypeThe type of the object to create.
ObjectArgTypesThe argument types for the object constructor to invoke.
Parameters
objectArgsThe values of to use in the object creation.
Returns
The Qt object that is created on the heap.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ monthsBetween()

DRN_FOUNDATION_EXPORT std::chrono::months drn::foundation::monthsBetween ( const ::QDate & from,
const ::QDate & to )
nodiscardnoexcept

Calculates the number of complete months between two dates.

This function is ideal for determining the duration between two dates in terms of full months.

Precondition
The starting date must be valid.
The ending date must be valid.
Parameters
fromThe starting date for the calculation.
toThe ending date for the calculation.
Returns
The number of full months between the two dates. This will be negative if the to date is earlier than the from date.

◆ obfuscate() [1/2]

DRN_FOUNDATION_EXPORT::QString drn::foundation::obfuscate ( const ::QString & input)

Obfuscates a given string. Useful to obfuscate sensitive information in strings while still showing enough characters to be potentially recognizable. This is particularly useful in logging, debugging, or displaying sensitive data like secrets or passwords without revealing the full value.

Parameters
inputThe string to be obfuscated.
Returns
An obfuscated string showing only the first and last quarters, and replacing the middle part with "..." if the string length is sufficiently long. If the length of the input string is less than the minimum required number of characters, the function simply returns the obfuscation character sequence "...".

◆ obfuscate() [2/2]

DRN_FOUNDATION_EXPORT std::optional<::QString > drn::foundation::obfuscate ( const std::optional<::QString > & input)

Obfuscates a given string. Useful to obfuscate sensitive information in strings while still showing enough characters to be potentially recognizable. This is particularly useful in logging, debugging, or displaying sensitive data like secrets or passwords without revealing the full value.

Parameters
inputThe string to be obfuscated.
Returns
When the supplied input has a value, an obfuscated string showing only the first and last quarters, and replacing the middle part with "..." if the string length is sufficiently long. If the length of the input string is less than the minimum required number of characters, the function simply returns the obfuscation character sequence "...". If the input does not have a value, a null optional is given.

◆ operator!=() [1/3]

template<typename ObservedType, typename ObservedPtrType>
bool drn::foundation::operator!= ( const ObservedType * lhs,
const ObserverPtr< ObservedPtrType > & rhs )

Inequality operator test to determine if a smart pointer is observing a specific naked pointer.

Template Parameters
ObservedTypeThe type of the naked pointer that is to be tested for being observed.
ObservedPtrTypeThe type of the smart pointer that is to be tested for observing.
Parameters
lhsThe naked pointer to test for being observed.
rhsThe smart pointer to test for observing.
Returns
True when the smart pointer does not point to the naked pointer, false otherwise.

◆ operator!=() [2/3]

template<typename KeyType, typename ValueType>
bool drn::foundation::operator!= ( const TypeIndexMap< KeyType, ValueType > & lhs,
const TypeIndexMap< KeyType, ValueType > & rhs )

Determines if two type-indexed maps are /not/ identical.

Template Parameters
KeyTypeThe type for the typed-key.
ValueTypeThe type for the values to store under the typed-key
Parameters
lhsThe left-hand side to compare.
rhsThe right-hand side to compare against.
Returns
True when any key or value is different, false otherwise.

◆ operator!=() [3/3]

template<typename ObservedType>
bool drn::foundation::operator!= ( std::nullptr_t ,
const ObserverPtr< ObservedType > & rhs )

Inequality operator test to determine a pointer that is being observed is null.

Template Parameters
ObservedTypeThe type of the pointer being observed.
Parameters
rhsThe object to test if it is null.
Returns
True when the object is not null, i.e. observing something, false otherwise.

◆ operator&()

template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, FlagType > drn::foundation::operator& ( const FlagType lhs,
const FlagType rhs )
nodiscardnoexcept

Computes the logical AND operation of two flags. This is used to evaluate the intersection of two flags, where a flag is enabled only if it is set in both operands. It simplifies the handling of bitwise operations when working with flags.

Precondition
The FlagType must be registered with the enumeration flag system.
Template Parameters
FlagTypeThe type of enumeration that describes the possible flags.
Parameters
lhsThe first flag to be evaluated.
rhsThe second flag to be evaluated.
Returns
The resulting flag representing the intersection of the two input flags.

◆ operator<<() [1/10]

DRN_FOUNDATION_EXPORT::QDebug drn::foundation::operator<< ( ::QDebug out,
const Percentage & p )

Full object Qt stream insertion operator.

Parameters
outThe stream to place the data into.
pThe data to place into the stream.
Returns
The modified stream after insertion.

◆ operator<<() [2/10]

DRN_FOUNDATION_EXPORT::QDebug drn::foundation::operator<< ( ::QDebug out,
const std::chrono::days & val )

◆ operator<<() [3/10]

DRN_FOUNDATION_EXPORT::QDebug drn::foundation::operator<< ( ::QDebug out,
const std::chrono::hours & val )

◆ operator<<() [4/10]

DRN_FOUNDATION_EXPORT::QDebug drn::foundation::operator<< ( ::QDebug out,
const std::chrono::milliseconds & val )

◆ operator<<() [5/10]

DRN_FOUNDATION_EXPORT::QDebug drn::foundation::operator<< ( ::QDebug out,
const std::chrono::months & val )

◆ operator<<() [6/10]

DRN_FOUNDATION_EXPORT::QDebug drn::foundation::operator<< ( ::QDebug out,
const std::chrono::seconds & val )

◆ operator<<() [7/10]

template<typename ValueType>
::QDebug drn::foundation::operator<< ( ::QDebug out,
const std::optional< ValueType > & opt )

◆ operator<<() [8/10]

template<typename ObservedType>
std::ostream & drn::foundation::operator<< ( std::ostream & o,
const ObserverPtr< ObservedType > & observer )

Stream insertion operator for outputting the contests of the smart pointer. When the smart pointer is observing another pointer, the object pointed to will have its stream insertion operator used. When the smart pointer is null, the stream will be populated with "<nullptr>".

Template Parameters
ObservedTypeThe type the smart pointer is observing.
Parameters
oThe stream to place the contents into.
observerThe smart pointer to output.
Returns
The stream populated with the contents of the smart pointer.

◆ operator<<() [9/10]

DRN_FOUNDATION_EXPORT std::ostream & drn::foundation::operator<< ( std::ostream & out,
const Percentage & p )

Full object stream insertion operator.

Parameters
outThe stream to place the data into.
pThe data to place into the stream.
Returns
The modified stream after insertion.

◆ operator<<() [10/10]

template<typename KeyType, typename ValueType>
std::ostream & drn::foundation::operator<< ( std::ostream & out,
const TypeIndexMap< KeyType, ValueType > & data )

Full object standard output stream insertion operator.

Parameters
outThe stream to place the data into.
dataThe data to place into the stream.
Returns
The modified stream after insertion.

◆ operator<=>() [1/3]

DRN_FOUNDATION_EXPORT std::strong_ordering drn::foundation::operator<=> ( const ::QDate & lhs,
const ::QDate & rhs )
nodiscardnoexcept

◆ operator<=>() [2/3]

DRN_FOUNDATION_EXPORT std::strong_ordering drn::foundation::operator<=> ( const ::QString & lhs,
const ::QString & rhs )
nodiscardnoexcept

◆ operator<=>() [3/3]

DRN_FOUNDATION_EXPORT std::strong_ordering drn::foundation::operator<=> ( const pecunia::Money & lhs,
const pecunia::Money & rhs )
nodiscardnoexcept

◆ operator==() [1/5]

template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, bool > drn::foundation::operator== ( const FlagType lhs,
const FlagType rhs )
nodiscardnoexcept

Compares two flag values and determines if they are equal.

Precondition
The FlagType must be registered with the enumeration flag system.
Template Parameters
FlagTypeThe type of enumeration that describes the possible flags.
Parameters
lhsThe first flag to be compared.
rhsThe second flag to be compared.
Returns
true if the flags are equal; false otherwise.

◆ operator==() [2/5]

template<typename ObservedType, typename ObservedPtrType>
bool drn::foundation::operator== ( const ObservedType * lhs,
const ObserverPtr< ObservedPtrType > & rhs )

Equality operator test to determine if a smart pointer is observing a specific naked pointer.

Template Parameters
ObservedTypeThe type of the naked pointer that is to be tested for being observed.
ObservedPtrTypeThe type of the smart pointer that is to be tested for observing.
Parameters
lhsThe naked pointer to test for being observed.
rhsThe smart pointer to test for observing.
Returns
True when the smart pointer points to the naked pointer, false otherwise.

◆ operator==() [3/5]

template<typename ObservedType, typename ObservedPtrType>
bool drn::foundation::operator== ( const ObservedType * lhs,
const QtPtr< ObservedPtrType > & rhs )

Equality operator for comparing against a naked type.

Template Parameters
ObservedTypeThe type of the naked object to compare.
ObservedPtrTypeThe type of the Qt object to compare.
Parameters
lhsThe naked pointer to compare to.
rhsThe pointer to compare.
Returns
True when the two supplied pointers point to the same object, false otherwise.

◆ operator==() [4/5]

template<typename KeyType, typename ValueType>
bool drn::foundation::operator== ( const TypeIndexMap< KeyType, ValueType > & lhs,
const TypeIndexMap< KeyType, ValueType > & rhs )

Determines if two type-indexed maps are identical.

Template Parameters
KeyTypeThe type for the typed-key.
ValueTypeThe type for the values to store under the typed-key
Parameters
lhsThe left-hand side to compare.
rhsThe right-hand side to compare against.
Returns
True when all keys and values are identical, false otherwise.

◆ operator==() [5/5]

template<typename ObservedType>
bool drn::foundation::operator== ( std::nullptr_t ,
const ObserverPtr< ObservedType > & rhs )

Equality operator test to determine a pointer that is being observed is null.

Template Parameters
ObservedTypeThe type of the pointer being observed.
Parameters
rhsThe object to test if it is null.
Returns
True when the object is null, i.e. not observing anything, false otherwise.

◆ operator|()

template<typename FlagType>
std::enable_if_t< detail::IsRegisteredEnumerationFlag< FlagType >::value, FlagType > drn::foundation::operator| ( const FlagType lhs,
const FlagType rhs )
nodiscardnoexcept

Combines two sets of flags using a logical OR operation. This operation can be used to create a new flag set that contains all flags present in at least one of the inputs.

Precondition
The FlagType must be registered with the enumeration flag system.
Template Parameters
FlagTypeThe type of enumeration that describes the possible flags.
Parameters
lhsThe first set of flags to be included in the resulting combination.
rhsThe second set of flags to be included in the resulting combination.
Returns
The combined result flags containing all flags from both the input sets. The result reflects the logical OR operation applied to the inputs.

◆ presentationText() [1/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const ::QDate & value)

Converts a given object into a human-readable presentation text.

Parameters
valueThe object to be converted into a human-readable text form.
Returns
The human-readable representation of the date, typically formatted according to local conventions.

◆ presentationText() [2/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const ::qint8 & value)

Converts a signed 8-bit integer value into a string representation.

Parameters
valueThe integer value that needs to be converted into a string.
Returns
A string that represents the integer value, making it suitable for display or other textual operations that require a string format.

◆ presentationText() [3/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const ::quint8 & value)

Converts a unsigned 8-bit numeric value into a human-readable presentation text.

Parameters
valueThe numeric value to be converted into a human-readable text form.
Returns
The human-readable text representation of the numeric value, suitable for display purposes.

◆ presentationText() [4/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::Currency & code)

Converts a supplied currency object into a human-readable presentation text.

Parameters
codeThe currency object to be converted into a human-readable text form.
Returns
The human-readable representation of the currency value which makes it suitable for display, typically in a locale-aware format, with the currency symbol spaced appropriately.

◆ presentationText() [5/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::Currency & code,
const SpaceCurrency & shouldBeSpaced )

Converts a supplied currency object into a human-readable presentation text with optional spacing. This method formats the given currency object into a string representation that is suitable for display purposes. It accounts for optional spacing based on the provided parameters, making it adaptable for different localization needs.

Parameters
codeThe currency object to be converted into a human-readable text form.
shouldBeSpacedIndicates whether a space should be inserted between the currency symbol and the amount.
Returns
The human-readable representation of the currency, optionally including a space for better readability.

◆ presentationText() [6/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::FloatingPoint & value)

Converts a floating-point number into a human-readable presentation text for display in GUI elements.

This function formats a floating-point value into a locale-appropriate textual representation, ensuring it is displayed with a fixed precision suitable for graphical user interfaces or other display contexts.

Parameters
valueThe floating-point value to be converted into a formatted text representation.
Returns
A formatted string representation of the provided floating-point value, typically displayed with a fixed precision.

◆ presentationText() [7/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::Money & money)

Converts a supplied money object into its human-readable presentation text.

Parameters
moneyThe object to be converted into human-readable text form.
Returns
The human-readable representation of the money value in a format suitable for display with a locale-aware representation, and without its currency.

◆ presentationText() [8/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::Money & money,
const LocaleAware & isLocaleAware,
const WithCurrency & shouldAddCurrency )

Converts a supplied money object into its human-readable presentation text.

Parameters
moneyThe object to be converted into human-readable text form.
isLocaleAwareSpecifies if a locale-specific decimal point should be used.
shouldAddCurrencySpecifies if the currency symbol should be included in the output.
Returns
The human-readable representation of the money value, formatted according to the specified parameters. The currency is spaced.

◆ presentationText() [9/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::Money & money,
const LocaleAware & isLocaleAware,
const WithCurrency & shouldAddCurrency,
const SpaceCurrency & shouldBeSpaced,
const TruncateZeros & shouldTruncate )

Converts the given money object into a human-readable presentation text based on various formatting options.

Parameters
moneyThe object representing the monetary value to be converted.
isLocaleAwareDetermines if the conversion should consider locale-aware formatting for decimal points.
shouldAddCurrencySpecifies whether the currency symbol should be included in the output string.
shouldBeSpacedDetermines if there should be a space between the currency symbol and the monetary value.
shouldTruncateIndicates whether trailing zeros should be removed from the formatted string.
Returns
The formatted human-readable representation of the monetary value considering the given options.

◆ presentationText() [10/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::Money & money,
const WithCurrency & shouldAddCurrency )

Converts a supplied money object into its human-readable presentation text.

Parameters
moneyThe object to be converted into human-readable text form.
shouldAddCurrencySpecifies if the currency symbol should be included in the output.
Returns
The human-readable representation of the money value, formatted according to the specified parameters. The decimal point is locale aware, and the currency is spaced.

◆ presentationText() [11/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const pecunia::Money & money,
const WithCurrency & shouldAddCurrency,
const SpaceCurrency & shouldBeSpaced )

Converts a supplied money object into its human-readable presentation text.

Parameters
moneyThe object to be converted into human-readable text form.
shouldAddCurrencySpecifies if the currency symbol should be included in the output.
shouldBeSpacedSpecifies if a space should be added between the amount, and the currency symbol.
Returns
The human-readable representation of the money value, formatted according to the specified parameters. The decimal point is locale aware.

◆ presentationText() [12/13]

DRN_FOUNDATION_EXPORT::QString drn::foundation::presentationText ( const Percentage & p)

Generates a text representation for a percentage value.

This function creates a formatted string displaying the percentage value based on the rate and precision defined in the provided percentage object. It is useful for displaying percentage values in a user-readable format, such as in GUIs, logs, or reports.

Parameters
pAn object representing the percentage, containing the rate and precision.
Returns
A string representing the percentage value, appended with a percentage symbol.
Here is the call graph for this function:

◆ presentationText() [13/13]

template<typename ValueType>
::QString drn::foundation::presentationText ( const std::optional< ValueType > & opt)

Converts a value to a human-readable text representation.

This is useful for when you need to display an object's value to an end-user in a GUI element.

Template Parameters
ValueTypeThe type to format for displaying. It must support a call to the function presentationText.
Parameters
optThe value to format for displaying.
Returns
The value formatted for displaying when present, else a translated text describing that nothing was set.
Here is the caller graph for this function:

◆ valueOrDefault()

template<typename ValueType>
ValueType drn::foundation::valueOrDefault ( const std::optional< ValueType > & opt)
noexcept

A convenience function to retrieve a value from an optional.

Template Parameters
ValueTypeThe type to retrieve when present. The type must have a default constructor.
Parameters
optThe object containing the value to potentially retrieve.
Returns
Gives the value stored in the object, else a default constructed value when not present.

◆ valueOrThrow()

template<typename ExceptionType, typename ValueType, typename ... ExceptionArgs>
ValueType drn::foundation::valueOrThrow ( const std::optional< ValueType > & value,
ExceptionArgs ... args )

A convenience function to retrieve a value from an optional when it's present. When a value is not present, an exception is thrown.

Template Parameters
ValueTypeThe type to retrieve from the optional.
ExceptionTypeThe type of the exception to throw.
ExceptionArgsThe argument types for the thrown exception type.
Parameters
valueThe object containing the value to potentially retrieve.
argsThe arguments for the thrown exception.
Returns
Gives the value stored in the object.

Variable Documentation

◆ daysInMonth

PartialDays drn::foundation::daysInMonth {daysInYear.count() / monthsInYear.count()}
inlineconstexpr

The average number of days per month, accounting for leap years, in a standard Gregorian calendar year.

◆ daysInWeek

std::chrono::days drn::foundation::daysInWeek {7}
inlineconstexpr

The total number of days in a standard Gregorian calendar year.

◆ daysInYear

PartialDays drn::foundation::daysInYear {365.2425}
inlineconstexpr

The average number of days per year, accounting for leap years, in a standard Gregorian calendar year.

◆ displayDigits

long drn::foundation::displayDigits {3}
inlineconstexpr

The number digits after the decimal for displaying floating-point numbers to the user.

◆ hoursInDay

std::chrono::hours drn::foundation::hoursInDay {24}
inlineconstexpr

The total number of hours in a day.

◆ hoursInWeek

std::chrono::hours drn::foundation::hoursInWeek {hoursInDay.count() * daysInWeek.count()}
inlineconstexpr

The total number of hours in a standard Gregorian calendar year.

◆ monthsInYear

std::chrono::months drn::foundation::monthsInYear {12}
inlineconstexpr

The total number of months in a standard Gregorian calendar year.