parcel 0.2.2
Wrappable, wire-transferable C++23 value system with JSON serialization
Loading...
Searching...
No Matches
parcel::IPayloadFieldDescriptor< Payload > Struct Template Referenceabstract

Field-descriptor extension that knows how to read/write a specific Payload. More...

#include <struct.h>

Inheritance diagram for parcel::IPayloadFieldDescriptor< Payload >:
Collaboration diagram for parcel::IPayloadFieldDescriptor< Payload >:

Public Member Functions

virtual void to_json_into (json_t &v_obj, Payload const &p) const =0
 Serialize this field from p into the value object v_obj.
 
virtual void from_json_into (json_t const &field_json, Payload &p, ParcelRegistry const &reg) const =0
 Deserialize this field from field_json into p.
 
virtual void to_string_into (std::string &out, Payload const &p) const =0
 Append key: value for this field to the rendered string.
 
virtual std::partial_ordering compare (Payload const &a, Payload const &b) const =0
 Three-way compare this field across two payload instances.
 
virtual DisplayInfomutable_display_info ()=0
 Mutable access to this field's display info — used by FieldsBuilder.
 
virtual void set_required (bool r)=0
 Override the field's required flag.
 
- Public Member Functions inherited from parcel::IFieldDescriptor
virtual std::string_view key () const =0
 JSON key under which this field appears in "v".
 
virtual std::string_view kind () const =0
 Cell kind id for the field's value type.
 
virtual DisplayInfo display_info () const =0
 Display info for this field.
 
virtual bool is_required () const =0
 Whether the field must be present on deserialization.
 
virtual json_t to_json () const =0
 Serialize the field descriptor itself.
 

Detailed Description

template<typename Payload>
struct parcel::IPayloadFieldDescriptor< Payload >

Field-descriptor extension that knows how to read/write a specific Payload.

Refines IFieldDescriptor with hooks the StructCell machinery uses to project payload members in and out of JSON.

Template Parameters
PayloadThe struct type whose fields are described.

Member Function Documentation

◆ compare()

template<typename Payload >
virtual std::partial_ordering parcel::IPayloadFieldDescriptor< Payload >::compare ( Payload const &  a,
Payload const &  b 
) const
pure virtual

Three-way compare this field across two payload instances.

StructCell::compare walks fields in declaration order and short- circuits on the first non-equal result; ignores display info. Optional fields follow std::optional's <=>: absent < present, both absent is equal.

Implemented in parcel::InheritedFieldDescriptor< DerivedPayload, ParentPayload >, and parcel::MemberFieldDescriptor< Payload, FieldT, CellT >.

◆ from_json_into()

template<typename Payload >
virtual void parcel::IPayloadFieldDescriptor< Payload >::from_json_into ( json_t const &  field_json,
Payload &  p,
ParcelRegistry const &  reg 
) const
pure virtual

Deserialize this field from field_json into p.

Parameters
field_jsonJSON value for this field (already a wrapped cell).
pPayload instance to write into.
regRegistry forwarded to nested cell deserializers.

Implemented in parcel::InheritedFieldDescriptor< DerivedPayload, ParentPayload >, and parcel::MemberFieldDescriptor< Payload, FieldT, CellT >.

◆ to_json_into()

template<typename Payload >
virtual void parcel::IPayloadFieldDescriptor< Payload >::to_json_into ( json_t v_obj,
Payload const &  p 
) const
pure virtual

Serialize this field from p into the value object v_obj.

Parameters
v_objTarget JSON object (the "v" block of the cell).
pPayload instance to read from.

Implemented in parcel::InheritedFieldDescriptor< DerivedPayload, ParentPayload >, and parcel::MemberFieldDescriptor< Payload, FieldT, CellT >.

◆ to_string_into()

template<typename Payload >
virtual void parcel::IPayloadFieldDescriptor< Payload >::to_string_into ( std::string &  out,
Payload const &  p 
) const
pure virtual

Append key: value for this field to the rendered string.

Parameters
outString buffer to append to.
pPayload instance to read from.

Implemented in parcel::InheritedFieldDescriptor< DerivedPayload, ParentPayload >, and parcel::MemberFieldDescriptor< Payload, FieldT, CellT >.


The documentation for this struct was generated from the following file: