-
Notifications
You must be signed in to change notification settings - Fork 0
API muesli fluent projectable
Defined in header <muesli/fluent/projectable>
template<ValueType>
struct projector_codecForward declaration of apply_codec
Binds this codec to a member of a struct
Creates a member_codec that automatically extracts/injects the field from/to the owner struct during encode/decode operations.
template<auto MemberPtr> constexpr auto member() const noexceptReturns: A member_codec<Derived, MemberPtr> wrapping this codec
Example:
struct Record { int id; };
auto id_codec = int32_codec.member<&Record::id>();
Record rec{42};
auto encoded = id_codec.encode(rec);Projects this codec from an owner type using a custom projector
Creates a projector_codec with custom encode/decode transformation logic. Allows flexible field extraction and reconstruction.
template<typename Owner, typename Projector> constexpr auto project(Projector proj) const noexceptParameters:
-
proj— The projector function
Returns: A projector_codec wrapping this codec
- Related codecs:
apply_codec
struct member_codecForward declaration of member_codec
Binds this codec to a member of a struct
Creates a member_codec that automatically extracts/injects the field from/to the owner struct during encode/decode operations.
template<auto MemberPtr> constexpr auto member() const noexceptReturns: A member_codec<Derived, MemberPtr> wrapping this codec
Example:
struct Record { int id; };
auto id_codec = int32_codec.member<&Record::id>();
Record rec{42};
auto encoded = id_codec.encode(rec);Projects this codec from an owner type using a custom projector
Creates a projector_codec with custom encode/decode transformation logic. Allows flexible field extraction and reconstruction.
template<typename Owner, typename Projector> constexpr auto project(Projector proj) const noexceptParameters:
-
proj— The projector function
Returns: A projector_codec wrapping this codec
template<Derived>
struct projectableMixin providing .member<>() and .project<>() for member/projection codecs
This mixin provides two methods for adapting codecs to structured data:
- .member<&T::field>(): Bind this codec to a specific member of a struct
- .project(projector): Project from an owner type via custom transformation
Used for:
- Struct field serialisation
- Custom value extraction/injection
- Computed/derived field handling
Binds this codec to a member of a struct
Creates a member_codec that automatically extracts/injects the field from/to the owner struct during encode/decode operations.
template<auto MemberPtr> constexpr auto member() const noexceptReturns: A member_codec<Derived, MemberPtr> wrapping this codec
Example:
struct Record { int id; };
auto id_codec = int32_codec.member<&Record::id>();
Record rec{42};
auto encoded = id_codec.encode(rec);Projects this codec from an owner type using a custom projector
Creates a projector_codec with custom encode/decode transformation logic. Allows flexible field extraction and reconstruction.
template<typename Owner, typename Projector> constexpr auto project(Projector proj) const noexceptParameters:
-
proj— The projector function
Returns: A projector_codec wrapping this codec
template<auto MemberPtr> constexpr auto member() const noexceptBinds this codec to a member of a struct
Creates a member_codec that automatically extracts/injects the field from/to the owner struct during encode/decode operations.
| Parameter | Description |
|---|---|
MemberPtr |
A pointer-to-member of form &OwnerType::memberName |
Returns: A member_codec<Derived, MemberPtr> wrapping this codec
struct Record { int id; };
auto id_codec = int32_codec.member<&Record::id>();
Record rec{42};
auto encoded = id_codec.encode(rec);template<typename Owner, typename Projector> constexpr auto project(Projector proj) const noexceptProjects this codec from an owner type using a custom projector
Creates a projector_codec with custom encode/decode transformation logic. Allows flexible field extraction and reconstruction.
| Parameter | Description |
|---|---|
Owner |
The owner type from which to project |
Projector |
A callable that takes const Owner& and returns the member value |
-
proj— The projector function
Returns: A projector_codec wrapping this codec