ores.cpp.wire-codec
Table of Contents
This page is the node for the ores.cpp.wire-codec facet of the codegen
template library, part of the ores.cpp technical space. Each archetype
below is documented, and holds its mustache source, in its own
linked page — this page is the facet-level summary and the routing
table to them.
1. Summary
Templates generating a type's wire codec: the header that states the four
functions and the wire_traits specialisation that names them, the
translation unit that holds the field list and the four definitions, and the
tests that require each type and each protocol message to read back what it
wrote.
2. The ores.cpp.wire-codec facet
Disabled by default (#+default: disabled): a component opts in one entity at
a time by enabling the facet in the entity's own :PROPERTIES: drawer with
:ores.cpp.wire-codec.enabled: true.
The opt-in is per entity rather than per component because the codec states every member of the type, and a member whose type has no carrier cannot be encoded. A component joins as its models are covered, which is the same order the story that introduced this facet states: one component at a time.
3. Mustache incantations
The field list repeats the member order cpp_domain_type_class.hpp.mustache
declares, and it has to: the JSON is a list of members in declaration order, so
a list that disagreed with the struct would encode a different object. The
repetition is deliberate and is guarded by the per-type round trip, which
fails the moment the two orders part – one test per type, in both formats.
A member the model marks :no_wire: is absent from the field list.
4. Archetypes
| Archetype | Description |
|---|---|
| ores.cpp.wire-codec.codec_header | Declares a type's four wire functions and the wire_traits specialisation naming them. wire-codec facet. |
| ores.cpp.wire-codec.codec_impl | States a type's field list and defines its four wire functions over it. wire-codec facet. |
| ores.cpp.wire-codec.protocol_codec_impl | Defines each protocol message's four wire functions. wire-codec facet. |
| ores.cpp.wire-codec.protocol_roundtrip_tests | Requires each protocol message to read back exactly what its wire codec wrote, in JSON and in MessagePack. wire-codec facet. |
| ores.cpp.wire-codec.roundtrip_tests | Requires a type to read back exactly what its wire codec wrote, in JSON and in MessagePack. wire-codec facet. |
5. See also
- Codegen template library — the groups overview.
- ores.cpp.domain.json_io_header — the streaming form of the same type, which this facet does not replace.