|
parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
|
Polymorphic root of every parcel cell. More...
#include <cell.h>

Public Member Functions | |
| virtual std::string_view | kind () const =0 |
| Wire-stable kind identifier for this cell. | |
| virtual std::optional< DisplayInfo > const & | overridden_display_info () const =0 |
| Read-only access to this cell's optional display info. | |
| virtual json_t | to_json () const =0 |
| Serialize this cell to its canonical JSON representation. | |
| virtual std::string | to_string () const =0 |
| Render the cell's value as a compact human-readable string. | |
| virtual std::string | to_formatted_string () const |
| Render the cell as a multi-line, indented string. | |
| virtual cell_t | clone () const =0 |
| Deep-copy this cell. | |
| virtual std::partial_ordering | compare (ICell const &other) const =0 |
| Three-way compare against another cell. | |
| 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). | |
Protected Member Functions | |
| virtual void | set_display_info (std::optional< DisplayInfo > m)=0 |
| Replace this cell's display info in place. | |
Friends | |
| bool | operator== (ICell const &a, ICell const &b) |
Equality through compare; ignores display info. | |
| std::partial_ordering | operator<=> (ICell const &a, ICell const &b) |
Three-way comparison through compare; ignores display info. | |
Polymorphic root of every parcel cell.
Wire shape: {"k": <kind>, "v": <value>, "d": <display info>} where the "d" block is omitted when no display info is set. Every concrete cell exposes its kind via kind(), can serialize through to_json(), render via to_string(), and clone deeply via clone().
Display info is read-only on the public surface: callers retrieve it via overridden_display_info() and only the immutable with_* builders may change it.
|
pure virtual |
Deep-copy this cell.
cell_t whose state is independent of the original. Implemented in parcel::BaseCell< Derived, Storage >, parcel::BaseCell< ColorCell, comms::Color >, parcel::BaseCell< Derived, Payload >, parcel::BaseCell< DisplayInfoCell, comms::DisplayInfo >, parcel::BaseCell< DurationMsCell, std::chrono::milliseconds >, parcel::BaseCell< FlagCell, comms::FlagRef >, parcel::BaseCell< FlagSetCell, comms::FlagSet >, parcel::BaseCell< HashMapCell, std::unordered_map< std::string, cell_t > >, parcel::BaseCell< IconCell, comms::Icon >, parcel::BaseCell< ListCell, std::vector< cell_t > >, parcel::BaseCell< MapCell, std::map< std::string, cell_t > >, parcel::BaseCell< PathCell, std::filesystem::path >, parcel::BaseCell< PrimitiveCell< T >, T >, parcel::BaseCell< SemVerCell, comms::SemVer >, parcel::BaseCell< SystemTimePointCell, std::chrono::sys_seconds >, parcel::BaseCell< TypedHashMapCell< T >, std::unordered_map< std::string, T::storage_t > >, parcel::BaseCell< TypedListCell< T >, std::vector< T::storage_t > >, parcel::BaseCell< TypedMapCell< T >, std::map< std::string, T::storage_t > >, parcel::BaseCell< UnionCell< Ts... >, std::variant< Ts::storage_t... > >, parcel::BaseCell< UnixMillisCell, std::chrono::sys_time< std::chrono::milliseconds > >, parcel::BaseCell< VersionConstraintCell, comms::VersionConstraint >, parcel::BaseCell< YmdCell, std::chrono::year_month_day >, parcel::OriginCell, parcel::ListCell, parcel::MapCell, parcel::StructCell< Derived, Payload, StructId >, parcel::SelfStructCell< Derived >, parcel::UnionCell< Ts >, and parcel::HashMapCell.
|
pure virtual |
Three-way compare against another cell.
Compares by kind id first (lexicographic on the string view); within the same kind, compares the held value. Display info is intentionally ignored — two cells with the same kind/value but different DisplayInfo are equivalent under this relation.
| other | Cell to compare with. |
std::partial_ordering — unordered whenever the storage type only supports equality (or contains incomparable values such as floating-point NaN). Implemented in parcel::BaseCell< Derived, Storage >, parcel::BaseCell< ColorCell, comms::Color >, parcel::BaseCell< Derived, Payload >, parcel::BaseCell< DisplayInfoCell, comms::DisplayInfo >, parcel::BaseCell< DurationMsCell, std::chrono::milliseconds >, parcel::BaseCell< FlagCell, comms::FlagRef >, parcel::BaseCell< FlagSetCell, comms::FlagSet >, parcel::BaseCell< HashMapCell, std::unordered_map< std::string, cell_t > >, parcel::BaseCell< IconCell, comms::Icon >, parcel::BaseCell< ListCell, std::vector< cell_t > >, parcel::BaseCell< MapCell, std::map< std::string, cell_t > >, parcel::BaseCell< PathCell, std::filesystem::path >, parcel::BaseCell< PrimitiveCell< T >, T >, parcel::BaseCell< SemVerCell, comms::SemVer >, parcel::BaseCell< SystemTimePointCell, std::chrono::sys_seconds >, parcel::BaseCell< TypedHashMapCell< T >, std::unordered_map< std::string, T::storage_t > >, parcel::BaseCell< TypedListCell< T >, std::vector< T::storage_t > >, parcel::BaseCell< TypedMapCell< T >, std::map< std::string, T::storage_t > >, parcel::BaseCell< UnionCell< Ts... >, std::variant< Ts::storage_t... > >, parcel::BaseCell< UnixMillisCell, std::chrono::sys_time< std::chrono::milliseconds > >, parcel::BaseCell< VersionConstraintCell, comms::VersionConstraint >, parcel::BaseCell< YmdCell, std::chrono::year_month_day >, parcel::OriginCell, parcel::TypedListCell< T >, parcel::ListCell, parcel::TypedMapCell< T >, parcel::MapCell, parcel::StructCell< Derived, Payload, StructId >, parcel::SelfStructCell< Derived >, parcel::UnionCell< Ts >, parcel::TypedHashMapCell< T >, and parcel::HashMapCell.
|
inlinevirtualnoexcept |
Equality-consistent hash that mirrors compare's display-info-insensitivity.
Default implementation hashes the kind id and the JSON dump of "v", which works for every cell whose to_json() payload omits nested DisplayInfo. Heterogeneous container cells (ListCell, MapCell, HashMapCell) override this to recurse through hash_value() on their children — that is what keeps the hash display-info-insensitive when children carry display info of their own.
Reimplemented in parcel::ListCell, parcel::MapCell, and parcel::HashMapCell.
|
pure virtual |
Wire-stable kind identifier for this cell.
kind_id on the concrete type. Implemented in parcel::BaseCell< Derived, Storage >, parcel::BaseCell< ColorCell, comms::Color >, parcel::BaseCell< Derived, Payload >, parcel::BaseCell< DisplayInfoCell, comms::DisplayInfo >, parcel::BaseCell< DurationMsCell, std::chrono::milliseconds >, parcel::BaseCell< FlagCell, comms::FlagRef >, parcel::BaseCell< FlagSetCell, comms::FlagSet >, parcel::BaseCell< HashMapCell, std::unordered_map< std::string, cell_t > >, parcel::BaseCell< IconCell, comms::Icon >, parcel::BaseCell< ListCell, std::vector< cell_t > >, parcel::BaseCell< MapCell, std::map< std::string, cell_t > >, parcel::BaseCell< PathCell, std::filesystem::path >, parcel::BaseCell< PrimitiveCell< T >, T >, parcel::BaseCell< SemVerCell, comms::SemVer >, parcel::BaseCell< SystemTimePointCell, std::chrono::sys_seconds >, parcel::BaseCell< TypedHashMapCell< T >, std::unordered_map< std::string, T::storage_t > >, parcel::BaseCell< TypedListCell< T >, std::vector< T::storage_t > >, parcel::BaseCell< TypedMapCell< T >, std::map< std::string, T::storage_t > >, parcel::BaseCell< UnionCell< Ts... >, std::variant< Ts::storage_t... > >, parcel::BaseCell< UnixMillisCell, std::chrono::sys_time< std::chrono::milliseconds > >, parcel::BaseCell< VersionConstraintCell, comms::VersionConstraint >, parcel::BaseCell< YmdCell, std::chrono::year_month_day >, parcel::OriginCell, and parcel::SelfStructCell< Derived >.
|
pure virtual |
Read-only access to this cell's optional display info.
Implemented in parcel::BaseCell< Derived, Storage >, parcel::BaseCell< ColorCell, comms::Color >, parcel::BaseCell< Derived, Payload >, parcel::BaseCell< DisplayInfoCell, comms::DisplayInfo >, parcel::BaseCell< DurationMsCell, std::chrono::milliseconds >, parcel::BaseCell< FlagCell, comms::FlagRef >, parcel::BaseCell< FlagSetCell, comms::FlagSet >, parcel::BaseCell< HashMapCell, std::unordered_map< std::string, cell_t > >, parcel::BaseCell< IconCell, comms::Icon >, parcel::BaseCell< ListCell, std::vector< cell_t > >, parcel::BaseCell< MapCell, std::map< std::string, cell_t > >, parcel::BaseCell< PathCell, std::filesystem::path >, parcel::BaseCell< PrimitiveCell< T >, T >, parcel::BaseCell< SemVerCell, comms::SemVer >, parcel::BaseCell< SystemTimePointCell, std::chrono::sys_seconds >, parcel::BaseCell< TypedHashMapCell< T >, std::unordered_map< std::string, T::storage_t > >, parcel::BaseCell< TypedListCell< T >, std::vector< T::storage_t > >, parcel::BaseCell< TypedMapCell< T >, std::map< std::string, T::storage_t > >, parcel::BaseCell< UnionCell< Ts... >, std::variant< Ts::storage_t... > >, parcel::BaseCell< UnixMillisCell, std::chrono::sys_time< std::chrono::milliseconds > >, parcel::BaseCell< VersionConstraintCell, comms::VersionConstraint >, parcel::BaseCell< YmdCell, std::chrono::year_month_day >, parcel::OriginCell, and parcel::SelfStructCell< Derived >.
|
protectedpure virtual |
Replace this cell's display info in place.
Used by with_* builders on freshly cloned receivers and by JSON deserializers; no other public path mutates display info.
| m | New display info value (may be empty to clear). |
Implemented in parcel::BaseCell< Derived, Storage >, parcel::BaseCell< ColorCell, comms::Color >, parcel::BaseCell< Derived, Payload >, parcel::BaseCell< DisplayInfoCell, comms::DisplayInfo >, parcel::BaseCell< DurationMsCell, std::chrono::milliseconds >, parcel::BaseCell< FlagCell, comms::FlagRef >, parcel::BaseCell< FlagSetCell, comms::FlagSet >, parcel::BaseCell< HashMapCell, std::unordered_map< std::string, cell_t > >, parcel::BaseCell< IconCell, comms::Icon >, parcel::BaseCell< ListCell, std::vector< cell_t > >, parcel::BaseCell< MapCell, std::map< std::string, cell_t > >, parcel::BaseCell< PathCell, std::filesystem::path >, parcel::BaseCell< PrimitiveCell< T >, T >, parcel::BaseCell< SemVerCell, comms::SemVer >, parcel::BaseCell< SystemTimePointCell, std::chrono::sys_seconds >, parcel::BaseCell< TypedHashMapCell< T >, std::unordered_map< std::string, T::storage_t > >, parcel::BaseCell< TypedListCell< T >, std::vector< T::storage_t > >, parcel::BaseCell< TypedMapCell< T >, std::map< std::string, T::storage_t > >, parcel::BaseCell< UnionCell< Ts... >, std::variant< Ts::storage_t... > >, parcel::BaseCell< UnixMillisCell, std::chrono::sys_time< std::chrono::milliseconds > >, parcel::BaseCell< VersionConstraintCell, comms::VersionConstraint >, parcel::BaseCell< YmdCell, std::chrono::year_month_day >, parcel::OriginCell, and parcel::SelfStructCell< Derived >.
|
inlinevirtual |
Render the cell as a multi-line, indented string.
to_string(); concrete cells may override.
|
pure virtual |
Serialize this cell to its canonical JSON representation.
{"k", "v", optional "d"}. Implemented in parcel::BaseCell< Derived, Storage >, parcel::BaseCell< ColorCell, comms::Color >, parcel::BaseCell< Derived, Payload >, parcel::BaseCell< DisplayInfoCell, comms::DisplayInfo >, parcel::BaseCell< DurationMsCell, std::chrono::milliseconds >, parcel::BaseCell< FlagCell, comms::FlagRef >, parcel::BaseCell< FlagSetCell, comms::FlagSet >, parcel::BaseCell< HashMapCell, std::unordered_map< std::string, cell_t > >, parcel::BaseCell< IconCell, comms::Icon >, parcel::BaseCell< ListCell, std::vector< cell_t > >, parcel::BaseCell< MapCell, std::map< std::string, cell_t > >, parcel::BaseCell< PathCell, std::filesystem::path >, parcel::BaseCell< PrimitiveCell< T >, T >, parcel::BaseCell< SemVerCell, comms::SemVer >, parcel::BaseCell< SystemTimePointCell, std::chrono::sys_seconds >, parcel::BaseCell< TypedHashMapCell< T >, std::unordered_map< std::string, T::storage_t > >, parcel::BaseCell< TypedListCell< T >, std::vector< T::storage_t > >, parcel::BaseCell< TypedMapCell< T >, std::map< std::string, T::storage_t > >, parcel::BaseCell< UnionCell< Ts... >, std::variant< Ts::storage_t... > >, parcel::BaseCell< UnixMillisCell, std::chrono::sys_time< std::chrono::milliseconds > >, parcel::BaseCell< VersionConstraintCell, comms::VersionConstraint >, parcel::BaseCell< YmdCell, std::chrono::year_month_day >, parcel::OriginCell, parcel::SystemTimePointCell, parcel::UnixMillisCell, parcel::DurationMsCell, parcel::YmdCell, parcel::PathCell, parcel::TypedListCell< T >, parcel::ListCell, parcel::TypedMapCell< T >, parcel::MapCell, parcel::StructCell< Derived, Payload, StructId >, parcel::SelfStructCell< Derived >, parcel::UnionCell< Ts >, parcel::TypedHashMapCell< T >, and parcel::HashMapCell.
|
pure virtual |
Render the cell's value as a compact human-readable string.
Implemented in parcel::ColorCell, parcel::IconCell, parcel::DisplayInfoCell, parcel::FlagCell, parcel::FlagSetCell, parcel::SemVerCell, parcel::VersionConstraintCell, parcel::OriginCell, parcel::SystemTimePointCell, parcel::UnixMillisCell, parcel::DurationMsCell, parcel::YmdCell, parcel::PathCell, parcel::TypedListCell< T >, parcel::ListCell, parcel::TypedMapCell< T >, parcel::MapCell, parcel::PrimitiveCell< T >, parcel::StructCell< Derived, Payload, StructId >, parcel::SelfStructCell< Derived >, parcel::UnionCell< Ts >, parcel::TypedHashMapCell< T >, and parcel::HashMapCell.
|
inline |
Return a deep copy with color set to the typed color.
| color | New color. |
cell_t; this cell is unmodified.
|
inline |
Return a deep copy with color parsed from a color string (hex like "#ffcc00", a CSS-functional form, or a CSS color name).
| v | Color string accepted by comms::Color::parse. |
cell_t; this cell is unmodified. | InvalidJsonException | if v does not parse to a color. |
|
inline |
Return a deep copy with description set to v.
| v | New description. |
cell_t; this cell is unmodified.
|
inline |
Return a deep copy with the entire display info block replaced.
| m | New display info to attach. |
cell_t; this cell is unmodified.
|
inline |
Return a deep copy with icon set to the typed icon.
| icon | New icon. |
cell_t; this cell is unmodified.
|
inline |
Return a deep copy with icon parsed from an Iconify set:name string (e.g.
"mdi:account").
| v | Iconify set:name identifier. |
cell_t; this cell is unmodified. | std::invalid_argument | if v is not a valid set:name icon. |
|
inline |
Return a deep copy with name set to v.
| v | New name. |
cell_t; this cell is unmodified.