HikoGUI
A low latency retained GUI
Loading...
Searching...
No Matches
audio_direction.hpp
1// Copyright Take Vos 2021-2022.
2// Distributed under the Boost Software License, Version 1.0.
3// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
4
5#pragma once
6
7#include "../utility/utility.hpp"
8#include "../macros.hpp"
9#include <string_view>
10#include <utility>
11#include <format>
12
13hi_export_module(hikogui.audio.audio_direction);
14
15hi_export namespace hi { inline namespace v1 {
16
17hi_export enum class audio_direction : unsigned char { none = 0b00, input = 0b01, output = 0b10, bidirectional = 0b11 };
18
19hi_export [[nodiscard]] constexpr audio_direction operator&(audio_direction const& lhs, audio_direction const& rhs) noexcept
20{
21 return static_cast<audio_direction>(std::to_underlying(lhs) & std::to_underlying(rhs));
22}
23
24hi_export [[nodiscard]] constexpr audio_direction operator|(audio_direction const& lhs, audio_direction const& rhs) noexcept
25{
26 return static_cast<audio_direction>(std::to_underlying(lhs) | std::to_underlying(rhs));
27}
28
29hi_export [[nodiscard]] constexpr bool to_bool(audio_direction const &rhs) noexcept
30{
31 return to_bool(std::to_underlying(rhs));
32}
33
34// clang-format off
35hi_export constexpr auto audio_direction_metadata = enum_metadata{
36 audio_direction::none, "none",
37 audio_direction::input, "input",
38 audio_direction::output, "output",
39 audio_direction::bidirectional, "bidirectional"
40};
41// clang-format on
42
43}}
44
45// XXX #617 MSVC bug does not handle partial specialization in modules.
46hi_export template<>
47struct std::formatter<hi::audio_direction, char> : std::formatter<std::string_view, char> {
48 auto format(hi::audio_direction const& t, auto& fc) const
49 {
50 return std::formatter<std::string_view, char>::format(hi::audio_direction_metadata[t], fc);
51 }
52};
The HikoGUI namespace.
Definition array_generic.hpp:20
DOXYGEN BUG.
Definition algorithm_misc.hpp:20