carb::variant::IVariant

Defined in carb/variant/IVariant.h

struct IVariant

Interface for carb.variant.plugin

Public Functions

VariantArrayPtr createArray(const Variant *p = nullptr, size_t count = 0)

Creates a VariantArray object from the given parameters.

Parameters
  • p – The raw array to copy into the new VariantArray; may be nullptr to produce an empty array.

  • count – The count of items in p.

Returns

A newly created VariantArray object.

VariantMapPtr createMap()

Creates a VariantMap object.

Returns

A newly created VariantMap object.

Public Members

const VTable *(*getVTable)(RString type) noexcept

Retrieves a v-table by variant type.

Typically not used; see Translator instead.

Param type

The type to translate.

Return

A v-table for the given type, or nullptr in case of an unknown type.

bool (*registerType)(const VTable *vtable) noexcept

Registers a user variant type.

Note

vtable->typeName must be a unique name within the running process and may not match any of the built-in type names.

Param vtable

Must not be nullptr. This pointer is retained by carb.variant.plugin so the caller must guarantee its lifetime until it is unregistered with unregisterType(). A program that still references the v-table in a VariantData (or Variant) after it is unregistered is malformed.

Return

true if vtable->typeName was available and the type was successfully registered; false otherwise.

bool (*unregisterType)(RString type) noexcept

Registers a user variant type.

Param type

The name of the type previously registered with registerType().

Return

true if the type was unregistered; false otherwise (i.e. the type was not previously registered).

Public Static Functions

static inline constexpr carb::InterfaceDesc getInterfaceDesc() noexcept

Returns information about this interface.

Auto-generated by CARB_PLUGIN_INTERFACE() or CARB_PLUGIN_INTERFACE_EX.

Returns

The carb::InterfaceDesc struct with information about this interface.

static inline constexpr carb::InterfaceDesc getLatestInterfaceDesc() noexcept

Returns information about the latest version of this interface.

Auto-generated by CARB_PLUGIN_INTERFACE() or CARB_PLUGIN_INTERFACE_EX.

Returns

The carb::InterfaceDesc struct with information about the latest version of this interface.