Skip to content

Conversation

@ckerr
Copy link
Member

@ckerr ckerr commented Dec 18, 2025

This is a followup to bf48ead with several goals.

  • Naming simplification:

    • renamed the namespace to libtransmission::serializer.
    • renamed the file to serializer.h
    • renamed the tr_variant<->T converter registry to Converters.
  • Converters now has container-like concepts to make it Just Work when a user tries to convert containers of T, e.g. std::vector<T>, std::set<T>, QStringList, small:vector<T>, etc.

  • Fields are now stored in a std::tuple instead of a std::array. This has two important benefits:

    1. Fields are smaller and can be made constexpr / consteval
    2. The previous type erasure approach is no longer needed. The void pointer casts and typeinfo lookups are gone. The new code is typesafe.
  • Removed use of the CRTP. You can now serialize any struct without having to subclass Serializable.

  • Added a new suite of unit tests for both Converters and for settings serialization.

I love the featureset and now it does everything that I need; but on the other hand, this was a lot of work and is on the very edge of how much C++ metaprogramming I'm comfortable with using in production code. I hope to not have to touch this code again for awhile.

This is a followup to bf48ead with several goals.

- `Converters` now has container-like concepts to make it Just Work
  when a user tries to convert containers of T, e.g. std::vector<T>,
  std::set<T>, QStringList, small:vector<T>, etc.

- `Fields` are now stored in a std::tuple instead of a std::array.
  This has two important benefits:
  1. `Fields` are smaller and can be made constexpr / consteval
  2. We no longer need to use type erasure. The void pointer casts
  and typeinfo lookups are gone and the new code is typesafe.

- naming cleanup:

  - renamed the namespace to `libtransmission::serializer`.
  - renamed the file to `serializer.h`
  - renamed the tr_variant<->T converter registry class to `Converters`.

- removed use of the CRTP. You can now serialize any struct
  without having to subclass `Serializable`.

I think I am done refactoring this for awhile.
@ckerr ckerr added scope:core type:refactor A code change that neither fixes a bug nor adds a feature notes:none Should not be listed in release notes labels Dec 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

notes:none Should not be listed in release notes scope:core type:refactor A code change that neither fixes a bug nor adds a feature

Development

Successfully merging this pull request may close these issues.

1 participant