kDB: Knowledge DataBase
Loading...
Searching...
No Matches
knowCore::QuantityValue< _T_ > Class Template Reference

#include <QuantityValue.h>

Classes

struct  Constructor
 

Public Member Functions

 QuantityValue (const _T_ &_value, const Unit &_unit)
 
Unit unit () const
 
_T_ value () const
 
cres_qresult< QuantityValueoperator+ (const QuantityValue &_rhs) const
 
cres_qresult< QuantityValueoperator- (const QuantityValue &_rhs) const
 
cres_qresult< QuantityValueoperator/ (const QuantityValue &_rhs) const
 
cres_qresult< QuantityValueoperator* (const QuantityValue &_rhs) const
 
QuantityValue operator/ (const _T_ &_rhs) const
 
QuantityValue operator* (const _T_ &_rhs) const
 
bool operator== (const QuantityValue &_rhs) const
 
cres_qresult< bool > operator< (const QuantityValue &_rhs) const
 
cres_qresult< QByteArray > md5 () const
 
cres_qresult< QJsonValue > toJsonValue (const SerialisationContexts &_contexts=defaultSerialisationContext()) const
 
cres_qresult< QCborValue > toCborValue (const SerialisationContexts &_contexts=defaultSerialisationContext()) const
 
cres_qresult< QString > toRdfLiteral (const SerialisationContexts &_contexts=defaultSerialisationContext()) const
 
cres_qresult< QString > printable () const
 
template<typename _TOther_ >
requires (not std::is_base_of_v<Value, _TOther_>)
cres_qresult< QuantityValue< _T_ > > create (const _TOther_ &_value, const knowCore::Uri &_unit_uri)
 
template<typename _TOther_ >
requires (not std::is_base_of_v<Value, _TOther_>)
cres_qresult< QuantityValue< _T_ > > create (const _TOther_ &_value, const Symbol &_unit_symbol)
 

Static Public Member Functions

template<typename _TOther_ , typename _TUri_ >
requires (not std::is_base_of_v<Value, _TOther_> and knowCore::Uris::IsUriDefinitionV<_TUri_>)
static cres_qresult< QuantityValuecreate (const _TOther_ &_value, const _TUri_ &_unit_uri)
 
template<typename _TOther_ >
requires (not std::is_base_of_v<Value, _TOther_>)
static cres_qresult< QuantityValuecreate (const _TOther_ &_value, const knowCore::Uri &_unit_uri)
 
static cres_qresult< QuantityValuecreate (const Value &_value, const knowCore::Uri &_unit_uri)
 
template<typename _TOther_ >
requires (not std::is_base_of_v<Value, _TOther_>)
static cres_qresult< QuantityValuecreate (const _TOther_ &_value, const QString &_unit_uri)=delete
 
static cres_qresult< QuantityValuecreate (const Value &_value, const QString &_unit_uri)=delete
 
template<typename _TOther_ >
requires (not std::is_base_of_v<Value, _TOther_>)
static cres_qresult< QuantityValuecreate (const _TOther_ &_value, const Symbol &_unit_symbol)
 
static cres_qresult< QuantityValuecreate (const Value &_value, const Symbol &_unit_symbol)
 
static cres_qresult< QuantityValuefromJsonValue (const QJsonValue &_value, const DeserialisationContexts &_context=defaultDeserialisationContext())
 
static cres_qresult< QuantityValuefromCborValue (const QCborValue &_value, const DeserialisationContexts &_context=defaultDeserialisationContext())
 
static cres_qresult< QuantityValuefromRdfLiteral (const QString &_value, const DeserialisationContexts &_context=defaultDeserialisationContext())
 

Detailed Description

template<typename _T_>
class knowCore::QuantityValue< _T_ >

This class can be use to combine a number with a Unit. Look at UnitNumber for an alias combining BigNumber with Unit.

Member Function Documentation

◆ fromCborValue()

template<typename _T_ >
cres_qresult< QuantityValue< _T_ > > knowCore::QuantityValue< _T_ >::fromCborValue ( const QCborValue & _value,
const DeserialisationContexts & _context = defaultDeserialisationContext() )
inlinestatic

Convert from cbor

◆ fromJsonValue()

template<typename _T_ >
cres_qresult< QuantityValue< _T_ > > knowCore::QuantityValue< _T_ >::fromJsonValue ( const QJsonValue & _value,
const DeserialisationContexts & _context = defaultDeserialisationContext() )
inlinestatic

Convert from json

◆ fromRdfLiteral()

template<typename _T_ >
cres_qresult< QuantityValue< _T_ > > knowCore::QuantityValue< _T_ >::fromRdfLiteral ( const QString & _value,
const DeserialisationContexts & _context = defaultDeserialisationContext() )
inlinestatic

Convert from a rdf literal (something like "12.0 m/s")

◆ md5()

template<typename _T_ >
cres_qresult< QByteArray > knowCore::QuantityValue< _T_ >::md5 ( ) const
inline
Returns
a md5 hash of the value

◆ operator*() [1/2]

template<typename _T_ >
QuantityValue< _T_ > knowCore::QuantityValue< _T_ >::operator* ( const _T_ & _rhs) const

Multiplication.

◆ operator*() [2/2]

template<typename _T_ >
cres_qresult< QuantityValue< _T_ > > knowCore::QuantityValue< _T_ >::operator* ( const QuantityValue< _T_ > & _rhs) const
inline

Attempt a multiplication, return an error if units are not compatible

◆ operator+()

template<typename _T_ >
cres_qresult< QuantityValue< _T_ > > knowCore::QuantityValue< _T_ >::operator+ ( const QuantityValue< _T_ > & _rhs) const
inline

Attempt an addition, return an error if units are not compatible

◆ operator-()

template<typename _T_ >
cres_qresult< QuantityValue< _T_ > > knowCore::QuantityValue< _T_ >::operator- ( const QuantityValue< _T_ > & _rhs) const
inline

Attempt an substractionm, return an error if units are not compatible

◆ operator/() [1/2]

template<typename _T_ >
QuantityValue< _T_ > knowCore::QuantityValue< _T_ >::operator/ ( const _T_ & _rhs) const

Division.

◆ operator/() [2/2]

template<typename _T_ >
cres_qresult< QuantityValue< _T_ > > knowCore::QuantityValue< _T_ >::operator/ ( const QuantityValue< _T_ > & _rhs) const
inline

Attempt a division, return an error if units are not compatible

◆ operator<()

template<typename _T_ >
cres_qresult< bool > knowCore::QuantityValue< _T_ >::operator< ( const QuantityValue< _T_ > & _rhs) const

Compare two values for inferirority. It will return an error if the units are not compatible.

◆ operator==()

template<typename _T_ >
bool knowCore::QuantityValue< _T_ >::operator== ( const QuantityValue< _T_ > & _rhs) const

Compare two values. Note, that comparing two numbers with different unit is acceptable and will return false.

◆ printable()

template<typename _T_ >
cres_qresult< QString > knowCore::QuantityValue< _T_ >::printable ( ) const
inline

Return a printable value

◆ toCborValue()

template<typename _T_ >
cres_qresult< QCborValue > knowCore::QuantityValue< _T_ >::toCborValue ( const SerialisationContexts & _contexts = defaultSerialisationContext()) const
inline

Convert to cbor

◆ toJsonValue()

template<typename _T_ >
cres_qresult< QJsonValue > knowCore::QuantityValue< _T_ >::toJsonValue ( const SerialisationContexts & _contexts = defaultSerialisationContext()) const
inline

Convert to json

◆ toRdfLiteral()

template<typename _T_ >
cres_qresult< QString > knowCore::QuantityValue< _T_ >::toRdfLiteral ( const SerialisationContexts & _contexts = defaultSerialisationContext()) const
inline

Convert to a rdf literal (something like "12.0 m/s")

◆ unit()

template<typename _T_ >
Unit knowCore::QuantityValue< _T_ >::unit ( ) const
inline
Returns
the Unit associated with this number

◆ value()

template<typename _T_ >
_T_ knowCore::QuantityValue< _T_ >::value ( ) const
inline
Returns
the value

The documentation for this class was generated from the following files: