mirror of
https://github.com/transmission/transmission.git
synced 2026-02-15 07:26:49 +00:00
* 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>