refactor: new tr_variant API in transmission-remote and other cleanup (#6798)

* refactor: remove `Arguments`

* refactor: replace pointer args with lvalue reference

* refactor: use `uint16_t` for port number

* chore: housekeeping

* refactor: replace `char*` with `std::string_view`

* refactor: simplify argument parsing code

* refactor: use new `tr_variant` API in remote

* chore: rename function to snake_case

* chore: move `break` statements in switches outside of compound statements

* chore: use `std::string` literals

* refactor: extract tor start/stop to `MODE_TORRENT_START_STOP`

* refactor: extract tor actions to `MODE_TORRENT_ACTION`

* chore: iwyu

* fix: msvc build failure

* chore: misc cleanup

* fix: dereference optional

* chore: misc cleanup

* ui: fix minor formatting errors

* fix: remove redundant if branches for response string

* code review: remove `o` prefix for optionals

* code review: add condition clause

* code review: check `left_until_done` instead

* fix: unchecked nullptr

* code review: don't reassign method name

* code review: revert accidentally renaming `addIdArg` to `get_id_arg`

* code review: use `TR_ASSERT` instead of `assert`

* refactor: fix static auto constexpr naming

* code review: assert array size

* code review: assert that `arguments` key exists
This commit is contained in:
Yat Ho
2024-08-18 03:04:49 +08:00
committed by GitHub
parent fea9a8efb7
commit 1e16912ae4
5 changed files with 1714 additions and 1659 deletions

View File

@@ -552,7 +552,7 @@ std::string tr_strpercent(double x)
return fmt::format("{:.0Lf}", x);
}
std::string tr_strratio(double ratio, char const* infinity)
std::string tr_strratio(double ratio, std::string_view infinity)
{
if ((int)ratio == TR_RATIO_NA)
{
@@ -561,7 +561,7 @@ std::string tr_strratio(double ratio, char const* infinity)
if ((int)ratio == TR_RATIO_INF)
{
return infinity != nullptr ? infinity : "";
return std::string{ infinity };
}
return tr_strpercent(ratio);