|
| template<auto MemberPtr, CellLike CellT> |
| FieldsBuilder & | field (std::string key) |
| | Declare a field with an explicit cell wrapper CellT.
|
| |
template<auto MemberPtr>
requires HasDefaultCellWrapper< typename detail::member_pointer_traits<decltype(MemberPtr)>::field_type> |
| FieldsBuilder & | field (std::string key) |
| | Declare a field with cell wrapper inferred via default_cell_for.
|
| |
| FieldsBuilder & | name (std::string v) |
| | Set the name display info of the most recently declared field.
|
| |
| FieldsBuilder & | description (std::string v) |
| | Set the description display info of the most recently declared field.
|
| |
| FieldsBuilder & | icon (comms::Icon icon) |
| | Set the icon display info of the most recently declared field to the typed icon.
|
| |
| FieldsBuilder & | icon (std::string const &v) |
| | Set the icon display info of the most recently declared field, parsing an Iconify set:name string (e.g.
|
| |
| FieldsBuilder & | color (comms::Color color) |
| | Set the color display info of the most recently declared field to the typed color.
|
| |
| FieldsBuilder & | color (std::string const &v) |
| | Set the color display info of the most recently declared field, parsing a color string (hex, CSS-functional, or a CSS color name).
|
| |
| FieldsBuilder & | is_required (bool v=true) |
| | Override the required flag of the most recently declared field.
|
| |
| FieldsBuilder & | optional () |
| | Shorthand for is_required(false).
|
| |
template<CellLike ParentCell>
requires std::is_base_of_v<typename ParentCell::payload_type, Payload> |
| FieldsBuilder & | extend () |
| | Splice in every field declared by another struct cell.
|
| |
| FieldsBuilder & | remove_field (const std::string_view key) |
| | Drop a previously declared (or inherited) field by key.
|
| |
| payload_field_descriptors_t | build () |
| | Move out the accumulated field descriptors.
|
| |
template<typename Payload>
class parcel::FieldsBuilder< Payload >
Fluent builder used inside Derived::field_descriptors() to declare struct fields.
Typical use:
.
field<&Person::name>(
"name")
.field<&Person::email>(
"email").
optional()
Fluent builder used inside Derived::field_descriptors() to declare struct fields.
Definition struct.h:342
FieldsBuilder & description(std::string v)
Set the description display info of the most recently declared field.
Definition struct.h:413
FieldsBuilder & field(std::string key)
Declare a field with an explicit cell wrapper CellT.
Definition struct.h:355
FieldsBuilder & optional()
Shorthand for is_required(false).
Definition struct.h:486
payload_field_descriptors_t build()
Move out the accumulated field descriptors.
Definition struct.h:543
Leaf cell wrapping a single scalar (or complex) value of type T.
Definition primitive.h:316
Field-list reuse via extend<ParentCell>():
struct Address { std::string street; std::string city; };
struct HomeAddress : Address { std::string label; };
return FieldsBuilder<HomeAddress>{}
.extend<AddressCell>()
.field<&HomeAddress::label>("label")
.build();
Duplicate keys are last-wins: a field<>() call with the same key as an already-declared field replaces it in place. remove_field(key) drops a previously declared (or inherited) field.
- Template Parameters
-
| Payload | The struct type whose fields are being declared. |
- See also
- default_cell_for — drives the inference overload.
-
InheritedFieldDescriptor — backs
extend<>.
template<typename Payload >
template<CellLike ParentCell>
requires std::is_base_of_v<typename ParentCell::payload_type, Payload>
Splice in every field declared by another struct cell.
Each parent field is wrapped in InheritedFieldDescriptor and appended in declaration order. A subsequent field<>(key) with the same key replaces the inherited entry in place (last-wins). The constraint requires ParentCell's payload to be a base of (or the same as) Payload — extending from an unrelated struct cell will not compile.
After this call, last_ points at the most recently spliced field, so a chained .name(...) / .description(...) / .optional() mutates that inherited field's per-call descriptor copy without affecting the parent cell.
- Template Parameters
-
| ParentCell | A CellLike exposing payload_type whose payload is a base of (or same as) Payload. |
- Returns
*this for chaining.
template<typename Payload >
template<auto MemberPtr>
requires HasDefaultCellWrapper< typename detail::member_pointer_traits<decltype(MemberPtr)>::field_type>
Declare a field with cell wrapper inferred via default_cell_for.
Available for any field type that has a default_cell_for specialization (every PrimitiveStorage type out of the box, plus std::vector, std::map, std::variant, and std::optional of those).
- Template Parameters
-
| MemberPtr | Pointer-to-member of Payload. |
- Parameters
-
| key | JSON key for this field. |
- Returns
*this for chaining.