10 struct VariantValue::IRep_ {
11 virtual ~IRep_ () =
default;
12 virtual Type GetType ()
const = 0;
24 inline VariantValue::VariantValue (nullopt_t)
28 template <same_as<
bool> BOOL_T>
29 inline VariantValue::VariantValue (BOOL_T val)
30 : fVal_{val ? kTrueRep_ : kFalseRep_}
37 template <Characters::IConvertibleToString STRINGISH_T>
39 requires (not same_as<remove_cvref_t<STRINGISH_T>, String>)
40 : VariantValue{String{forward<STRINGISH_T> (val)}}
45 requires (is_convertible_v<T, VariantValue>)
46 : VariantValue{val.has_value () ? VariantValue{*val} : VariantValue{}}
51 requires (
requires (T x) { VariantValue{x}; })
53 *
this = VariantValue{forward<T> (val)};
58 if (fVal_ ==
nullptr) {
61 return fVal_->GetType ();
63 inline VariantValue::operator bool ()
const
65 return fVal_ !=
nullptr;
67 template <
typename RETURNTYPE>
69 requires (Private_::IVariantValueAsBasic_<RETURNTYPE> or
70 (Common::IOptional<RETURNTYPE> and Private_::IVariantValueAsBasic_<Common::ExtractValueType_t<RETURNTYPE>>))
73 return this->AsBool_ ();
76 return this->AsBLOB_ ();
79 return static_cast<RETURNTYPE> (this->AsInteger_ ());
82 return static_cast<RETURNTYPE> (this->AsUnsignedInteger_ ());
85 return static_cast<RETURNTYPE> (this->AsFloatType_ ());
88 return this->AsDate_ ();
91 return this->AsDateTime_ ();
94 return this->AsString_ ().
As<wstring> ();
97 return this->AsString_ ();
100 return this->AsMapping_ ();
103 return this->AsSequence_ ();
112#if qStroika_HasComponent_boost
117 else if constexpr (Common::IOptional<RETURNTYPE>) {
118 if (this->
empty ()) {
140 constexpr EnumNames<DataExchange::VariantValue::Type> DefaultNames<DataExchange::VariantValue::Type>::k{{{
141 {DataExchange::VariantValue::eNull, L
"Null"},
142 {DataExchange::VariantValue::eBLOB, L
"BLOB"},
143 {DataExchange::VariantValue::eBoolean, L
"Boolean"},
144 {DataExchange::VariantValue::eInteger, L
"Integer"},
145 {DataExchange::VariantValue::eUnsignedInteger, L
"Unsigned-Integer"},
146 {DataExchange::VariantValue::eFloat, L
"Float"},
147 {DataExchange::VariantValue::eDate, L
"Date"},
148 {DataExchange::VariantValue::eDateTime, L
"DateTime"},
149 {DataExchange::VariantValue::eString, L
"String"},
150 {DataExchange::VariantValue::eArray, L
"Array"},
151 {DataExchange::VariantValue::eMap, L
"Map"},
A generalization of a vector: a container whose elements are keyed by the natural numbers.
Simple variant-value (case variant union) object, with (variant) basic types analogous to a value in ...
nonvirtual bool operator==(const VariantValue &rhs) const
compares as if first normalized with Normalize()
VariantValue()=default
construct a VariantValue from most any 'basic type' you would expect to find in a weakly typed langua...
nonvirtual bool empty() const
Type
Enumeration of variant types.
nonvirtual VariantValue & operator=(VariantValue &&rhs) noexcept=default
nonvirtual RETURNTYPE As() const
nonvirtual strong_ordering operator<=>(const VariantValue &rhs) const
compares as if first normalized with Normalize()
Compares values as if first normalized with Normalize () method.
Compares values as if first normalized with Normalize () method.