ExpressionValue.h header
#include <ew/core/ExpressionValue.h>
Namespace ew::core
Blank struct
struct ew::core::Blank
An absent value – distinct from the number 0 and from empty text.
A blank is 0 in arithmetic, is ignored by the aggregate functions, and reads as empty ("") in the text functions. That is a spreadsheet's blank-cell rule, and it is the right rule everywhere: a character with no age recorded is not aged zero, and averaging the field across a cast must not pull the average toward zero for everyone it was never written for.
Members
bool operator==(const Blank &, const Blank &)=default
Every blank equals every other blank.
Types
using ew::core::expression::Value = std::variant<double, QString, Blank>
A value an expression computes with: a number, text, or blank.
Functions
std::optional< double > ew::core::expression::asNumber(const Value &value)
The number value carries: the number itself, a blank as 0, or std::nullopt for text that does not parse as a number.
QString ew::core::expression::asText(const Value &value)
The text value carries: text as-is, a number formatted for display, or "" for a blank.
QString ew::core::expression::formatNumber(double value)
Formats value for display, trimming trailing zeros.
bool ew::core::expression::isTrue(const Value &value)
Whether value counts as true: any non-zero number, and any text that is neither empty nor a spelling of zero. A blank is false.
Text is admitted deliberately. A condition tests what a field or a variable holds, and a Flag stored as "yes" has to be usable as a condition without the author converting it first.