|
|
std::size_t | index () const noexcept |
| | Index of the currently active alternative.
|
| |
| template<std::size_t I> |
| auto & | get () |
| | Access the value at alternative I (mutable).
|
| |
| template<std::size_t I> |
| auto const & | get () const |
| | Access the value at alternative I (const).
|
| |
| template<typename S > |
| S & | get () |
| | Access the value held in storage type S (mutable).
|
| |
| template<typename S > |
| S const & | get () const |
| | Access the value held in storage type S (const).
|
| |
|
std::string_view | active_kind () const |
| | Kind id of the currently active alternative.
|
| |
| std::string | to_string () const override |
| | Render the cell's value as a compact human-readable string.
|
| |
| json_t | to_json () const override |
| | Default JSON serialization for cells with JSON-convertible storage.
|
| |
| cell_t | clone () const override |
| | Deep-copy this cell.
|
| |
| std::partial_ordering | compare (ICell const &other) const override |
| | Three-way comparison: kind, then active alternative index, then the active alternative's wrapper-level compare.
|
| |
| template<typename F > |
| decltype(auto) | visit (F &&f) |
| | Visit the active alternative with f, called as f(storage).
|
| |
|
template<typename F > |
| decltype(auto) | visit (F &&f) const |
| | Const overload of visit.
|
| |
|
template<std::size_t I> |
| auto * | get_if () noexcept |
| | Returns a pointer to the active alternative if it lives at slot I, else nullptr — never throws.
|
| |
|
template<std::size_t I> |
| auto const * | get_if () const noexcept |
| | Const overload of get_if<I>.
|
| |
|
template<typename S > |
| S * | get_if () noexcept |
| | Returns a pointer to the active alternative if its storage is S, else nullptr — never throws.
|
| |
|
template<typename S > |
| S const * | get_if () const noexcept |
| | Const overload of get_if<S>.
|
| |
|
template<std::size_t I> |
| bool | holds_alternative () const noexcept |
| | true if the active alternative lives at slot I.
|
| |
|
template<typename S > |
| bool | holds () const noexcept |
| | true if the active alternative's storage type is S.
|
| |
template<typename U >
requires std::assignable_from<Storage&, U&&> |
| Derived & | operator= (U &&v) |
| | Assign to the storage from v.
|
| |
| | explicit (false) BaseCell(U &&v) |
| | Construct by forwarding into the storage (v becomes Storage::value).
|
| |
| UnionCell< Ts... > & | operator= (U &&v) |
| | Assign to the storage from v.
|
| |
|
std::variant< Ts::storage_t... > & | get () |
| | Mutable access to the held storage.
|
| |
|
std::variant< Ts::storage_t... > const & | get () const |
| | Read-only access to the held storage.
|
| |
| void | inject_display_info (json_t &j) const |
| | Copy this cell's display info (if any) into the JSON object under "d".
|
| |
| virtual std::string | to_formatted_string () const |
| | Render the cell as a multi-line, indented string.
|
| |
| virtual std::size_t | hash_value () const noexcept |
| | Equality-consistent hash that mirrors compare's display-info-insensitivity.
|
| |
| cell_t | with_display_info (DisplayInfo m) const |
| | Return a deep copy with the entire display info block replaced.
|
| |
| cell_t | with_name (std::string v) const |
| | Return a deep copy with name set to v.
|
| |
| cell_t | with_description (std::string v) const |
| | Return a deep copy with description set to v.
|
| |
| cell_t | with_icon (comms::Icon icon) const |
| | Return a deep copy with icon set to the typed icon.
|
| |
| cell_t | with_icon (std::string const &v) const |
| | Return a deep copy with icon parsed from an Iconify set:name string (e.g.
|
| |
| cell_t | with_color (comms::Color color) const |
| | Return a deep copy with color set to the typed color.
|
| |
| cell_t | with_color (std::string const &v) const |
| | Return a deep copy with color parsed from a color string (hex like "#ffcc00", a CSS-functional form, or a CSS color name).
|
| |
|
|
static constexpr std::size_t | alternative_count = sizeof...(Ts) |
| | Number of alternatives.
|
| |
|
static constexpr std::array< std::string_view, sizeof...(Ts)> | alternatives {Ts::kind_id...} |
| | Kind id of each alternative in template order.
|
| |
| static constexpr std::string_view | kind_id {kind_id_buf.data(), kind_id_buf.size()} |
| | Wire kind id of this union ("u:" + alternatives joined by ",").
|
| |
|
static constexpr std::string_view | KEY_KIND = "k" |
| | JSON key for the kind id ("k").
|
| |
|
static constexpr std::string_view | KEY_VALUE = "v" |
| | JSON key for the value payload ("v").
|
| |
|
static constexpr std::string_view | KEY_DESCRIPTION = "d" |
| | JSON key for the optional display info block ("d").
|
| |
template<CellLike... Ts>
class parcel::UnionCell< Ts >
Closed-set polymorphic cell — exactly one of Ts at runtime.
Wire shape (example for UnionCell<I32Cell, StringCell>):
{"k": "u:i32,string", "v": {"k": "i32", "v": 42}}
The active alternative is recovered from the inner v.k. Storage is std::variant<typename Ts::storage_t...> so values are raw, not wrapped cells. Each unique parameter pack registers under its own kind:
Closed-set polymorphic cell — exactly one of Ts at runtime.
Definition union.h:100
static constexpr std::string_view kind_id
Wire kind id of this union ("u:" + alternatives joined by ",").
Definition union.h:159
- Template Parameters
-
| Ts | One or more CellLike alternative types (at least one). |
- See also
- UnionCellTypeDescriptor