morph 0.1.0
Asynchronous bridge between GUI thread and business models
Loading...
Searching...
No Matches
morph::ui::Value Class Reference

The document's typed value (spec 5 §3): what every expression evaluates to. More...

#include <value.hpp>

Public Member Functions

 Value () noexcept=default
 Constructs null.
 Value (std::nullptr_t null) noexcept
 Constructs null.
 Value (bool flag) noexcept
 Constructs a bool.
template<std::signed_integral I>
 Value (I number) noexcept
 Constructs an int from any signed integer.
 Value (std::string text) noexcept
 Constructs a string.
 Value (char const *text)
 Constructs a string from a C string, which would otherwise convert to bool.
 Value (Decimal number) noexcept
 Constructs a decimal.
 Value (Quantity quantity) noexcept
 Constructs a quantity.
 Value (time::DateTime instant) noexcept
 Constructs a timestamp.
 Value (ValueList items)
 Constructs a list.
 Value (ValueRecord fields)
 Constructs a record.
ValueKind kind () const noexcept
 The kind of value held.
bool isNull () const noexcept
 Whether the value is null.
bool const * asBool () const noexcept
 The bool, if held.
std::int64_t const * asInt () const noexcept
 The int, if held.
std::string const * asString () const noexcept
 The string, if held.
Decimal const * asDecimal () const noexcept
 The decimal, if held.
Quantity const * asQuantity () const noexcept
 The quantity, if held.
time::DateTime const * asTimestamp () const noexcept
 The timestamp, if held.
ValueList const * asList () const noexcept
 The list, if held.
ValueRecord const * asRecord () const noexcept
 The record, if held.
Value const * field (std::string_view name) const
 A field of a record.
bool operator== (Value const &other) const
 Deep equality: same kind and equal content; a decimal's places take part.

Detailed Description

The document's typed value (spec 5 §3): what every expression evaluates to.

A value is immutable once built. Lists and records share their storage between copies, so copying a value — which the reactive core does on every read — costs a reference count, not a deep copy. Equality is deep.

Definition at line 157 of file value.hpp.

Constructor & Destructor Documentation

◆ Value() [1/10]

morph::ui::Value::Value ( std::nullptr_t null)
inlinenoexcept

Constructs null.

Parameters
nullUnused.

Definition at line 164 of file value.hpp.

◆ Value() [2/10]

morph::ui::Value::Value ( bool flag)
inlinenoexcept

Constructs a bool.

Parameters
flagThe value.

Definition at line 168 of file value.hpp.

◆ Value() [3/10]

template<std::signed_integral I>
morph::ui::Value::Value ( I number)
inlinenoexcept

Constructs an int from any signed integer.

Template Parameters
IA signed integer type.
Parameters
numberThe value.

Definition at line 174 of file value.hpp.

◆ Value() [4/10]

morph::ui::Value::Value ( std::string text)
inlinenoexcept

Constructs a string.

Parameters
textUTF-8 text.

Definition at line 178 of file value.hpp.

◆ Value() [5/10]

morph::ui::Value::Value ( char const * text)
inline

Constructs a string from a C string, which would otherwise convert to bool.

Parameters
textNUL-terminated UTF-8 text.

Definition at line 182 of file value.hpp.

◆ Value() [6/10]

morph::ui::Value::Value ( Decimal number)
inlinenoexcept

Constructs a decimal.

Parameters
numberThe exact value with its places.

Definition at line 186 of file value.hpp.

◆ Value() [7/10]

morph::ui::Value::Value ( Quantity quantity)
inlinenoexcept

Constructs a quantity.

Parameters
quantityThe magnitude and unit.

Definition at line 190 of file value.hpp.

◆ Value() [8/10]

morph::ui::Value::Value ( time::DateTime instant)
inlinenoexcept

Constructs a timestamp.

Parameters
instantThe UTC instant.

Definition at line 194 of file value.hpp.

◆ Value() [9/10]

morph::ui::Value::Value ( ValueList items)
inline

Constructs a list.

Parameters
itemsThe elements.

Definition at line 198 of file value.hpp.

◆ Value() [10/10]

morph::ui::Value::Value ( ValueRecord fields)
inline

Constructs a record.

Parameters
fieldsThe fields.

Definition at line 203 of file value.hpp.

Member Function Documentation

◆ kind()

ValueKind morph::ui::Value::kind ( ) const
inlinenodiscardnoexcept

The kind of value held.

Returns
The kind.

Definition at line 208 of file value.hpp.

◆ isNull()

bool morph::ui::Value::isNull ( ) const
inlinenodiscardnoexcept

Whether the value is null.

Returns
kind() == ValueKind::Null.

Definition at line 212 of file value.hpp.

◆ asBool()

bool const * morph::ui::Value::asBool ( ) const
inlinenodiscardnoexcept

The bool, if held.

Returns
A pointer to it, or nullptr.

Definition at line 216 of file value.hpp.

◆ asInt()

std::int64_t const * morph::ui::Value::asInt ( ) const
inlinenodiscardnoexcept

The int, if held.

Returns
A pointer to it, or nullptr.

Definition at line 220 of file value.hpp.

◆ asString()

std::string const * morph::ui::Value::asString ( ) const
inlinenodiscardnoexcept

The string, if held.

Returns
A pointer to it, or nullptr.

Definition at line 224 of file value.hpp.

◆ asDecimal()

Decimal const * morph::ui::Value::asDecimal ( ) const
inlinenodiscardnoexcept

The decimal, if held.

Returns
A pointer to it, or nullptr.

Definition at line 228 of file value.hpp.

◆ asQuantity()

Quantity const * morph::ui::Value::asQuantity ( ) const
inlinenodiscardnoexcept

The quantity, if held.

Returns
A pointer to it, or nullptr.

Definition at line 232 of file value.hpp.

◆ asTimestamp()

time::DateTime const * morph::ui::Value::asTimestamp ( ) const
inlinenodiscardnoexcept

The timestamp, if held.

Returns
A pointer to it, or nullptr.

Definition at line 236 of file value.hpp.

◆ asList()

ValueList const * morph::ui::Value::asList ( ) const
inlinenodiscardnoexcept

The list, if held.

Returns
A pointer to it, or nullptr.

Definition at line 240 of file value.hpp.

◆ asRecord()

ValueRecord const * morph::ui::Value::asRecord ( ) const
inlinenodiscardnoexcept

The record, if held.

Returns
A pointer to it, or nullptr.

Definition at line 247 of file value.hpp.

◆ field()

Value const * morph::ui::Value::field ( std::string_view name) const
inlinenodiscard

A field of a record.

Parameters
nameThe field name.
Returns
A pointer to the field, or nullptr when this is not a record or has no such field.

Definition at line 255 of file value.hpp.

◆ operator==()

bool morph::ui::Value::operator== ( Value const & other) const
inlinenodiscard

Deep equality: same kind and equal content; a decimal's places take part.

Parameters
otherThe value to compare with.
Returns
Whether the two values are equal.

Definition at line 268 of file value.hpp.


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