Files
transmission/tests
Charles Kerr 4599a7312e refactor: libtransmission::serializer redesign (#7954)
* refactor: libtransmission::serializer redesign

This is a followup to bf48eadaeb 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.

* fix: naming is hard

docs: better code comments

* fix: clang-tidy readability-identifier-naming

* Update tests/libtransmission/serializer-tests.cc

Co-authored-by: Yat Ho <lagoho7@gmail.com>

* refactor: remove tr_variant<->int converter

* improve tests

---------

Co-authored-by: Yat Ho <lagoho7@gmail.com>
2025-12-21 06:04:18 -06:00
..
2023-12-23 10:32:04 -06:00