4#ifndef _Stroika_Foundation_Memory_VariantValue_h_
5#define _Stroika_Foundation_Memory_VariantValue_h_ 1
7#include "Stroika/Foundation/StroikaPreComp.h"
14#if qStroika_HasComponent_boost
15DISABLE_COMPILER_GCC_WARNING_START (
"GCC diagnostic ignored \"-Wstringop-overflow\"");
16#include <boost/json/value.hpp>
17DISABLE_COMPILER_GCC_WARNING_END (
"GCC diagnostic ignored \"-Wstringop-overflow\"");
21#include "Stroika/Foundation/Common/Common.h"
23#include "Stroika/Foundation/Containers/Mapping.h"
24#include "Stroika/Foundation/Containers/Sequence.h"
37 using Characters::String;
38 using Containers::Mapping;
39 using Containers::Sequence;
47 concept IVariantValueAsBasic_ =
48 Common::IAnyOf<T, bool, BLOB, Date, DateTime, wstring, String, Mapping<String, VariantValue>, map<wstring, VariantValue>, Sequence<VariantValue>, vector<VariantValue>>
49#if qStroika_HasComponent_boost
50 or same_as<T, boost::json::value>
52 or integral<T> or floating_point<T>;
175 using FloatType_ =
long double;
181 using IntegerType_ =
long long int;
187 using UnsignedIntegerType_ =
unsigned long long int;
231 using Type::eBoolean;
233 using Type::eDateTime;
235 using Type::eInteger;
237#if qCompilerAndStdLib_InternalCompilerErrorTSubCopy_Buggy
238 static constexpr Type eNull = Type::eNull;
243 using Type::eUnsignedInteger;
279 template <Characters::IConvertibleToString STRINGISH_T>
281 requires (not same_as<remove_cvref_t<STRINGISH_T>,
String>);
283 explicit VariantValue (
const map<wstring, VariantValue>& val);
286 explicit VariantValue (
const vector<VariantValue>& val);
292 template <
typename T>
294 requires (is_convertible_v<T, VariantValue>);
295#if qStroika_HasComponent_boost
305 template <
typename T>
312 nonvirtual
Type GetType ()
const;
323 nonvirtual
bool empty ()
const;
378 template <
typename RETURNTYPE>
379 nonvirtual RETURNTYPE
As () const
380 requires (Private_::IVariantValueAsBasic_<RETURNTYPE> or
381 (Common::IOptional<RETURNTYPE> and Private_::IVariantValueAsBasic_<Common::ExtractValueType_t<RETURNTYPE>>));
393 nonvirtual explicit operator
bool () const;
398 template <typename T>
399 explicit operator T () const
400 requires (requires (T) { As<T> (); })
436 nonvirtual
bool AsBool_ ()
const;
437 nonvirtual Date AsDate_ ()
const;
438 nonvirtual DateTime AsDateTime_ ()
const;
439 nonvirtual BLOB AsBLOB_ ()
const;
440 nonvirtual IntegerType_ AsInteger_ ()
const;
441 nonvirtual UnsignedIntegerType_ AsUnsignedInteger_ ()
const;
442 nonvirtual FloatType_ AsFloatType_ ()
const;
443 nonvirtual String AsString_ ()
const;
444 nonvirtual Mapping<String, VariantValue> AsMapping_ ()
const;
445 nonvirtual Sequence<VariantValue> AsSequence_ ()
const;
446#if qStroika_HasComponent_boost
447 nonvirtual boost::json::value AsBoostJSONValue_ ()
const;
463 struct EqualsComparer;
466 struct ThreeWayComparer;
472 shared_ptr<IRep_> fVal_;
475 template <
typename T>
479 static const shared_ptr<IRep_> kFalseRep_;
480 static const shared_ptr<IRep_> kTrueRep_;
482 static_assert (totally_ordered<VariantValue>);
529#include "VariantValue.inl"
#define Stroika_Define_Enum_Bounds(FIRST_ITEM, LAST_ITEM)
String is like std::u32string, except it is much easier to use, often much more space efficient,...
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 VariantValue ConvertTo(Type to) const
Return this VariantValue converted to the given type (as if by As<T> for the T appropriate to 'Type t...
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
nonvirtual String ToString() const
Type
Enumeration of variant types.
nonvirtual VariantValue & operator=(VariantValue &&rhs) noexcept=default
nonvirtual bool IsConvertibleTo(Type to) const
nonvirtual RETURNTYPE As() const
nonvirtual VariantValue Normalize() const
nonvirtual strong_ordering operator<=>(const VariantValue &rhs) const
compares as if first normalized with Normalize()
Iterable<T> is a base class for containers which easily produce an Iterator<T> to traverse them.
Compares values as if first normalized with Normalize () method.
Compares values as if first normalized with Normalize () method.