blob: aa26d49e29b784d4c485e7999383de8c172b6ed8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
#include "kapi/cio.hpp"
#include <optional>
#include <utility>
namespace teachos::cio
{
auto constinit null_device = output_device{};
auto constinit active_device = &null_device;
auto set_output_device(output_device & device) -> std::optional<output_device *>
{
if (&device == active_device)
{
return {};
}
return std::exchange(active_device, &device);
}
auto print(std::string_view text) -> void { active_device->write(text); }
auto println(std::string_view text) -> void { active_device->writeln(text); }
auto print_error(std::string_view text) -> void { active_device->write_error(text); }
auto println_error(std::string_view text) -> void { active_device->writeln_error(text); }
} // namespace teachos::cio
|