Skip to content

Commit 3b2ad7b

Browse files
committed
api: add set_client_name / client_name to have easier client_name control
1 parent ac62ad8 commit 3b2ad7b

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

include/libremidi/configurations.hpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,4 +68,21 @@ LIBREMIDI_EXPORT
6868
libremidi::API midi_api(const output_api_configuration& conf);
6969
LIBREMIDI_EXPORT
7070
libremidi::API midi_api(const observer_api_configuration& conf);
71+
72+
void set_client_name(auto&& conf, std::string name)
73+
{
74+
std::visit([&](auto& impl) {
75+
if constexpr (requires { impl.client_name; })
76+
impl.client_name = std::move(name);
77+
}, conf);
78+
}
79+
80+
std::optional<std::string> client_name(const auto& conf) noexcept
81+
{
82+
return std::visit([&](auto& impl) -> std::optional<std::string> {
83+
if constexpr (requires { impl.client_name; })
84+
return impl.client_name;
85+
return std::nullopt;
86+
}, conf);
87+
}
7188
}

0 commit comments

Comments
 (0)