diff options
| author | Felix Morgner <felix.morgner@ost.ch> | 2025-07-24 20:51:55 +0000 |
|---|---|---|
| committer | Felix Morgner <felix.morgner@ost.ch> | 2025-07-24 20:51:55 +0000 |
| commit | dd04850c27e8bc273506f4a64bb28b7ddf111dc5 (patch) | |
| tree | a00212f5c903e80e4e729c87ce34ece2c40e4ee6 /kapi/src/cio.cpp | |
| parent | feac668578a35aac280b59d478a57b6937bb68da (diff) | |
| download | teachos-dd04850c27e8bc273506f4a64bb28b7ddf111dc5.tar.xz teachos-dd04850c27e8bc273506f4a64bb28b7ddf111dc5.zip | |
kapi: rework text device interface
Diffstat (limited to 'kapi/src/cio.cpp')
| -rw-r--r-- | kapi/src/cio.cpp | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/kapi/src/cio.cpp b/kapi/src/cio.cpp new file mode 100644 index 0000000..aa26d49 --- /dev/null +++ b/kapi/src/cio.cpp @@ -0,0 +1,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
\ No newline at end of file |
