Type-safe tagged union that can hold any of the types listed in PROMEKI_VARIANT_TYPES.
More...
|
| enum | Type {
TypeInvalid
, TypeBool
, TypeU8
, TypeS8
,
TypeU16
, TypeS16
, TypeU32
, TypeS32
,
TypeU64
, TypeS64
, TypeFloat
, TypeDouble
,
TypeString
, TypeDateTime
, TypeTimeStamp
, TypeSize2D
,
TypeUUID
, TypeTimecode
, TypeRational
} |
| | Enumerates every type the variant can hold. More...
|
| |
template<typename... Types>
class VariantImpl< Types >
Type-safe tagged union that can hold any of the types listed in PROMEKI_VARIANT_TYPES.
VariantImpl is a thin wrapper around std::variant that adds a Type enum, human-readable type names, and automatic type-conversion logic via the templated get() method. It is not intended to be used directly; instead use
- Example
bool valid = v.isValid();
Variant::Type
t = v.type();
Dynamic array container wrapping std::vector.
Definition list.h:40
bool set(size_t index, const T &val)
Sets an item in the list by index.
Definition list.h:541
Encoding-aware string class with copy-on-write semantics.
Definition string.h:35
the Variant type alias which is instantiated with the concrete type list.
- Template Parameters
-
| Types | The set of types the variant can hold (generated from PROMEKI_VARIANT_TYPES). |
template<typename... Types>
Converts the stored value to the requested type To.
The method uses std::visit with a compile-time conversion matrix. If the stored type is already To, the value is returned directly. Otherwise an appropriate conversion is attempted (numeric casts, string parsing, toString() calls, etc.). When no conversion path exists, a default-constructed To is returned and err (if non-null) is set to Error::Invalid.
- Template Parameters
-
| To | The desired result type. |
- Parameters
-
- Returns
- The converted value, or a default-constructed
To on failure.
template<typename... Types>
Converts complex types to their String representation, leaving simple types unchanged.
Types such as String, DateTime, TimeStamp, Size2Du32, UUID, Timecode, and Rational are converted to String via get<std::string>(). All other types (numeric, bool, invalid) are returned as-is.
- Returns
- A new VariantImpl containing either the original value or its String representation.