Lightweight 0.20260617.0
Loading...
Searching...
No Matches
Lightweight::Description< Record > Struct Template Reference

Customization point providing pre-computed reflection metadata for a record type. More...

Detailed Description

template<typename Record>
struct Lightweight::Description< Record >

Customization point providing pre-computed reflection metadata for a record type.

The DataMapper reflects over records to discover their fields, field names, and types. By default this is done at compile time via the reflection-cpp library, which is accurate but expensive to instantiate for records with many members and dense relationship graphs (the cost is paid once per record type per translation unit and multiplies across the reachable relationship graph).

Tools such as ddl2cpp know a record's structure ahead of time and can emit an explicit specialization of this template. When a specialization exists the DataMapper reads the pre-baked metadata instead of evaluating reflection, which dramatically reduces compile time. Records without a specialization keep working unchanged via automatic reflection — the same "specialize-or-reflect" approach already used for the optional static TableName member.

A specialization must provide:

  • static constexpr std::size_t FieldCount; — number of members.
  • using Members = RecordMemberList<&Record::a, &Record::b, ...>; — the members, in declaration order.
  • static constexpr std::array<std::string_view, FieldCount> FieldNames; — the resolved SQL column name for each field (i.e. the value FieldNameAt would otherwise compute).

Definition at line 123 of file Description.hpp.


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